jfreechart

时间:2017-05-24 05:47:44

标签: java jfreechart

如何在jfreechart中绘制半做坚果图表,例如使用以下链接,https://www.highcharts.com/demo/pie-semi-circle

这是我的代码

DefaultPieDataset dataset = new DefaultPieDataset( );

dataset.setValue("Safari-32", new Long( 32) );  dataset.setValue("Chrome-44", new Long( 44) ); 
dataset.setValue("Apple-24", new Long( 24) ); 
dataset.setValue("Google-75", new Long( 75) ); 
dataset.setValue("Michele", new Long( 97) );  dataset.setValue("Jony", new Long( 41) );

JFreeChart chart = ChartFactory.createRingChart("Chart title", dataset, true, false, false);
chart.setBackgroundPaint(Color.WHITE);
chart.setBorderVisible(false); 

RingPlot plots = (RingPlot) chart.getPlot();

Font font3 = new Font("Book Antiqua", Font.BOLD, 17); 



plots.setShadowPaint(null);
plots.setBackgroundPaint(null); 
plots.setOutlineVisible(false); 
plots.setLabelOutlinePaint(null);  
plots.setLabelBackgroundPaint(Color.WHITE);
plots.setCenterTextMode(CenterTextMode.FIXED);
String te = "334";
plots.setCenterText((String)te); plots.setCenterTextFont(font3);
plots.setLabelGenerator(null);  // Remove the labels from chart area

font3 = new Font("Book Antiqua", Font.PLAIN, 10); 
LegendTitle legend = chart.getLegend();
legend.setPosition(RectangleEdge.RIGHT); legend.setItemFont(font3); 

legend.setBorder(0, 0, 0, 0);



String filename = "D:\\ad\\do nut.jpg";
ChartUtilities.saveChartAsJPEG(new File(filename), chart, 250, 155);

这是我的代码,这会生成完整的圆环图。我需要一个从180度到0度的起始角度的甜甜圈

0 个答案:

没有答案