@fundar/data-chart-telling 1.0.0 → 1.1.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.
Files changed (155) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/README.md +57 -18
  3. package/dist/configuration/config.svelte.js +13 -1
  4. package/dist/configuration/themes/index.d.ts +124 -0
  5. package/dist/index.d.ts +2 -1
  6. package/dist/index.js +1 -0
  7. package/dist/layout/base/BasePlotLayout.svelte +18 -5
  8. package/dist/layout/hover/HoverSettings.d.ts +20 -6
  9. package/dist/layout/hover/HoverSettings.js +29 -4
  10. package/dist/layout/legend/LegendState.svelte.d.ts +5 -0
  11. package/dist/layout/legend/LegendState.svelte.js +4 -0
  12. package/dist/layout/plot/Plot.svelte +6 -3
  13. package/dist/layout/plot/PublicPlotContext.d.ts +5 -4
  14. package/dist/layout/plot/PublicPlotContext.js +7 -3
  15. package/dist/layout/plot/Slice.js +4 -2
  16. package/dist/layout/scales/EdgeTicks.d.ts +39 -0
  17. package/dist/layout/scales/EdgeTicks.js +82 -0
  18. package/dist/layout/scales/NiceTicks.d.ts +40 -0
  19. package/dist/layout/scales/NiceTicks.js +72 -0
  20. package/dist/layout/scales/ScalesLayout.svelte +64 -30
  21. package/dist/layout/scales/ScalesLayout.svelte.d.ts +5 -0
  22. package/dist/layout/scales/SveltePlotScale.d.ts +15 -0
  23. package/dist/layout/scales/SveltePlotScale.js +79 -0
  24. package/dist/layout/styles/ValueLabels.js +3 -2
  25. package/dist/layout/timeline/Timeline.svelte +5 -2
  26. package/dist/layout/timeline/Timeline.svelte.d.ts +2 -0
  27. package/dist/layout/timeline/TimelineLayout.svelte +38 -12
  28. package/dist/layout/timeline/TimelineLayout.svelte.d.ts +7 -5
  29. package/dist/layout/timeline/TimelineRule.svelte +1 -0
  30. package/dist/layout/timeline/TimelineState.svelte.d.ts +13 -5
  31. package/dist/layout/timeline/TimelineState.svelte.js +42 -8
  32. package/dist/layout/timeline/TimelineTime.d.ts +18 -0
  33. package/dist/layout/timeline/TimelineTime.js +117 -0
  34. package/dist/layout/tooltip/Tooltip.svelte +6 -3
  35. package/dist/layout/tooltip/Tooltip.svelte.d.ts +2 -0
  36. package/dist/layout/tooltip/TooltipState.svelte.d.ts +8 -2
  37. package/dist/layout/tooltip/TooltipState.svelte.js +22 -3
  38. package/dist/markers/delta/DeltaMarker.svelte +9 -7
  39. package/dist/phases/Pipeline.js +3 -2
  40. package/dist/phases/data/DataPhase.d.ts +5 -11
  41. package/dist/phases/data/DataPhase.js +11 -8
  42. package/dist/phases/facet/FacetPanels.d.ts +54 -0
  43. package/dist/phases/facet/FacetPanels.js +95 -0
  44. package/dist/phases/facet/FacetPhase.d.ts +1 -42
  45. package/dist/phases/facet/FacetPhase.js +1 -87
  46. package/dist/phases/hover/HoverPhase.d.ts +6 -43
  47. package/dist/phases/hover/HoverPhase.js +19 -54
  48. package/dist/phases/mapping/MappingPhase.d.ts +1 -1
  49. package/dist/phases/mapping/MappingPhase.js +2 -4
  50. package/dist/phases/scales/ScalesPhase.d.ts +1 -3
  51. package/dist/phases/scales/ScalesPhase.js +17 -21
  52. package/dist/phases/sharedScales/SharedScalesPhase.d.ts +4 -1
  53. package/dist/phases/sharedScales/SharedScalesPhase.js +10 -7
  54. package/dist/phases/statistics/StatisticsPhase.js +3 -4
  55. package/dist/phases/tooltip/TooltipPhase.d.ts +4 -2
  56. package/dist/phases/tooltip/TooltipPhase.js +10 -3
  57. package/dist/phases/transforms/ProcessedPositions.d.ts +30 -0
  58. package/dist/phases/transforms/ProcessedPositions.js +74 -0
  59. package/dist/phases/transforms/TransformsPhase.d.ts +5 -42
  60. package/dist/phases/transforms/TransformsPhase.js +20 -57
  61. package/dist/plots/area/markers.js +1 -2
  62. package/dist/plots/bar/defaults.js +6 -10
  63. package/dist/plots/bar/markers.js +5 -4
  64. package/dist/plots/box/BoxSummaries.d.ts +19 -0
  65. package/dist/plots/box/BoxSummaries.js +101 -0
  66. package/dist/plots/box/Plot.svelte +42 -0
  67. package/dist/plots/box/Plot.svelte.d.ts +26 -0
  68. package/dist/plots/box/defaults.d.ts +12 -0
  69. package/dist/plots/box/defaults.js +34 -0
  70. package/dist/plots/box/markers.d.ts +12 -0
  71. package/dist/plots/box/markers.js +34 -0
  72. package/dist/plots/geo/phases/hover.js +5 -5
  73. package/dist/plots/geo/phases/markers.js +3 -4
  74. package/dist/plots/geo/slices.js +6 -3
  75. package/dist/plots/heatmap/markers.js +2 -1
  76. package/dist/plots/histogram/defaults.js +1 -1
  77. package/dist/plots/histogram/markers.js +4 -4
  78. package/dist/plots/line/markers.js +1 -2
  79. package/dist/plots/pyramid/defaults.js +3 -2
  80. package/dist/plots/pyramid/markers.js +3 -6
  81. package/dist/plots/scatter/defaults.js +3 -2
  82. package/dist/plots/scatter/markers.js +4 -3
  83. package/dist/types/configuration/styling.d.ts +24 -2
  84. package/dist/types/layout/composer.d.ts +5 -2
  85. package/dist/types/layout/scales.d.ts +16 -0
  86. package/dist/types/layout/timeline.d.ts +14 -5
  87. package/dist/types/phases/hover/phase.d.ts +6 -0
  88. package/dist/types/phases/state.d.ts +5 -2
  89. package/dist/types/phases/statistics/phase.d.ts +3 -1
  90. package/dist/types/phases/transforms/phase.d.ts +10 -0
  91. package/dist/types/plots/box/props.d.ts +10 -0
  92. package/dist/types/plots/box/props.js +1 -0
  93. package/dist/types/plots/box/state.d.ts +23 -0
  94. package/dist/types/plots/box/state.js +1 -0
  95. package/dist/types/plots/props.d.ts +2 -0
  96. package/docs/chrome.md +39 -8
  97. package/docs/composer.md +19 -3
  98. package/docs/concepts.md +1 -1
  99. package/docs/development.md +14 -5
  100. package/docs/facets.md +62 -8
  101. package/docs/getting-started.md +8 -9
  102. package/docs/legend.md +62 -15
  103. package/docs/markers.md +17 -6
  104. package/docs/plots.md +168 -42
  105. package/docs/scales.md +36 -19
  106. package/docs/state.md +1 -1
  107. package/docs/styles-and-segments.md +85 -31
  108. package/docs/theming.md +30 -19
  109. package/docs/timeline.md +62 -28
  110. package/docs/tooltip-and-hover.md +72 -24
  111. package/docs/transforms-and-statistics.md +47 -17
  112. package/examples/BarValues.svelte +2 -2
  113. package/examples/Box.svelte +7 -0
  114. package/examples/Chrome.svelte +17 -0
  115. package/examples/ChromeOrder.svelte +18 -0
  116. package/examples/Composer.svelte +23 -0
  117. package/examples/CustomTooltip.svelte +21 -14
  118. package/examples/Facets.svelte +3 -3
  119. package/examples/FacetsCarousel.svelte +14 -0
  120. package/examples/FacetsRowsCols.svelte +23 -0
  121. package/examples/FirstPlot.svelte +7 -0
  122. package/examples/Gaps.svelte +21 -0
  123. package/examples/GroupedBars.svelte +15 -0
  124. package/examples/Heatmap.svelte +7 -0
  125. package/examples/HeatmapSegments.svelte +26 -0
  126. package/examples/Histogram.svelte +14 -0
  127. package/examples/HorizontalBars.svelte +15 -0
  128. package/examples/LegendSections.svelte +27 -0
  129. package/examples/LegendToggle.svelte +3 -3
  130. package/examples/LineByRegion.svelte +18 -0
  131. package/examples/LineDates.svelte +15 -0
  132. package/examples/Markers.svelte +27 -0
  133. package/examples/MovingAverage.svelte +15 -0
  134. package/examples/Pyramid.svelte +7 -0
  135. package/examples/Regression.svelte +14 -0
  136. package/examples/ResponsiveLine.svelte +7 -7
  137. package/examples/Scales.svelte +26 -0
  138. package/examples/Scatter.svelte +16 -0
  139. package/examples/SegmentHighlight.svelte +22 -0
  140. package/examples/Segments.svelte +11 -3
  141. package/examples/SegmentsBySeries.svelte +25 -0
  142. package/examples/StackedArea.svelte +16 -0
  143. package/examples/StackedBars.svelte +15 -0
  144. package/examples/TimelinePlayer.svelte +8 -7
  145. package/examples/TimelineRule.svelte +19 -0
  146. package/examples/Tooltip.svelte +3 -3
  147. package/examples/ValueLabels.svelte +21 -0
  148. package/examples/data.ts +320 -8
  149. package/llms-full.txt +33 -5
  150. package/llms.txt +30 -2
  151. package/package.json +3 -2
  152. package/dist/layout/scales/buildScale.d.ts +0 -8
  153. package/dist/layout/scales/buildScale.js +0 -67
  154. package/dist/layout/scales/niceDomain.d.ts +0 -23
  155. package/dist/layout/scales/niceDomain.js +0 -59
