markstar 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +33 -0
- package/bin/markstar.js +152 -0
- package/package.json +34 -0
- package/skills/data-to-chart/SKILL.md +157 -0
- package/skills/data-to-chart/reference/chart-mapping.md +187 -0
- package/skills/data-to-chart/reference/dashboard-guide.md +427 -0
- package/skills/data-to-chart/reference/data-processing.md +198 -0
- package/skills/data-to-chart/reference/echarts-templates.md +601 -0
|
@@ -0,0 +1,601 @@
|
|
|
1
|
+
# ECharts 图表模板参考
|
|
2
|
+
|
|
3
|
+
> **使用方式**:Agent 在 Step 5 生成代码前加载此文件。参考各类型的 option 骨架,但必须根据实际数据的维度、系列数、值域灵活调整,不可机械套用。
|
|
4
|
+
>
|
|
5
|
+
> 标记说明:🔴 = 必须项(该图表类型的核心配置,移除后图表无法正确呈现) | 🟡 = 推荐项(提升可读性和交互体验) | ⚪ = 可选项(按需添加)
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## 主题配色方案
|
|
10
|
+
|
|
11
|
+
Agent 根据用户场景自动选择配色,在输出中不透露选择细节。
|
|
12
|
+
|
|
13
|
+
### 方案 A:专业商务 — 默认
|
|
14
|
+
|
|
15
|
+
适用:报告、PPT、数据分析、商业场景。浅色背景、清晰配色、专业感。
|
|
16
|
+
|
|
17
|
+
```css
|
|
18
|
+
/* -- 核心颜色 -- */
|
|
19
|
+
--bg: #F7F8FA;
|
|
20
|
+
--card-bg: #FFFFFF;
|
|
21
|
+
--card-shadow: 0 2px 16px rgba(0,0,0,0.08);
|
|
22
|
+
--title: #1F2937;
|
|
23
|
+
--subtitle: #6B7280;
|
|
24
|
+
--border: #E5E7EB;
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
### 方案 B:科技深色
|
|
28
|
+
|
|
29
|
+
适用:大屏、仪表盘、深夜查看、科技感展示。深色背景带微光效果。
|
|
30
|
+
|
|
31
|
+
```css
|
|
32
|
+
/* -- 核心颜色 -- */
|
|
33
|
+
--bg: #0F172A;
|
|
34
|
+
--card-bg: #1E293B;
|
|
35
|
+
--card-shadow: 0 4px 24px rgba(0,0,0,0.4);
|
|
36
|
+
--title: #E2E8F0;
|
|
37
|
+
--subtitle: #94A3B8;
|
|
38
|
+
--border: #334155;
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### 方案 C:简约学术 — 备选
|
|
42
|
+
|
|
43
|
+
适用:学术论文、打印、色盲友好场景。极简白底、高对比度、无障碍配色。
|
|
44
|
+
|
|
45
|
+
```css
|
|
46
|
+
/* -- 核心颜色 -- */
|
|
47
|
+
--bg: #FFFFFF;
|
|
48
|
+
--card-bg: #FFFFFF;
|
|
49
|
+
--card-shadow: 0 1px 4px rgba(0,0,0,0.06);
|
|
50
|
+
--title: #111827;
|
|
51
|
+
--subtitle: #4B5563;
|
|
52
|
+
--border: #D1D5DB;
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### 自动选择规则
|
|
56
|
+
|
|
57
|
+
| 场景关键词 | 方案 |
|
|
58
|
+
|-----------|------|
|
|
59
|
+
| 大屏、仪表盘、深色、暗色、科技 | B — 科技深色 |
|
|
60
|
+
| 论文、打印、学术、出版、无障碍 | C — 简约学术 |
|
|
61
|
+
| 其他(默认) | A — 专业商务 |
|
|
62
|
+
|
|
63
|
+
---
|
|
64
|
+
|
|
65
|
+
## 通用配置(所有图表类型共享)
|
|
66
|
+
|
|
67
|
+
```javascript
|
|
68
|
+
// 🔴 必须:tooltip — 鼠标悬停提示
|
|
69
|
+
tooltip: {
|
|
70
|
+
trigger: 'axis', // line/bar 用 'axis', pie/scatter 用 'item'
|
|
71
|
+
axisPointer: { type: 'shadow' } // bar 可选
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// 🟡 推荐:legend — 多系列时显示图例
|
|
75
|
+
legend: {
|
|
76
|
+
type: 'scroll', // 系列多时支持滚动
|
|
77
|
+
bottom: 0,
|
|
78
|
+
textStyle: { fontSize: 12 }
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// 🟡 推荐:toolbox — 保存图片等工具
|
|
82
|
+
toolbox: {
|
|
83
|
+
feature: {
|
|
84
|
+
saveAsImage: { title: '保存为图片' },
|
|
85
|
+
dataView: { title: '数据视图', readOnly: false }
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// 🟡 推荐:color — 调色板(按所选主题使用对应方案)
|
|
90
|
+
// 方案 A(默认):['#4E79A7','#59A14F','#F28E2B','#E15759','#76B7B2','#B07AA1','#FF9DA7','#9C755F','#BAB0AC']
|
|
91
|
+
// 方案 B(深色):['#00DDFF','#37A2FF','#FF0087','#FFBF00','#00E396','#FEBE4A','#A78BFA','#34D399','#FF6B6B']
|
|
92
|
+
// 方案 C(简约):['#0072B2','#009E73','#F0E442','#CC79A7','#56B4E9','#E69F00','#D55E00','#999999']
|
|
93
|
+
|
|
94
|
+
// ⚪ 可选:grid — 绘图区域边距
|
|
95
|
+
grid: { left: '3%', right: '4%', bottom: '15%', containLabel: true }
|
|
96
|
+
|
|
97
|
+
// ⚪ 可选:animation — 动画
|
|
98
|
+
animation: true,
|
|
99
|
+
animationDuration: 800
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
---
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
## 图表类型模板
|
|
106
|
+
|
|
107
|
+
### 1. 折线图 `line`
|
|
108
|
+
|
|
109
|
+
```javascript
|
|
110
|
+
option = {
|
|
111
|
+
// 🔴 必须
|
|
112
|
+
xAxis: { type: 'category', data: ['2020', '2021', '2022', '2023', '2024'] },
|
|
113
|
+
yAxis: { type: 'value' },
|
|
114
|
+
series: [{ type: 'line', data: [120, 200, 150, 80, 70] }],
|
|
115
|
+
|
|
116
|
+
// 🟡 推荐
|
|
117
|
+
tooltip: { trigger: 'axis' },
|
|
118
|
+
// 🟡 多系列时添加
|
|
119
|
+
legend: { data: ['系列1'], bottom: 0 },
|
|
120
|
+
|
|
121
|
+
// ⚪ 面积图变体
|
|
122
|
+
// series: [{ type: 'line', areaStyle: {}, data: [...] }]
|
|
123
|
+
// ⚪ 平滑曲线
|
|
124
|
+
// series: [{ type: 'line', smooth: true, data: [...] }]
|
|
125
|
+
};
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
### 2. 饼图 `pie`
|
|
129
|
+
|
|
130
|
+
```javascript
|
|
131
|
+
option = {
|
|
132
|
+
// 🔴 必须
|
|
133
|
+
series: [{
|
|
134
|
+
type: 'pie',
|
|
135
|
+
radius: '60%', // 或 ['40%', '70%'] 做环形图
|
|
136
|
+
data: [
|
|
137
|
+
{ name: '类别A', value: 100 },
|
|
138
|
+
{ name: '类别B', value: 200 },
|
|
139
|
+
{ name: '类别C', value: 150 }
|
|
140
|
+
],
|
|
141
|
+
// 🔴 饼图推荐显示标签
|
|
142
|
+
label: { show: true, formatter: '{b}: {d}%' }
|
|
143
|
+
}],
|
|
144
|
+
|
|
145
|
+
// 🟡 推荐
|
|
146
|
+
tooltip: { trigger: 'item', formatter: '{b}: {c} ({d}%)' },
|
|
147
|
+
legend: { type: 'scroll', bottom: 0 },
|
|
148
|
+
|
|
149
|
+
// ⚪ 可选效果
|
|
150
|
+
// emphasis: { itemStyle: { shadowBlur: 10, shadowColor: 'rgba(0,0,0,0.5)' } }
|
|
151
|
+
};
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
### 3. 柱状图 `bar`
|
|
155
|
+
|
|
156
|
+
```javascript
|
|
157
|
+
option = {
|
|
158
|
+
// 🔴 必须
|
|
159
|
+
xAxis: { type: 'category', data: ['类别A', '类别B', '类别C', '类别D'] },
|
|
160
|
+
yAxis: { type: 'value' },
|
|
161
|
+
series: [{ type: 'bar', data: [320, 200, 150, 80] }],
|
|
162
|
+
|
|
163
|
+
// 🟡 推荐
|
|
164
|
+
tooltip: { trigger: 'axis' },
|
|
165
|
+
|
|
166
|
+
// ⚪ 水平柱状图(分类名过长时用)
|
|
167
|
+
// yAxis: { type: 'category', data: [...] },
|
|
168
|
+
// xAxis: { type: 'value' },
|
|
169
|
+
// ⚪ 堆叠柱状图
|
|
170
|
+
// series: [
|
|
171
|
+
// { type: 'bar', stack: 'total', data: [...] },
|
|
172
|
+
// { type: 'bar', stack: 'total', data: [...] }
|
|
173
|
+
// ]
|
|
174
|
+
};
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
### 4. 堆叠图 `bar`(stack) / `line`(areaStyle)
|
|
178
|
+
|
|
179
|
+
```javascript
|
|
180
|
+
option = {
|
|
181
|
+
// 🔴 必须
|
|
182
|
+
xAxis: { type: 'category', data: ['Q1', 'Q2', 'Q3', 'Q4'] },
|
|
183
|
+
yAxis: { type: 'value' },
|
|
184
|
+
series: [
|
|
185
|
+
{ name: '产品A', type: 'bar', stack: 'total', data: [120, 200, 150, 80] },
|
|
186
|
+
{ name: '产品B', type: 'bar', stack: 'total', data: [80, 120, 180, 110] },
|
|
187
|
+
{ name: '产品C', type: 'bar', stack: 'total', data: [60, 80, 100, 140] }
|
|
188
|
+
],
|
|
189
|
+
|
|
190
|
+
// 🔴 多系列必须有 legend
|
|
191
|
+
legend: { data: ['产品A', '产品B', '产品C'], bottom: 0 },
|
|
192
|
+
|
|
193
|
+
// 🟡 推荐
|
|
194
|
+
tooltip: { trigger: 'axis' },
|
|
195
|
+
|
|
196
|
+
// ⚪ 面积堆叠变体(改 type 为 line + areaStyle)
|
|
197
|
+
// series: [
|
|
198
|
+
// { name: '产品A', type: 'line', stack: 'total', areaStyle: {}, data: [...] }
|
|
199
|
+
// ]
|
|
200
|
+
};
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
### 5. 散点图 `scatter`
|
|
204
|
+
|
|
205
|
+
```javascript
|
|
206
|
+
option = {
|
|
207
|
+
// 🔴 必须
|
|
208
|
+
xAxis: { type: 'value', name: 'X 轴标签' },
|
|
209
|
+
yAxis: { type: 'value', name: 'Y 轴标签' },
|
|
210
|
+
series: [{
|
|
211
|
+
type: 'scatter',
|
|
212
|
+
data: [[10, 20], [15, 30], [20, 25], [25, 40], [30, 35]],
|
|
213
|
+
symbolSize: 8
|
|
214
|
+
}],
|
|
215
|
+
|
|
216
|
+
// 🟡 推荐
|
|
217
|
+
tooltip: { trigger: 'item', formatter: 'X: {c[0]}<br/>Y: {c[1]}' },
|
|
218
|
+
|
|
219
|
+
// ⚪ 多系列散点
|
|
220
|
+
// series: [
|
|
221
|
+
// { name: '组A', type: 'scatter', data: [...] },
|
|
222
|
+
// { name: '组B', type: 'scatter', data: [...] }
|
|
223
|
+
// ]
|
|
224
|
+
};
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
### 6. 地图 `map`(中国地图)
|
|
228
|
+
|
|
229
|
+
```javascript
|
|
230
|
+
// 🔴 必须:额外引入中国地图 GeoJSON,放在 <script> 中,在 echarts.init 之前
|
|
231
|
+
// <script src="https://geo.datav.aliyun.com/areas_v3/bound/100000_full.json"></script>
|
|
232
|
+
// 或通过 fetch 加载后 registerMap
|
|
233
|
+
|
|
234
|
+
option = {
|
|
235
|
+
// 🔴 必须
|
|
236
|
+
series: [{
|
|
237
|
+
type: 'map',
|
|
238
|
+
map: 'china',
|
|
239
|
+
data: [
|
|
240
|
+
{ name: '广东', value: 1000 },
|
|
241
|
+
{ name: '江苏', value: 800 },
|
|
242
|
+
// ... 各省数据
|
|
243
|
+
],
|
|
244
|
+
label: { show: true, fontSize: 10 }
|
|
245
|
+
}],
|
|
246
|
+
|
|
247
|
+
// 🔴 地图必须有 visualMap
|
|
248
|
+
visualMap: {
|
|
249
|
+
min: 0,
|
|
250
|
+
max: 1000,
|
|
251
|
+
left: 'left',
|
|
252
|
+
bottom: 'bottom',
|
|
253
|
+
text: ['高', '低'],
|
|
254
|
+
inRange: { color: ['#E0F3F8', '#045A8D'] }
|
|
255
|
+
},
|
|
256
|
+
|
|
257
|
+
// 🟡 推荐
|
|
258
|
+
tooltip: { trigger: 'item', formatter: '{b}: {c}' }
|
|
259
|
+
};
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
### 7. 漏斗图 `funnel`
|
|
263
|
+
|
|
264
|
+
```javascript
|
|
265
|
+
option = {
|
|
266
|
+
// 🔴 必须
|
|
267
|
+
series: [{
|
|
268
|
+
type: 'funnel',
|
|
269
|
+
left: '10%',
|
|
270
|
+
right: '10%',
|
|
271
|
+
width: '80%',
|
|
272
|
+
data: [
|
|
273
|
+
{ name: '访问', value: 1000 },
|
|
274
|
+
{ name: '注册', value: 600 },
|
|
275
|
+
{ name: '下单', value: 300 },
|
|
276
|
+
{ name: '支付', value: 150 }
|
|
277
|
+
],
|
|
278
|
+
label: { show: true, formatter: '{b}: {c}' },
|
|
279
|
+
sort: 'descending' // 🔴 漏斗图默认从大到小排列
|
|
280
|
+
}],
|
|
281
|
+
|
|
282
|
+
// 🟡 推荐
|
|
283
|
+
tooltip: { trigger: 'item', formatter: '{b}: {c}' }
|
|
284
|
+
};
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
### 8. 仪表盘 `gauge`
|
|
288
|
+
|
|
289
|
+
```javascript
|
|
290
|
+
option = {
|
|
291
|
+
// 🔴 必须
|
|
292
|
+
series: [{
|
|
293
|
+
type: 'gauge',
|
|
294
|
+
min: 0,
|
|
295
|
+
max: 100,
|
|
296
|
+
detail: { formatter: '{value}%', fontSize: 20 },
|
|
297
|
+
data: [{ value: 75, name: '完成率' }],
|
|
298
|
+
axisLine: {
|
|
299
|
+
lineStyle: { color: [[0.3, '#67E0E3'], [0.7, '#37A2DA'], [1, '#FD666D']], width: 20 }
|
|
300
|
+
}
|
|
301
|
+
}]
|
|
302
|
+
};
|
|
303
|
+
```
|
|
304
|
+
|
|
305
|
+
### 9. 旭日图/矩形树图 `sunburst` / `treemap`
|
|
306
|
+
|
|
307
|
+
```javascript
|
|
308
|
+
// sunburst
|
|
309
|
+
option = {
|
|
310
|
+
// 🔴 必须
|
|
311
|
+
series: [{
|
|
312
|
+
type: 'sunburst',
|
|
313
|
+
data: [{
|
|
314
|
+
name: '大类A',
|
|
315
|
+
children: [
|
|
316
|
+
{ name: '小类A1', value: 100 },
|
|
317
|
+
{ name: '小类A2', value: 200 }
|
|
318
|
+
]
|
|
319
|
+
}, {
|
|
320
|
+
name: '大类B',
|
|
321
|
+
children: [
|
|
322
|
+
{ name: '小类B1', value: 150 }
|
|
323
|
+
]
|
|
324
|
+
}],
|
|
325
|
+
radius: ['15%', '80%'],
|
|
326
|
+
label: { rotate: 'radial' }
|
|
327
|
+
}]
|
|
328
|
+
};
|
|
329
|
+
|
|
330
|
+
// treemap
|
|
331
|
+
option = {
|
|
332
|
+
// 🔴 必须
|
|
333
|
+
series: [{
|
|
334
|
+
type: 'treemap',
|
|
335
|
+
data: [{
|
|
336
|
+
name: '大类A',
|
|
337
|
+
children: [
|
|
338
|
+
{ name: '小类A1', value: 100 },
|
|
339
|
+
{ name: '小类A2', value: 200 }
|
|
340
|
+
]
|
|
341
|
+
}, {
|
|
342
|
+
name: '大类B',
|
|
343
|
+
children: [
|
|
344
|
+
{ name: '小类B1', value: 150 }
|
|
345
|
+
]
|
|
346
|
+
}],
|
|
347
|
+
label: { show: true, formatter: '{b}' }
|
|
348
|
+
}]
|
|
349
|
+
};
|
|
350
|
+
```
|
|
351
|
+
|
|
352
|
+
### 10. 雷达图 `radar`
|
|
353
|
+
|
|
354
|
+
```javascript
|
|
355
|
+
option = {
|
|
356
|
+
// 🔴 必须
|
|
357
|
+
radar: {
|
|
358
|
+
indicator: [
|
|
359
|
+
{ name: '指标A', max: 100 },
|
|
360
|
+
{ name: '指标B', max: 100 },
|
|
361
|
+
{ name: '指标C', max: 100 },
|
|
362
|
+
{ name: '指标D', max: 100 }
|
|
363
|
+
]
|
|
364
|
+
},
|
|
365
|
+
series: [{
|
|
366
|
+
type: 'radar',
|
|
367
|
+
data: [{ value: [80, 90, 70, 85], name: '当前' }],
|
|
368
|
+
areaStyle: {}
|
|
369
|
+
}],
|
|
370
|
+
|
|
371
|
+
// 🟡 推荐:多系列对比
|
|
372
|
+
// data: [
|
|
373
|
+
// { value: [80, 90, 70, 85], name: '当前' },
|
|
374
|
+
// { value: [60, 70, 80, 75], name: '目标' }
|
|
375
|
+
// ]
|
|
376
|
+
|
|
377
|
+
// 🟡 推荐
|
|
378
|
+
legend: { data: ['当前'], bottom: 0 },
|
|
379
|
+
tooltip: { trigger: 'item' }
|
|
380
|
+
};
|
|
381
|
+
```
|
|
382
|
+
|
|
383
|
+
### 11. 箱线图 `boxplot`
|
|
384
|
+
|
|
385
|
+
```javascript
|
|
386
|
+
// ⚠️ 箱线图需要 echarts-stat 扩展
|
|
387
|
+
// <script src="https://cdn.jsdelivr.net/npm/echarts-stat@1.1.0/dist/ecStat.min.js"></script>
|
|
388
|
+
option = {
|
|
389
|
+
// 🔴 必须
|
|
390
|
+
xAxis: { type: 'category', data: ['组A', '组B', '组C'] },
|
|
391
|
+
yAxis: { type: 'value' },
|
|
392
|
+
series: [{
|
|
393
|
+
type: 'boxplot',
|
|
394
|
+
data: [
|
|
395
|
+
[10, 20, 30, 40, 50], // [min, Q1, median, Q3, max]
|
|
396
|
+
[15, 25, 35, 45, 55],
|
|
397
|
+
[5, 15, 25, 35, 45]
|
|
398
|
+
]
|
|
399
|
+
}],
|
|
400
|
+
|
|
401
|
+
// 🟡 推荐
|
|
402
|
+
tooltip: { trigger: 'item' }
|
|
403
|
+
};
|
|
404
|
+
```
|
|
405
|
+
|
|
406
|
+
### 12. K 线图 `candlestick`
|
|
407
|
+
|
|
408
|
+
```javascript
|
|
409
|
+
option = {
|
|
410
|
+
// 🔴 必须
|
|
411
|
+
xAxis: { type: 'category', data: ['1月', '2月', '3月', '4月'] },
|
|
412
|
+
yAxis: { type: 'value' },
|
|
413
|
+
series: [{
|
|
414
|
+
type: 'candlestick',
|
|
415
|
+
data: [
|
|
416
|
+
[20, 34, 10, 38], // [open, close, low, high]
|
|
417
|
+
[40, 35, 30, 50],
|
|
418
|
+
[31, 38, 30, 42],
|
|
419
|
+
[38, 30, 20, 45]
|
|
420
|
+
],
|
|
421
|
+
// 🟡 上涨/下跌颜色
|
|
422
|
+
itemStyle: { color: '#EF5350', color0: '#26A69A', borderColor: '#EF5350', borderColor0: '#26A69A' }
|
|
423
|
+
}],
|
|
424
|
+
|
|
425
|
+
// 🟡 推荐
|
|
426
|
+
tooltip: { trigger: 'axis' }
|
|
427
|
+
};
|
|
428
|
+
```
|
|
429
|
+
|
|
430
|
+
---
|
|
431
|
+
|
|
432
|
+
## 完整 HTML 骨架
|
|
433
|
+
|
|
434
|
+
按所选主题方案生成对应骨架,替换 `option` 对象即可。三种方案用同一结构,仅 CSS 变量和调色板不同。
|
|
435
|
+
|
|
436
|
+
### 方案 A 骨架:专业商务(默认)
|
|
437
|
+
|
|
438
|
+
```html
|
|
439
|
+
<!DOCTYPE html>
|
|
440
|
+
<html lang="zh-CN">
|
|
441
|
+
<head>
|
|
442
|
+
<meta charset="UTF-8">
|
|
443
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
444
|
+
<title><!-- 图表标题 --></title>
|
|
445
|
+
<script src="https://cdn.jsdelivr.net/npm/echarts@5.4.3/dist/echarts.min.js"></script>
|
|
446
|
+
<style>
|
|
447
|
+
* { margin: 0; padding: 0; box-sizing: border-box; }
|
|
448
|
+
body {
|
|
449
|
+
font-family: "Microsoft YaHei", "PingFang SC", "Helvetica Neue", sans-serif;
|
|
450
|
+
background: #F7F8FA;
|
|
451
|
+
display: flex;
|
|
452
|
+
justify-content: center;
|
|
453
|
+
align-items: center;
|
|
454
|
+
min-height: 100vh;
|
|
455
|
+
padding: 24px;
|
|
456
|
+
}
|
|
457
|
+
.wrapper {
|
|
458
|
+
width: 100%;
|
|
459
|
+
max-width: 1100px;
|
|
460
|
+
background: #FFFFFF;
|
|
461
|
+
border-radius: 12px;
|
|
462
|
+
box-shadow: 0 2px 16px rgba(0,0,0,0.08);
|
|
463
|
+
padding: 28px 24px 16px;
|
|
464
|
+
}
|
|
465
|
+
h1 { text-align: center; font-size: 22px; color: #1F2937; font-weight: 600; margin-bottom: 2px; }
|
|
466
|
+
.subtitle { text-align: center; font-size: 13px; color: #6B7280; margin-bottom: 12px; }
|
|
467
|
+
#chart { width: 100%; height: 520px; }
|
|
468
|
+
.note { font-size: 12px; color: #9CA3AF; text-align: center; margin-top: 8px; line-height: 1.6; }
|
|
469
|
+
</style>
|
|
470
|
+
</head>
|
|
471
|
+
<body>
|
|
472
|
+
<div class="wrapper">
|
|
473
|
+
<h1><!-- 图表标题 --></h1>
|
|
474
|
+
<div class="subtitle"><!-- 数据来源说明 --></div>
|
|
475
|
+
<div id="chart"></div>
|
|
476
|
+
<div class="note"><!-- 脚注 --></div>
|
|
477
|
+
</div>
|
|
478
|
+
<script>
|
|
479
|
+
var chart = echarts.init(document.getElementById('chart'));
|
|
480
|
+
var option = { /* 替换为具体图表 option */ };
|
|
481
|
+
chart.setOption(option);
|
|
482
|
+
window.addEventListener('resize', function() { chart.resize(); });
|
|
483
|
+
</script>
|
|
484
|
+
</body>
|
|
485
|
+
</html>
|
|
486
|
+
```
|
|
487
|
+
|
|
488
|
+
### 方案 B 骨架:科技深色
|
|
489
|
+
|
|
490
|
+
```html
|
|
491
|
+
<!DOCTYPE html>
|
|
492
|
+
<html lang="zh-CN" class="dark">
|
|
493
|
+
<head>
|
|
494
|
+
<meta charset="UTF-8">
|
|
495
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
496
|
+
<title><!-- 图表标题 --></title>
|
|
497
|
+
<script src="https://cdn.jsdelivr.net/npm/echarts@5.4.3/dist/echarts.min.js"></script>
|
|
498
|
+
<style>
|
|
499
|
+
* { margin: 0; padding: 0; box-sizing: border-box; }
|
|
500
|
+
body {
|
|
501
|
+
font-family: "Microsoft YaHei", "PingFang SC", "Helvetica Neue", sans-serif;
|
|
502
|
+
background: #0F172A;
|
|
503
|
+
display: flex;
|
|
504
|
+
justify-content: center;
|
|
505
|
+
align-items: center;
|
|
506
|
+
min-height: 100vh;
|
|
507
|
+
padding: 24px;
|
|
508
|
+
}
|
|
509
|
+
.wrapper {
|
|
510
|
+
width: 100%;
|
|
511
|
+
max-width: 1100px;
|
|
512
|
+
background: #1E293B;
|
|
513
|
+
border-radius: 14px;
|
|
514
|
+
box-shadow: 0 4px 24px rgba(0,0,0,0.4), 0 0 1px rgba(148,163,184,0.1);
|
|
515
|
+
padding: 28px 24px 16px;
|
|
516
|
+
border: 1px solid #334155;
|
|
517
|
+
}
|
|
518
|
+
h1 { text-align: center; font-size: 22px; color: #E2E8F0; font-weight: 600; margin-bottom: 2px; }
|
|
519
|
+
.subtitle { text-align: center; font-size: 13px; color: #94A3B8; margin-bottom: 12px; }
|
|
520
|
+
#chart { width: 100%; height: 520px; }
|
|
521
|
+
.note { font-size: 12px; color: #64748B; text-align: center; margin-top: 8px; line-height: 1.6; }
|
|
522
|
+
|
|
523
|
+
/* 深色主题 ECharts 覆盖 — textStyle 在 option 中设置 */
|
|
524
|
+
.note em { color: #94A3B8; font-style: normal; }
|
|
525
|
+
</style>
|
|
526
|
+
</head>
|
|
527
|
+
<body>
|
|
528
|
+
<div class="wrapper">
|
|
529
|
+
<h1><!-- 图表标题 --></h1>
|
|
530
|
+
<div class="subtitle"><!-- 数据来源说明 --></div>
|
|
531
|
+
<div id="chart"></div>
|
|
532
|
+
<div class="note"><!-- 脚注 --></div>
|
|
533
|
+
</div>
|
|
534
|
+
<script>
|
|
535
|
+
var chart = echarts.init(document.getElementById('chart'), null, {
|
|
536
|
+
// 深色计算背景,让图表透明区域融入深色背景
|
|
537
|
+
backgroundColor: 'transparent'
|
|
538
|
+
});
|
|
539
|
+
var option = {
|
|
540
|
+
// 深色主题必须设置全局文本颜色
|
|
541
|
+
// textStyle: { color: '#CBD5E1' },
|
|
542
|
+
/* 替换为具体图表 option */
|
|
543
|
+
};
|
|
544
|
+
chart.setOption(option);
|
|
545
|
+
window.addEventListener('resize', function() { chart.resize(); });
|
|
546
|
+
</script>
|
|
547
|
+
</body>
|
|
548
|
+
</html>
|
|
549
|
+
```
|
|
550
|
+
|
|
551
|
+
### 方案 C 骨架:简约学术
|
|
552
|
+
|
|
553
|
+
```html
|
|
554
|
+
<!DOCTYPE html>
|
|
555
|
+
<html lang="zh-CN">
|
|
556
|
+
<head>
|
|
557
|
+
<meta charset="UTF-8">
|
|
558
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
559
|
+
<title><!-- 图表标题 --></title>
|
|
560
|
+
<script src="https://cdn.jsdelivr.net/npm/echarts@5.4.3/dist/echarts.min.js"></script>
|
|
561
|
+
<style>
|
|
562
|
+
* { margin: 0; padding: 0; box-sizing: border-box; }
|
|
563
|
+
body {
|
|
564
|
+
font-family: "Microsoft YaHei", "PingFang SC", "Helvetica Neue", sans-serif;
|
|
565
|
+
background: #FFFFFF;
|
|
566
|
+
display: flex;
|
|
567
|
+
justify-content: center;
|
|
568
|
+
align-items: center;
|
|
569
|
+
min-height: 100vh;
|
|
570
|
+
padding: 24px;
|
|
571
|
+
}
|
|
572
|
+
.wrapper {
|
|
573
|
+
width: 100%;
|
|
574
|
+
max-width: 960px;
|
|
575
|
+
background: #FFFFFF;
|
|
576
|
+
border: 1px solid #D1D5DB;
|
|
577
|
+
border-radius: 4px;
|
|
578
|
+
box-shadow: 0 1px 4px rgba(0,0,0,0.06);
|
|
579
|
+
padding: 24px 20px 14px;
|
|
580
|
+
}
|
|
581
|
+
h1 { text-align: center; font-size: 18px; color: #111827; font-weight: 600; margin-bottom: 2px; }
|
|
582
|
+
.subtitle { text-align: center; font-size: 12px; color: #4B5563; margin-bottom: 10px; }
|
|
583
|
+
#chart { width: 100%; height: 480px; }
|
|
584
|
+
.note { font-size: 11px; color: #6B7280; text-align: center; margin-top: 6px; line-height: 1.6; }
|
|
585
|
+
</style>
|
|
586
|
+
</head>
|
|
587
|
+
<body>
|
|
588
|
+
<div class="wrapper">
|
|
589
|
+
<h1><!-- 图表标题 --></h1>
|
|
590
|
+
<div class="subtitle"><!-- 数据来源说明 --></div>
|
|
591
|
+
<div id="chart"></div>
|
|
592
|
+
<div class="note"><!-- 脚注 --></div>
|
|
593
|
+
</div>
|
|
594
|
+
<script>
|
|
595
|
+
var chart = echarts.init(document.getElementById('chart'));
|
|
596
|
+
chart.setOption({ /* 替换为具体图表 option */ });
|
|
597
|
+
window.addEventListener('resize', function() { chart.resize(); });
|
|
598
|
+
</script>
|
|
599
|
+
</body>
|
|
600
|
+
</html>
|
|
601
|
+
```
|