Get information about the line between two datapoints

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Post Reply
mightymouse
Posts: 1
Joined: Mon Sep 03, 2018 10:16 pm
antibot: No, of course not.

Get information about the line between two datapoints

Post by mightymouse » Mon Sep 03, 2018 11:24 pm

I have a combined plot similar to this:

Image.


My question is: Is it possible to get information from about the dataset, or nearest data point, etc. on a mouse click or mouse over when the mouse event occurs between two data points. I have maximum four time series in my plot, and I have been trying to solve it for days now. I know I can use this if I click on a data point/annotation/legend, and it works fine. But I need to to get the same when I am clicking or hovering over the line between two connected points.

Code: Select all

  @Override
    public void chartMouseClicked(ChartMouseEventFX event) {
        
            // Chart entity contains information about the chart compenent
            final ChartEntity en = event.getEntity();
            
            if (en instanceof LegendItemEntity) {
                String legendItemEntity = ((LegendItemEntity) en).getSeriesKey().toString();
     
                }
In my plot, i have a steprender, and for that, I collect all data points before the coordinate of the click, and if the nearest has approx the same y-value, I know the value. But I think this approach is costly especially if there are a lot of data points.

I hope there is built in function that allows me to do this :)
Btw. I am using JFree 1.5.0. with JavaFX

Post Reply