马一丁

Update the test renderer

... ... @@ -364,6 +364,68 @@ def build_chapters() -> list[dict]:
],
}
pest_block = {
"type": "pestTable",
"title": "宏观环境脉冲扫描(PEST)",
"summary": "模拟四大维度的外部约束与机会,验证 pestTable 的渲染样式。",
"political": [
{
"title": "地方条例征求意见",
"detail": "短视频发布需实名溯源,平台合规沟通窗口期开启",
"trend": "正面利好",
"impact": 7,
},
{
"title": "监管关注情绪煽动",
"detail": "对夸大矛盾的账号重点巡查,舆论阈值下调",
"trend": "持续观察",
"impact": 6,
},
],
"economic": [
{
"title": "周边商户营收波动",
"detail": "客流短期下滑 12%,但直播带货订单上升",
"trend": "中性",
"impact": 5,
},
{
"title": "品牌赞助谨慎",
"detail": "赞助延期观察声誉风险,对官宣节奏有压力",
"trend": "不确定",
"impact": 4,
},
],
"social": [
{
"title": "核心群体情绪分化",
"detail": "本地居民关注安全,外地游客关注体验与退款",
"trend": "负面影响",
"impact": 8,
},
{
"title": "高校社群自发求证",
"detail": "校媒与学生会组织“以图搜图”科普贴,情绪趋稳",
"trend": "正面利好",
"impact": 6,
},
],
"technological": [
{
"title": "AI 生成内容被混入",
"detail": "局部画面被放大后再传播,需水印溯源工具辅助鉴伪",
"trend": "负面影响",
"impact": 7,
},
{
"title": "多模态检索上线",
"detail": "平台试行“视频反诈”模型,自动提示剪辑痕迹",
"trend": "正面利好",
"impact": 5,
},
],
}
callout_block = {
"type": "callout",
"tone": "warning",
... ... @@ -422,6 +484,164 @@ def build_chapters() -> list[dict]:
}
widget_block = build_widget_block()
stacked_bar_chart_block = {
"type": "widget",
"widgetId": "demo-stacked-sentiment",
"widgetType": "chart.js/bar",
"props": {
"type": "bar",
"options": {
"responsive": True,
"plugins": {"legend": {"position": "bottom"}},
"scales": {
"x": {"stacked": True},
"y": {"stacked": True, "title": {"display": True, "text": "信息量"}},
},
},
},
"data": {
"labels": ["周一", "周二", "周三", "周四", "周五"],
"datasets": [
{"label": "正向", "data": [18, 22, 24, 19, 16], "backgroundColor": "#27ae60"},
{"label": "中性", "data": [22, 20, 18, 21, 23], "backgroundColor": "#f39c12"},
{"label": "负向", "data": [12, 14, 10, 9, 11], "backgroundColor": "#c0392b"},
],
},
}
doughnut_chart_block = {
"type": "widget",
"widgetId": "demo-sentiment-share",
"widgetType": "chart.js/doughnut",
"props": {
"type": "doughnut",
"options": {"plugins": {"legend": {"position": "right"}, "tooltip": {"enabled": True}}},
},
"data": {
"labels": ["政策", "经济", "社会", "技术"],
"datasets": [
{
"label": "关注度占比",
"data": [24, 30, 28, 18],
"backgroundColor": ["#8e44ad", "#16a085", "#e67e22", "#2980b9"],
"hoverOffset": 6,
}
],
},
}
radar_chart_block = {
"type": "widget",
"widgetId": "demo-response-radar",
"widgetType": "chart.js/radar",
"props": {
"type": "radar",
"options": {
"plugins": {"legend": {"position": "top"}},
"scales": {"r": {"beginAtZero": True, "max": 100}},
},
},
"data": {
"labels": ["透明度", "响应速度", "一致性", "互动度", "信息量"],
"datasets": [
{
"label": "官方渠道",
"data": [78, 88, 82, 66, 91],
"backgroundColor": "rgba(46,204,113,0.15)",
"borderColor": "#2ecc71",
"pointBackgroundColor": "#27ae60",
},
{
"label": "民间讨论",
"data": [64, 72, 58, 74, 63],
"backgroundColor": "rgba(52,152,219,0.12)",
"borderColor": "#3498db",
"pointBackgroundColor": "#2980b9",
},
],
},
}
polar_area_chart_block = {
"type": "widget",
"widgetId": "demo-channel-polar",
"widgetType": "chart.js/polarArea",
"props": {"type": "polarArea"},
"data": {
"labels": ["短视频", "微博", "社区论坛", "新闻客户端", "线下反馈"],
"datasets": [
{
"label": "渠道渗透度",
"data": [62, 54, 38, 45, 28],
"backgroundColor": [
"rgba(231,76,60,0.65)",
"rgba(142,68,173,0.6)",
"rgba(52,152,219,0.55)",
"rgba(46,204,113,0.55)",
"rgba(241,196,15,0.6)",
],
}
],
},
}
scatter_chart_block = {
"type": "widget",
"widgetId": "demo-correlation-scatter",
"widgetType": "chart.js/scatter",
"props": {
"type": "scatter",
"options": {
"plugins": {"legend": {"position": "bottom"}},
"scales": {
"x": {"title": {"display": True, "text": "情绪极性"}, "min": -1, "max": 1},
"y": {"title": {"display": True, "text": "互动量"}, "beginAtZero": True},
},
},
},
"data": {
"datasets": [
{
"label": "帖子散点",
"data": [
{"x": -0.65, "y": 120},
{"x": -0.25, "y": 190},
{"x": 0.05, "y": 260},
{"x": 0.42, "y": 340},
{"x": 0.78, "y": 410},
],
"backgroundColor": "rgba(52,152,219,0.7)",
}
],
},
}
bubble_chart_block = {
"type": "widget",
"widgetId": "demo-impact-bubble",
"widgetType": "chart.js/bubble",
"props": {
"type": "bubble",
"options": {
"plugins": {"legend": {"position": "bottom"}},
"scales": {
"x": {"title": {"display": True, "text": "曝光量 (万)"}, "beginAtZero": True},
"y": {"title": {"display": True, "text": "情绪强度"}, "min": -100, "max": 100},
},
},
},
"data": {
"datasets": [
{
"label": "渠道分布",
"data": [
{"x": 8, "y": 35, "r": 12},
{"x": 12, "y": -28, "r": 10},
{"x": 18, "y": 22, "r": 14},
{"x": 25, "y": 48, "r": 16},
{"x": 6, "y": -12, "r": 8},
],
"backgroundColor": "rgba(192,57,43,0.55)",
"borderColor": "#c0392b",
}
],
},
}
chapter_1 = {
"chapterId": "S1",
... ... @@ -469,7 +689,9 @@ def build_chapters() -> list[dict]:
{
"type": "paragraph",
"inlines": [
{"text": "以下内容逐一覆盖 paragraph/list/table/swot/table/widget 等全部块类型。"}
{
"text": "以下内容逐一覆盖 paragraph/list/table/swot/pest/widget 等全部块类型。",
}
],
},
{
... ... @@ -484,14 +706,35 @@ def build_chapters() -> list[dict]:
{
"type": "heading",
"level": 3,
"text": "2.2 高阶块与富媒体",
"text": "2.2 图表组件演示",
"anchor": "charts-demo",
},
{
"type": "paragraph",
"inlines": [
{
"text": "折线/柱状/饼图/雷达/极区/散点/气泡等多类型图表,用于验证 Chart.js 兼容性。",
}
],
},
widget_block,
stacked_bar_chart_block,
doughnut_chart_block,
radar_chart_block,
polar_area_chart_block,
scatter_chart_block,
bubble_chart_block,
{
"type": "heading",
"level": 3,
"text": "2.3 高阶块与富媒体",
"anchor": "advanced-blocks",
},
blockquote_block,
callout_block,
engine_quote_block,
swot_block,
widget_block,
pest_block,
code_block,
math_block,
figure_block,
... ... @@ -554,16 +797,16 @@ def main() -> int:
report_id = f"all-blocks-demo-{timestamp}"
metadata = {
"title": "社会公共热点事件渲染测试",
"subtitle": "覆盖全部 IR 块类型的示例数据",
"query": "公共事件渲染能力自检",
"subtitle": "覆盖全部 IR 块类型的示例数据,含多种图表与 PEST 演示",
"query": "公共事件渲染能力自检 / Chart & PEST",
"toc": {"title": "目录", "depth": 3},
"hero": {
"summary": "用于验证 Report Engine 在 HTML / PDF 渲染时对各类区块的兼容性。",
"summary": "用于验证 Report Engine 在 HTML / PDF 渲染时对各类区块、Chart.js 组件与 PEST 模块的兼容性。",
"kpis": [
{"label": "示例块数量", "value": "14", "delta": "+100%", "tone": "up"},
{"label": "图表数", "value": "1", "delta": "安全检查", "tone": "neutral"},
{"label": "示例块数量", "value": "20+", "delta": "含 PEST", "tone": "up"},
{"label": "图表数", "value": "7", "delta": "新增多类型", "tone": "neutral"},
],
"highlights": ["覆盖全部 block", "含行内/块级公式", "Chart.js 数据有效"],
"highlights": ["覆盖全部 block", "含行内/块级公式", "Chart.js 多类型", "PEST + SWOT"],
"actions": ["重新生成", "导出 PDF"],
},
}
... ...