0

I'm creating a JFreeChart with an XYLineAndShapeRenderer.

Now I want to add titles to the displayed graphs as follows:

enter image description here

But the method renderer.setItemLabelsVisible(true); seems to be deprecated:

enter image description here

Now I have tried doing the following:

    renderer.setBaseItemLabelGenerator(new StandardXYItemLabelGenerator());
    renderer.setBaseItemLabelsVisible(true);

But no result showed up.

Then I tried

renderer.setSeriesItemLabelsVisible(2, true);

But this also yields no result.

So my question is:

What is the correct alternative for renderer.setItemLabelsVisible(true);?

Jean-Paul
  • 19,910
  • 9
  • 62
  • 88

2 Answers2

1

You're probably looking for one of the setBaseItemLabelsVisible() implementations, suggested in the API. There are examples here and here.

Addendum: For individual labels, consider a suitable annotation, seen here and here.

Community
  • 1
  • 1
trashgod
  • 203,806
  • 29
  • 246
  • 1,045
  • As the examples cited work using `setBaseItemLabelGenerator()`, I'm guessing something else is wrong; please edit your question to include an [sscce](http://sscce.org/) that exhibits the problem you describe. – trashgod Aug 20 '13 at 19:56
-1
final IntervalMarker target = new IntervalMarker(4.5,5.0);target.setLabel("30 day moving average");
target.setLabelPaint(Color.RED);
target.setLabelAnchor(RectangleAnchor.LEFT);
target.setLabelTextAnchor(TextAnchor.TOP_LEFT);target.setPaint(Color.RED);
plot.addRangeMarker(target, Layer.BACKGROUND);
Nico
  • 12,493
  • 5
  • 42
  • 62