0

In a nutshell: how to add a legend to a JFreeChart DialPlot?

More specifically, my DiaPlot looks like this: enter image description here

And I would like to indicate that values in [-100, 0] (red) range are "badluck" while values in [0, 100] (green) range are "goodluck".

Hence I'd like to add a legend to the DialPlot but unfortunately it seems that is doesn't have the setFixedLegendItems() method as other JFreeChart chart types do have.

Any idea / hint would be more than welcome.

Thanks! Thomas

Tom
  • 1,375
  • 3
  • 24
  • 45

1 Answers1

1

You can add a DialLayer, such as org.jfree.chart.plot.dial.DialTextAnnotation. Update the annotation in your implementation of PlotChangeListener. Related examples are seen here and here.

Community
  • 1
  • 1
trashgod
  • 203,806
  • 29
  • 246
  • 1,045
  • Thanks a lot but I'm not sure to understand how I could create a legend based on these examples (i.e. a one-color box with a description next to it) as I understand that it only writes text. To be more specific, I'd like to have the setFixedLegendItems() functionality on a DialPlot (where the colors of the legend correspond to the green and red lines on the DialPlot). Is there any approach to achieve this? Thx! – Tom Jun 16 '14 at 19:05
  • Not that I know. `DialTextAnnotation` is black, but you can change the text and color of an adjacent `JComponent`. – trashgod Jun 16 '14 at 22:35