问题
I've never used JFreeChart before. It has been told me that it's a pretty good product for drawing charts in Java.
I have a doubt, and I would like to have some advices by someone that has already some JFreeChart experience:
is JFreeChart designed only for display static precomputed set of values?
Or is there any "pretty easy" way to handle mouse event (possibly dragging) in order to dynamically change the displayed curves (and consequentely the associated data set)?
With "pretty easy" I mean been able to do the following without having to write too much lines of code:
- Click on a displayed chart (for example Line Chart ) and identify the closer point of the dataset displayed .
- Use some sort of drag event to change the dataset value according to the movement of the mouse
- Show the updated chart interactively
回答1:
JFreeChart can certainly handle dynamic charts, as shown here; and you can interact in a variety of ways with an existing chart, as shown here.
Addendum: Here's a few more specifics:
The default tooltip generator displays data when you hover over a point, but you can also supply a custom generator.
ChartPanel
implements bothMouseListener
andMouseMotionListener
.The JWS demo is a trove of examples, many interactive. The
crosshair
demos are particularly appealing.
来源:https://stackoverflow.com/questions/6337851/jfreechart-general-issue-on-the-possibility-of-interactlively-modify-a-displayed