Lazarus

Programming => Graphics and Multimedia => TAChart => Topic started by: arneolav on May 16, 2020, 11:25:28 pm

Title: LineSeries.GetMax, GetMin. Error in use of NaN
Post by: arneolav on May 16, 2020, 11:25:28 pm
Hi!
I'v got an error on LineSeries.GetMax/GetMin

Max/MinValue : Double

LineSeries.AddXY(DateTime, NaN, ReferenceText, clBlack)
Error on:   
LineSeries.GetMax(MaxDateTime, MaxValue); (Same error on GetMin)

This is ok:
AreaSeries.AddXY(DateTime, NaN, ReferenceText,  clBlack)
AreaSeries.GetMax(MaxDateTime, MaxValue);         
AreaSeries.GetMin(MinDateTime, MinValue);         

Error dump attached:
Title: Re: LineSeries.GetMax, GetMin. Error in use of NaN
Post by: wp on May 17, 2020, 11:02:08 am
I can reproduce the issue with the line series, but I cannot reproduce that there is no error for the area series, in other words: I see the crash also with TAreaSeries, and this is to be expected since the bug is a missing check for NaN in TListChartsource which is used by both series types. Please specify what exactly you are doing. Ideally, upload a simple demo program showing that TLineSeries does not work but TAreaSeries does.
Title: Re: LineSeries.GetMax, GetMin. Error in use of NaN
Post by: arneolav on May 17, 2020, 02:22:30 pm
After some more testing I'v found the same error in AreaSeries.
When only a few (up to 7) numbers are greater than limit value, then both Area and Line does work.
With some more numbers, non of them does work.



Title: Re: LineSeries.GetMax, GetMin. Error in use of NaN
Post by: wp on May 18, 2020, 11:46:14 am
Added the missing NaN check to trunk (and requested backporting to Laz fixes). Please check. If you do not use trunk you can fix it yourself easily:
I noticed that there is another bug: the area series crashes when y of the first or last data point is NaN. Trying to fix it...

[EDIT]
Backporting to fixes is not possible fix refers to a trunk-only feature.
Title: Re: LineSeries.GetMax, GetMin. Error in use of NaN
Post by: arneolav on May 18, 2020, 01:37:39 pm
Thanks!
Did some testing, all ok in normal test. Example on celcius numbers > 10 are removed ok.
But on Area, test Lux > 0, to provocate first/last error;
No "dump error", but first numbers are set to negative.  (Lux values are never negative in input.)
I'll look more on this.
Title: Re: LineSeries.GetMax, GetMin. Error in use of NaN
Post by: wp on May 18, 2020, 01:40:24 pm
... celcius numbers ... test Lux > 0 ... dump error ...
Sorry, I don't know what you are talking about.
Title: Re: LineSeries.GetMax, GetMin. Error in use of NaN
Post by: arneolav on May 18, 2020, 06:23:56 pm
celcius numbers: degree Celsius numbers ( °C )

Sensors may report light as Lux, Lumen or Candela
The lux (symbol: lx) is the SI derived unit of illuminance, measuring luminous flux per unit area. (Sunlight illuminance)
The lumen (symbol: lm) is the SI derived unit for brightness.
A candela is the SI base unit of luminous intensity. It measures how bright something is

dump error: I mean I got no error. (no dump, no error).
....

Negative numbers:
There are no negative numbers in the actual test input from sensor, (Lux, Sunlight).
By night the sensors are reporting 0, zero. (no light, input value = 0).
But the AreaSerie display 0 numbers as a range from zero to -1.
This is not new now and is not an problem.

....
The fix in  tacustomsources.pas did solve the problem, Thank you!

Title: Re: LineSeries.GetMax, GetMin. Error in use of NaN
Post by: wp on May 18, 2020, 06:56:10 pm
I know about these units, but was not aware that you had plotted such values. It just came out of nothing.

Yes, Areaderies plots down to neg infinity. But you can activate the UseZeroLevel, then the area will start at 0 (or whatever you choose as zero level). With only zeros in the ChartSource the left axis still goes down to -1. You can force the y axis to begin at 0 by setting Chart.Extent.YMin = 0 and chart.Extent.UseYMin = true.
Title: Re: LineSeries.GetMax, GetMin. Error in use of NaN
Post by: arneolav on May 18, 2020, 08:59:42 pm
UseZeroLevel.... Of course, there is also a solution for this in TaChart.
I am constantly amazed at how many opportunities exist in TaChart, far beyond my imagination!
Again Thanks!
TinyPortal © 2005-2018