Series with different dates on same chart

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
dave
Newbie
Newbie
Posts: 35
Joined: Fri Feb 24, 2006 12:00 am

Series with different dates on same chart

Post by dave » Wed May 02, 2007 7:40 am

Hi,

I would like some advice on how I could plot 2 series with possibly different dates (users will specify what date range they want to look for both series) on the same chart and also have the difference between each data point being plotted out as well.

For example, the dataset to plot the 2 series could be similar to below:

Date1, Data1, Date2, Data2, Difference (Data1-Data2)
1-Jan-2007, 10, 15-Jul-2006, 5, 5
2-Jan-2007, 15, 16-Jul-2006, 10, 5
3-Jan-2007, 10, 17-Jul-2006, 10, 0
4-Jan-2007,10,null,null,10

I would like to have Date1 & Data1 as one series, Date2 & Data2 as second series and Difference as another series (?) on the same chart.

Would you have any suggestions on how the x-axis should be (since there are 2 different dates)? Or how could the users still see the dates for the 2 series?

Thank you.

Edu
Advanced
Posts: 206
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia

Post by Edu » Wed May 02, 2007 10:21 am

Hi Dave

We understand that you want the first point of the first series, in the same X position, that the first point of the second series. One possibility is using the same points to both series, and putting the dates as a label of its points, as below code:

Code: Select all

 
//tChart1.Axes.Bottom.Labels.Visible = false;

Steema.TeeChart.Styles.Line line1 = new Steema.TeeChart.Styles.Line(tChart1.Chart);
            //line1.Marks.Visible = true;
            line1.Add(0, 10, "1-Jan-2007");
            line1.Add(1, 15, "2-Jan-2007");
            line1.Add(2, 10, "3-Jan-2007");
            line1.Add(3, 10, "4-Jan-2007");
            
            Steema.TeeChart.Styles.Line line2 = new Steema.TeeChart.Styles.Line(tChart1.Chart);
            //line2.Marks.Visible = true;
            line2.Add(0, 5, "15-Jan-2007"); 
            line2.Add(1, 10, "16-Jan-2007"); 
            line2.Add(2, 10, "17-Jan-2007"); 
The other possibility can be to use a custom axis. The first possibility it's more easier if then you want to use the substract function.

Now, the labels of the bottom axis only have got the labels of line1. You can use one of this possibilities:

1- Use a marks of the series, and hide the labels of bottom axis.
2- The line2 can use the top axis.
3- You can change the text of the labels of bottom axis, as below code:

Code: Select all

 tChart1.Axes.Bottom.Labels.Items.Add(1, "1 and 15 Jan-2007");
Best Regards,
Edu

Steema Support Central
http://support.steema.com/

dave
Newbie
Newbie
Posts: 35
Joined: Fri Feb 24, 2006 12:00 am

Post by dave » Thu May 03, 2007 1:31 am

Thanks Edu. If I'm also plotting the difference between the 2 series, do I add another line similar to the examples you gave or can I use the Subtract function?

Edu
Advanced
Posts: 206
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia

Post by Edu » Thu May 03, 2007 7:56 am

Hi Dave

Yes, you have to add another line, then you have two possibilities to put the values, one of them is calculating the substract and then put the values with add() method, the other one is using subtract function, as below code:

Code: Select all

 
            //Substract function
            //Add a series to be used for an Subtract Function  
            Steema.TeeChart.Styles.Line line3 = new Steema.TeeChart.Styles.Line(tChart1.Chart);        
            //Define the Function Type for the new Series     
            Steema.TeeChart.Functions.Subtract subtract1 = new Steema.TeeChart.Functions.Subtract();
            line3.Function = subtract1;          
            //Define the Datasource for the new Function Series        
            line3.DataSource = new object[] { line1, line2 };
Best Regards,
Edu

Steema Support Central
http://support.steema.com/

dave
Newbie
Newbie
Posts: 35
Joined: Fri Feb 24, 2006 12:00 am

Post by dave » Fri May 04, 2007 1:17 am

Hi Edu,

Thanks for the sample code... it works very well. :D

Post Reply