Lazarus

Programming => Graphics and Multimedia => TAChart => Topic started by: AL on November 14, 2019, 07:23:21 pm

Title: Peak detection in TAChart ?
Post by: AL on November 14, 2019, 07:23:21 pm
Is there a way to detect peaks with TAChart in a TlineSeries?

Thanks,

Al
Title: Re: Peak detection in TAChart
Post by: Thaddy on November 14, 2019, 07:31:21 pm
You should not misuse the TaChart for that:TaChart is the presentation layer, not the compute layer.
 You should detect peaks in the data before you display it. And that is a simple max run.
Title: Re: Peak detection in TAChart ?
Post by: wp on November 14, 2019, 07:56:31 pm
No automatic peak detection, I agree with Thaddy.

There is a manual interactive peak detection with some limitations, though. Look at example "distancedemo" in folder "demo/distance" of your Lazarus installation, page "Fit": Select "Find peak" in the "Measure" box, then, holding the RIGHT mouse button down, drag from the somewhere below the peak to somewhere after the peak. The routine will fit a parabola to the data in the range spanned by the mouse range and display y and y value of the parabola's extremum.

Note, however, that this does not separate overlapping peaks or subtract a varying background. Therefore, the peak producing the shoulder near x=6 is reported at an incorrect value (7.75, but from the construction of the curve it should be at 2*pi = 6.28; finding the correct value requires more effort).
Title: Re: Peak detection in TAChart
Post by: AL on November 14, 2019, 08:51:32 pm
WP:  Thanks for pointing that demo.  This is interesting, I will study that.

You should not misuse the TaChart for that:TaChart is the presentation layer, not the compute layer.
 You should detect peaks in the data before you display it. And that is a simple max run.
This is what I tought, but I wanted to ask, just in case.  This package is so good, you never know.
At the moment, this is what I do, looking for max ( up to 3 peaks), but I need something a little fancier.

Thank you both for your quick answers