@@ -0,0 +1,14 @@
1
+ <script lang="ts">
2
+ import { LinePlot } from '@fundar/data-chart-telling';
3
+ import { REGION_VALUES } from './data';
4
+ </script>
5
+
6
+ <!-- A carousel shows `visible` panels at a time, with navigation below. -->
7
+ <LinePlot
8
+ width={720}
9
+ height={340}
10
+ data={REGION_VALUES}
11
+ x="date"
12
+ y="value"
13
+ facet={{ by: 'region', columns: 3, mode: 'carousel', visible: 2, navLayout: 'below' }}
14
+ />
@@ -0,0 +1,23 @@
1
+ <script lang="ts">
2
+ import { LinePlot } from '@fundar/data-chart-telling';
3
+ import { REGION_VALUES } from './data';
4
+
5
+ // Each region's value split into two sectors.
6
+ const SECTORS = [
7
+ { sector: 'Goods', share: 0.8 },
8
+ { sector: 'Services', share: 1.4 }
9
+ ];
10
+ const rows = REGION_VALUES.flatMap((row) =>
11
+ SECTORS.map(({ sector, share }) => ({ ...row, sector, value: row.value * share }))
12
+ );
13
+ </script>
14
+
15
+ <!-- One panel per region and sector; `scales: 'free'` fits each panel to its own data. -->
16
+ <LinePlot
17
+ width={720}
18
+ height={420}
19
+ data={rows}
20
+ x="date"
21
+ y="value"
22
+ facet={{ rows: 'region', cols: 'sector', scales: 'free' }}
23
+ />
@@ -0,0 +1,7 @@
1
+ <script lang="ts">
2
+ import { LinePlot } from '@fundar/data-chart-telling';
3
+ import { REGION_VALUES } from './data';
4
+ </script>
5
+
6
+ <!-- The smallest useful plot: rows, the fields to map and a pixel size. -->
7
+ <LinePlot width={720} height={400} data={REGION_VALUES} x="date" y="value" color="region" />
@@ -0,0 +1,21 @@
1
+ <script lang="ts">
2
+ import { LinePlot } from '@fundar/data-chart-telling';
3
+ import { LIFE_GAPS } from './data';
4
+ </script>
5
+
6
+ <!-- Missing values bridged: dashed in the middle, faded at the start, extended to the 2025 projection at the end. -->
7
+ <LinePlot
8
+ width={720}
9
+ height={400}
10
+ series={[{ name: 'female', x: 'year', y: 'value', data: LIFE_GAPS }]}
11
+ scales={{ x: { edgeTicks: true }, y: { domain: [55, 85] } }}
12
+ styles={{
13
+ gaps: {
14
+ default: {
15
+ middle: { interpolate: 'linear', style: { stroke: { strokeDasharray: '4 4' } } },
16
+ start: { x: 1940, style: { stroke: { strokeOpacity: 0.4 } } },
17
+ end: { x: 2025, y: 81.1 }
18
+ }
19
+ }
20
+ }}
21
+ />
@@ -0,0 +1,15 @@
1
+ <script lang="ts">
2
+ import { BarPlot } from '@fundar/data-chart-telling';
3
+ import { PROVINCE_VALUES } from './data';
4
+ </script>
5
+
6
+ <!-- Vertical bars, grouped by `color`. -->
7
+ <BarPlot
8
+ width={720}
9
+ height={400}
10
+ data={PROVINCE_VALUES}
11
+ x="province"
12
+ y="value"
13
+ color="sex"
14
+ scales={{ y: { domain: [70, 85] } }}
15
+ />
@@ -0,0 +1,7 @@
1
+ <script lang="ts">
2
+ import { HeatmapPlot } from '@fundar/data-chart-telling';
3
+ import { HOUSEHOLDS } from './data';
4
+ </script>
5
+
6
+ <!-- One cell per number of rooms and of people, colored by the share of households. -->
7
+ <HeatmapPlot width={560} height={360} data={HOUSEHOLDS} x="rooms" y="people" color="share" />
@@ -0,0 +1,26 @@
1
+ <script lang="ts">
2
+ import { HeatmapPlot } from '@fundar/data-chart-telling';
3
+ import { HOUSEHOLDS } from './data';
4
+ </script>
5
+
6
+ <!-- Segments on a heatmap: an outlined column and a filled block of overcrowded households. -->
7
+ <HeatmapPlot
8
+ width={560}
9
+ height={360}
10
+ data={HOUSEHOLDS}
11
+ x="rooms"
12
+ y="people"
13
+ color="share"
14
+ segments={{
15
+ default: [
16
+ {
17
+ areas: [{ x: { from: '1', to: '1' } }],
18
+ styles: { stroke: '#f59e0b', strokeWidth: 2 }
19
+ },
20
+ {
21
+ areas: [{ x: { from: '1', to: '2' }, y: { from: '4', to: '5+' } }],
22
+ styles: { fill: '#ef4444', fillOpacity: 0.8 }
23
+ }
24
+ ]
25
+ }}
26
+ />
@@ -0,0 +1,14 @@
1
+ <script lang="ts">
2
+ import { HistogramPlot } from '@fundar/data-chart-telling';
3
+ import { HEIGHTS } from './data';
4
+ </script>
5
+
6
+ <!-- Two overlapping distributions, one per `grouping` value. -->
7
+ <HistogramPlot
8
+ width={720}
9
+ height={400}
10
+ data={HEIGHTS}
11
+ x="height"
12
+ grouping="group"
13
+ segments={{ default: [{ styles: { fillOpacity: 0.7 } }] }}
14
+ />
@@ -0,0 +1,15 @@
1
+ <script lang="ts">
2
+ import { BarPlot } from '@fundar/data-chart-telling';
3
+ import { PROVINCE_VALUES } from './data';
4
+ </script>
5
+
6
+ <!-- Horizontal bars: the categories go on `y`, the values on `x`. -->
7
+ <BarPlot
8
+ width={720}
9
+ height={400}
10
+ data={PROVINCE_VALUES}
11
+ x="value"
12
+ y="province"
13
+ color="sex"
14
+ scales={{ x: { domain: [70, 85] } }}
15
+ />
@@ -0,0 +1,27 @@
1
+ <script lang="ts">
2
+ import { LinePlot } from '@fundar/data-chart-telling';
3
+ import { REGION_VALUES } from './data';
4
+ </script>
5
+
6
+ <!-- An explicit legend: a discrete section of toggles and a continuous ramp. -->
7
+ <LinePlot
8
+ width={720}
9
+ height={400}
10
+ data={REGION_VALUES}
11
+ x="date"
12
+ y="value"
13
+ color="region"
14
+ legend={[
15
+ {
16
+ type: 'discrete',
17
+ title: 'Region',
18
+ interactive: { enabled: true },
19
+ items: [
20
+ { name: 'GBA', color: '#4f46e5', symbol: 'line' },
21
+ { name: 'Cuyo', color: '#e6580d', symbol: 'line' },
22
+ { name: 'Northwest', color: '#16a34a', symbol: 'line' }
23
+ ]
24
+ },
25
+ { type: 'continuous', title: 'Share', min: 0, max: 100, scheme: 'blues' }
26
+ ]}
27
+ />
@@ -1,6 +1,6 @@
1
1
  <script lang="ts">
