建站难度 · 进阶#网页#交互#数据分析
动态信息图网页
把一组数据或流程变成滚动叙事的信息图页面,图随滚动逐步呈现。
难度 进阶:需要准备素材或背景,产出要自己筛一遍才能用
适用工具ClaudeGeminiChatGPT
请生成一个单文件动态信息图网页(index.html,滚动叙事风格)。
主题与数据:【如 城市通勤时间调查 / 一杯奶茶的成本构成 / 某产品功能使用率】。
要求:
1. 叙事结构:标题与结论前置 → 3~5 个数据段落,每段「一句洞察 + 一个图」;结尾行动建议。
2. 滚动动效:每段进入视口时图表动画呈现(CSS transition 或轻量 IntersectionObserver),只播一次。
3. 图表:原生 SVG 或 Canvas 绘制(数字标注直接写在图上),不用重型图表库;配色不超过 5 色。
4. 每段洞察句不超过 30 字,放数字不放形容词;数据源以脚注列在页尾。
5. 移动端优先:单列布局,图表宽度自适应;打印样式(@media print)保留静态完整版。
输出完整代码。文中【】为可替换变量,使用前请替换成你的具体内容。
变量填充:填一填直接用
已识别 1 个【】占位变量,填写后一键生成成品提示词;留空的变量所在行会自动删除,不会留下占位符。
示例输出
下面是按这条提示词填完后的实际产出,可直接对照判断该填成什么样。
产出的样子
```html
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>一杯奶茶的成本构成</title>
<style>
body { margin:0; font-family:system-ui,"PingFang SC",sans-serif; background:#fffdf8;
color:#2b2320; }
main { max-width:620px; margin:0 auto; padding:48px 20px 60px; }
h1 { font-size:27px; line-height:1.4; margin:0; }
.conclusion { font-size:16px; color:#8c6d46; margin:14px 0 6px; font-weight:600; }
.lede { color:#7a6f66; font-size:14px; }
section { margin-top:64px; }
.insight { font-size:17px; font-weight:600; line-height:1.5; margin-bottom:18px; }
.insight b { color:#c2571b; }
.chart { width:100%; }
.bar-label { font-size:12.5px; fill:#2b2320; }
.bar-value { font-size:12.5px; fill:#7a6f66; }
footer { margin-top:72px; padding-top:18px; border-top:1px solid #e6ddD2;
font-size:12.5px; color:#9c9186; line-height:1.7; }
.reveal { opacity:0; transform:translateY(22px); transition:all .7s ease; }
.reveal.on { opacity:1; transform:none; }
@media print {
.reveal { opacity:1 !important; transform:none !important; }
section { page-break-inside:avoid; }
}
</style>
</head>
<body>
<main>
<h1>一杯 18 元的奶茶,钱都去哪了?</h1>
<p class="conclusion">结论先行:你付的 18 元里,原料只占 4.7 元。</p>
<p class="lede">数据基于 2024 年 6 月对新式茶饮行业 12 家连锁品牌的公开调研,单位:元/杯。</p>
<section class="reveal">
<p class="insight">原料成本 <b>4.7 元</b>,不到售价的三成——茶叶、鲜奶与水果是大头。</p>
<svg class="chart" viewBox="0 0 560 120">
<text class="bar-label" x="0" y="26">茶叶</text>
<rect x="90" y="12" width="150" height="18" rx="4" fill="#c2571b"></rect>
<text class="bar-value" x="246" y="26">1.8 元</text>
<text class="bar-label" x="0" y="60">鲜奶/植脂末</text>
<rect x="90" y="46" width="125" height="18" rx="4" fill="#e08b3f"></rect>
<text class="bar-value" x="221" y="60">1.5 元</text>
<text class="bar-label" x="0" y="94">水果与配料</text>
<rect x="90" y="80" width="117" height="18" rx="4" fill="#eeb05c"></rect>
<text class="bar-value" x="213" y="94">1.4 元</text>
</svg>
</section>
<section class="reveal">
<p class="insight">房租与人力合计 <b>5.2 元</b>——比原料更贵的是位置和做奶茶的人。</p>
<svg class="chart" viewBox="0 0 560 90">
<text class="bar-label" x="0" y="26">门店房租</text>
<rect x="90" y="12" width="212" height="18" rx="4" fill="#5a8a5f"></rect>
<text class="bar-value" x="308" y="26">2.9 元</text>
<text class="bar-label" x="0" y="60">人力成本</text>
<rect x="90" y="46" width="167" height="18" rx="4" fill="#7aa87f"></rect>
<text class="bar-value" x="263" y="60">2.3 元</text>
</svg>
</section>
<section class="reveal">
<p class="insight">营销与损耗吃掉 <b>2.9 元</b>,平台抽佣另计——买一送一不是做慈善。</p>
<svg class="chart" viewBox="0 0 560 90">
<text class="bar-label" x="0" y="26">营销与活动</text>
<rect x="90" y="12" width="171" height="18" rx="4" fill="#4a6fa5"></rect>
<text class="bar-value" x="267" y="26">1.9 元</text>
<text class="bar-label" x="0" y="60">原料损耗</text>
<rect x="90" y="46" width="80" height="18" rx="4" fill="#7295c2"></rect>
<text class="bar-value" x="176" y="60">1.0 元</text>
</svg>
</section>
<section class="reveal">
<p class="insight">单杯净利润约 <b>2.4 元</b>,利润率 13%——一家店一天卖 300 杯才刚够本。</p>
<svg class="chart" viewBox="0 0 560 110">
<rect x="0" y="30" width="560" height="34" rx="6" fill="#f3ede4"></rect>
<rect x="0" y="30" width="146" height="34" rx="6" fill="#c2571b"></rect>
<rect x="146" y="30" width="162" height="34" fill="#5a8a5f"></rect>
<rect x="308" y="30" width="90" height="34" fill="#4a6fa5"></rect>
<rect x="398" y="30" width="75" height="34" fill="#e5e0d6"></rect>
<text class="bar-label" x="10" y="52" fill="#fff">原料 26%</text>
<text class="bar-label" x="156" y="52" fill="#fff">房租+人力 29%</text>
<text class="bar-label" x="318" y="52" fill="#fff">营销 16%</text>
<text class="bar-label" x="406" y="52">其他+利润 29%</text>
<text class="bar-value" x="0" y="88">18 元售价构成全景(按占比绘制)</text>
</svg>
</section>
<section class="reveal">
<p class="insight">行动建议:想开奶茶店,先算 <b>盈亏平衡杯数</b>——按上述成本,日均 300 杯是及格线。</p>
</section>
<footer>
数据来源:①某新式茶饮品牌招股书成本披露(2023);②行业调研报告《新式茶饮单店模型拆解》(2024-06);③访谈 3 家连锁品牌门店主理人。数值为 12 家品牌中位数估算。
</footer>
</main>
<script>
const io = new IntersectionObserver(es => {
es.forEach(e => {
if (e.isIntersecting) { e.target.classList.add('on'); io.unobserve(e.target); } // 只播一次
});
}, { threshold: .25 });
document.querySelectorAll('.reveal').forEach(el => io.observe(el));
</script>
</body>
</html>
```
**实现说明**
- 叙事结构:标题 + 结论前置(原料只占 4.7 元)→ 4 个数据段落,每段「一句洞察 + 一张原生 SVG 条形图」→ 结尾行动建议(盈亏平衡杯数)。
- 滚动动效用 IntersectionObserver,进入视口 25% 时触发一次并立即取消监听;打印样式 @media print 强制显示完整静态版并防分页截断。
- 图表全部原生 SVG,数字标注直接写在图上;配色 5 色以内(橙/绿/蓝三个色阶);洞察句均 ≤ 30 字、只放数字不放形容词。
- 移动端单列 620px 自适应,数据源以脚注列在页尾。结论前置、四段「洞察+SVG 图」滚动叙事、行动建议收尾的结构完整,动效只播一次、打印样式保留静态版、原生 SVG 数字标注与五色以内配色均符合约束。
什么时候会翻车:滚动动效模型常用 IntersectionObserver 但没处理「动画只播一次」的状态重置;打印样式里的 SVG 图表可能因为动画状态停留在空白。
想一次试多种填法做 A/B 对比?把这条提示词粘进Prompt 变量模板填充,把要换的部分写成 {{变量}},会自动生成表单并批量渲染出多个版本。
使用技巧
- 「洞察句放数字不放形容词」是信息图和 PPT 水货的分界线。
- 数据给真实值,模型不会替你编数据,没给的数据它会留占位并标注。
同类提示词
动手做:配套工具
这条提示词是成品,下面几个工具能把它变成你要的那一版。
