jfreechart-fx | Extensions for JFreeChart to support JavaFX client
kandi X-RAY | jfreechart-fx Summary
kandi X-RAY | jfreechart-fx Summary
JFreeChart-FX is an extension for [JFreeChart] "JFreeChart Project Page at GitHub") that allows JFreeChart to be used in JavaFX applications.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Override paint to paint a chart .
- Zoomable axis .
- Creates the context menu for the export .
- Handle a mouse pressed event .
- Draw the chart .
- Handle the export to PNG PNG .
- Gets the tooltip text text for a given coordinate .
- Called when mouse pressed
- Returns true if the modifiers have the same modifiers .
- Returns true if enabled
jfreechart-fx Key Features
jfreechart-fx Examples and Code Snippets
Community Discussions
Trending Discussions on jfreechart-fx
QUESTION
I am currently trying to figure out, howjfreechart
's splitting into swing(1.5) and JavaFX (1.0.1) affects the JavaFX part. As far as I (very limited knowledge on this topic) understand The jfree-fx
uses fxgraphics2d
to draw its original swing components(?) into an FX-canvas to add this into JavaFX nodes.
Now my question is, if that fxgraphics2d
object is still interactable with? I mean things like tooltips and scrolling and similar stuff normal jfreechart
s offer. Since my knowledge and time is somewhat limited, I would want to know, if it is worth digging deeper into jfree-fx (if those charts are still interactable with) or if those charts are solely pictures of the actual chart and not interactable with. Then I would need to find a better solution.
I am currently learning how to build a candlestick chart within my java application. While I managed to build a chart only using JavaFX, its performance was really bad as soon as there were drawn some hundred candlesticks.
Then I came across jfreechart
, of which I read, that its performance is well above the internal JavaFX charting possibilities. So today I managed to construct my first chart with jfreechart-fx
and performance is quite ok. Further I find it much more intuitive to build those charts... but I am not sure if the jfree-fx
version only prints images or real chart objects to the nodes. (I read somewhere something about converting a chart into an image to increase performance of drawing...)
Thank you for any information on that topic.
For example here is my JFreeChart Class, which is drawn correctly, but I just do not get any interaction with the chart with my mouse. E.g. I'd like to zoom in/out using the mousewheel and I'd like to pan the chart to the left/right by clickhold leftmouse. That why I am concerned that I am only looking at an image right now. All viable solutions I find through google seem to address only JFreeChart
and not JFreeChart-FX
.
ANSWER
Answered 2019-Aug-30 at 19:09I haven't looked at jFreeChart in detail, but I think the main difference between it and the in-built JavaFX charting API is that jFreeChart uses a canvas for its implementation, whereas the in-built charts use the scene graph. Roughly, though not exactly, its similar to this definition of a retained mode (scene graph) vs immediate mode (canvas).
It's probably possible to add interactivity to canvas rendered graphics. It is likely technically challenging beyond basic whole-chart zoom and drag ops. Implementing or demonstrating the addition of such interactivity with canvas rendered graphics is beyond what I would be prepared to do within the context of a StackOverflow answer.
JFreeChart includes an interaction
package:
I suggest you investigate the interaction package, try using it and see if it offers the level of interaction you need.
As Roger mentions in the comments, you can get some basic interaction on a JFreeChartFX chart by wrapping the chart in a ChartViewer using ChartViewer(JFreeChart myChart)
.
Related question:
An aside on Canvas vs SceneGraph
This info on how canvas works is included so that you might have a better idea of what is going on here (note everything here may not be 100% correct, but is close enough to help understanding).
Technically, JavaFX only uses a SceneGraph for rendering. How canvas is internally implemented, as far as I understand, is that each canvas is a node in the scenegraph and comes with a command queue of drawing instructions. When you draw to the canvas, it doesn't draw immediately, instead it puts the drawing commands into a queue, then, at some point, before the next 60fps drawing pulse completes, it renders those to an image buffer that it relays into a JavaFX node. Old commands are forgotten by the canvas command queue once executed, so everything just ends up as pixels eventually. You can keep track of drawing commands within your application and re-issue them to repaint the canvas from scratch if you wish, but canvas won't help with that.
What JFreeChartFX is doing is providing an adapter which makes a JavaFX canvas look like a Swing painting surface, so that the heavy lifting and internal engine of JFreeChart can be used to issue all of the drawing commands, and those can be rendered to either a JavaFX canvas or Swing canvas depending upon the desired output UI tech.
If JFreeChart also provided a similar adapter for JavaFX events, rather than Swing events, and if JFreeChart already has a way to do interactivity using Swing events, then it could potentially add interactivity to JFreeChartFX using a similar adapter or replacement for Swing event mechanisms. Perhaps that is what the interaction
package linked above is doing.
QUESTION
I managed to create a Candlestick Chart using JFreeChart-FX
and display it using the fxgraphics2d
API. But I am pretty much confused on how to enable any interaction with my chart and need some help to this.
I'd be very grateful for any help in the right direction.
I started with this example to get up my initial Chart and altered it so that it uses my data. Then I use a custom Canvas
, which utilizes fxgraphics2d
to make the JPanel
component accessable as a node for my JavaFX
applicaiton.
So I know there is for example a specific PanHandlerFX
class, but I am lost to utilize this. As far as I was able to research (e.g. here), I need to add the PanHandlerFX
class to the list of availableMouseHandlers
of my ChartCanvas. But my canvas
does not offer anything like availableMouseHandlers
. I feel lost now, since there is so few tutorials and information to find regarding the JFree-FX charts and the documentation does not help me either.
Here is my custom canvas class:
...ANSWER
Answered 2019-Aug-29 at 02:02As shown here, construct a ChartViewer
with your JFreeChart
to create an interactive chart. The viewer's enclosed ChartCanvas
will manage the PanHandlerFX
for you. As a concrete example, add the following line to the example, and drag as described here:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install jfreechart-fx
You can use jfreechart-fx like any standard Java library. Please include the the jar files in your classpath. You can also use any IDE and you can run and debug the jfreechart-fx component as you would do with any other Java program. Best practice is to use a build tool that supports dependency management such as Maven or Gradle. For Maven installation, please refer maven.apache.org. For Gradle installation, please refer gradle.org .
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page