2
2
  import { LinePlot } from '@fundar/data-chart-telling';
3
- import { ROWS } from './data';
3
+ import { REGION_VALUES } from './data';
4
4
  import LegendReader from './LegendReader.svelte';
5
5
  </script>
6
6
 
@@ -13,8 +13,8 @@
13
13
  <LinePlot
14
14
  width={720}
15
15
  height={400}
16
- data={ROWS}
17
- x="year"
16
+ data={REGION_VALUES}
17
+ x="date"
18
18
  y="value"
19
19
  color="region"
20
20
  legend={{ series: { interactive: { enabled: true, disabled: { mode: 'omit' } } } }}
@@ -0,0 +1,18 @@
1
+ <script lang="ts">
2
+ import { LinePlot } from '@fundar/data-chart-telling';
3
+ import { REGION_VALUES } from './data';
4
+ </script>
5
+
6
+ <!-- One line per region, with a title, the automatic legend, end-of-line values and a tooltip. -->
7
+ <LinePlot
8
+ width={720}
9
+ height={400}
10
+ title="Monthly inflation by region (%)"
11
+ data={REGION_VALUES}
12
+ x="date"
13
+ y="value"
14
+ color="region"
15
+ tooltip
16
+ scales={{ x: { label: false } }}
17
+ styles={{ values: { show: true } }}
18
+ />
@@ -0,0 +1,15 @@
1
+ <script lang="ts">
2
+ import { LinePlot } from '@fundar/data-chart-telling';
3
+ import { PRICES } from './data';
4
+ </script>
5
+
6
+ <!-- A line per commodity over a date axis, with end-of-line labels. -->
7
+ <LinePlot
8
+ width={720}
9
+ height={400}
10
+ data={PRICES}
11
+ x="date"
12
+ y="index"
13
+ color="commodity"
14
+ styles={{ values: { show: true, format: (v, name) => `${name}: ${v}` } }}
15
+ />
@@ -0,0 +1,27 @@
1
+ <script lang="ts">
2
+ import { LinePlot } from '@fundar/data-chart-telling';
3
+ import { LIFE } from './data';
4
+ </script>
5
+
6
+ <!-- Markers add marks to a plot: a hover highlight, a reference rule and a delta between two series. -->
7
+ <LinePlot
8
+ width={720}
9
+ height={400}
10
+ data={LIFE}
11
+ x="year"
12
+ y="value"
13
+ color="sex"
14
+ scales={{ x: { edgeTicks: true } }}
15
+ markers={[
16
+ { type: 'hover' },
17
+ { type: 'rule', axis: 'x', value: 2001, styles: { stroke: '#999', strokeDasharray: '4 4' } },
18
+ {
19
+ type: 'delta',
20
+ axis: 'x',
21
+ at: 1980,
22
+ from: { type: 'series', series: 'female' },
23
+ to: { type: 'series', series: 'male' },
24
+ formatDiff: (difference) => difference.toFixed(1)
25
+ }
26
+ ]}
27
+ />
@@ -0,0 +1,15 @@
1
+ <script lang="ts">
2
+ import { LinePlot } from '@fundar/data-chart-telling';
3
+ import { PRICES } from './data';
4
+ </script>
5
+
6
+ <!-- A 6-month moving average, run on the plot's rows. -->
7
+ <LinePlot
8
+ width={720}
9
+ height={400}
10
+ data={PRICES}
11
+ x="date"
12
+ y="index"
13
+ color="commodity"
14
+ transforms={[{ type: 'windowY', k: 6, reduce: 'mean' }]}
15
+ />
@@ -0,0 +1,7 @@
1
+ <script lang="ts">
2
+ import { PyramidPlot } from '@fundar/data-chart-telling';
3
+ import { AGES } from './data';
4
+ </script>
5
+
6
+ <!-- A population pyramid: one side per `color` value. -->
7
+ <PyramidPlot width={720} height={400} data={AGES} x="share" y="ageGroup" color="sex" />
@@ -0,0 +1,14 @@
1
+ <script lang="ts">
2
+ import { ScatterPlot } from '@fundar/data-chart-telling';
3
+ import { COUNTRIES } from './data';
4
+ </script>
5
+
6
+ <!-- A linear regression with its 95% confidence band. -->
7
+ <ScatterPlot
8
+ width={720}
9
+ height={400}
10
+ data={COUNTRIES}
11
+ x="gdp"
12
+ y="life"
13
+ statistics={[{ type: 'regression', regressionType: 'linear', confidence: 0.95 }]}
14
+ />
@@ -1,6 +1,6 @@
1
1
  <script lang="ts">
