@cfasim-ui/docs 0.3.11

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.
Files changed (60) hide show
  1. package/LICENSE +201 -0
  2. package/charts/ChartMenu/ChartMenu.vue +140 -0
  3. package/charts/ChartMenu/download.ts +44 -0
  4. package/charts/ChartTooltip/ChartTooltip.vue +97 -0
  5. package/charts/ChoroplethMap/ChoroplethMap.md +398 -0
  6. package/charts/ChoroplethMap/ChoroplethMap.vue +777 -0
  7. package/charts/ChoroplethMap/hsaMapping.ts +4116 -0
  8. package/charts/DataTable/DataTable.md +143 -0
  9. package/charts/DataTable/DataTable.vue +277 -0
  10. package/charts/LineChart/LineChart.md +472 -0
  11. package/charts/LineChart/LineChart.vue +1216 -0
  12. package/charts/index.ts +23 -0
  13. package/charts/tooltip-position.ts +49 -0
  14. package/components/Box/Box.md +49 -0
  15. package/components/Box/Box.vue +52 -0
  16. package/components/Button/Button.md +67 -0
  17. package/components/Button/Button.vue +81 -0
  18. package/components/Expander/Expander.md +34 -0
  19. package/components/Expander/Expander.vue +95 -0
  20. package/components/Hint/Hint.md +29 -0
  21. package/components/Hint/Hint.vue +83 -0
  22. package/components/Icon/Icon.md +67 -0
  23. package/components/Icon/Icon.vue +112 -0
  24. package/components/LightDarkToggle/LightDarkToggle.vue +49 -0
  25. package/components/NumberInput/NumberInput.md +305 -0
  26. package/components/NumberInput/NumberInput.vue +531 -0
  27. package/components/SelectBox/SelectBox.md +110 -0
  28. package/components/SelectBox/SelectBox.vue +195 -0
  29. package/components/SidebarLayout/SidebarLayout.md +104 -0
  30. package/components/SidebarLayout/SidebarLayout.vue +466 -0
  31. package/components/Spinner/Spinner.md +51 -0
  32. package/components/Spinner/Spinner.vue +55 -0
  33. package/components/TextInput/TextInput.md +82 -0
  34. package/components/TextInput/TextInput.vue +94 -0
  35. package/components/Toggle/Toggle.md +81 -0
  36. package/components/Toggle/Toggle.vue +81 -0
  37. package/components/index.ts +15 -0
  38. package/index.json +121 -0
  39. package/package.json +24 -0
  40. package/pyodide/index.ts +7 -0
  41. package/pyodide/pyodide.worker.ts +233 -0
  42. package/pyodide/pyodideWorkerApi.ts +102 -0
  43. package/pyodide/useModel.ts +86 -0
  44. package/pyodide/vitePlugin.js +51 -0
  45. package/shared/ModelOutput.ts +88 -0
  46. package/shared/csv.ts +22 -0
  47. package/shared/index.ts +24 -0
  48. package/shared/transferUtils.ts +126 -0
  49. package/shared/useUrlParams.ts +296 -0
  50. package/theme/all.js +5 -0
  51. package/theme/base.css +176 -0
  52. package/theme/cfasim.css +3 -0
  53. package/theme/theme.css +113 -0
  54. package/theme/themes/cdc.css +22 -0
  55. package/theme/utilities.css +518 -0
  56. package/wasm/index.ts +2 -0
  57. package/wasm/useModel.ts +53 -0
  58. package/wasm/vitePlugin.js +35 -0
  59. package/wasm/wasm.worker.ts +74 -0
  60. package/wasm/wasmWorkerApi.ts +38 -0
