@fundar/data-chart-telling 1.2.0 → 1.3.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/CHANGELOG.md +13 -0
- package/README.md +2 -1
- package/dist/configuration/config.svelte.js +12 -0
- package/dist/layout/facet/scope.d.ts +40 -0
- package/dist/layout/facet/scope.js +104 -0
- package/dist/layout/legend/DiscreteSymbolIcon.svelte +38 -14
- package/dist/layout/legend/LegendState.svelte.js +3 -5
- package/dist/layout/margins/PlotMargins.svelte.js +31 -0
- package/dist/layout/plot/Plot.svelte +22 -2
- package/dist/layout/scales/ScalesLayout.svelte +21 -0
- package/dist/markers/delta/Delta.d.ts +6 -1
- package/dist/markers/delta/Delta.js +15 -0
- package/dist/markers/delta/DeltaMarker.svelte +9 -87
- package/dist/markers/delta/DeltaPoint.svelte +97 -0
- package/dist/markers/delta/DeltaPoint.svelte.d.ts +29 -0
- package/dist/markers/rule/RuleMarker.svelte +5 -2
- package/dist/phases/facet/FacetPhase.d.ts +2 -1
- package/dist/phases/facet/FacetPhase.js +19 -4
- package/dist/phases/statistics/StatisticsPhase.js +9 -1
- package/dist/plots/utils/segments.d.ts +4 -1
- package/dist/plots/utils/segments.js +19 -6
- package/dist/types/configuration/styling.d.ts +8 -0
- package/dist/types/layout/facet.d.ts +18 -0
- package/dist/types/layout/legend.d.ts +2 -0
- package/dist/types/layout/plot.d.ts +2 -0
- package/dist/types/markers/axis/delta.d.ts +15 -2
- package/dist/types/markers/axis/rule.d.ts +9 -2
- package/dist/types/phases/facet/phase.d.ts +4 -0
- package/dist/types/plots/props.d.ts +6 -3
- package/dist/types/plots/segments/config.d.ts +4 -2
- package/docs/facets.md +47 -0
- package/docs/markers.md +54 -26
- package/docs/styles-and-segments.md +1 -0
- package/docs/theming.md +1 -1
- package/examples/FacetsScoped.svelte +26 -0
- package/llms-full.txt +5 -3
- package/llms.txt +1 -0
- package/package.json +1 -1
package/docs/theming.md
CHANGED
|
@@ -40,7 +40,7 @@ resetConfiguration(); // back to the shipped defaults
|
|
|
40
40
|
| `spacing`, `chrome` | Padding around header, legend and caption; the chrome `order` and `rowGap` |
|
|
41
41
|
| `title`, `subtitle`, `caption` | Text blocks: `font`, `size`, `weight`, `color`, `leading`, `spacing` |
|
|
42
42
|
| `divider` | The line a `'divider'` in the chrome `order` draws |
|
|
43
|
-
| `legend` | Text, gaps, swatches, `disabledOpacity`, paginated nav buttons, the continuous bar, its handles, ticks and labels, and the `seriesTitle` and `sizeScale` options
|
|
43
|
+
| `legend` | Text, gaps, swatches, the series `icon` (`rounded`, and the shape each mark draws as in `marks`), `disabledOpacity`, paginated nav buttons, the continuous bar, its handles, ticks and labels, and the `seriesTitle` and `sizeScale` options |
|
|
44
44
|
| `axis` | Axis color, font and tick sizes, `grid`, and the number locale (below) |
|
|
45
45
|
| `tooltip` | Tooltip background, color, font size, padding, radius, border |
|
|
46
46
|
| `margins` | Default margin per side (`'auto'` or a number) |
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { LinePlot } from '@fundar/data-chart-telling';
|
|
3
|
+
import { REGION_VALUES } from './datasets';
|
|
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. `facet` on a marker or a segment limits it to the panels it names: the rule is drawn in GBA only, and Services is dashed in Cuyo only. -->
|
|
16
|
+
<LinePlot
|
|
17
|
+
width={900}
|
|
18
|
+
height={360}
|
|
19
|
+
data={rows}
|
|
20
|
+
x="date"
|
|
21
|
+
y="value"
|
|
22
|
+
color="sector"
|
|
23
|
+
facet={{ by: 'region', columns: 3 }}
|
|
24
|
+
markers={[{ type: 'rule', axis: 'y', value: 10, facet: 'GBA' }]}
|
|
25
|
+
segments={{ Services: [{ facet: 'Cuyo', styles: { stroke: { strokeDasharray: '4 4' } } }] }}
|
|
26
|
+
/>
|
package/llms-full.txt
CHANGED
|
@@ -68,6 +68,7 @@ Per kind: `BarPlot` x = category, y = value (swap for horizontal bars); `Pyramid
|
|
|
68
68
|
7. `r` takes raw values and its sqrt scale makes area follow the value; tune with `scales.r.range`. A literal number is a fixed pixel radius.
|
|
69
69
|
8. Narrow plots with long category or series names: shorten the text in the data, format with `tickFormat` / `values.format`, or give `margins` more room.
|
|
70
70
|
9. In Svelte 5 components, `state` is taken by the `$state` rune: name local variables otherwise.
|
|
71
|
+
10. In a `facet`, every panel draws the plot's `markers` and `segments`. Give one a `facet` (a `by` value, a list of them, or `{ row, col }` in a `rows`/`cols` grid) to draw it only in the panels it names: `markers={[{ type: 'rule', axis: 'y', value: 10, facet: 'GBA' }]}`, `segments={{ Services: [{ facet: 'Cuyo', styles: { stroke: { strokeDasharray: '4 4' } } }] }}`. A plot with no facet leaves out whatever names one.
|
|
71
72
|
10. Stacking is `transforms={[{ type: 'stackY' }]}`, also for horizontal bars (the value channel is the one stacked).
|
|
72
73
|
|
|
73
74
|
## Reading and driving plot state (custom UI)
|
|
@@ -88,13 +89,13 @@ Add with `markers={[{ type: '...' }]}`. For x/y plots:
|
|
|
88
89
|
`area arrow bar bollinger box brush cell component delaunayLink delaunayMesh delta density difference dot hover hull image line raster rect regression rule text tick trail violin voronoi voronoiMesh waffle`.
|
|
89
90
|
GeoPlot: `graticule sphere dot text vector link contour inset geo-hover geo-component`.
|
|
90
91
|
|
|
91
|
-
- `delta` annotates the difference between two series at a position: `{ type: 'delta', axis: 'x', at: 2020, from: { type: 'series', series: 'A' }, to: { type: 'series', series: 'B' }, formatDiff: (d) => d.toFixed(1) }
|
|
92
|
-
- `rule` (`axis`, `value
|
|
92
|
+
- `delta` annotates the difference between two series at a position: `{ type: 'delta', axis: 'x', at: 2020, from: { type: 'series', series: 'A' }, to: { type: 'series', series: 'B' }, formatDiff: (d) => d.toFixed(1) }`; `at` can be a list of positions, one delta at each (`at: [1991, 2001]`), and `line`, `text` and `dot` can be functions of the position (`text: (at) => at === 2022 ? { dx: -20, textAnchor: 'end' } : { dx: 20 }`).
|
|
93
|
+
- `rule` (`axis`, `value`; a list draws a line at each), `text` (`text`), `dot` annotate; `component` mounts your own Svelte component inside the plot (it can call `usePlot()`).
|
|
93
94
|
- Each plot kind types its own marker union (`AxisBasedMarkersConfig`, `GeoMarkersConfig`); `satisfies` on a markers array gives completion.
|
|
94
95
|
|
|
95
96
|
## Theming and locale
|
|
96
97
|
|
|
97
|
-
- `setConfiguration(partial)` deep-merges global defaults (colors, fonts, spacing, legend, tooltip, timeline); `resetConfiguration()` restores them. Inside an `$effect`, wrap the call in `untrack`.
|
|
98
|
+
- `setConfiguration(partial)` deep-merges global defaults (colors, fonts, spacing, legend, tooltip, timeline); `resetConfiguration()` restores them. Legend series icons: `legend.icon.rounded` (default `false`) and `legend.icon.marks` (shape per mark: `line`, `dot`, `area`, `bar`, `cell`, `rect`, `geo`; a symbol or `'line'`). Inside an `$effect`, wrap the call in `untrack`.
|
|
98
99
|
- `THEMES` has `Default Editorial Dark Compact`: `setConfiguration(THEMES.Editorial)`.
|
|
99
100
|
- Number and date text follows `axis.locale` (default `'es-AR'`) in the configuration; per axis, `tickFormat: (d) => new Intl.NumberFormat('en-US').format(d)` or an `Intl.*FormatOptions` object.
|
|
100
101
|
|
|
@@ -150,4 +151,5 @@ GeoPlot: `graticule sphere dot text vector link contour inset geo-hover geo-comp
|
|
|
150
151
|
- `ChromeOrder.svelte` - ordering chrome blocks with dividers.
|
|
151
152
|
- `FacetsCarousel.svelte` - facets as a carousel.
|
|
152
153
|
- `FacetsRowsCols.svelte` - facets by rows and columns.
|
|
154
|
+
- `FacetsScoped.svelte` - markers and segments in some facet panels.
|
|
153
155
|
- `Composer.svelte` - several plots in one figure.
|
package/llms.txt
CHANGED
|
@@ -92,6 +92,7 @@ Start with the full guide: it lists the mental model, the props every plot share
|
|
|
92
92
|
- [Ordering chrome blocks with dividers](./examples/ChromeOrder.svelte)
|
|
93
93
|
- [Facets as a carousel](./examples/FacetsCarousel.svelte)
|
|
94
94
|
- [Facets by rows and columns](./examples/FacetsRowsCols.svelte)
|
|
95
|
+
- [Markers and segments in some facet panels](./examples/FacetsScoped.svelte)
|
|
95
96
|
- [Several plots in one figure](./examples/Composer.svelte)
|
|
96
97
|
- [Example datasets, one file each](./examples/datasets)
|
|
97
98
|
|