Page 1 of 1

Line Chart with various points

Posted: Mon Jul 27, 2009 8:53 am
by 14045267
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.

Re: Line Chart with various points

Posted: Mon Jul 27, 2009 9:13 am
by narcis
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.

Re: Line Chart with various points

Posted: Sun Aug 02, 2009 8:34 am
by 14045267
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.

Re: Line Chart with various points

Posted: Mon Aug 03, 2009 11:49 am
by 10050769
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,