Page 1 of 1

NaN Values

Posted: Tue Nov 22, 2011 9:01 am
by 16560004
Hi,

I plot the same YData : Array of Double; with TLineSeries in many different plots. To save memory it will be best to add the YData by adding array of data. My problem is that sometime the Data contains NaN values so I have tried to do like this.

XData is a array of double with values from 1 to Length(YData)

with Series1.XValues do begin
Value := TChartValues(XData);
Count := Length(XData);
Modified := True;
end;
with Series1.YValues do begin
Value := TChartValues(YData);
Count := Length(YData);
Modified := True;
end;
for ii 0 to High(YData) do begin
if IsNaN(YData[ii]) then begin
Series1.SetNull(ii);
end;
end;
Series1.Repaint

But still my program crash with error “Invalid pointer operation”.

So my question is why can’t TChartValues contain NaN values when.

TChartValue : Double;
TChartValues : Array of TChartValue;
And NaN values are defined in IEEE Standard 754.


Best regards

Re: NaN Values

Posted: Tue Nov 22, 2011 10:58 am
by narcis
Hi BOA,
But still my program crash with error “Invalid pointer operation”.
Can you please attach a simple example project we can run "as-is" to reproduce the problem here¿
So my question is why can’t TChartValues contain NaN values when.

TChartValue : Double;
TChartValues : Array of TChartValue;
And NaN values are defined in IEEE Standard 754.
TeeChart doesn't automatically handle NaN values because there's no standard way to represent them and everybody expects they applications to deal NaNs in a different way so it's left to the programmer processing them to fit their needs.

Thanks in advance.

Re: NaN Values

Posted: Tue Nov 22, 2011 1:20 pm
by 16560004
Hi Narcis,

Please see my attach project.

Yes I am award of that.
TTreatNullsStyle = (tnDontPaint, tnSkip, tnIgnore)
And of course TChart needs to know how to draw/handle NaN points. But what wonder me is why TChartValue can’t have the value NaN.

The same problem appear in this
Series1.AddXYNull(100,0); //Okay
Why can I not write?
Series1.AddXYNull(100,NaN); //Invalid floating point operation

Best regards,

Re: NaN Values

Posted: Tue Nov 22, 2011 2:42 pm
by narcis
Hello,

Thanks for the project. Ok, now that I see the complete code I see that it's just a matter of commenting out the NaN assignment.

Code: Select all

The same problem appear in this
Series1.AddXYNull(100,0); //Okay
Why can I not write?
Series1.AddXYNull(100,NaN); //Invalid floating point operation
Ok, I have added your request (TV52015914) to the wish list to be considered for inclusion in future releases. By the way, how would you expect NaN values to be treated in TeeChart series? Would you consider those points null? And which value would you paint for them? Notice that in some circumstances null points are painted in series as well! That's probably the main reason why NaN values are not supported.

Re: NaN Values

Posted: Tue Nov 22, 2011 8:05 pm
by 16560004
Hi Narcis,

I am not quit sure how your null points is define, as I understand it, it still has a real value you just paint it with the same color as the background => invisible.
This is after my opinion not the same as a NaN value because if you for example do something like this
If ANaNValue > ARealValue then you will get the exact error that is the reason to my problem ‘Invalid floating point operation’. Where as if you do something like this ANewValue := ANaNValue * ARealValue you don’t get a error the result is just rightfully NaN.
So after my opinion a NaN value should not be painted at all but still be allowed in the array. You should also be able to do further calculations with the array. This is also how other mathematical programs do (for example Matlab).

Best regards,

Re: NaN Values

Posted: Wed Nov 23, 2011 8:04 am
by narcis
Hello,

Thanks for the feedback. I'll add in the wish-list description.