NaN Values

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
BOA
Newbie
Newbie
Posts: 7
Joined: Tue Aug 16, 2011 12:00 am

NaN Values

Post by BOA » Tue Nov 22, 2011 9:01 am

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

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

Re: NaN Values

Post by Narcís » Tue Nov 22, 2011 10:58 am

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.
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

BOA
Newbie
Newbie
Posts: 7
Joined: Tue Aug 16, 2011 12:00 am

Re: NaN Values

Post by BOA » Tue Nov 22, 2011 1:20 pm

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,
Attachments
Project.zip
(7.44 KiB) Downloaded 396 times

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

Re: NaN Values

Post by Narcís » Tue Nov 22, 2011 2:42 pm

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.
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

BOA
Newbie
Newbie
Posts: 7
Joined: Tue Aug 16, 2011 12:00 am

Re: NaN Values

Post by BOA » Tue Nov 22, 2011 8:05 pm

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,

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

Re: NaN Values

Post by Narcís » Wed Nov 23, 2011 8:04 am

Hello,

Thanks for the feedback. I'll add in the wish-list description.
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

Post Reply