1

I am adding tooltip to Box and Whisker plot.

final BoxAndWhiskerRenderer renderer = new BoxAndWhiskerRenderer();
String tooltipformat = "Max: {5}\nQ3: {7}\nQ1: {6}\nMin: {4}\nMean: {2}\nMedian: {3}";
renderer.setBaseToolTipGenerator(new BoxAndWhiskerToolTipGenerator(tooltipformat,NumberFormat.getNumberInstance()));

I get the result below.

enter image description here

Instead of getting the tooltip label in a column, I got it in a row. Why does the \n is useless?

Sam
  • 1,252
  • 5
  • 20
  • 43

2 Answers2

1

Use HTML will do.

String tooltipformat = "<html><body>Max: {5}<br>Q3: {7}<br>Median: {3}<br>Q1: {6}<br>Min: {4}<br>Mean: {2}</body></html>";
renderer.setBaseToolTipGenerator(new BoxAndWhiskerToolTipGenerator(tooltipformat,NumberFormat.getNumberInstance()));
Sam
  • 1,252
  • 5
  • 20
  • 43
1

Because ChartPanel uses a ToolTipManager.sharedInstance(), you can break multi-line tooltips as suggested here and here. As another example, the following changes to BarChartDemo1, seen here, produce the results illustrated below.

BarRenderer renderer = (BarRenderer) plot.getRenderer();
renderer.setBaseToolTipGenerator(new StandardCategoryToolTipGenerator(
    "<html>Series: {0}<br>Category: {1}<br>Value: {2}</html>",
    NumberFormat.getInstance()));

image

trashgod
  • 203,806
  • 29
  • 246
  • 1,045