我尝试了“LegendTitle”,但它没有用。我怎么能隐藏传说? 我有两个图形:CategoryPlot和
JFreeChart chart = ChartFactory.createStackedBarChart(res.getString("bar_chart.title"),
res.getString("bar_chart.sections.title"),
MessageFormat.format(res.getString("bar_chart.duration.title"),
res.getString("bar_chart.length.unit"),
"DM_ACTIVITY",
"activity_duration"),
dsTime);
CategoryPlot plot = chart.getCategoryPlot();
plot.setDataset(1, dsLength);
plot.mapDatasetToRangeAxis(1, 1);
plot.setRangeAxis(1, new NumberAxis(
MessageFormat.format(res.getString("bar_chart.length.title"),
dataContext.getUnitLabel(dataContext.getOverrideUnitSysId(),
"CD_HOLE_SECT_GROUP", "md_hole_sect_top"))
));
StackedBarRenderer barRenderer = (StackedBarRenderer) plot.getRenderer(0);
barRenderer.setBarPainter(new StandardBarPainter());
LineAndShapeRenderer shapeRenderer = new LineAndShapeRenderer();
shapeRenderer.setSeriesShape(0, new Rectangle.Float(-10, -10, 20, 20));
shapeRenderer.setLegendShape(0, new Rectangle.Float(-5, -5, 10, 10));
shapeRenderer.setBasePaint(Color.red);
shapeRenderer.setSeriesPaint(0, Color.red);
shapeRenderer.setBaseOutlinePaint(Color.white);
shapeRenderer.setBaseToolTipGenerator(new StandardCategoryToolTipGenerator());
plot.setRenderer(1, shapeRenderer);
plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD);
LegendTitle legend1 = new LegendTitle(shapeRenderer);
legend1.setVisible(false);
for (int i = 0; i < TIME_NONE; i++) {
plot.getRenderer().setSeriesPaint(i, Color.decode("#" + res.getString("color." + keys[i])));
}