Page 1 of 1

Calculation and Automatic Scale without Null Values

Posted: Wed Jul 02, 2008 2:13 pm
by 13049497
Hello,

i have problems with NullValues. To draw gaps within some Lines i musst add one point with Color.Transparent and an y-value. This value is recognized by TChart although its not really an value. Its an dummy value for drawing the gap. Now, the problems were the automatic scale of TChart with one of this DummyValue at the end and of course within the calculation of the SeriesStats.

Some example code:

Code: Select all

Steema.TeeChart.Styles.FastLine line = new Steema.TeeChart.Styles.FastLine();           

line.TreatNulls = Steema.TeeChart.Styles.TreatNullsStyle.DoNotPaint;

line.Add(1,2);
line.Add(2,6);
line.Add(3,1);
line.Add(9,0, Color.Transparent);
            
tChart1.Series.Add(line);
In this sample, the average must be 3, but the Stats (and i think a averagefunction too) calculates 2.25. Also the TChart scale automatic choose as minxvalue 0 and maxvalue 9, so the view is very bad ;)
A change of the TreatNulls property effects only the draw of the line and doesnt help me.

I hope you know what i mean and can give me a workaround or an solution for it.

Thanks in advance!

Posted: Wed Jul 02, 2008 2:24 pm
by narcis
Hi AIS,

I'm sorry but I don't understand which is the exact problem here and why are you adding the null value at the end of the series. Would you be so kind to give us some more details of what you are trying to achieve?

Thanks in advance.

Posted: Wed Jul 02, 2008 2:56 pm
by 13049497
Hi Narcís,

i would only say, that the calculation of average and something like that includes thoose dummyvalues (not visible points). Therefore its not important if the codeline

Code: Select all

line.Add(9,0, Color.Transparent);
is on the end or in the middle of the adding. The Calculation of the Average also include non visible Points of series and thats not what i want, because with these points i just "made" gaps visible.

That the automatic scale is not working, if the last value is one of this dummyvalues is not so crtitical, because that can i check and delete. In my sample it is not working, because the last dummyvalue is to far away from the others (bottom axis -> X) and so, it looks like:

Image

Other Example with "normal" data:

Code: Select all

Steema.TeeChart.Styles.FastLine line = new Steema.TeeChart.Styles.FastLine();           

line.TreatNulls = Steema.TeeChart.Styles.TreatNullsStyle.DoNotPaint;

line.Add(1,2);
line.Add(2,6);
line.Add(3,1);
line.Add(9, 0, Color.Transparent);
line.Add(10, 3);
line.Add(11, 6);
line.Add(12, 0);
            
tChart1.Series.Add(line);
Image

Calculation by TChart:
Average = (2 + 6 + 1 +0 + 3 + 6 + 0) / 7 = 2,5xx
wanted Average= (2 + 6 + 1 +3 + 6 +0) / 6 = 3

I will show gaps in my Chart but dont calculate with non visible values, thats what i want.

I hope this is better for understanding ;)

Posted: Thu Jul 03, 2008 10:22 am
by narcis
Hi AIS,

Thanks for the information, now it's clear to me.

You can use Average function without using null values like this:

Code: Select all

		public Form1()
		{
			InitializeComponent();
			InitializeChart();		
		}

		private void InitializeChart()
		{
			Steema.TeeChart.Styles.FastLine line = new Steema.TeeChart.Styles.FastLine();

			line.TreatNulls = Steema.TeeChart.Styles.TreatNullsStyle.DoNotPaint;

			line.Add(1, 2);
			line.Add(2, 6);
			line.Add(3, 1);
			line.Add(9, 0, Color.Transparent);
			line.Add(10, 3);
			line.Add(11, 6);
			line.Add(12, 0);

			tChart1.Series.Add(line);

			Steema.TeeChart.Styles.FastLine avgLine = new Steema.TeeChart.Styles.FastLine(tChart1.Chart);
			
			bool useNulls = false;
			Steema.TeeChart.Functions.Average avg1 = new Steema.TeeChart.Functions.Average(useNulls);
			
			avgLine.Function = avg1;
			avgLine.DataSource = line;
		}

Posted: Thu Jul 03, 2008 11:17 am
by 13049497
Thanks Narcís for this solution.

Is it possible to use the SeriesStatsTool in the same way?

Posted: Fri Jul 04, 2008 9:39 am
by narcis
Hi AIS,

I'm afraid it is not possible for now. I've added your request to our wish-list to be considered for inclusion in future releases.