Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
210 views
in Technique[技术] by (71.8m points)

java - How to customize a tooltip of CategoryPlot items in JFreeChart?

I need to change the format of the default tooltip in the bars drawn in the plot of a chart.

I don't know if my direction of looking at the problem is right. I am looking at the default format for the class StandardCategoryToolTipGenerator that is

DEFAULT_TOOL_TIP_FORMAT_STRING = "({0}, {1}) = {2}"

How can I redefine this value?

Thanks in advance.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

The StandardCategoryToolTipGenerator sets the MessageFormat ArgumentIndex values to the series, category and value. Try this example on your plot.

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...