正如我在图片中显示的那样,我想将列标签(值 434、2562、....)向上移动一点。有什么办法可以配置吗?我最初的问题是,由于列之间的差异,最后两列上的标签不再可见(它们实际上是 15 和 24 或类似的 stg)。我不知道如何改变它。谢谢
问问题
4250 次
2 回答
3
You can use BarRenderer3D.setSeriesPositiveItemLabelPosition
.
For example :
DefaultCategoryDataset dataset = new DefaultCategoryDataset();
dataset.addValue(51.0, "Series 1", "key1");
dataset.addValue(44.3, "Series 1", "key2");
// create the chart...
JFreeChart chart = ChartFactory.createBarChart3D("Demo","Category","Value",dataset,PlotOrientation.VERTICAL,false,true,false);
CategoryPlot plot = chart.getCategoryPlot();
CategoryAxis domainAxis = plot.getDomainAxis();
domainAxis.setVisible(false);
NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
rangeAxis.setUpperMargin(0.15);
BarRenderer3D renderer = (BarRenderer3D) plot.getRenderer();
CategoryItemLabelGenerator generator = new StandardCategoryItemLabelGenerator();
renderer.setSeriesItemLabelGenerator(0, generator);
renderer.setSeriesItemLabelsVisible(0, true);
renderer.setSeriesPositiveItemLabelPosition(0, new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12,TextAnchor.BASELINE_CENTER));
renderer.setItemLabelAnchorOffset(10);
The result is :
于 2013-01-16T12:07:30.937 回答
1
CategoryPlot plot = (CategoryPlot) chart.getPlot();
BarRenderer renderer = (BarRenderer) plot.getRenderer();
renderer.setBasePositiveItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.TOP_CENTER,TextAnchor.HALF_ASCENT_CENTER,0D));
于 2013-05-23T06:09:53.763 回答