我正在尝试将 aStandardXYItemLabelGenerator
与XYAreaRenderer2
渲染器一起使用,但没有显示任何内容。如果使用相同的代码,XYLineAndShapeRenderer
我可以正确地看到图表上的标签。我怎样才能看到这些标签XYAreaChart
?
// create the chart...
final JFreeChart chart = ChartFactory.createXYAreaChart(
header_label, // chart title
x_label, // x axis label
y_label, // y axis lsabel
dataset, // data
PlotOrientation.VERTICAL,
includeLegend, // include legend
true, // tooltips
false // urls
);
// NOW DO SOME OPTIONAL CUSTOMIZATION OF THE CHART...
chart.setBackgroundPaint(Color.white);
// get a reference to the plot for further customization...
final XYPlot plot = chart.getXYPlot();
plot.setBackgroundPaint(Color.lightGray);
plot.setDomainGridlinePaint(Color.white); // X Axis is Domain
plot.setRangeGridlinePaint(Color.white); // Y Axis is Range
// Allow lines and shapes to be visible
renderer1 = new XYAreaRenderer();
// Set the tooltip generator
renderer1.setBaseToolTipGenerator(toolTipGenerator);
NumberFormat.getNumberInstance().setMaximumFractionDigits(2);
// renderer1.setBaseItemLabelGenerator(new StandardXYItemLabelGenerator("{0} {1} {2}", NumberFormat.getNumberInstance(), NumberFormat.getNumberInstance()));
renderer1.setBaseItemLabelGenerator(new StandardXYItemLabelGenerator("test {0} {1} {2}", NumberFormat.getNumberInstance(), NumberFormat.getNumberInstance()));
renderer1.setBaseItemLabelsVisible(true);
plot.setRenderer(renderer1);