2
2
  import { LinePlot } from '@fundar/data-chart-telling';
3
- import { ROWS } from './data';
3
+ import { REGION_VALUES } from './data';
4
4
 
5
5
  // A plot draws at the pixel size it is given. To fill a container (or the
6
6
  // window), bind its size and pass it down.
@@ -13,15 +13,15 @@
13
13
  <LinePlot
14
14
  {width}
15
15
  {height}
16
- title="Value by region"
17
- subtitle="Index, 2016-2023"
18
- data={ROWS}
19
- x="year"
16
+ title="Monthly inflation by region"
17
+ subtitle="Change from the previous month, 2023-2026"
18
+ data={REGION_VALUES}
19
+ x="date"
20
20
  y="value"
21
21
  color="region"
22
22
  scales={{
23
- x: { label: 'Year', tickFormat: (d) => String(d) },
24
- y: { label: 'Index' }
23
+ x: { label: 'Month' },
24
+ y: { label: 'Inflation (%)' }
25
25
  }}
26
26
  styles={{ values: { show: true, format: (v, name) => `${name}: ${v}` } }}
27
27
  margins={{ right: 'auto' }}
@@ -0,0 +1,26 @@
1
+ <script lang="ts">
2
+ import { LinePlot } from '@fundar/data-chart-telling';
3
+ import { PRICES } from './data';
4
+ </script>
5
+
6
+ <!-- Axis labels, a fixed domain with gridlines and a color per series. -->
7
+ <LinePlot
8
+ width={720}
9
+ height={400}
10
+ data={PRICES}
11
+ x="date"
12
+ y="index"
13
+ color="commodity"
14
+ scales={{
15
+ x: { label: 'Month' },
16
+ y: { label: 'Index (Jan 2021 = 100)', domain: [0, 600], grid: true },
17
+ color: {
18
+ scheme: {
19
+ 'Brent oil': '#1b9e77',
20
+ 'Natural gas': '#d95f02',
21
+ Coal: '#7570b3',
22
+ Wheat: '#e7298a'
23
+ }
24
+ }
25
+ }}
26
+ />
@@ -0,0 +1,16 @@
1
+ <script lang="ts">
2
+ import { ScatterPlot } from '@fundar/data-chart-telling';
3
+ import { COUNTRIES } from './data';
4
+ </script>
5
+
6
+ <!-- Points sized by `r`, colored by `color` and shaped by `symbol`. -->
7
+ <ScatterPlot
8
+ width={720}
9
+ height={420}
10
+ data={COUNTRIES}
11
+ x="gdp"
12
+ y="life"
13
+ r="population"
14
+ color="continent"
15
+ symbol="income"
16
+ />
@@ -0,0 +1,22 @@
1
+ <script lang="ts">
2
+ import { LinePlot } from '@fundar/data-chart-telling';
3
+ import { REGION_VALUES } from './data';
4
+
5
+ const gba = REGION_VALUES.filter((row) => row.region === 'GBA');
6
+ </script>
7
+
8
+ <!-- A grey line with the 2023-2024 surge drawn in red. -->
9
+ <LinePlot
10
+ width={720}
11
+ height={380}
12
+ series={[{ name: 'GBA', x: 'date', y: 'value', data: gba }]}
13
+ segments={{
14
+ GBA: [
15
+ { styles: { stroke: { stroke: '#94a3b8', strokeWidth: 1 } } },
16
+ {
17
+ areas: [{ x: { from: new Date('2023-07-01'), to: new Date('2024-03-01') } }],
18
+ styles: { stroke: { stroke: '#ef4444', strokeWidth: 3 } }
19
+ }
20
+ ]
21
+ }}
22
+ />
@@ -1,17 +1,25 @@
1
1
  <script lang="ts">
