-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
582 lines (572 loc) · 29.1 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="shortcut icon" href="favicon.ico" type="image/x-icon">
<title>Learning D3.js</title>
<script src="https://cdn.tailwindcss.com"></script>
<script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>
<style>
::-webkit-scrollbar {
width: 12px;
height: 12px;
}
::-webkit-scrollbar-thumb {
border-radius: 10px;
background-color: rgba(156, 163, 175, 1);
border: 3px solid transparent;
background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover {
background-color: rgba(107, 114, 128, 1);
}
html {
scrollbar-gutter: stable
}
</style>
</head>
<body>
<h1 class="my-8 text-center text-3xl font-bold"><span class="text-blue-500">Learning</span> <span
class="text-orange-400">D3.js</span> <span class="text-purple-500">Line-by-Line</span></h1>
<p class="text-center text-sm font-light">通过阅读<a href="https://observablehq.com/@d3" target="_blank"
class="text-blue-400 hover:text-blue-500 transition-colors duration-300">官方样例</a>的每一行代码并复现来学习 D3.js</p>
<div id="app" class="w-full p-4 sm:p-16 flex flex-col justify-center items-center gap-8">
<section v-for="item of content" class="container">
<!-- chart type -->
<h2 class="my-6">
<button
class="p-2 text-2xl font-bold text-gray-800 border-l-4 border-gray-500 rounded-l-sm rounded-r transition-colors duration-300"
:class="collapsedThemeArr.has(item.theme) ? 'bg-gray-300 hover:bg-gray-200' : 'hover:bg-gray-300'"
@click="toggleTheme(item.theme)">{{
item.themeTitle || item.theme }}</button>
</h2>
<!-- example list -->
<div v-show="!collapsedThemeArr.has(item.theme)" class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4">
<div class="flex flex-col border rounded-md" v-for="example of item.examples" :key="example.folder">
<div class="grow p-4">
<!-- chart title -->
<h3 class="pb-4 text-xl font-bold text-gray-700">{{ example.name }}</h3>
<!-- chart description -->
<p class="text-base text-gray-600">{{ example.description }}</p>
</div>
<div
class="shrink-0 p-4 flex flex-wrap justify-start items-center gap-2 text-xs font-bold bg-gray-50 border-t rounded-b-md">
<!-- reference of D3 example from Observable -->
<a v-if="example.reference"
class="px-2.5 py-1.5 text-blue-600 hover:text-white bg-blue-100 hover:bg-blue-500 border border-blue-500 rounded transition-colors duration-300"
:href='example.reference' target="_blank">参考</a>
<a v-if="example.folder"
class="px-2.5 py-1.5 text-green-600 hover:text-white bg-green-100 hover:bg-green-500 border border-green-500 rounded transition-colors duration-300"
:href=`./${item.theme}/${example.folder}/index.html` target="_blank">演示</a>
<a v-if="example.folder"
class="px-2.5 py-1.5 text-gray-600 hover:text-white bg-gray-200 hover:bg-gray-500 border border-gray-500 rounded transition-colors duration-300"
:href=`https://github.com/Benbinbin/d3-learning/tree/main/${item.theme}/${example.folder}/`
target="_blank">代码</a>
<a v-if="example.note"
class="px-2.5 py-1.5 text-purple-600 hover:text-white bg-purple-100 hover:bg-purple-500 border border-purple-500 rounded transition-colors duration-300"
:href="example.note" target="_blank">笔记</a>
</div>
</div>
</div>
</section>
</div>
<script>
const { createApp, ref } = Vue
createApp({
setup() {
const content = [
{
theme: 'scatterplot',
themeTitle: '散点图',
examples: [
{
name: '静态散点图',
description: '静态(宽高固定)的散点图',
reference: 'https://observablehq.com/@benbinbin/scatterplot',
folder: 'static-scatterplot',
note: 'https://datavis-note.benbinbin.com/article/d3/chart-example/d3-chart-example-scatterplot#静态图'
},
{
name: '响应式散点图 v1',
description: '响应式散点图方案一',
reference: 'https://observablehq.com/@benbinbin/scatterplot',
folder: 'responsive-scatterplot-version-1',
note: 'https://datavis-note.benbinbin.com/article/d3/chart-example/d3-chart-example-scatterplot#方案一'
},
{
name: '响应式散点图 v2',
description: '响应式散点图方案二',
reference: 'https://observablehq.com/@benbinbin/scatterplot',
folder: 'responsive-scatterplot-version-2',
note: 'https://datavis-note.benbinbin.com/article/d3/chart-example/d3-chart-example-scatterplot#方案二'
},
{
name: '交互式散点图-提示框',
reference: 'https://observablehq.com/@benbinbin/scatterplot',
folder: 'scatterplot-tooltip',
note: 'https://datavis-note.benbinbin.com/article/d3/chart-example/d3-chart-example-scatterplot#tooltip'
},
{
name: '交互散点图-辅助线',
reference: 'https://observablehq.com/@benbinbin/scatterplot',
folder: 'scatterplot-crosshair',
note: 'https://datavis-note.benbinbin.com/article/d3/chart-example/d3-chart-example-scatterplot#辅助线'
},
{
name: '交互散点图-高亮显示',
reference: 'https://observablehq.com/@benbinbin/scatterplot',
folder: 'scatterplot-highlight',
note: 'https://datavis-note.benbinbin.com/article/d3/chart-example/d3-chart-example-scatterplot#高亮显示'
},
{
name: '交互散点图-刷选',
reference: 'https://observablehq.com/@benbinbin/brushable-scatterplot',
folder: 'scatterplot-brush',
note: 'https://datavis-note.benbinbin.com/article/d3/chart-example/d3-chart-example-scatterplot#刷选'
},
{
name: '交互散点图-缩放',
reference: 'https://observablehq.com/@benbinbin/scatterplot-tour',
folder: 'scatterplot-zoom',
note: 'https://datavis-note.benbinbin.com/article/d3/chart-example/d3-chart-example-scatterplot#区域缩放'
},
{
name: '动效散点图-路径展开',
reference: 'https://observablehq.com/@benbinbin/scatterplot-connected',
folder: 'scatterplot-connected',
note: 'https://datavis-note.benbinbin.com/article/d3/chart-example/d3-chart-example-scatterplot#路径展开'
},
{
name: '动效散点图-位置变动',
reference: 'https://observablehq.com/@benbinbin/the-wealth-health-of-nations',
folder: 'scatterplot-move-animation',
note: 'https://datavis-note.benbinbin.com/article/d3/chart-example/d3-chart-example-scatterplot#位置变动'
},
{
name: '变体-散点图矩阵',
reference: 'https://observablehq.com/@benbinbin/scatterplot-matrix',
folder: 'scatterplot-matrix',
note: 'https://datavis-note.benbinbin.com/article/d3/chart-example/d3-chart-example-scatterplot#散点图矩阵'
},
]
},
{
theme: 'barchart',
themeTitle: '条形图',
examples: [
{
name: '静态条形图',
description: '静态(宽高固定)的条形图',
reference: 'https://observablehq.com/@benbinbin/bar-chart',
folder: 'static-barchart',
note: 'https://datavis-note.benbinbin.com/article/d3/chart-example/d3-chart-example-bar-chart#静态图'
},
{
name: '水平方向的条形图',
reference: 'https://observablehq.com/@benbinbin/bar-chart-horizontal',
folder: 'horizontal-barchart',
note: 'https://datavis-note.benbinbin.com/article/d3/chart-example/d3-chart-example-bar-chart#水平方向条形图'
},
{
name: '发散型的条形图',
reference: 'https://observablehq.com/@benbinbin/bar-chart-diverging',
folder: 'diverge-barchart',
note: 'https://datavis-note.benbinbin.com/article/d3/chart-example/d3-chart-example-bar-chart#发散型的条形图'
},
{
name: '交互条形图-缩放平移',
reference: 'https://observablehq.com/@benbinbin/zoomable-bar-chart',
folder: 'zoomable-barchart',
note: 'https://datavis-note.benbinbin.com/article/d3/chart-example/d3-chart-example-bar-chart#缩放平移'
},
{
name: '交互条形图-层级下钻',
reference: 'https://observablehq.com/@benbinbin/hierarchical-bar-chart',
folder: 'hierarchical-barchart',
note: 'https://datavis-note.benbinbin.com/article/d3/chart-example/d3-chart-example-bar-chart#层级下钻'
},
{
name: '动效条形图-可追踪条带的过渡(样例一)',
description: '为条形图添加过渡动效,可以利用物体恒存 object constancy 让用户更容易地留意和理解数据是如何变化的。',
reference: 'https://observablehq.com/@benbinbin/bar-chart-transitions',
folder: 'transition-barchart',
note: 'https://datavis-note.benbinbin.com/article/d3/chart-example/d3-chart-example-bar-chart#可追踪条带的过渡'
},
{
name: '动效条形图-可追踪条带的过渡(样例二)',
reference: 'https://observablehq.com/@benbinbin/bar-chart-race',
folder: 'barchart-race',
note: 'https://datavis-note.benbinbin.com/article/d3/chart-example/d3-chart-example-bar-chart#可追踪条带的过渡'
},
{
name: '直方图',
reference: 'https://observablehq.com/@benbinbin/d3-histogram',
folder: 'histogram',
note: 'https://datavis-note.benbinbin.com/article/d3/chart-example/d3-chart-example-bar-chart#直方图'
},
{
name: '堆叠条形图',
reference: 'https://observablehq.com/@benbinbin/stacked-bar-chart',
folder: 'stacked-barchart',
note: 'https://datavis-note.benbinbin.com/article/d3/chart-example/d3-chart-example-bar-chart#堆叠条形图'
},
{
name: '堆叠条形图示例',
description: '音乐产业在 1973-2018 年间的收益,并按(媒介)格式进行划分',
reference: 'https://observablehq.com/@benbinbin/revenue-by-music-format-1973-2018',
folder: 'revenue-by-music-format',
note: 'https://datavis-note.benbinbin.com/article/d3/chart-example/d3-chart-example-bar-chart#堆叠条形图示例'
},
{
name: '横向堆叠条形图',
reference: 'https://observablehq.com/@benbinbin/stacked-bar-chart-horizontal',
folder: 'horizontal-stacked-barchart',
note: 'https://datavis-note.benbinbin.com/article/d3/chart-example/d3-chart-example-bar-chart#横向堆叠条形图'
},
{
name: '发散型的堆叠条形图',
reference: 'https://observablehq.com/@benbinbin/diverging-stacked-bar-chart',
folder: 'diverge-stacked-barchart',
note: 'https://datavis-note.benbinbin.com/article/d3/chart-example/d3-chart-example-bar-chart#发散型的堆叠条形图'
},
{
name: '标准化的堆叠条形图',
reference: 'https://observablehq.com/@benbinbin/stacked-bar-chart-normalized',
folder: 'normalized-stacked-barchart',
note: 'https://datavis-note.benbinbin.com/article/d3/chart-example/d3-chart-example-bar-chart#标准化的堆叠条形图'
},
{
name: '分组条形图',
reference: 'https://observablehq.com/@benbinbin/grouped-bar-chart',
folder: 'group-barchart',
note: 'https://datavis-note.benbinbin.com/article/d3/chart-example/d3-chart-example-bar-chart#分组条形图'
},
{
name: '分组条形图与堆叠条形图的转换',
reference: 'https://observablehq.com/@benbinbin/stacked-to-grouped-bars',
folder: 'stacked-to-group-barchart',
note: 'https://datavis-note.benbinbin.com/article/d3/chart-example/d3-chart-example-bar-chart#分组条形图与堆叠条形图的转换'
}
]
},
{
theme: 'linechart',
themeTitle: '折线图',
examples: [
{
name: '静态折线图',
reference: 'https://observablehq.com/@benbinbin/line-chart',
folder: 'static-linechart',
note: 'https://datavis-note.benbinbin.com/article/d3/chart-example/d3-chart-example-line-chart#静态图'
},
{
name: '数据缺失的折线图',
reference: 'https://observablehq.com/@benbinbin/line-chart-missing-data',
folder: 'linechart-with-missing-data',
note: 'https://datavis-note.benbinbin.com/article/d3/chart-example/d3-chart-example-line-chart#数据缺失的折线图'
},
{
name: '条形图-折线图双轴图',
reference: 'https://observablehq.com/@benbinbin/bar-line-chart',
folder: 'bar-line-chart',
note: 'https://datavis-note.benbinbin.com/article/d3/chart-example/d3-chart-example-line-chart#双轴图'
},
{
name: '彩色折线图',
reference: 'https://observablehq.com/@benbinbin/variable-color-line',
folder: 'variable-color-line-chart',
note: 'https://datavis-note.benbinbin.com/article/d3/chart-example/d3-chart-example-line-chart#彩色折线图'
},
{
name: '渐变色折线图',
reference: 'https://observablehq.com/@benbinbin/gradient-encoding',
folder: 'gradient-encoding-line-chart',
note: 'https://datavis-note.benbinbin.com/article/d3/chart-example/d3-chart-example-line-chart#彩色折线图'
},
{
name: '阈值二色折线图',
reference: 'https://observablehq.com/@benbinbin/threshold-encoding',
folder: 'threshold-encoding-line-chart',
note: 'https://datavis-note.benbinbin.com/article/d3/chart-example/d3-chart-example-line-chart#彩色折线图'
},
{
name: '线段内标注的折线图',
reference: 'https://observablehq.com/@benbinbin/inline-labels',
folder: 'inline-labels-line-chart',
note: 'https://datavis-note.benbinbin.com/article/d3/chart-example/d3-chart-example-line-chart#带标注的折线图'
},
{
name: '斜率图',
reference: 'https://observablehq.com/@benbinbin/slope-chart',
folder: 'slope-chart',
note: 'https://datavis-note.benbinbin.com/article/d3/chart-example/d3-chart-example-line-chart#斜率图'
},
{
name: '癌症生存率',
reference: 'https://observablehq.com/@benbinbin/cancer-survival-rates',
folder: 'cancer-survival-rates',
note: 'https://datavis-note.benbinbin.com/article/d3/chart-example/d3-chart-example-line-chart#斜率图'
},
{
name: '蜡烛线',
reference: 'https://observablehq.com/@benbinbin/candlestick-chart',
folder: 'candlestick-chart',
note: 'https://datavis-note.benbinbin.com/article/d3/chart-example/d3-chart-example-line-chart#蜡烛线'
},
{
name: '美国线',
reference: 'https://observablehq.com/@benbinbin/ohlc-chart',
folder: 'ohlc-chart',
note: 'https://datavis-note.benbinbin.com/article/d3/chart-example/d3-chart-example-line-chart#美国线'
},
{
name: '多系列折线图',
reference: 'https://observablehq.com/@benbinbin/line-chart-multiple-series',
folder: 'multiple-series-line-chart',
note: 'https://datavis-note.benbinbin.com/article/d3/chart-example/d3-chart-example-line-chart#多系列折线图'
},
{
name: '时刻线图',
reference: 'https://observablehq.com/@benbinbin/mareys-trains',
folder: 'stringline-chart',
note: 'https://datavis-note.benbinbin.com/article/d3/chart-example/d3-chart-example-line-chart#时刻线图'
},
{
name: '交互式绘制折线图',
reference: 'https://observablehq.com/@benbinbin/you-draw-it',
folder: 'you-draw-it',
note: 'https://datavis-note.benbinbin.com/article/d3/chart-example/d3-chart-example-line-chart#交互式绘制折线图'
},
{
name: '带有提示框的折线图',
reference: 'https://observablehq.com/@benbinbin/line-chart-with-tooltip-2',
folder: 'linechart-with-tooltip',
note: 'https://datavis-note.benbinbin.com/article/d3/chart-example/d3-chart-example-line-chart#带有提示框的折线图'
},
{
name: '折线图展开动效',
reference: 'https://observablehq.com/@benbinbin/connected-scatterplot',
folder: 'line-chart-connected',
note: 'https://datavis-note.benbinbin.com/article/d3/chart-example/d3-chart-example-line-chart#折线图展开动效'
},
{
name: '多系列折线图展开动效',
reference: 'https://observablehq.com/@benbinbin/sea-ice-extent-1978-2017',
folder: 'multiple-line-chart-expansion',
note: 'https://datavis-note.benbinbin.com/article/d3/chart-example/d3-chart-example-line-chart#折线图展开动效'
},
{
name: '比例尺切换动效',
reference: 'https://observablehq.com/@benbinbin/new-zealand-tourists-1921-2018',
folder: 'scale-switch',
note: 'https://datavis-note.benbinbin.com/article/d3/chart-example/d3-chart-example-line-chart#比例尺切换动效'
},
{
name: '路径切换补间动画',
reference: 'https://observablehq.com/@benbinbin/path-tween',
folder: 'path-tween',
note: 'https://datavis-note.benbinbin.com/article/d3/chart-example/d3-chart-example-line-chart#路径切换补间动画'
},
]
},
{
theme: 'areachart',
themeTitle: '面积图',
examples: [
{
name: '静态面积图',
reference: 'https://observablehq.com/@benbinbin/area-chart',
folder: 'static-areachart',
note: 'https://datavis-note.benbinbin.com/article/d3/chart-example/d3-chart-example-area-chart#静态图'
},
{
name: '数据缺失的面积图',
reference: 'https://observablehq.com/@benbinbin/area-chart-with-missing-data',
folder: 'areachart-with-missing-data',
note: 'https://datavis-note.benbinbin.com/article/d3/chart-example/d3-chart-example-area-chart#数据缺失的面积图'
},
{
name: '堆叠式面积图',
reference: 'https://observablehq.com/@benbinbin/stacked-area-chart',
folder: 'stacked-areachart',
note: 'https://datavis-note.benbinbin.com/article/d3/chart-example/d3-chart-example-area-chart#堆叠式面积图'
},
{
name: '标准化的堆叠式面积图',
reference: 'https://observablehq.com/@benbinbin/normalized-stacked-area-chart',
folder: 'normalized-stacked-areachart',
note: 'https://datavis-note.benbinbin.com/article/d3/chart-example/d3-chart-example-area-chart#标准化的堆叠式面积图'
},
{
name: '带状图',
reference: 'https://observablehq.com/@benbinbin/band-chart',
folder: 'band-chart',
note: 'https://datavis-note.benbinbin.com/article/d3/chart-example/d3-chart-example-area-chart#带状图'
},
{
name: '差异图',
reference: 'https://observablehq.com/@benbinbin/difference-chart',
folder: 'difference-chart',
note: 'https://datavis-note.benbinbin.com/article/d3/chart-example/d3-chart-example-area-chart#差异图'
},
{
name: '差异图 v2',
reference: 'https://observablehq.com/@benbinbin/difference-chart',
folder: 'difference-chart-v2',
note: 'https://datavis-note.benbinbin.com/article/d3/chart-example/d3-chart-example-area-chart#差异图'
},
{
name: '河流图',
reference: 'https://observablehq.com/@benbinbin/streamgraph',
folder: 'streamgraph',
note: 'https://datavis-note.benbinbin.com/article/d3/chart-example/d3-chart-example-area-chart#河流图'
},
{
name: '山脊线图',
reference: 'https://observablehq.com/@benbinbin/ridgeline-plot',
folder: 'ridgeline-plot',
note: 'https://datavis-note.benbinbin.com/article/d3/chart-example/d3-chart-example-area-chart#山脊线图'
},
{
name: '地平线图',
reference: 'https://observablehq.com/@benbinbin/horizon-chart',
folder: 'horizon-chart',
note: 'https://datavis-note.benbinbin.com/article/d3/chart-example/d3-chart-example-area-chart#地平线图'
},
{
name: '可缩放的面积图',
reference: 'https://observablehq.com/@benbinbin/zoomable-area-chart',
folder: 'zoomable-areachart',
note: 'https://datavis-note.benbinbin.com/article/d3/chart-example/d3-chart-example-area-chart#可缩放的面积图'
},
{
name: '可平移的面积图',
reference: 'https://observablehq.com/@benbinbin/pannable-chart',
folder: 'pannable-areachart',
note: 'https://datavis-note.benbinbin.com/article/d3/chart-example/d3-chart-example-area-chart#可平移的面积图'
},
{
name: '刷选',
reference: 'https://observablehq.com/@benbinbin/focus-context',
folder: 'areachart-minimap-brush',
note: 'https://datavis-note.benbinbin.com/article/d3/chart-example/d3-chart-example-area-chart#刷选'
},
{
name: '形状切换补间动画',
reference: 'https://observablehq.com/@benbinbin/shape-tweening',
folder: 'shape-tweening',
note: 'https://datavis-note.benbinbin.com/article/d3/chart-example/d3-chart-example-area-chart#形状切换补间动画'
},
{
name: '河流图切换动效',
reference: 'https://observablehq.com/@benbinbin/streamgraph-transitions',
folder: 'streamgraph-transition',
note: 'https://datavis-note.benbinbin.com/article/d3/chart-example/d3-chart-example-area-chart#河流图切换动效'
},
{
name: '美国各州人口分布',
reference: 'https://observablehq.com/@benbinbin/u-s-population-by-state-1790-1990',
folder: 'us-population-by-state',
note: 'https://datavis-note.benbinbin.com/article/d3/chart-example/d3-chart-example-area-chart#美国各州人口分布'
},
]
},
{
theme: 'piechart',
themeTitle: '饼图',
examples: [
{
name: '静态饼图',
reference: 'https://observablehq.com/@benbinbin/pie-chart',
folder: 'static-piechart',
note: 'https://datavis-note.benbinbin.com/article/d3/chart-example/d3-chart-example-pie-chart#静态图'
},
{
name: '环形图',
reference: 'https://observablehq.com/@benbinbin/donut-chart',
folder: 'donut-chart',
note: 'https://datavis-note.benbinbin.com/article/d3/chart-example/d3-chart-example-pie-chart#环形图'
},
{
name: '环形图矩阵',
reference: 'https://observablehq.com/@benbinbin/donut-multiples',
folder: 'donut-multiples',
note: 'https://datavis-note.benbinbin.com/article/d3/chart-example/d3-chart-example-pie-chart#环形图矩阵'
},
{
name: '面积不同的环形图矩阵',
reference: 'https://observablehq.com/@benbinbin/sized-donut-multiples',
folder: 'sized-donut-multiples',
note: 'https://datavis-note.benbinbin.com/article/d3/chart-example/d3-chart-example-pie-chart#环形图矩阵'
},
{
name: '弧形切换补间动画',
reference: 'https://observablehq.com/@benbinbin/arc-tween',
folder: 'arc-tween',
note: 'https://datavis-note.benbinbin.com/article/d3/chart-example/d3-chart-example-pie-chart#饼图更新'
},
]
},
{
theme: 'hierarchy',
themeTitle: '结构化数据可视化',
examples: [
{
name: 'Tidy Tree',
description: '紧凑型的树图 tree diagram。',
reference: 'https://observablehq.com/@d3/tidy-tree',
folder: 'static-tree-diagram',
},
{
name: 'Collapsible Tree',
description: '可交互(子树可伸缩)的树图 tree diagram。',
reference: 'https://observablehq.com/@d3/collapsible-tree',
folder: 'collapsible-tree',
},
{
name: 'Collapsible Tree Zoom',
description: '可交互(子树可伸缩,树图整体可缩放移动)的树图 tree diagram。',
reference: 'https://observablehq.com/@d3/collapsible-tree',
folder: 'collapsible-tree-zoom',
},
{
name: 'Radial Tidy Tree',
description: '径向树图 tree diagram。',
reference: 'https://observablehq.com/@d3/radial-tidy-tree',
folder: 'radial-tidy-tree',
},
{
name: '旭日图',
description: '静态旭日图 Sunburst Chart',
reference: 'https://observablehq.com/@d3/sunburst',
folder: 'sunburst',
},
{
name: 'Zoomable Sunburst',
description: '可下钻的旭日图。',
reference: 'https://observablehq.com/@d3/zoomable-sunburst',
folder: 'zoomable-sunburst',
},
]
},
]
const collapsedThemeArr = ref(new Set());
const toggleTheme = (theme) => {
console.log(collapsedThemeArr.value.has(theme))
if (collapsedThemeArr.value.has(theme)) {
collapsedThemeArr.value.delete(theme)
} else {
collapsedThemeArr.value.add(theme)
}
}
return {
content,
collapsedThemeArr,
toggleTheme
}
}
}).mount('#app')
</script>
</body>
</html>