0

I am new to JFreechart and having a play with the different features provided. I am looking at an option to overlay a JButton on top of Jfreechart. For eg:- I have a chart with time/price and at some points in the graph, I want to have an option to have a button so that I can retrieve more details. Even a custom tooltip would help, but having a button would give more flexibility.

Is this something that can be done using JFreeChart?

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
user1669327
  • 135
  • 3
  • 9

1 Answers1

1

To see what ChartEntity is under the mouse, you can add a ChartMouseListener to your ChartPanel, as shown here.

Community
  • 1
  • 1
trashgod
  • 203,806
  • 29
  • 246
  • 1,045
  • Thanks, but is there a possibility of adding a button inside the chart at specific points so that the button is over the chart? – user1669327 May 10 '13 at 22:44
  • I've never tried. You could change the layout in `ChartPanel` and `add()` the button, but I'd just put it in a nearby container. – trashgod May 10 '13 at 23:01
  • The reason for the button(very small one) is I want to highlight the points which has additional details, so when I click the button I can display more information. This would allow me to attract attention to specific points in the chart instead of moving the cursor all over the chart. – user1669327 May 10 '13 at 23:18
  • I'd use an annotation for that; see also [`OverlayLayout`](http://stackoverflow.com/a/13437388/230513). – trashgod May 11 '13 at 03:07