将数据生成雷达图

本文介绍了如何在Java项目中添加相关依赖,以实现雷达图的生成。通过这些步骤,你可以创建出具有展示多维度数据能力的雷达图表。
摘要由CSDN通过智能技术生成

添加依赖

<dependency>
    <groupId>jfree</groupId>
    <artifactId>jfreechart</artifactId>
    <version>1.0.13</version>
</dependency>

<dependency>
    <groupId>jfree</groupId>
    <artifactId>jcommon</artifactId>
    <version>1.0.16</version>
</dependency>

<dependency>
    <groupId>org.jfree</groupId>
    <artifactId>jfreechart</artifactId>
    <version>1.5.0</version>
</dependency>

public class ImageUtil {

    public static void main(String args[]) {
        //在SWING中显示
        JFrame jf = new JFrame();
        jf.add(erstelleSpinnenDiagramm());
        jf.pack();
        jf.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
        jf.setVisible(true);
        //将JFreeChart保存为图片存在文件路径中
        saveAsFile("D:/test.png", 837, 630);
    }

    public static JPanel erstelleSpinnenDiagramm() {
        JFreeChart jfreechart = createChart();
        ChartPanel chartpanel = new ChartPanel(jfreechart);
        return chartpanel;
    }

    public static void saveAsFile(String outputPath, int weight, int height) {
        FileOutputStream out = null;
        try {
            File outFile = new File(outputPath);
            if (!outFile.getParentFile().exists()) {
                outFile.getParentFile().mkdirs();
            }
            out = new FileOutputStream(outputPath);
// 保存为PNG
            ChartUtilities.writeChartAsPNG(out, createChart(), weight, height);
// 保存为JPEG
// ChartUtilities.writeChartAsJPEG(out, chart, 500, 400);
            out.flush();
        } catch (FileNotFoundException e) {
            e.prin
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值