Jfreechart selection
Asked Answered
H

2

7

Is there a way to be able to click on a segment on a plot and have jfreechart tell me the x/y coordinates of that point or somehow return the corresponding data associated with that line?

Does jfreechart have any packages at all for interacting with the plot?

Hallux answered 21/1, 2009 at 13:9 Comment(0)
C
5

Implementing the ChartMouseListener interface will provide you ChartMouseEvents when the user clicks on the chart. A ChartEntity is available from the ChartMouseEvent to give you specific information about what was clicked on.

I believe there's a demo showing how to capture chart mouse events in the JFreeChart Developer's Guide.

Concrete answered 21/1, 2009 at 16:35 Comment(0)
C
1

See this method in JFreeChart class:

public BufferedImage createBufferedImage(int width, int height,
                                             ChartRenderingInfo info)

You pass an instance of ChartRenderingInfo which you can use later to obtain the information about various parts using a code like this:

ChartEntity entity = info.getEntityCollection().getEntity(x, y);

See the javadoc for ChartRenderingInfo for other information that's available there.

Centaur answered 21/1, 2009 at 13:52 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.