Skip to content

Radar chart (purple) — generate this PDF with Java (RADAR)

JQuick-PdfCreditReport Demo

RADAR2 页 A4 · 121 KB

Presents the overall picture of multi-dimensional credit scores as a purple radar chart.

Download the PDFView raw template fileBack to all demos

Radar chart (purple) — RADAR
Rendered output

Output specs

PDF pages
2
Chart type
RADAR
Template lines
165
Source lines
85

Java source · JQuickCreditReport05RadarTest.java

This is the complete test class that produced the PDF above — copy it and run as-is; see the quick-start section for the Maven dependency.

/*
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * Copyright (c) [2025-2099] Martin ([email protected])
 */
package com.github.paohaijiao.demo.creditreport;

import com.github.paohaijiao.JOption;
import com.github.paohaijiao.JRadar;
import com.github.paohaijiao.code.JSeriesType;
import com.github.paohaijiao.code.JTrigger;
import com.github.paohaijiao.config.JPdfConfig;
import com.github.paohaijiao.demo.constant.JQuickConstant;
import com.github.paohaijiao.enums.JChartType;
import com.github.paohaijiao.executor.JQuickPdfFactory;
import com.github.paohaijiao.factory.JChartRendererFactory;
import com.github.paohaijiao.series.JRadarSeries;
import org.junit.Test;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;

/**
 * 统一信用报告 —— 风格 05:雷达图(紫色)
 *
 * <p>以 {@code report/credit_report_05_radar.txt} 为模板,把雷达图渲染成 SVG 后
 * 绑定到模板中的 {@code ${svg}} 占位符,输出到 {@code D:\test\creditreport\05_radar.pdf}。</p>
 *
 * @author Martin
 * @version 1.0.0
 */
public class JQuickCreditReport05RadarTest {

    public static final String path = JQuickConstant.path;

    @Test
    public void report05Radar() throws IOException {
        JOption option = new JOption();
        option.title().text("信用评级多维评估").subtext("各维度得分(满分100)");
        option.tooltip().trigger(JTrigger.item);
        JRadar radar = new JRadar();
        radar.indicator(
                new JRadar.Indicator().name("偿债能力").max(100),
                new JRadar.Indicator().name("盈利能力").max(100),
                new JRadar.Indicator().name("运营能力").max(100),
                new JRadar.Indicator().name("成长能力").max(100),
                new JRadar.Indicator().name("现金流").max(100),
                new JRadar.Indicator().name("信用历史").max(100)
        );
        option.radar(radar);
        JRadarSeries current = new JRadarSeries();
        current.name("本期评分").type(JSeriesType.radar).data(88, 92, 85, 95, 80, 90);
        JRadarSeries last = new JRadarSeries();
        last.name("上期评分").type(JSeriesType.radar).data(82, 85, 80, 88, 76, 86);
        option.series(current, last);

        String svg = JChartRendererFactory.renderChart(JChartType.RADAR, option);

        File dir = new File(path + "creditreport");
        if (!dir.exists()) {
            dir.mkdirs();
        }
        FileOutputStream fileOutputStream = new FileOutputStream(path + "creditreport/05_radar.pdf");
        JPdfConfig config = new JPdfConfig();
        // 开启 flex 行布局:图表与其右侧的指标说明面板在宽度允许时并排,而不是换行堆叠。
        config.getLayoutConfig().setFlexLayout(true);
        JQuickPdfFactory factory = new JQuickPdfFactory(config);
        factory.bind("svg", svg);
        byte[] bytes = factory.executeResource("report/credit_report_05_radar.txt");
        fileOutputStream.write(bytes);
        fileOutputStream.close();
    }
}

Minimal invocation (3 lines)

Skip the full test class — the core is these three lines: bind the chart SVG, execute the template, get the PDF bytes. Copy them straight into your project.