2
2
  import { LinePlot } from '@fundar/data-chart-telling';
3
3
  import type { LineSegmentStyle, SegmentsConfig } from '@fundar/data-chart-telling';
4
- import { ROWS } from './data';
4
+ import { REGION_VALUES } from './data';
5
5
 
6
6
  // `segments` maps a series name (or 'default' for all series) to its rules.
7
7
  const segments = {
8
8
  default: [
9
9
  {
10
- areas: [{ x: { from: 2020, to: 2023 } }],
10
+ areas: [{ x: { from: new Date('2025-01-01'), to: new Date('2026-08-01') } }],
11
11
  styles: { stroke: { strokeDasharray: '6 4', strokeOpacity: 0.7 } }
12
12
  }
13
13
  ]
14
14
  } satisfies SegmentsConfig<LineSegmentStyle>;
15
15
  </script>
16
16
 
17
- <LinePlot width={720} height={400} data={ROWS} x="year" y="value" color="region" {segments} />
17
+ <LinePlot
18
+ width={720}
19
+ height={400}
20
+ data={REGION_VALUES}
21
+ x="date"
22
+ y="value"
23
+ color="region"
24
+ {segments}
25
+ />
@@ -0,0 +1,25 @@
1
+ <script lang="ts">
2
+ import { LinePlot } from '@fundar/data-chart-telling';
3
+ import { LIFE } from './data';
4
+ </script>
5
+
6
+ <!-- Segments per series name, plus `default` for rules shared by every series. -->
7
+ <LinePlot
8
+ width={720}
9
+ height={380}
10
+ data={LIFE}
11
+ x="year"
12
+ y="value"
13
+ color="sex"
14
+ scales={{ x: { edgeTicks: true } }}
15
+ segments={{
16
+ female: [{ styles: { stroke: { stroke: 'steelblue' } } }],
17
+ male: [{ styles: { stroke: { stroke: 'tomato' } } }],
18
+ default: [
19
+ {
20
+ areas: [{ x: { from: 1965, to: 1980 } }],
21
+ styles: { dots: { dotRadius: 5, dotSymbol: 'circle' } }
22
+ }
23
+ ]
24
+ }}
25
+ />
@@ -0,0 +1,16 @@
1
+ <script lang="ts">
2
+ import { AreaPlot } from '@fundar/data-chart-telling';
3
+ import { AGE_SHARES } from './data';
4
+ </script>
5
+
6
+ <!-- Each age group's share of the population, stacked with `stackY` so the bands add up to 100%. -->
7
+ <AreaPlot
8
+ width={720}
9
+ height={400}
10
+ data={AGE_SHARES}
11
+ x="year"
12
+ y="share"
13
+ color="ageGroup"
14
+ scales={{ x: { ticks: [1991, 2001, 2010, 2022] } }}
15
+ transforms={[{ type: 'stackY' }]}
16
+ />
@@ -0,0 +1,15 @@
1
+ <script lang="ts">
2
+ import { BarPlot } from '@fundar/data-chart-telling';
3
+ import { SEX_SHARES } from './data';
4
+ </script>
5
+
6
+ <!-- Each sex's share of the population per census, stacked with `stackY` so a bar adds up to 100%. -->
7
+ <BarPlot
8
+ width={720}
9
+ height={400}
10
+ data={SEX_SHARES}
11
+ x="year"
12
+ y="share"
13
+ color="sex"
14
+ transforms={[{ type: 'stackY' }]}
15
+ />
@@ -1,20 +1,21 @@
1
1
  <script lang="ts">
