Project approval volume trend (government / project supervision) — generate this PDF with Java (BAR)
BAR2 页 A4 · 98 KB
Counts the applications received and approved per month and compares approval throughput with a bar chart to spot backlog months.

Output specs
- PDF pages
- 2
- Chart type
- BAR
- Template lines
- 82
- Source lines
- 89
Java source · JQuickBiz17ProjectApprovalTest.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.axis.JCategoryAxis;
import com.github.paohaijiao.axis.JValueAxis;
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.JBar;
import org.junit.Test;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
/**
* 业务场景 Demo 17:项目审批数量趋势(政务/项目监管平台)
*
* <p>业务场景:项目监管平台按月统计「受理 / 审批通过 / 退回补正」三类的项目审批数量,
* 用于观察审批负荷与办理质量的变化。</p>
* <p>实际图表类型:{@link JChartType#BAR} 柱状图(分组柱,用于对比三类审批结果)。</p>
*
* <p>模板:{@code report/biz/17_project_approval.txt};图表以 SVG 文本形式绑定到模板的
* {@code ${svg}} 占位符,输出到 {@code D:\test\biz\17_project_approval.pdf}。</p>
*
* <p>图表尺寸说明:图表按 700pt × 380pt(宽 × 高)的横版比例设计;模板中 {@code <svg>}
* 只声明宽度、不声明高度,因此宽度被页面自动收窄时高度会按原比例同步缩放,不会纵向拉伸变形。</p>
*
* @author Martin
* @version 1.0.0
*/
public class JQuickBiz17ProjectApprovalTest {
public static final String path = JQuickConstant.path;
@Test
public void biz17ProjectApproval() throws IOException {
JOption option = new JOption();
option.title().text("2024年项目审批数量趋势").subtext("受理 / 审批通过 / 退回补正(单位:件)");
option.tooltip().trigger(JTrigger.axis);
JCategoryAxis xAxis = new JCategoryAxis();
xAxis.data("1月", "2月", "3月", "4月", "5月", "6月", "7月", "8月", "9月", "10月", "11月", "12月");
option.xAxis(xAxis);
option.yAxis(new JValueAxis());
// 三类审批结果各一根柱,沿用政务系统低饱和主色
JBar accepted = new JBar();
accepted.name("受理").data(142, 138, 155, 163, 158, 171, 182, 176, 195, 203, 214, 226);
JBar approved = new JBar();
approved.name("审批通过").data(112, 110, 124, 132, 128, 140, 150, 145, 161, 169, 178, 189);
JBar returned = new JBar();
returned.name("退回补正").data(22, 20, 24, 25, 23, 26, 27, 25, 28, 27, 29, 30);
option.series(accepted, approved, returned);
String svg = JChartRendererFactory.renderChart(JChartType.BAR, option);
File dir = new File(path + "biz");
if (!dir.exists()) {
dir.mkdirs();
}
FileOutputStream fileOutputStream = new FileOutputStream(path + "biz/17_project_approval.pdf");
JPdfConfig config = new JPdfConfig();
// 开启 flex 行布局,使模板中的 display:flex 生效(图表居中)
config.getLayoutConfig().setFlexLayout(true);
JQuickPdfFactory factory = new JQuickPdfFactory(config);
factory.bind("svg", svg);
byte[] bytes = factory.executeResource("report/biz/17_project_approval.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/17_project_approval.txt");Template file · 17_project_approval.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="textAlignment:center; marginBottom:10px; padding:14px; background:#2F5597; borderRadius:4px; keepTogether:true">
<h1 style="textAlignment:center; color:white; marginBottom:6px; fontSize:18pt; bold:true">'项目审批数量趋势月报'</h1>
<p style="color:white; fontSize:10pt; margin:2px">'统计周期:2024年1月 - 2024年12月'</p>
<p style="color:white; fontSize:10pt; margin:2px">'编制单位:市政务服务管理局 | 报送对象:项目监管联席会议'</p>
</div>
<div style="marginBottom:10px">
<h2 style="color:#2F5597; fontSize:13pt; bold:true; marginBottom:6px">'一、月度审批数量趋势'</h2>
<div style="display:flex; justifyContent:center">
<svg style="width:700pt">${svg}</svg>
</div>
<p style="fontSize:9pt; color:#6c757d; italic:true; marginTop:6px">'图 1 2024年1-12月受理 / 审批通过 / 退回补正项目数量(数据来源:市项目审批监管系统)'</p>
</div>
<div style="marginBottom:10px">
<h2 style="color:#2F5597; fontSize:13pt; bold:true; marginBottom:6px">'二、季度审批结果汇总'</h2>
<table style="width:560px; fontSize:10pt">
<tr>
<th style="width:120px; backgroundColor:#2F5597; color:white; padding:6px; textAlign:center; border:1px solid #DCE3EC">'季度'</th>
<th style="width:110px; backgroundColor:#2F5597; color:white; padding:6px; textAlign:center; border:1px solid #DCE3EC">'受理(件)'</th>
<th style="width:110px; backgroundColor:#2F5597; color:white; padding:6px; textAlign:center; border:1px solid #DCE3EC">'审批通过(件)'</th>
<th style="width:110px; backgroundColor:#2F5597; color:white; padding:6px; textAlign:center; border:1px solid #DCE3EC">'退回补正(件)'</th>
<th style="width:110px; backgroundColor:#2F5597; color:white; padding:6px; textAlign:center; border:1px solid #DCE3EC">'通过率'</th>
</tr>
<tr>
<td style="padding:5px; border:1px solid #DCE3EC">'第一季度'</td>
<td style="padding:5px; textAlign:right; border:1px solid #DCE3EC">'435'</td>
<td style="padding:5px; textAlign:right; border:1px solid #DCE3EC">'346'</td>
<td style="padding:5px; textAlign:right; border:1px solid #DCE3EC">'66'</td>
<td style="padding:5px; textAlign:right; border:1px solid #DCE3EC">'79.5%'</td>
</tr>
<tr>
<td style="padding:5px; backgroundColor:#EAF1F8; border:1px solid #DCE3EC">'第二季度'</td>
<td style="padding:5px; textAlign:right; backgroundColor:#EAF1F8; border:1px solid #DCE3EC">'492'</td>
<td style="padding:5px; textAlign:right; backgroundColor:#EAF1F8; border:1px solid #DCE3EC">'400'</td>
<td style="padding:5px; textAlign:right; backgroundColor:#EAF1F8; border:1px solid #DCE3EC">'74'</td>
<td style="padding:5px; textAlign:right; backgroundColor:#EAF1F8; border:1px solid #DCE3EC">'81.3%'</td>
</tr>
<tr>
<td style="padding:5px; border:1px solid #DCE3EC">'第三季度'</td>
<td style="padding:5px; textAlign:right; border:1px solid #DCE3EC">'553'</td>
<td style="padding:5px; textAlign:right; border:1px solid #DCE3EC">'456'</td>
<td style="padding:5px; textAlign:right; border:1px solid #DCE3EC">'80'</td>
<td style="padding:5px; textAlign:right; border:1px solid #DCE3EC">'82.5%'</td>
</tr>
<tr>
<td style="padding:5px; backgroundColor:#EAF1F8; border:1px solid #DCE3EC">'第四季度'</td>
<td style="padding:5px; textAlign:right; backgroundColor:#EAF1F8; border:1px solid #DCE3EC">'643'</td>
<td style="padding:5px; textAlign:right; backgroundColor:#EAF1F8; border:1px solid #DCE3EC">'536'</td>
<td style="padding:5px; textAlign:right; backgroundColor:#EAF1F8; border:1px solid #DCE3EC">'86'</td>
<td style="padding:5px; textAlign:right; backgroundColor:#EAF1F8; border:1px solid #DCE3EC">'83.4%'</td>
</tr>
<tr>
<td style="padding:6px; bold:true; border:1px solid #DCE3EC">'全年合计'</td>
<td style="padding:6px; textAlign:right; bold:true; border:1px solid #DCE3EC">'2,123'</td>
<td style="padding:6px; textAlign:right; bold:true; border:1px solid #DCE3EC">'1,738'</td>
<td style="padding:6px; textAlign:right; bold:true; border:1px solid #DCE3EC">'306'</td>
<td style="padding:6px; textAlign:right; bold:true; border:1px solid #DCE3EC">'81.9%'</td>
</tr>
</table>
</div>
<div style="marginBottom:10px">
<h2 style="color:#2F5597; fontSize:13pt; bold:true; marginBottom:6px">'三、审批运行结论'</h2>
<list style="listStyleType:disc; paddingLeft:16px; fontSize:10pt">
<li style="marginBottom:5px"><span style="bold:true; color:#2F5597">'审批总量稳步上行:'</span>'全年受理项目 2,123 件、审批通过 1,738 件,四季度受理量较一季度增长 47.8%(643 件对 435 件)。'</li>
<li style="marginBottom:5px"><span style="bold:true; color:#2F5597">'通过率逐季提升:'</span>'通过率由一季度 79.5% 升至四季度 83.4%,全年 81.9%;退回补正占比由 15.2% 降至 13.4%。'</li>
<li style="marginBottom:5px"><span style="bold:true; color:#2F5597">'退回补正高位平稳:'</span>'全年退回补正 306 件,月均 25.5 件,四季度 86 件为年内高点,材料完整性仍是主要影响因素。'</li>
<li style="marginBottom:5px"><span style="bold:true; color:#2F5597">'年末高峰特征明显:'</span>'12月受理 226 件、审批通过 189 件,均为全年单月峰值,与年度项目集中申报节奏一致。'</li>
<li style="marginBottom:5px"><span style="bold:true; color:#2F5597">'建议:'</span>'在年末申报高峰前增设预审窗口,并完善线上材料校验规则,力争将退回补正占比压降至 12% 以内。'</li>
</list>
</div>
<div style="textAlignment:center; marginTop:10px; paddingTop:10px; borderTop:1px solid #dee2e6; color:#6c757d; fontSize:8pt">
<p>'数据来源:市项目审批监管系统 | 生成时间:2025年1月10日'</p>
<p>'内部资料 · 未经许可请勿外传'</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.