Click here to Skip to main content
15,892,737 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a chart with 4 series. Each series is added at different times, depending on what is switched on/off of the app features. All series have on the x axis:
DateTime.Now.ToString("mm:ss")

so I thought that at any time the series data are available, they will be added to the chart at that time that happens on x axis. Looks like is not like that. This chart shows a blue line and a red line. The blue line started first then after few seconds I checked checkBox2 which activate the red line, that happened exactly at 27:38 (where you can see a small drop on the blue line). I do not understand why the red line starts at the far left of the chart and not at the time that was triggered (27:38).

This is my code:
string reqTemp = textBox9.Text;
        textBox2.Text = avTemp.ToString("F");
        this.chart1.Series["Actual Temperature"].Points.AddXY(DateTime.Now.ToString("mm:ss"), avTemp);
        if (checkBox2.Checked == true)
        {
            this.chart1.Series["Requested Temperature"].Points.AddXY(DateTime.Now.ToString("mm:ss"), reqTemp);
        }   


Chart picturehttp://i41.tinypic.com/wwd7nk.jpg[^]

How can I have the series added after the first one was already running, starting at the time they are switched on? Basically all series sharing the same x axis.
Posted
Updated 10-Jul-13 10:34am
v2

It really depends on how you built the chart, do you have the code for that or did you use the designer?
Most likely you need to have the series all added at the same time, then only populate when you check the box.
 
Share this answer
 
Comments
Millone 11-Jul-13 11:09am    
The only code relevant the chart is in my question. All the other settings are in the designer. However, would not make sensor for me to run it only when I check the box because that is an additional feature. The chart is always running with 2 series, adition 2 are added if the checkbox is checked.
There are several things it can be, but the most likely given that you are not binding your series is minimum and maximum of your x axis. Your first series starts at say 0 and at the point you check then box the x axis extends from 0 to 27:38+. Your second series x axis is not bound to your first series x axis so it's minimum value is 27:38, that is why it starts on the left. The reason this doesn't show on the x axis is that you have the charts x axis tied to the first series.
You either need to create some point classes, do binding, or tie the series 2 max min to the series 1 max min
 
Share this answer
 
Comments
Millone 11-Jul-13 3:14am    
Thanks a lot for your advices. How can I bind the second series x axis to the first series x axis?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900