// config 可省略;svg 来自 JChartRendererFactory.renderChart(...),见下方完整源码
factory.bind("svg", svg);
byte[] pdf = new JQuickPdfFactory(config).executeResource("report/credit_report_05_radar.txt");

Template file · 05_radar.txt

An HTML-like template with inline CSS that renders to PDF once bound to data. The full template is below — copy it or download the raw file.

<pdf>
<body>
  <div style="display:flex; marginBottom:18px">
    <div style="width:240px; height:96px; backgroundColor:#4A148C; borderRadius:6px; textAlignment:center; verticalAlignment:center">
      <h1 style="textAlignment:center; color:white; fontSize:18; margin:0">'企业信用评级报告'</h1>
    </div>
    <div style="width:380px; paddingLeft:16px">
      <p style="fontSize:10; color:#4A148C; margin:3px 0">'报告编号: CR-2023-08975'</p>
      <p style="fontSize:10; color:#4A148C; margin:3px 0">'评估日期: 2023年11月15日'</p>
      <p style="fontSize:10; color:#4A148C; margin:3px 0">'评估机构: 四川省企业信用评估中心'</p>
    </div>
  </div>

  <div style="marginBottom:18px">
    <h2 style="color:#4A148C; fontSize:14; marginBottom:8px">'四川省泡海椒科技有限公司'</h2>
    <table style="width:620px; fontSize:10">
      <tr>
        <th style="backgroundColor:#4A148C; color:white; padding:5px; textAlign:left">'项目'</th>
        <th style="backgroundColor:#4A148C; color:white; padding:5px; textAlign:left">'内容'</th>
        <th style="backgroundColor:#4A148C; color:white; padding:5px; textAlign:left">'项目'</th>
        <th style="backgroundColor:#4A148C; color:white; padding:5px; textAlign:left">'内容'</th>
      </tr>
      <tr>
        <td style="backgroundColor:#f3e5f5; padding:5px; textAlign:left; bold:true">'统一信用代码'</td>
        <td style="padding:5px;">'91110108MA01XX1234'</td>
        <td style="backgroundColor:#f3e5f5; padding:5px; textAlign:left; bold:true">'成立日期'</td>
        <td style="padding:5px;">'2018年5月20日'</td>
      </tr>
      <tr>
        <td style="backgroundColor:#f3e5f5; padding:5px; textAlign:left; bold:true">'注册资本'</td>
        <td style="padding:5px;">'1000万元人民币'</td>
        <td style="backgroundColor:#f3e5f5; padding:5px; textAlign:left; bold:true">'法定代表人'</td>
        <td style="padding:5px;">'泡海椒'</td>
      </tr>
      <tr>
        <td style="backgroundColor:#f3e5f5; padding:5px; textAlign:left; bold:true">'所属行业'</td>
        <td style="padding:5px;">'软件和信息技术服务业'</td>
        <td style="backgroundColor:#f3e5f5; padding:5px; textAlign:left; bold:true">'企业规模'</td>
        <td style="padding:5px;">'中型(150-200人)'</td>
      </tr>
    </table>
  </div>

  <div style="marginBottom:18px">
    <h2 style="color:#7B1FA2; borderBottom:1px solid #7B1FA2; paddingBottom:4px; fontSize:13; marginBottom:10px">'历年财务数据(单位:万元)'</h2>
    <table style="width:620px; fontSize:10; marginTop:8px">
      <tr>
        <th style="backgroundColor:#7B1FA2; color:white; padding:6px; textAlign:left">'财务指标'</th>
        <th style="backgroundColor:#7B1FA2; color:white; padding:6px; textAlign:right">'2020年'</th>
        <th style="backgroundColor:#7B1FA2; color:white; padding:6px; textAlign:right">'2021年'</th>
        <th style="backgroundColor:#7B1FA2; color:white; padding:6px; textAlign:right">'2022年'</th>
        <th style="backgroundColor:#7B1FA2; color:white; padding:6px; textAlign:right">'2023年'</th>
        <th style="backgroundColor:#7B1FA2; color:white; padding:6px; textAlign:right">'增长率'</th>
      </tr>
      <tr>
        <td style="backgroundColor:#f3e5f5; padding:5px; textAlign:left; bold:true">'营业收入'</td>
        <td style="padding:5px; textAlign:right">'8,560'</td>
        <td style="padding:5px; textAlign:right">'12,340'</td>
        <td style="padding:5px; textAlign:right">'18,920'</td>
        <td style="padding:5px; textAlign:right">'25,680'</td>
        <td style="padding:5px; textAlign:right; color:#7B1FA2; bold:true">'+44.2%'</td>
      </tr>
      <tr>
        <td style="backgroundColor:#f3e5f5; padding:5px; textAlign:left; bold:true">'净利润'</td>
        <td style="padding:5px; textAlign:right">'1,240'</td>
        <td style="padding:5px; textAlign:right">'2,150'</td>
        <td style="padding:5px; textAlign:right">'3,890'</td>
        <td style="padding:5px; textAlign:right">'5,420'</td>
        <td style="padding:5px; textAlign:right; color:#7B1FA2; bold:true">'+63.8%'</td>
      </tr>
      <tr>
        <td style="backgroundColor:#f3e5f5; padding:5px; textAlign:left; bold:true">'总资产'</td>
        <td style="padding:5px; textAlign:right">'15,800'</td>
        <td style="padding:5px; textAlign:right">'22,450'</td>
        <td style="padding:5px; textAlign:right">'31,200'</td>
        <td style="padding:5px; textAlign:right">'42,800'</td>
        <td style="padding:5px; textAlign:right; color:#7B1FA2; bold:true">'+39.5%'</td>
      </tr>
      <tr>
        <td style="backgroundColor:#f3e5f5; padding:5px; textAlign:left; bold:true">'净资产'</td>
        <td style="padding:5px; textAlign:right">'9,200'</td>
        <td style="padding:5px; textAlign:right">'13,800'</td>
        <td style="padding:5px; textAlign:right">'19,500'</td>
        <td style="padding:5px; textAlign:right">'26,400'</td>
        <td style="padding:5px; textAlign:right; color:#7B1FA2; bold:true">'+42.1%'</td>
      </tr>
      <tr>
        <td style="backgroundColor:#f3e5f5; padding:5px; textAlign:left; borderTop:2px solid #7B1FA2; bold:true">'毛利率'</td>
        <td style="padding:5px; textAlign:right; borderTop:2px solid #7B1FA2; bold:true">'42.5%'</td>
        <td style="padding:5px; textAlign:right; borderTop:2px solid #7B1FA2; bold:true">'45.8%'</td>
        <td style="padding:5px; textAlign:right; borderTop:2px solid #7B1FA2; bold:true">'48.2%'</td>
        <td style="padding:5px; textAlign:right; borderTop:2px solid #7B1FA2; bold:true">'51.6%'</td>
        <td style="padding:5px; textAlign:right; borderTop:2px solid #7B1FA2; color:#7B1FA2; bold:true">'+9.1%'</td>
      </tr>
    </table>
  </div>

  <div style="marginBottom:18px">
    <h2 style="color:#7B1FA2; borderBottom:1px solid #7B1FA2; paddingBottom:4px; fontSize:13; marginBottom:10px">'关键经营指标'</h2>
    <div style="display:flex; marginBottom:10px">
      <div style="width:24px; paddingTop:4px">
        <div style="width:12px; height:12px; borderRadius:6px; backgroundColor:#9C27B0"></div>
      </div>
      <p style="width:570px; fontSize:11; margin:0">'营收增长率:连续三年保持40%以上增长,2023年达到25,680万元'</p>
    </div>
    <div style="display:flex; marginBottom:10px">
      <div style="width:24px; paddingTop:4px">
        <div style="width:12px; height:12px; borderRadius:6px; backgroundColor:#9C27B0"></div>
      </div>
      <p style="width:570px; fontSize:11; margin:0">'利润率提升:净利率从14.5%提升至21.1%,盈利能力显著增强'</p>
    </div>
    <div style="display:flex; marginBottom:10px">
      <div style="width:24px; paddingTop:4px">
        <div style="width:12px; height:12px; borderRadius:6px; backgroundColor:#9C27B0"></div>
      </div>
      <p style="width:570px; fontSize:11; margin:0">'研发投入:研发费用年均增长38.9%,占营收比例达13.3%'</p>
    </div>
    <div style="display:flex; marginBottom:10px">
      <div style="width:24px; paddingTop:4px">
        <div style="width:12px; height:12px; borderRadius:6px; backgroundColor:#9C27B0"></div>
      </div>
      <p style="width:570px; fontSize:11; margin:0">'人才结构:技术研发人员占比42%,硕士以上学历占35%'</p>
    </div>
    <div style="display:flex; marginBottom:10px">
      <div style="width:24px; paddingTop:4px">
        <div style="width:12px; height:12px; borderRadius:6px; backgroundColor:#9C27B0"></div>
      </div>
      <p style="width:570px; fontSize:11; margin:0">'客户质量:服务15家上市公司,客户续约率92%,大客户满意度4.8/5.0'</p>
    </div>
    <div style="display:flex; marginBottom:10px">
      <div style="width:24px; paddingTop:4px">
        <div style="width:12px; height:12px; borderRadius:6px; backgroundColor:#9C27B0"></div>
      </div>
      <p style="width:570px; fontSize:11; margin:0">'资产质量:资产负债率维持在38%左右,流动比率2.8,偿债能力良好'</p>
    </div>
  </div>

  <div style="marginBottom:18px">
    <h2 style="color:#7B1FA2; borderBottom:1px solid #7B1FA2; paddingBottom:4px; fontSize:13; marginBottom:10px">'信用评级多维雷达图'</h2>
    <div style="display:flex; justifyContent:center">
      <svg style="width:480px;height:400px">${svg}</svg>
    </div>
    <div style="display:flex; justifyContent:center; marginTop:10px">
      <p style="width:150px; fontSize:10; color:#7B1FA2; margin:0">'财务状况(90分): 营收稳定增长'</p>
      <p style="width:150px; fontSize:10; color:#7B1FA2; margin:0">'经营能力(95分): 客户留存率高'</p>
      <p style="width:150px; fontSize:10; color:#7B1FA2; margin:0">'偿债能力(85分): 负债率合理'</p>
      <p style="width:150px; fontSize:10; color:#7B1FA2; margin:0">'发展潜力(92分): 研发投入增加'</p>
    </div>
  </div>

  <div style="marginBottom:18px; background:linear-gradient(135deg, #f3e5f5 0%, #e1bee7 100%); borderRadius:10px; padding:16px">
    <h2 style="color:#4A148C; margin-top:0; fontSize:13; marginBottom:8px">'综合评价'</h2>
    <p style="fontSize:11; margin:0">
      '四川省泡海椒科技有限公司作为国家级高新技术企业和专精特新"小巨人"企业,在云计算和大数据领域表现出色。'
      '公司财务状况健康,经营能力突出,技术创新能力强,具备良好的发展潜力。信用评级为AAA级,展望稳定。'
    </p>
  </div>

  <div style="textAlignment:left; marginTop:18px; paddingTop:10px; borderTop:1px solid #e1bee7; color:#6a1b9a; fontSize:9">
    <p>'本报告依据公开信息和专业评估模型生成,仅供参考 | 报告生成时间: 2025年09月06日'</p>
    <p>'© 2023 企业信用评估中心 版权所有 | 认证编号: CE-2023-001'</p>
  </div>
</body>
</pdf>

More demos in this group

The PDF, preview image, template and source code on this page were all produced by a real JQuick-Pdf run and are free to copy into your own project.