When using JFreeChart with a ChartPanel I was able to register a ChartMouseListener. The listener's event provided information about which point in the chart was clicked. With FXGraphics2D I can use the generic setOnMouseClicked of the JavaFx Canvas to register a mouse event handler but the only information I get in the event is the coordinate within the canvas. How can I convert this to the information which point in the dataset was clicked, or is there any other recommended way of doing this?
Thanks
Timm
Mouse Event Handling
Re: Mouse Event Handling
Sorry, I started from the jfreechart example provided FxGraphics2D which was using a simple canvas. Now I discovered that there actually is a ChartCanvas which seems to provide the functionality I was looking for: https://github.com/jfree/jfreechart/tre ... e/chart/fx.
Where do I get the org/jfree/chart/fx part of the distribution? It is not in the maven artifact 'org.jfree:jfreechart:1.0.19' nor in the jfreechart-1.0.19.jar downloaded from the site. Is this not yet build into the release and needs to be taken directly from the source repository?
Where do I get the org/jfree/chart/fx part of the distribution? It is not in the maven artifact 'org.jfree:jfreechart:1.0.19' nor in the jfreechart-1.0.19.jar downloaded from the site. Is this not yet build into the release and needs to be taken directly from the source repository?
Re: Mouse Event Handling
To answer myself here: Use maven to build your own jfreechart.jar with javafx support. Then just use ChartCanvas as a replacement for ChartPanel
-
- JFreeChart Project Leader
- Posts: 11734
- Joined: Fri Mar 14, 2003 10:29 am
- antibot: No, of course not.
- Contact:
Re: Mouse Event Handling
Glad you found the ChartCanvas class. The JavaFX support is missing from the 1.0.19 build because we're still supporting Java 1.6 and that doesn't include JavaFX. If you want the JavaFX support, there is a build script you can run under JDK 1.8. I would like to get two new JFreeChart releases done, one without JavaFX (v 1.0.20) and one with (v 1.5.0). I have been working on it, but struggling to find enough time.
David Gilbert
JFreeChart Project Leader
Read my blog
Support JFree via the Github sponsorship program
JFreeChart Project Leader

