Skip to content

Supplier A vs. B dual-radar capability comparison (procurement) — generate this PDF with Java (DoubleRadar)

JQuick-PdfBiz Demo

DoubleRadar1 页 A4 · 459 KB

Two side-by-side radar charts comparing suppliers A and B across quality, price, delivery, service, technology and responsiveness, supporting the procurement strategy of prioritizing A for strategic goods while introducing B for competition on general goods.

Download the PDFView raw template fileBack to all demos

Supplier A vs. B dual-radar capability comparison (procurement) — DoubleRadar
Rendered output

Output specs

PDF pages
1
Chart type
DoubleRadar
Template lines
36
Source lines
105

Java source · JQuickBiz66TwoRadarTest.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.JDoubleRadarChartData;
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.awt.Color;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Arrays;

/**
 * 业务场景 Demo 66:两家供应商多维度能力双雷达对比(采购管理)
 *
 * <p>业务场景:采购管理部门从质量、价格、交付、服务、技术、响应六个维度
 * 综合打分,以双雷达图并列对比供应商 A 与供应商 B 的能力。</p>
 * <p>实际图表类型:{@link JChartType#DoubleRadar} 双雷达图。</p>
 *
 * <p>模板:{@code report/biz/66_twoRadar.txt};图表以 SVG 文本形式绑定到模板的
 * {@code ${svg}} 占位符,输出到 {@code D:\test\biz\66_twoRadar.pdf}。</p>
 *
 * <p>图表尺寸说明:图表按 700pt 宽的横版比例设计;模板中 {@code <svg>}
 * 只声明宽度、不声明高度,宽度被页面自动收窄时高度会按原比例同步缩放。</p>
 *
 * @author Martin
 * @version 1.0.0
 */
public class JQuickBiz66TwoRadarTest {

    public static final String path = JQuickConstant.path;

    @Test
    public void biz66TwoRadar() throws IOException {
        JDoubleRadarChartData chartData = new JDoubleRadarChartData();
        chartData.setTitleText("两家供应商多维度能力双雷达对比");
        chartData.setSubtitleText("左:供应商 A 右:供应商 B 维度:质量/价格/交付/服务/技术/响应");
        chartData.setLeftTitle("供应商 A");
        chartData.setRightTitle("供应商 B");
        chartData.setDimensions(Arrays.asList("质量", "价格", "交付", "服务", "技术", "响应"));

        JDoubleRadarChartData.RadarData leftRadar = new JDoubleRadarChartData.RadarData();
        JDoubleRadarChartData.Series leftSeries = new JDoubleRadarChartData.Series();
        leftSeries.setName("供应商 A");
        leftSeries.setValues(Arrays.asList(92.0, 70.0, 85.0, 80.0, 90.0, 75.0));
        leftSeries.setColor(new Color(136, 14, 79));
        leftRadar.setSeriesList(Arrays.asList(leftSeries));
        chartData.setLeftRadar(leftRadar);

        JDoubleRadarChartData.RadarData rightRadar = new JDoubleRadarChartData.RadarData();
        JDoubleRadarChartData.Series rightSeries = new JDoubleRadarChartData.Series();
        rightSeries.setName("供应商 B");
        rightSeries.setValues(Arrays.asList(78.0, 92.0, 70.0, 75.0, 72.0, 88.0));
        rightSeries.setColor(new Color(194, 24, 91));
        rightRadar.setSeriesList(Arrays.asList(rightSeries));
        chartData.setRightRadar(rightRadar);

        chartData.setGridLevels(5);
        chartData.setFillAlpha(70);
        chartData.setLineWidth(2.0f);
        chartData.setShowDataPoints(true);
        chartData.setLegendAtTop(true);
        chartData.setShowLegendSide(false);
        chartData.setFooterText("数据来源:供应商综合评估(满分 100)");

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

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

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

Template file · 66_twoRadar.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>
  // 66 双雷达图 Demo:左右两个雷达并列展示两组对象的多维度能力对比
  <div style="background:#880E4F; 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:#F8BBD0; fontSize:9">'左:供应商 A 右:供应商 B 维度:质量/价格/交付/服务/技术/响应'</p>
      </div>
      <div style="width:220px; textAlignment:right; borderLeft:1px solid #F48FB1; paddingLeft:10px">
        <p style="color:white; fontSize:9">'评估年度:2024 年'</p>
        <p style="color:#F8BBD0; fontSize:9">'评估方式:综合打分(满分 100)'</p>
        <p style="color:#F8BBD0; fontSize:9">'编制:采购管理部'</p>
      </div>
    </div>
  </div>

  <div style="marginBottom:10px; padding:10px; backgroundColor:#F7F9FC; borderRadius:4px; borderTop:2px solid #880E4F">
    <h2 style="color:#880E4F; marginBottom:6px; fontSize:13; bold:true">'一、供应商 A 与 B 六维能力对比'</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  双雷达图:左侧雷达为供应商 A,右侧雷达为供应商 B,六维评分对比'</p>
  </div>

  <list style="listStyleType:disc; paddingLeft:16px; fontSize:10">
    <li style="marginBottom:6px"><span style="bold:true; color:#880E4F">'质量与技术:'</span>'供应商 A 在质量稳定性和技术实力上得分更高。'</li>
    <li style="marginBottom:6px"><span style="bold:true; color:#880E4F">'价格与响应:'</span>'供应商 B 价格更具竞争力,响应速度更快。'</li>
    <li style="marginBottom:6px"><span style="bold:true; color:#880E4F">'建议:'</span>'战略物资优先 A,通用类物资可引入 B 形成竞争,降低综合采购成本。'</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.