Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#
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 10-Jul-13 11:29am
Millone742
Edited 10-Jul-13 11:34am
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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
  Permalink  
Comments
Millone at 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?
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

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.
  Permalink  
Comments
Millone at 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.

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

  Print Answers RSS
0 Maciej Los 295
1 OriginalGriff 273
2 Aajmot Sk 234
3 Marcin Kozub 205
4 Richard MacCutchan 200
0 OriginalGriff 7,903
1 Sergey Alexandrovich Kryukov 7,127
2 DamithSL 5,604
3 Manas Bhardwaj 4,986
4 Maciej Los 4,820


Advertise | Privacy | Mobile
Web03 | 2.8.1411023.1 | Last Updated 11 Jul 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100