java JFreeChart 条形图标签
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7155294/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
JFreeChart Bar Graph Labels
提问by codix
I have made it possible for value labels to appear on top of the bar in JFreeChart. However, it would look better if the labels are inside the bars. How do I make this work? The image below shows what I wanted the graph to look like.
我使值标签可以出现在 JFreeChart 中的栏顶部。但是,如果标签位于条形内部,效果会更好。我如何使这项工作?下图显示了我希望图形的外观。
回答by codix
I used the following code to make it work:
我使用以下代码使其工作:
StackedBarRenderer renderer = new StackedBarRenderer(false);
renderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator());
renderer.setBaseItemLabelsVisible(true);
chart.getCategoryPlot().setRenderer(renderer);`
回答by trashgod
Just specify the desired ItemLabelPosition
in your CategoryItemLabelGenerator
. BarChartDemo3
is an example, shown here.
只需ItemLabelPosition
在您的CategoryItemLabelGenerator
. BarChartDemo3
是一个例子,显示在这里。