Skip to content

City development line-radar assessment chart (development research) — generate this PDF with Java (LineRadar)

JQuick-PdfBiz Demo

LineRadar1 页 A4 · 301 KB

A quarterly GDP-growth line combined with eight development-index scatter points (innovation, coordination, green, openness, sharing and more) on one chart, highlighting the strong green score and the room to improve innovation.

Download the PDFView raw template fileBack to all demos

City development line-radar assessment chart (development research) — LineRadar
Rendered output

Output specs

PDF pages
1
Chart type
LineRadar
Template lines
36
Source lines
93

Java source · JQuickBiz61LineRadarTest.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.biz;

import com.github.paohaijiao.JOption;
import com.github.paohaijiao.combol.JLineScatterChartData;
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 org.junit.Test;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Arrays;
import java.util.List;

/**
 * 业务场景 Demo 61:城市综合发展评估折线雷达图(发改研究)
 *
 * <p>业务场景:发改研究院以折线展示季度 GDP 走势,以雷达散点展示创新、协调、
 * 绿色、开放、共享五维发展指数得分,综合评估城市发展质量。</p>
 * <p>实际图表类型:{@link JChartType#LineRadar} 折线雷达混合图。</p>
 *
 * <p>模板:{@code report/biz/61_lineRadar.txt};图表以 SVG 文本形式绑定到模板的
 * {@code ${svg}} 占位符,输出到 {@code D:\test\biz\61_lineRadar.pdf}。</p>
 *
 * <p>图表尺寸说明:图表按 700pt 宽的横版比例设计;模板中 {@code <svg>}
 * 只声明宽度、不声明高度,宽度被页面自动收窄时高度会按原比例同步缩放。</p>
 *
 * @author Martin
 * @version 1.0.0
 */
public class JQuickBiz61LineRadarTest {

    public static final String path = JQuickConstant.path;

    @Test
    public void biz61LineRadar() throws IOException {
        List<String> categories = Arrays.asList("创新", "协调", "绿色", "开放", "共享", "安全", "包容", "高效");
        // 折线:各季度 GDP 增速(%)
        List<Double> lineValues = Arrays.asList(5.2, 5.5, 5.8, 5.6, 6.0, 6.2, 5.9, 6.3);
        // 雷达散点:各维度发展指数得分(满分 100)
        List<Double> scatterValues = Arrays.asList(78.0, 72.0, 88.0, 65.0, 80.0, 70.0, 76.0, 74.0);

        JLineScatterChartData data = new JLineScatterChartData();
        data.setTitleText("城市综合发展评估折线雷达图");
        data.setSubtitleText("折线:季度 GDP 增速(%) 雷达散点:八维发展指数得分");
        data.setFooterText("数据来源:统计公报与专项评估");
        data.setCategories(categories);
        data.setLineValues(lineValues);
        data.setScatterValues(scatterValues);
        data.setLineSeriesName("GDP 增速");
        data.setScatterSeriesName("发展指数");
        data.setMaxValue(100);
        data.setGridCount(5);
        data.setShowDataLabels(true);

        JOption option = new JOption();
        option.setData(data);

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

        File dir = new File(path + "biz");
        if (!dir.exists()) {
            dir.mkdirs();
        }
        FileOutputStream fileOutputStream = new FileOutputStream(path + "biz/61_lineRadar.pdf");
        JPdfConfig config = new JPdfConfig();
        config.getLayoutConfig().setFlexLayout(true);
        JQuickPdfFactory factory = new JQuickPdfFactory(config);
        factory.bind("svg", svg);
        byte[] bytes = factory.executeResource("report/biz/61_lineRadar.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/biz/61_lineRadar.txt");

Template file · 61_lineRadar.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>
  // 61 折线雷达混合图 Demo:折线展示时间序列趋势,雷达展示多维度能力分布
  <div style="background:#00695C; padding:12px; borderRadius:4px; marginBottom:10px; keepTogether:true">
    <div style="display:flex; justifyContent:space-between">
      <div style="width:320px">
        <h1 style="color:white; fontSize:17; bold:true; marginBottom:3px">'城市综合发展评估折线雷达图'</h1>
        <p style="color:#B2DFDB; fontSize:9">'折线:GDP 季度走势 雷达:五维发展指数得分'</p>
      </div>
      <div style="width:220px; textAlignment:right; borderLeft:1px solid #4DB6AC; paddingLeft:10px">
        <p style="color:white; fontSize:9">'统计年度:2024 年'</p>
        <p style="color:#B2DFDB; fontSize:9">'评估对象:某市'</p>
        <p style="color:#B2DFDB; fontSize:9">'编制:发改研究院'</p>
      </div>
    </div>
  </div>

  <div style="marginBottom:10px; padding:10px; backgroundColor:#F7F9FC; borderRadius:4px; borderTop:2px solid #00695C">
    <h2 style="color:#00695C; marginBottom:6px; fontSize:13; bold:true">'一、季度 GDP 走势与五维发展指数'</h2>
    <div style="display:flex; justifyContent:center">
      <svg style="width:700pt">${svg}</svg>
    </div>
    <p style="fontSize:9; color:#6c757d; italic:true; marginTop:6px">'图 1  折线雷达混合图:折线反映季度 GDP 增速,雷达散点反映创新、协调、绿色、开放、共享五维得分'</p>
  </div>

  <list style="listStyleType:disc; paddingLeft:16px; fontSize:10">
    <li style="marginBottom:6px"><span style="bold:true; color:#00695C">'经济稳步增长:'</span>'四个季度 GDP 增速保持在合理区间,四季度小幅回升。'</li>
    <li style="marginBottom:6px"><span style="bold:true; color:#00695C">'绿色指数突出:'</span>'五维中绿色发展得分最高,生态环境治理成效显著。'</li>
    <li style="marginBottom:6px"><span style="bold:true; color:#00695C">'建议:'</span>'创新维度仍有提升空间,建议加大研发投入与人才引进力度。'</li>
  </list>

  <lineSeparator style="strokeColor:#DCE3EC"></lineSeparator>
  <p style="color:#6c757d; fontSize:8; textAlignment:center; marginTop:6px">'生成时间:2025年1月6日 | 批准人:研究院院长'</p>
</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.