2
我在JFreeChart RingPlot上工作时遇到了一些麻烦。我已经设法将标签放入图表中,但我无法按自己的意愿更改其位置。我现在在哪里;JFreeChart - 环形图简单标签定位
我需要靠拢的LABES到图表的边缘,使我可以降低部分深度,并且具有更好的环的外观。到目前为止,我尝试使用setSimpleLabelOffset和setLabelGap方法,但效果不佳。
这是我的代码;
DefaultPieDataset dataset = new DefaultPieDataset();
dataset.setValue("Critical", new Integer(5));
dataset.setValue("Important", new Integer(20));
dataset.setValue("Moderate", new Integer(19));
dataset.setValue("Low", new Integer(5));
JFreeChart chart = ChartFactory.createRingChart("", dataset, false, true, false);
RingPlot pie = (RingPlot) chart.getPlot();
pie.setBackgroundPaint(Color.WHITE);
pie.setOutlineVisible(false);
pie.setShadowPaint(null);
pie.setSimpleLabels(true);
pie.setLabelGenerator(new StandardPieSectionLabelGenerator("{1}"));
//pie.setSimpleLabelOffset(new RectangleInsets(1, 1, 1, 1));
//pie.setLabelGap(0.05);
//pie.setLabelPadding(new RectangleInsets(100, 5, 10, 5));
pie.setLabelBackgroundPaint(null);
pie.setLabelOutlinePaint(null);
pie.setLabelShadowPaint(null);
pie.setSectionDepth(0.50);
pie.setSectionOutlinesVisible(false);
pie.setSeparatorsVisible(false);
pie.setIgnoreZeroValues(true);
任何想法我怎么能做到这一点? 在此先感谢。
编辑:感谢@trashgod的回应,但是我的环境出了问题。我复制并粘贴你上面提出和我所得到的是这样的整个代码:
什么版本'jfreechart'和'jcommon'您使用的? – trashgod