2
2
  import { BarPlot } from '@fundar/data-chart-telling';
3
- import { ROWS } from './data';
3
+ import { REGION_VALUES } from './data';
4
4
  </script>
5
5
 
6
6
  <!--
7
7
  `timeline` slices the rows by `accessor`. A timeline is a player by default:
8
- play/pause, the current step and a slider in the chrome. `type: 'rule'`
9
- draws a guide beside the plot with no controls instead. To build your own
10
- widget, read `useFigure().timeline` (seek, play, pause, next, ...).
8
+ play/pause, the current step and a slider in the chrome. `progress` sets where
9
+ it starts. `type: 'rule'` draws a guide beside the plot with no controls
10
+ instead (see TimelineRule). To build your own widget, read
11
+ `useFigure().timeline` (seek, play, pause, next, ...).
11
12
  -->
12
13
  <BarPlot
13
14
  width={720}
14
15
  height={400}
15
- data={ROWS}
16
+ data={REGION_VALUES}
16
17
  x="region"
17
18
  y="value"
18
- scales={{ y: { domain: [0, 200] } }}
19
- timeline={{ accessor: 'year', player: { autoplay: false, loop: true } }}
19
+ scales={{ y: { domain: [0, 30] } }}
20
+ timeline={{ accessor: 'date', progress: 0.25, player: { autoplay: false, loop: true } }}
20
21
  />
