This question already has answers here:
JFreeChart - customizing RingChart
                                
                                    (1个答案)
                                
                        
                        
                            Make a custom ring chart in JFreeChart
                                
                                    (1个答案)
                                
                        
                        
                            How to remove separator line in jfree chart- donut chart
                                
                                    (1个答案)
                                
                        
                                2年前关闭。
            
                    
如何使用JFreeChart库创建空心饼图?

如果无法使用JFreeChart,那么任何人都可以推荐一个库,我可以使用该库来创建空心的饼图,例如以下示例:

java - 如何使用JFreeChart库创建空心饼图-LMLPHP

最佳答案

它可能在JFreeChart中,尝试这样的事情。

RingPlot plot = new RingPlot(dataset);
StringBuffer chartFileName = new StringBuffer(Integer.toString(generatedCharts)).append(Long.toString(System.currentTimeMillis())).append(".png");

JFreeChart chart = new JFreeChart("", JFreeChart.DEFAULT_TITLE_FONT, plot, true);
chart.setBackgroundPaint(new GradientPaint(new Point(0, 0), new Color(20, 20, 20), new Point(400, 200), Color.DARK_GRAY));

TextTitle t = chart.getTitle();
t.setHorizontalAlignment(org.jfree.ui.HorizontalAlignment.LEFT);
t.setPaint(new Color(240, 240, 240));
t.setFont(new Font("Arial", Font.BOLD, 26));

plot.setBackgroundPaint(null);
plot.setOutlineVisible(false);
plot.setLabelGenerator(null);
plot.setSectionDepth(0.35);
plot.setSectionOutlinesVisible(false);
plot.setSimpleLabels(true);
plot.setShadowPaint(null);
plot.setOuterSeparatorExtension(0);
plot.setInnerSeparatorExtension(0);
plot.setLabelGenerator(new StandardPieSectionLabelGenerator("{1}",new DecimalFormat("#,##0"), new DecimalFormat("0.000%")));
plot.setLabelBackgroundPaint(null);
plot.setLabelOutlinePaint(null);

Font font=new Font("",0,16);
plot.setLabelFont(font);

chart.getLegend().setFrame(BlockBorder.NONE);
chart.getLegend().setPosition(RectangleEdge.BOTTOM);
chart.setBackgroundPaint(java.awt.Color.white);
chart.setPadding(new RectangleInsets(4, 8, 2, 2));


输出将是

java - 如何使用JFreeChart库创建空心饼图-LMLPHP

关于java - 如何使用JFreeChart库创建空心饼图,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/47217549/

10-11 21:32