I want to implement a feature to a JFreeChart with a XYLineChart. So, for now I have a XYLineChart and I want to find the x-value depending the center of the peaks (see attached figure to understand what I want). So, I want to implement a threshold line (horizontal line, the blue one) which user can put where he wants, and at that specific y-value, the treshold line need to intersect the XYLine (spectrum). For me it's seems logically to start to iterate the values from that point and to see if the previous or forward points (let's say 10 points) has a lower tendency, if not, and has a higher tendency it's clear that the maxima is before the current point, and next iterate to that point and get the value of x depending of that maxima y.
Please, I need more ideas, and also if someone have time to guide me to due this thing that never done with and in JFreeChart (I think).
EDIT (1): This can be another solution? To extract the Y RangeValue, where the threshold line it intersect the data, and next to apply a line slope equation until the line slope equation is inversed (so there is the maxima). The LineFunction2D from JFreeChart is the way to do this?
You can use a ValueMarker
, illustrated here, to place a horizontal, blue line at the desired y-value. See also How do I find peaks in a dataset?.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With