@@ -0,0 +1,472 @@
1
+ # LineChart
2
+
3
+ A responsive SVG line chart with support for multiple series, axis labels, and custom styling.
4
+
5
+ ## Examples
6
+
7
+ ### Single series
8
+
9
+ <ComponentDemo>
10
+ <LineChart :data="[0, 4, 8, 15, 22, 30, 28, 20, 12, 5, 2]" :height="200" x-label="Days" y-label="Cases" tooltip-trigger="hover" />
11
+
12
+ <template #code>
13
+
14
+ ```vue
15
+ <LineChart
16
+ :data="[0, 4, 8, 15, 22, 30, 28, 20, 12, 5, 2]"
17
+ :height="200"
18
+ x-label="Days"
19
+ y-label="Cases"
20
+ tooltip-trigger="hover"
21
+ />
22
+ ```
23
+
24
+ </template>
25
+ </ComponentDemo>
26
+
27
+ ### Multiple series
28
+
29
+ <ComponentDemo>
30
+ <LineChart
31
+ :series="[
32
+ { data: [0, 10, 25, 45, 60, 55, 40, 20, 8], color: '#fb7e38', strokeWidth: 3 },
33
+ { data: [0, 5, 12, 20, 28, 25, 18, 10, 4], color: '#0057b7', strokeWidth: 3 },
34
+ ]"
35
+ :height="200"
36
+ x-label="Weeks"
37
+ y-label="Incidence"
38
+ />
39
+
40
+ <template #code>
41
+
42
+ ```vue
43
+ <LineChart
44
+ :series="[
45
+ {
46
+ data: [0, 10, 25, 45, 60, 55, 40, 20, 8],
47
+ color: '#fb7e38',
48
+ strokeWidth: 3,
49
+ },
50
+ {
51
+ data: [0, 5, 12, 20, 28, 25, 18, 10, 4],
52
+ color: '#0057b7',
53
+ strokeWidth: 3,
54
+ },
55
+ ]"
56
+ :height="200"
57
+ x-label="Weeks"
58
+ y-label="Incidence"
59
+ />
60
+ ```
61
+
62
+ </template>
63
+ </ComponentDemo>
64
+
65
+ ### Tooltip
66
+
67
+ Hover over the chart to see a tooltip with values at each data point. Set `tooltip-trigger="hover"` to enable the built-in tooltip with crosshair and highlight dots. Use the `#tooltip` slot for custom content.
68
+
69
+ <ComponentDemo>
70
+ <LineChart
71
+ :series="[
72
+ { data: [0, 10, 25, 45, 60, 55, 40, 20, 8], color: '#fb7e38', strokeWidth: 3 },
73
+ { data: [0, 5, 12, 20, 28, 25, 18, 10, 4], color: '#0057b7', strokeWidth: 3 },
74
+ ]"
75
+ :x-tick-format="(_, i) => ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep'][i]"
76
+ :height="200"
77
+ x-label="Month"
78
+ y-label="Incidence"
79
+ tooltip-trigger="hover"
80
+ />
81
+
82
+ <template #code>
83
+
84
+ ```vue
85
+ <LineChart
86
+ :series="[
87
+ {
88
+ data: [0, 10, 25, 45, 60, 55, 40, 20, 8],
89
+ color: '#fb7e38',
90
+ strokeWidth: 3,
91
+ },
92
+ {
93
+ data: [0, 5, 12, 20, 28, 25, 18, 10, 4],
94
+ color: '#0057b7',
95
+ strokeWidth: 3,
96
+ },
97
+ ]"
98
+ :x-tick-format="(_, i) => months[i]"
99
+ :height="200"
100
+ x-label="Month"
101
+ y-label="Incidence"
102
+ tooltip-trigger="hover"
103
+ />
104
+ ```
105
+
106
+ </template>
107
+ </ComponentDemo>
108
+
109
+ ### Custom axis ticks
110
+
111
+ Control tick placement with `x-ticks` and `y-ticks`. Pass a **number** for a fixed interval (in data units, respecting `xMin`) or an **array** of explicit values. Use `x-tick-format` / `y-tick-format` to customize labels.
112
+
113
+ <ComponentDemo>
114
+ <LineChart
115
+ :data="[0, 0.12, 0.28, 0.45, 0.61, 0.74, 0.83, 0.89, 0.93, 0.96, 0.97, 0.98, 0.99, 0.99, 1.0]"
116
+ :x-ticks="7"
117
+ :y-ticks="[0, 0.5, 1]"
118
+ :y-tick-format="(v) => `${(v * 100).toFixed(0)}%`"
119
+ :x-tick-format="(v) => `day ${v}`"
120
+ :height="220"
121
+ x-label="Time"
122
+ y-label="Coverage"
123
+ x-grid
124
+ y-grid
125
+ />
126
+
127
+ <template #code>
128
+
129
+ ```vue
130
+ <LineChart
131
+ :data="coverage"
132
+ :x-ticks="7"
133
+ :y-ticks="[0, 0.5, 1]"
134
+ :y-tick-format="(v) => `${(v * 100).toFixed(0)}%`"
135
+ :x-tick-format="(v) => `day ${v}`"
136
+ :height="220"
137
+ x-label="Time"
138
+ y-label="Coverage"
139
+ x-grid
140
+ y-grid
141
+ />
142
+ ```
143
+
144
+ </template>
145
+ </ComponentDemo>
146
+
147
+ ### Dashed baseline
148
+
149
+ <ComponentDemo>
150
+ <LineChart
151
+ :series="[
152
+ { data: [0, 10, 25, 45, 60, 55, 40, 20, 8], color: '#999', dashed: true, strokeWidth: 2 },
153
+ { data: [0, 5, 12, 20, 28, 25, 18, 10, 4], color: '#2563eb', strokeWidth: 2 },
154
+ ]"
155
+ :height="200"
156
+ />
157
+
158
+ <template #code>
159
+
160
+ ```vue
161
+ <LineChart
162
+ :series="[
163
+ {
164
+ data: [0, 10, 25, 45, 60, 55, 40, 20, 8],
165
+ color: '#999',
166
+ dashed: true,
167
+ strokeWidth: 2,
168
+ },
169
+ {
170
+ data: [0, 5, 12, 20, 28, 25, 18, 10, 4],
171
+ color: '#2563eb',
172
+ strokeWidth: 2,
173
+ },
174
+ ]"
175
+ :height="200"
176
+ />
177
+ ```
178
+
179
+ </template>
180
+ </ComponentDemo>
181
+
182
+ ### Many trajectories with low opacity
183
+
184
+ <ComponentDemo>
185
+ <LineChart
186
+ :series="Array.from({ length: 20 }, (_, i) => ({
187
+ data: Array.from({ length: 50 }, (_, t) => Math.max(0, 30 * Math.sin(t / 8) + (Math.random() - 0.5) * 15 + i * 0.5)),
188
+ color: '#0057b7',
189
+ }))"
190
+ :height="250"
191
+ :line-opacity="0.15"
192
+ x-label="Days"
193
+ y-label="Incidence"
194
+ />
195
+
196
+ <template #code>
197
+
198
+ ```vue
199
+ <LineChart
200
+ :series="trajectories"
201
+ :height="250"
202
+ :line-opacity="0.15"
203
+ x-label="Days"
204
+ y-label="Incidence"
205
+ />
206
+ ```
207
+
208
+ </template>
209
+ </ComponentDemo>
210
+
211
+ ### Grid lines
212
+
213
+ <ComponentDemo>
214
+ <LineChart
215
+ :series="[
216
+ { data: [0, 10, 25, 45, 60, 55, 40, 20, 8], color: '#fb7e38', strokeWidth: 3 },
217
+ { data: [0, 5, 12, 20, 28, 25, 18, 10, 4], color: '#0057b7', strokeWidth: 3 },
218
+ ]"
219
+ :height="200"
220
+ x-label="Weeks"
221
+ y-label="Incidence"
222
+ x-grid
223
+ y-grid
224
+ />
225
+
226
+ <template #code>
227
+
228
+ ```vue
229
+ <LineChart
230
+ :series="[
231
+ {
232
+ data: [0, 10, 25, 45, 60, 55, 40, 20, 8],
233
+ color: '#fb7e38',
234
+ strokeWidth: 3,
235
+ },
236
+ {
237
+ data: [0, 5, 12, 20, 28, 25, 18, 10, 4],
238
+ color: '#0057b7',
239
+ strokeWidth: 3,
240
+ },
241
+ ]"
242
+ :height="200"
243
+ x-label="Weeks"
244
+ y-label="Incidence"
245
+ x-grid
246
+ y-grid
247
+ />
248
+ ```
249
+
250
+ </template>
251
+ </ComponentDemo>
252
+
253
+ ### Dots
254
+
255
+ <ComponentDemo>
256
+ <LineChart
257
+ :series="[
258
+ { data: [0, 4, 8, 15, 22, 30, 28, 20, 12, 5, 2], color: '#0057b7', strokeWidth: 2, dots: true, dotRadius: 4, dotFill: '#fff', dotStroke: '#0057b7' },
259
+ ]"
260
+ :height="200"
261
+ x-label="Days"
262
+ y-label="Cases"
263
+ />
264
+
265
+ <template #code>
266
+
267
+ ```vue
268
+ <LineChart
269
+ :series="[
270
+ {
271
+ data: [0, 4, 8, 15, 22, 30, 28, 20, 12, 5, 2],
272
+ color: '#0057b7',
273
+ strokeWidth: 2,
274
+ dots: true,
275
+ dotRadius: 4,
276
+ dotFill: '#fff',
277
+ dotStroke: '#0057b7',
278
+ },
279
+ ]"
280
+ :height="200"
281
+ x-label="Days"
282
+ y-label="Cases"
283
+ />
284
+ ```
285
+
286
+ </template>
287
+ </ComponentDemo>
288
+
289
+ ### Area sections
290
+
291
+ Highlight a range of a series line by filling the area between the line and the x-axis. Labels are rendered below the chart and automatically stack when they overlap.
292
+
293
+ <ComponentDemo>
294
+ <LineChart
295
+ :series="[
296
+ { data: [0, 2, 5, 12, 25, 45, 70, 100, 130, 155, 170], color: '#000', strokeWidth: 1, legend: 'No interventions' },
297
+ { data: [0, 0, 0, 2, 8, 20, 40, 65, 90, 110, 120], color: '#999', strokeWidth: 1, dashed: true, legend: 'Interventions' },
298
+ ]"
299
+ :area-sections="[
300
+ { startIndex: 2, endIndex: 7, color: '#6366f1', strokeWidth: 0, legend: 'inline', label: 'Day 2–7', description: 'Rapid growth phase' },
301
+ { seriesIndex: 0, startIndex: 5, endIndex: 9, color: '#f43f5e', label: 'Day 5–9', description: 'Mitigation period' },
302
+ ]"
303
+ :height="250"
304
+ x-label="Days"
305
+ y-label="Cumulative count"
306
+ tooltip-trigger="hover"
307
+ :menu="false"
308
+ />
309
+
310
+ <template #code>
311
+
312
+ ```vue
313
+ <LineChart
314
+ :series="[
315
+ {
316
+ data: [0, 2, 5, 12, 25, 45, 70, 100, 130, 155, 170],
317
+ color: '#000',
318
+ strokeWidth: 1,
319
+ legend: 'No interventions',
320
+ },
321
+ {
322
+ data: [0, 0, 0, 2, 8, 20, 40, 65, 90, 110, 120],
323
+ color: '#999',
324
+ strokeWidth: 1,
325
+ dashed: true,
326
+ legend: 'Interventions',
327
+ },
328
+ ]"
329
+ :area-sections="[
330
+ {
331
+ startIndex: 2,
332
+ endIndex: 7,
333
+ color: '#6366f1',
334
+ strokeWidth: 0,
335
+ legend: 'inline',
336
+ label: 'Day 2–7',
337
+ description: 'Rapid growth phase',
338
+ },
339
+ {
340
+ seriesIndex: 0,
341
+ startIndex: 5,
342
+ endIndex: 9,
343
+ color: '#f43f5e',
344
+ label: 'Day 5–9',
345
+ description: 'Mitigation period',
346
+ },
347
+ ]"
348
+ :height="250"
349
+ x-label="Days"
350
+ y-label="Cumulative count"
351
+ tooltip-trigger="hover"
352
+ />
353
+ ```
354
+
355
+ </template>
356
+ </ComponentDemo>
357
+
358
+ ### Custom CSV download
359
+
360
+ By default, the Download CSV menu item exports the chart series as CSV. Use
361
+ the `csv` prop to supply your own content (for example, to include original
362
+ dates, categorical labels, or extra columns that aren't plotted). Use
363
+ `filename` to control the download filename (shared by SVG, PNG and CSV).
364
+
365
+ Pass `download-link` to also render a plain text link below the chart — set
366
+ it to `true` for the default label, or pass a string to customize it.
367
+
368
+ <ComponentDemo>
369
+ <LineChart
370
+ :data="[10, 22, 35, 48]"
371
+ :height="200"
372
+ filename="weekly-cases"
373
+ :csv="'week,cases\n2024-W01,10\n2024-W02,22\n2024-W03,35\n2024-W04,48'"
374
+ x-label="Week"
375
+ y-label="Cases"
376
+ download-link="Download weekly cases (CSV)"
377
+ />
378
+
379
+ <template #code>
380
+
381
+ ```vue
382
+ <LineChart
383
+ :data="[10, 22, 35, 48]"
384
+ :height="200"
385
+ filename="weekly-cases"
386
+ :csv="`week,cases
387
+ 2024-W01,10
388
+ 2024-W02,22
389
+ 2024-W03,35
390
+ 2024-W04,48`"
391
+ x-label="Week"
392
+ y-label="Cases"
393
+ download-link="Download weekly cases (CSV)"
394
+ />
395
+ ```
396
+
397
+ </template>
398
+ </ComponentDemo>
399
+
400
+ `csv` also accepts a function, which is useful for deferring serialization
401
+ until the user clicks Download:
402
+
403
+ ```vue
404
+ <LineChart :data="cases" :csv="() => buildCsv(cases, dates)" />
405
+ ```
406
+
407
+ ## Props
408
+
409
+ | Prop | Type | Required | Default |
410
+ |------|------|----------|---------|
411
+ | `data` | `number[]` | No | — |
412
+ | `series` | `Series[]` | No | — |
413
+ | `areas` | `Area[]` | No | — |
414
+ | `areaSections` | `AreaSection[]` | No | — |
415
+ | `width` | `number` | No | — |
416
+ | `height` | `number` | No | — |
417
+ | `lineOpacity` | `number` | No | `1` |
418
+ | `title` | `string` | No | — |
419
+ | `xLabel` | `string` | No | — |
420
+ | `yLabel` | `string` | No | — |
421
+ | `yMin` | `number` | No | — |
422
+ | `xMin` | `number` | No | — |
423
+ | `xTicks` | `number \| number[]` | No | — |
424
+ | `yTicks` | `number \| number[]` | No | — |
425
+ | `xTickFormat` | `(value: number, index: number) =&gt; string` | No | — |
426
+ | `yTickFormat` | `(value: number) =&gt; string` | No | — |
427
+ | `xLabels` | `string[]` | No | — |
428
+ | `debounce` | `number` | No | — |
429
+ | `menu` | `boolean \| string` | No | `true` |
430
+ | `xGrid` | `boolean` | No | — |
431
+ | `yGrid` | `boolean` | No | — |
432
+ | `tooltipData` | `unknown[]` | No | — |
433
+ | `tooltipTrigger` | `"hover" \| "click"` | No | — |
434
+ | `tooltipClamp` | `"none" \| "chart" \| "window"` | No | `"chart"` |
435
+ | `csv` | `string \| (() =&gt; string)` | No | — |
436
+ | `filename` | `string` | No | — |
437
+ | `downloadLink` | `boolean \| string` | No | — |
438
+
439
+
440
+ ### Series
441
+
442
+ ```ts
443
+ interface Series {
444
+ data: number[];
445
+ color?: string;
446
+ dashed?: boolean;
447
+ strokeWidth?: number;
448
+ opacity?: number;
449
+ line?: boolean;
450
+ dots?: boolean;
451
+ dotRadius?: number;
452
+ dotFill?: string;
453
+ dotStroke?: string;
454
+ }
455
+ ```
456
+
457
+ ### AreaSection
458
+
459
+ ```ts
460
+ interface AreaSection {
461
+ seriesIndex?: number; // omit for full-height fill
462
+ startIndex: number;
463
+ endIndex: number;
464
+ color?: string;
465
+ opacity?: number; // default: 0.15
466
+ label?: string;
467
+ description?: string;
468
+ strokeWidth?: number; // default: 2
469
+ dashed?: boolean;
470
+ legend?: "inline" | "below" | false; // default: "below"
471
+ }
472
+ ```