关闭

创建jfreechar饼图续(1)

156人阅读 评论(0) 收藏 举报

public final class PieChartFactory {

    private PieChartFactory() {
    }
    public static TimeSeries createTimeSeries(String name) {
        TimeSeries timeSeries = new TimeSeries(name);
        timeSeries.setMaximumItemAge(20);
        return timeSeries;
    }

    public static PieDataset createDataset(传入需要处理的数据) {

        //分区域
        String usered = "";
        String untapped = "";
        DefaultPieDataset result = new DefaultPieDataset();
        Long Capacity = 0L;//数据一
        Long useCapacity = 0L;//数据二
        result.setValue(usered, Capacity );设置值区域一
        result.setValue(untapped, useCapacity );设置值区域二
        return result;
    }

    //创建图

    public static JFreeChart createChart(PieDataset dataset, String title) {
        JFreeChart chart = ChartFactory.createPieChart3D(title, dataset, true, true, false);
        TextTitle textTitle = chart.getTitle();
        textTitle.setFont(new Font("", Font.PLAIN, 20));
       chart.getLegend().setItemFont(new Font("宋体", Font.PLAIN, 12));
        PiePlot3D plot = (PiePlot3D) chart.getPlot();
        plot.setStartAngle(-30);
        plot.setLabelFont(new Font("宋体", Font.PLAIN, 12));
        plot.setLabelGenerator(new StandardPieSectionLabelGenerator("{0}:{1}G({2})", NumberFormat.getNumberInstance(),
            new DecimalFormat("0.00%")));
        plot.setForegroundAlpha(1.0f);
        plot.setOutlinePaint(Color.WHITE);
        plot.setShadowPaint(Color.WHITE);
        plot.setBackgroundPaint(Color.white);
        chart.setBackgroundPaint(Color.white);
        return chart;
    }

}

0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:40294次
    • 积分:877
    • 等级:
    • 排名:千里之外
    • 原创:52篇
    • 转载:8篇
    • 译文:1篇
    • 评论:0条
    文章分类