Line Chart with various points

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
rino
Newbie
Newbie
Posts: 26
Joined: Wed May 23, 2007 12:00 am

Line Chart with various points

Post by rino » Mon Jul 27, 2009 8:53 am

Hi
I have a line chart which has 3 series . The problem is that for some series I dont have all the Y values for all the x values.
This means that some series can have more intermediate points then others.
For example if 2 series which have 10 points on the x Axis and another series only has values for x = 2 , x = 4, x= 6,
I want the line to be linear , for example if x = 2 y = 10 and x = 4 y = 20 I want tchart to automatically connect the two points with one straight line even though I do not have a Y for x = 3. I tried to set a null value at the missing places but it simply didnt draw anything in between.
I dont want to have to fill in the missing data . I just want the avaliable points to be connected by a straight linear line
Thanks.

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Re: Line Chart with various points

Post by Narcís » Mon Jul 27, 2009 9:13 am

Hi rino,

Yes, TeeChart already does this by default, for example:

Code: Select all

			Steema.TeeChart.Styles.Line line1 = new Steema.TeeChart.Styles.Line(tChart1.Chart);
			Steema.TeeChart.Styles.Line line2 = new Steema.TeeChart.Styles.Line(tChart1.Chart);
			Steema.TeeChart.Styles.Line line3 = new Steema.TeeChart.Styles.Line(tChart1.Chart);

			for (int i = 0; i < 10; i++)
			{
				line1.Add(i, i * 5);
			}

			line2.Add(0, 0);
			line2.Add(3, 12);
			line2.Add(7, 28);
			line2.Add(10, 40);

			line3.Add(0, 0);
			line3.Add(5, 15);
			line3.Add(10, 30);
If that's not what you are looking for please give us more details about what you'd like to achieve.

Thanks in advance.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

rino
Newbie
Newbie
Posts: 26
Joined: Wed May 23, 2007 12:00 am

Re: Line Chart with various points

Post by rino » Sun Aug 02, 2009 8:34 am

Hi Narcis
your solution doesnt seem to work for me. I have uploaded a sample project called TChartDifferentLinePointsIssue.zip
In the project I do something similar to what you suggest , but the problem is that the lines with the missing data are not streched , they simply finish early.
I need all the lines to start and end together . In you example (which is a litle like the project I sent you ) the lines with the missing data simply end before.
Look the green line. although it only has points 0, 4, 5, 6 , the point 4 is drawn where point 1 should be and not where point 4 should be.
Thanks.

Sandra
Site Admin
Site Admin
Posts: 3132
Joined: Fri Nov 07, 2008 12:00 am

Re: Line Chart with various points

Post by Sandra » Mon Aug 03, 2009 11:49 am

Hello rino,

I recomend two solution for your question that I think you can use for solve your problem:

First: You could specify (x,y) if you don't want to appears all values, for example next code:

Code: Select all

   
            if (seriesCount == 0 || row == 0 || row > 3)
            {
    
                series.Add(row,row, dataSource[row].label);
               
            }

Second:
Also, you have other option, that consist in put values of you don't use to null and all values appears . You could use next code for example:

Code: Select all

 if (seriesCount == 0 || row == 0 || row > 3)
            {
    
                series.Add(row, dataSource[row].label);
               
            }
            else
            {
                double? value;
                value = row;
                series.Add(value, dataSource[row].label);
            }
I hope will helps.

Thanks,
Best Regards,
Sandra Pazos / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Post Reply