【发布时间】:2016-05-23 13:54:02
【问题描述】:
我在处理 JFreeChart RingPlot 时遇到了一些麻烦。我已经设法将标签放在我的图表中,但我无法随意更改它们的位置。我现在在哪里;
我需要将实验室移到更靠近图表边缘的位置,以便降低剖面深度并获得更好的环外观。到目前为止,我尝试使用 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 的回复,但我猜我的环境有问题。我复制并粘贴了您在上面提供的整个代码,我得到的是:
【问题讨论】:
标签: java jfreechart pie-chart