@@ -0,0 +1,19 @@
1
+ <script lang="ts">
2
+ import { LinePlot } from '@fundar/data-chart-telling';
3
+ import { REGION_VALUES } from './data';
4
+
5
+ // A rule has no controls of its own: the page moves it through `progress` (0 to 1).
6
+ // One step per year; a line plot shows every row up to the current step.
7
+ let progress = $state(0.5);
8
+ </script>
9
+
10
+ <input type="range" min="0" max="1" step="0.001" bind:value={progress} />
11
+ <LinePlot
12
+ width={720}
13
+ height={400}
14
+ data={REGION_VALUES}
15
+ x="date"
16
+ y="value"
17
+ color="region"
18
+ timeline={{ accessor: (row) => row.date.getUTCFullYear(), type: 'rule', progress }}
19
+ />
@@ -1,6 +1,6 @@
1
1
  <script lang="ts">
2
2
  import { LinePlot } from '@fundar/data-chart-telling';
3
- import { ROWS } from './data';
3
+ import { REGION_VALUES } from './data';
4
4
  </script>
5
5
 
6
6
  <!--
@@ -10,8 +10,8 @@
10
10
  <LinePlot
11
11
  width={720}
12
12
  height={400}
13
- data={ROWS}
14
- x="year"
13
+ data={REGION_VALUES}
14
+ x="date"
15
15
  y="value"
16
16
  color="region"
17
17
  tooltip={{ strategy: 'x', format: (row) => `${row.region}: ${row.value}` }}
@@ -0,0 +1,21 @@
1
+ <script lang="ts">
2
+ import { LinePlot } from '@fundar/data-chart-telling';
3
+ import { PRICES } from './data';
4
+ </script>
5
+
6
+ <!-- End-of-line value labels with a custom format and font size. -->
7
+ <LinePlot
8
+ width={720}
9
+ height={400}
10
+ data={PRICES}
11
+ x="date"
12
+ y="index"
13
+ color="commodity"
14
+ styles={{
15
+ values: {
16
+ show: true,
17
+ format: (value, seriesName) => `${seriesName}: ${value.toFixed(0)}`,
18
+ fontStyle: { fontSize: 13 }
19
+ }
20
+ }}
21
+ />