@fundar/data-chart-telling 1.15.0 → 1.17.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 +38 -0
- package/dist/configuration/ConfigVars.svelte +14 -0
- package/dist/configuration/ConfigVars.svelte.d.ts +3 -0
- package/dist/configuration/config.svelte.d.ts +5 -0
- package/dist/configuration/config.svelte.js +18 -4
- package/dist/configuration/themes/dark.js +1 -1
- package/dist/configuration/themes/editorial.js +1 -1
- package/dist/index.d.ts +6 -3
- package/dist/index.js +2 -1
- package/dist/layout/base/BasePlotLayout.svelte +1 -1
- package/dist/layout/figure/Figure.svelte +5 -12
- package/dist/layout/figure/FigureChrome.svelte +2 -10
- package/dist/layout/geometry/GeometryLayout.svelte +42 -1
- package/dist/layout/hover/HoverSettings.d.ts +3 -1
- package/dist/layout/hover/HoverSettings.js +4 -2
- package/dist/layout/legend/DisabledStyle.d.ts +1 -1
- package/dist/layout/legend/DisabledStyle.js +1 -1
- package/dist/layout/legend/DiscreteBadgeItem.svelte +1 -1
- package/dist/layout/legend/DiscreteSection.svelte +1 -1
- package/dist/layout/legend/LegendState.svelte.d.ts +12 -2
- package/dist/layout/legend/LegendState.svelte.js +18 -4
- package/dist/layout/legend/LegendText.d.ts +4 -1
- package/dist/layout/legend/LegendText.js +7 -1
- package/dist/layout/margins/PlotMargins.svelte.d.ts +2 -2
- package/dist/layout/margins/PlotMargins.svelte.js +2 -2
- package/dist/layout/plot/Plot.svelte +4 -2
- package/dist/layout/plot/Plot.svelte.d.ts +2 -1
- package/dist/layout/scales/ScalesLayout.svelte +1 -1
- package/dist/layout/styles/ValueLabels.d.ts +33 -2
- package/dist/layout/styles/ValueLabels.js +67 -8
- package/dist/layout/timeline/Timeline.svelte +5 -1
- package/dist/layout/timeline/TimelineLayout.svelte +4 -1
- package/dist/layout/timeline/TimelineSteps.d.ts +6 -2
- package/dist/layout/timeline/TimelineSteps.js +9 -3
- package/dist/markers/area/AreaMarker.svelte +3 -0
- package/dist/markers/arrow/ArrowMarker.svelte +9 -5
- package/dist/markers/bar/BarMarker.svelte +45 -48
- package/dist/markers/bollinger/BollingerMarker.svelte +3 -0
- package/dist/markers/box/BoxMarker.svelte +3 -1
- package/dist/markers/cell/CellMarker.svelte +11 -7
- package/dist/markers/contour/ContourMarker.svelte +3 -0
- package/dist/markers/delaunay/DelaunayLinkMarker.svelte +9 -5
- package/dist/markers/delaunay/DelaunayMeshMarker.svelte +3 -0
- package/dist/markers/density/DensityMarker.svelte +3 -0
- package/dist/markers/difference/DifferenceMarker.svelte +3 -0
- package/dist/markers/dot/DotMarker.svelte +11 -6
- package/dist/markers/geo/GraticuleMarker.svelte +3 -0
- package/dist/markers/geo/SphereMarker.svelte +3 -0
- package/dist/markers/hover/HoverMarker.svelte +22 -6
- package/dist/markers/hull/HullMarker.svelte +3 -0
- package/dist/markers/image/ImageMarker.svelte +3 -0
- package/dist/markers/line/LineMarker.svelte +3 -0
- package/dist/markers/link/LinkMarker.svelte +3 -0
- package/dist/markers/raster/RasterMarker.svelte +3 -0
- package/dist/markers/rect/RectMarker.svelte +25 -17
- package/dist/markers/regression/RegressionMarker.svelte +3 -0
- package/dist/markers/rule/RuleMarker.svelte +15 -5
- package/dist/markers/text/TextFit.d.ts +44 -0
- package/dist/markers/text/TextFit.js +86 -0
- package/dist/markers/text/TextMarker.svelte +186 -90
- package/dist/markers/text/TextMarker.svelte.d.ts +2 -0
- package/dist/markers/tick/TickMarker.svelte +9 -3
- package/dist/markers/trail/TrailMarker.svelte +3 -0
- package/dist/markers/utils/BoxLabel.d.ts +58 -0
- package/dist/markers/utils/BoxLabel.js +175 -0
- package/dist/markers/utils/MarkerEvents.d.ts +23 -0
- package/dist/markers/utils/MarkerEvents.js +44 -0
- package/dist/markers/utils/MarkerLabel.svelte +33 -0
- package/dist/markers/utils/MarkerLabel.svelte.d.ts +10 -0
- package/dist/markers/utils/RowStroke.d.ts +9 -21
- package/dist/markers/utils/RowStroke.js +10 -21
- package/dist/markers/utils/RowStyle.d.ts +26 -0
- package/dist/markers/utils/RowStyle.js +55 -0
- package/dist/markers/vector/VectorMarker.svelte +3 -0
- package/dist/markers/voronoi/VoronoiMarker.svelte +9 -5
- package/dist/markers/voronoi/VoronoiMeshMarker.svelte +3 -0
- package/dist/markers/waffle/WaffleMarker.svelte +9 -5
- package/dist/phases/Pipeline.d.ts +3 -1
- package/dist/phases/Pipeline.js +1 -0
- package/dist/phases/data/DataPhase.js +51 -10
- package/dist/phases/hover/HoverPhase.js +9 -1
- package/dist/phases/mapping/MappingPhase.js +2 -1
- package/dist/phases/markers/MarkerStyles.d.ts +18 -0
- package/dist/phases/markers/MarkerStyles.js +111 -0
- package/dist/phases/markers/MarkersPhase.d.ts +1 -1
- package/dist/phases/markers/MarkersPhase.js +7 -5
- package/dist/phases/statistics/StatisticsPhase.js +1 -1
- package/dist/phases/transforms/Transforms.js +3 -1
- package/dist/phases/transforms/TransformsPhase.js +58 -4
- package/dist/phases/transforms/methods/TreemapTransform.d.ts +28 -0
- package/dist/phases/transforms/methods/TreemapTransform.js +119 -0
- package/dist/plots/correlation/heatmap/defaults.js +2 -2
- package/dist/plots/correlation/heatmap/markers.d.ts +0 -8
- package/dist/plots/correlation/heatmap/markers.js +8 -35
- package/dist/plots/correlation/scatter/markers.d.ts +1 -1
- package/dist/plots/correlation/scatter/markers.js +2 -2
- package/dist/plots/distribution/histogram/defaults.js +2 -2
- package/dist/plots/distribution/histogram/markers.d.ts +1 -10
- package/dist/plots/distribution/histogram/markers.js +17 -59
- package/dist/plots/distribution/pyramid/defaults.js +3 -3
- package/dist/plots/distribution/pyramid/markers.d.ts +0 -10
- package/dist/plots/distribution/pyramid/markers.js +13 -64
- package/dist/plots/distribution/violin/markers.js +1 -1
- package/dist/plots/map/geo/phases/markers.js +3 -2
- package/dist/plots/part-of-a-whole/treemap/Plot.svelte +47 -0
- package/dist/plots/part-of-a-whole/treemap/Plot.svelte.d.ts +26 -0
- package/dist/plots/part-of-a-whole/treemap/defaults.d.ts +10 -0
- package/dist/plots/part-of-a-whole/treemap/defaults.js +167 -0
- package/dist/plots/ranking/bar/defaults.js +2 -2
- package/dist/plots/ranking/bar/markers.d.ts +1 -11
- package/dist/plots/ranking/bar/markers.js +38 -80
- package/dist/plots/ranking/bullet/markers.js +2 -3
- package/dist/plots/ranking/cleveland/ClevelandMarkers.js +17 -13
- package/dist/types/configuration/styling.d.ts +33 -2
- package/dist/types/layout/legend.d.ts +8 -1
- package/dist/types/layout/mapping.d.ts +12 -3
- package/dist/types/layout/scales.d.ts +6 -0
- package/dist/types/layout/tooltip.d.ts +16 -4
- package/dist/types/markers/axis/arrow.d.ts +2 -8
- package/dist/types/markers/axis/bar.d.ts +4 -8
- package/dist/types/markers/axis/cell.d.ts +5 -5
- package/dist/types/markers/axis/delaunayLink.d.ts +2 -2
- package/dist/types/markers/axis/rect.d.ts +4 -8
- package/dist/types/markers/axis/rule.d.ts +2 -16
- package/dist/types/markers/axis/tick.d.ts +2 -2
- package/dist/types/markers/axis/voronoi.d.ts +2 -2
- package/dist/types/markers/axis/waffle.d.ts +4 -3
- package/dist/types/markers/basic/dot.d.ts +2 -2
- package/dist/types/markers/basic/text.d.ts +56 -14
- package/dist/types/markers/channels/commonMarkerConfig.d.ts +4 -1
- package/dist/types/markers/channels/commonMarkerConfigWithArea.d.ts +1 -2
- package/dist/types/markers/channels/commonMarkerConfigWithLabel.d.ts +10 -0
- package/dist/types/markers/channels/commonMarkerConfigWithLabel.js +1 -0
- package/dist/types/markers/channels/commonMarkerEvents.d.ts +17 -0
- package/dist/types/markers/channels/commonMarkerEvents.js +13 -0
- package/dist/types/markers/geo/contour.d.ts +2 -1
- package/dist/types/markers/geo/graticule.d.ts +2 -1
- package/dist/types/markers/geo/link.d.ts +2 -1
- package/dist/types/markers/geo/sphere.d.ts +2 -1
- package/dist/types/markers/geo/vector.d.ts +2 -1
- package/dist/types/phases/data/phase.d.ts +5 -0
- package/dist/types/phases/hover/phase.d.ts +2 -0
- package/dist/types/phases/state.d.ts +7 -0
- package/dist/types/phases/statistics/phase.d.ts +2 -1
- package/dist/types/phases/transforms/phase.d.ts +11 -0
- package/dist/types/plots/constants.d.ts +14 -14
- package/dist/types/plots/correlation/heatmap/props.d.ts +3 -3
- package/dist/types/plots/correlation/scatter/props.d.ts +3 -3
- package/dist/types/plots/data/common.d.ts +19 -6
- package/dist/types/plots/data/geo.d.ts +1 -1
- package/dist/types/plots/distribution/box/props.d.ts +3 -3
- package/dist/types/plots/distribution/density/props.d.ts +3 -11
- package/dist/types/plots/distribution/histogram/props.d.ts +3 -11
- package/dist/types/plots/distribution/pyramid/props.d.ts +3 -3
- package/dist/types/plots/distribution/violin/props.d.ts +3 -3
- package/dist/types/plots/evolution/area/props.d.ts +3 -3
- package/dist/types/plots/evolution/line/props.d.ts +3 -3
- package/dist/types/plots/part-of-a-whole/treemap/props.d.ts +19 -0
- package/dist/types/plots/part-of-a-whole/treemap/props.js +1 -0
- package/dist/types/plots/part-of-a-whole/treemap/state.d.ts +6 -0
- package/dist/types/plots/part-of-a-whole/treemap/state.js +1 -0
- package/dist/types/plots/props.d.ts +7 -4
- package/dist/types/plots/ranking/bar/props.d.ts +3 -3
- package/dist/types/plots/ranking/cleveland/props.d.ts +3 -3
- package/dist/types/plots/ranking/dumbbell/props.d.ts +3 -3
- package/dist/types/plots/ranking/forest/props.d.ts +3 -3
- package/dist/types/plots/ranking/lollipop/props.d.ts +3 -3
- package/dist/types/plots/styling.d.ts +24 -0
- package/dist/types/transforms/index.d.ts +3 -1
- package/dist/types/transforms/treemap.d.ts +32 -0
- package/dist/types/transforms/treemap.js +5 -0
- package/dist/utils/color/ColorTones.d.ts +19 -0
- package/dist/utils/color/ColorTones.js +64 -0
- package/dist/utils/color/CssColor.d.ts +14 -5
- package/dist/utils/color/CssColor.js +69 -27
- package/dist/utils/color/index.d.ts +4 -0
- package/dist/utils/color/index.js +4 -0
- package/dist/utils/grouping.d.ts +18 -1
- package/dist/utils/grouping.js +31 -0
- package/docs/concepts.md +3 -2
- package/docs/legend.md +8 -5
- package/docs/markers.md +76 -26
- package/docs/plots/part-of-a-whole/treemap.md +69 -0
- package/docs/plots/ranking/bar.md +1 -1
- package/docs/plots.md +21 -20
- package/docs/scales.md +3 -0
- package/docs/state.md +1 -1
- package/docs/styles-and-segments.md +19 -18
- package/docs/theming.md +5 -12
- package/docs/tooltip-and-hover.md +1 -1
- package/docs/transforms-and-statistics.md +17 -16
- package/examples/Treemap.svelte +13 -0
- package/examples/datasets/economic-activity.ts +40 -0
- package/examples/datasets/index.ts +1 -0
- package/llms-full.txt +5 -5
- package/llms.txt +2 -0
- package/package.json +3 -1
package/docs/markers.md
CHANGED
|
@@ -68,32 +68,32 @@ Many markers also take channel fields (`color`, `fill`, `opacity`, `r`, `symbol`
|
|
|
68
68
|
|
|
69
69
|
## Catalog for axis-based plots
|
|
70
70
|
|
|
71
|
-
| `type` | Draws
|
|
72
|
-
| -------------------------------------------------------- |
|
|
73
|
-
| `dot` | A point per row; `r`, `color`, `symbol`, `styles` (`DotStyle`)
|
|
74
|
-
| `text` | A label per row; `text` (string or function), `styles` (`FontStyle`), `declutter`, `edgeAware`, `fitMargins`
|
|
75
|
-
| `line` | A line through the rows
|
|
76
|
-
| `rule` | A reference line: `axis: 'x' \| 'y'`, `value` (a list draws a line at each, or a function with `data`), `styles
|
|
77
|
-
| `tick` | A short tick per row along one axis
|
|
78
|
-
| `bar` | A bar; `rect`, `cell`: rectangles and heatmap cells
|
|
79
|
-
| `rect` | A rectangle from `x1`/`x2`/`y1`/`y2`; `interval` turns `x`/`y` into ranges
|
|
80
|
-
| `area` | A filled area under a curve, or between `y1` and `y2`; `curve`
|
|
81
|
-
| `difference` | The area between two series, colored by which one is on top
|
|
82
|
-
| `arrow` | An arrow from `x1,y1` to `x2,y2`; `bend`, `headAngle`, `headLength
|
|
83
|
-
| `trail` | A variable-width ribbon along a path, its width set by `r`
|
|
84
|
-
| `delta` | The distance between two series (or a series and a fixed value) at a position - or at each of a list of them, `at: [1980, 2000]` - as a line and a label
|
|
85
|
-
| `hull` | The convex hull around a cluster of points
|
|
86
|
-
| `density` | 2D density contour bands
|
|
87
|
-
| `box` | A box plot; sub-marks styled through `bar`, `rule`, `dot`, `tickMedian`, `tickMinMax`; `thickness` sets its width in pixels, `slot` its share of a band
|
|
88
|
-
| `violin` | A violin per category of its rows: the mirrored density of `y` (or `x`), `kernel`, `bandwidth`, `trim`, `peak`, `slot`; add a narrow `box` over the same rows for the box inside
|
|
89
|
-
| `regression`, `bollinger` | A fitted curve, a moving-average band
|
|
90
|
-
| `waffle` | The value as a grid of unit squares; `unit`, `multiple`, `gap`
|
|
91
|
-
| `voronoi`, `voronoiMesh`, `delaunayLink`, `delaunayMesh` | Voronoi cells and Delaunay triangulation
|
|
92
|
-
| `image` | An image per row; `src`, `width`, `height`
|
|
93
|
-
| `raster` | A field sampled over a rectangle, drawn to a canvas
|
|
94
|
-
| `brush` | A drag-to-select rectangle with `onbrushstart`, `onbrush`, `onbrushend`
|
|
95
|
-
| `hover` | The in-plot hover highlight (see below)
|
|
96
|
-
| `component` | Your own Svelte component (see below)
|
|
71
|
+
| `type` | Draws |
|
|
72
|
+
| -------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
73
|
+
| `dot` | A point per row; `r`, `color`, `symbol`, `styles` (`DotStyle`) |
|
|
74
|
+
| `text` | A label per row; `text` (string or function), `styles` (`FontStyle`), `declutter`, `edgeAware`, `fitMargins`, `fit` |
|
|
75
|
+
| `line` | A line through the rows |
|
|
76
|
+
| `rule` | A reference line: `axis: 'x' \| 'y'`, `value` (a list draws a line at each, or a function with `data`), `styles` (`StrokeStyle`, and `inset`, `insetTop`, ... to pull it in from its ends) |
|
|
77
|
+
| `tick` | A short tick per row along one axis |
|
|
78
|
+
| `bar` | A bar; `rect`, `cell`: rectangles and heatmap cells |
|
|
79
|
+
| `rect` | A rectangle from `x1`/`x2`/`y1`/`y2`; `interval` turns `x`/`y` into ranges; `styles` (`AreaStyle`, and `inset`, `insetLeft`, ...); `label`, a text in each (`cell`, `bar` and `waffle` take it too) |
|
|
80
|
+
| `area` | A filled area under a curve, or between `y1` and `y2`; `curve` |
|
|
81
|
+
| `difference` | The area between two series, colored by which one is on top |
|
|
82
|
+
| `arrow` | An arrow from `x1,y1` to `x2,y2`; `bend`, `headAngle`, `headLength`, `styles` (`StrokeStyle`, and `inset`, `insetStart`, `insetEnd`) |
|
|
83
|
+
| `trail` | A variable-width ribbon along a path, its width set by `r` |
|
|
84
|
+
| `delta` | The distance between two series (or a series and a fixed value) at a position - or at each of a list of them, `at: [1980, 2000]` - as a line and a label |
|
|
85
|
+
| `hull` | The convex hull around a cluster of points |
|
|
86
|
+
| `density` | 2D density contour bands |
|
|
87
|
+
| `box` | A box plot; sub-marks styled through `bar`, `rule`, `dot`, `tickMedian`, `tickMinMax`; `thickness` sets its width in pixels, `slot` its share of a band |
|
|
88
|
+
| `violin` | A violin per category of its rows: the mirrored density of `y` (or `x`), `kernel`, `bandwidth`, `trim`, `peak`, `slot`; add a narrow `box` over the same rows for the box inside |
|
|
89
|
+
| `regression`, `bollinger` | A fitted curve, a moving-average band |
|
|
90
|
+
| `waffle` | The value as a grid of unit squares; `unit`, `multiple`, `gap` |
|
|
91
|
+
| `voronoi`, `voronoiMesh`, `delaunayLink`, `delaunayMesh` | Voronoi cells and Delaunay triangulation |
|
|
92
|
+
| `image` | An image per row; `src`, `width`, `height` |
|
|
93
|
+
| `raster` | A field sampled over a rectangle, drawn to a canvas |
|
|
94
|
+
| `brush` | A drag-to-select rectangle with `onbrushstart`, `onbrush`, `onbrushend` |
|
|
95
|
+
| `hover` | The in-plot hover highlight (see below) |
|
|
96
|
+
| `component` | Your own Svelte component (see below) |
|
|
97
97
|
|
|
98
98
|
## Markers in some facets
|
|
99
99
|
|
|
@@ -127,6 +127,56 @@ Every other marker draws from `data` rows, one mark per row, so it already takes
|
|
|
127
127
|
|
|
128
128
|
`{ type: 'hover' }` draws a crosshair, a dot and a label at the hovered point. It makes the plot hoverable on its own; add `tooltip` for a floating box too. Fields: `strategy`, `sync`, `ruleX`, `ruleY`, `areaX`, `areaY` (a band highlight on band scales), `showLabels`, `format`, the number fields `decimals`, `prefix`, `suffix` and `signDisplay` (they write the label's value; `format` gets a `number` function that does the same), and the styles `rule`, `area`, `dot`, `text`. See [Tooltip and hover](tooltip-and-hover.md).
|
|
129
129
|
|
|
130
|
+
## Styles that depend on the row
|
|
131
|
+
|
|
132
|
+
Everything a marker is drawn with goes in its `styles` - its colors, strokes and insets - and none of it sits beside `type`, `data` and the channels.
|
|
133
|
+
|
|
134
|
+
On the markers that draw a shape for each row - `rect`, `bar`, `cell`, `waffle`, `dot`, `tick`, `rule`, `arrow`, `voronoi` and `delaunayLink` - any field of `styles` can be a function of the row in place of a value, so each shape gets its own (`rect`, `cell`, `rule` and `arrow` take the insets that way too; `bar`'s are fractions of its band, the same for all):
|
|
135
|
+
|
|
136
|
+
```ts
|
|
137
|
+
{ type: 'rect', data: eras, x1: 'from', x2: 'to', y1: 0, y2: 100,
|
|
138
|
+
styles: { fill: 'steelblue', fillOpacity: (era) => (era.name === locked ? 0.55 : 0.12) } }
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
A color or an opacity the function returns is drawn as it is, not mapped through a scale. Where the function would only read a field, name the field: a number (`strokeWidth`, `fillOpacity`, an inset...) given as a string is the field of the rows, and so is a color when the rows have a field of that name - `fill: 'tint'` reads `row.tint`, but `fill: 'tomato'` is the color unless some row has a `tomato` field. A `text` marker does the same with `fill`, `fillOpacity`, `stroke`, `strokeWidth`, `fontWeight` and `fontStyle`; the other fields place and measure the labels, so they are one value for all. The markers that draw one shape for many rows (`line`, `area`, `density`, `hull`, a mesh) take plain values.
|
|
142
|
+
|
|
143
|
+
## A label in each shape
|
|
144
|
+
|
|
145
|
+
A `rect`, `cell`, `bar` or `waffle` marker takes a `label`: a text written in the middle of each shape, with every option of a `text` marker but `type`, `data`, `x` and `y`, which the shape sets. It never takes the pointer from the shape under it, so `onclick` and the hover go on as they were.
|
|
146
|
+
|
|
147
|
+
```ts
|
|
148
|
+
{ type: 'rect', data: tiles, x1: 'x1', x2: 'x2', y1: 'y1', y2: 'y2',
|
|
149
|
+
label: { text: 'name', styles: { fill: 'white' }, fit: { fallback: 'value' } } }
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
`anchor` puts the label against an edge (`'top'`, `'bottom'`, `'left'`, `'right'`) or in a corner (`'top-left'`...) instead of the middle, and `outside` puts one anchored to an edge beyond it; `gap` is its distance from the edge. A label outside is not fitted, and `fitMargins: true` grows the plot's margins to hold it where it would run past them. A label with a handler of its own (`onpointerenter`...) listens for the pointer; the others leave it to the shape. Its styles take functions of the row, to dim the label of a series, say. A label inside its shape with no `fill` of its own is written in the color that reads best on the shape's own - white on a dark one, near black on a light one - picked per row from the configuration's `text.label.contrast` (`['#ffffff', '#111827']`), or white or black where neither reaches the WCAG AA ratio of 4.5:1. The shape is read as it is seen: a `fillOpacity` under 1 blends it with the plot's `background`. One outside keeps its plot's color.
|
|
153
|
+
|
|
154
|
+
The label is fitted to its shape unless `fit` is `false`. One too big is written smaller, down to `minFontSize`; at that size it breaks into the lines the shape holds and the last one is cut short with an ellipsis; when fewer than `minLetters` letters would show, `fallback` - a value, a field or a function of the row - is written instead; and when not even that fits, nothing is. `padding` is the room kept free inside each edge. The defaults of `gap`, `padding`, `minFontSize` (8) and `minLetters` (3) are the configuration's `text.label`: `setConfiguration({ text: { label: { gap: 6 } } })`. A `text` marker of your own takes the same `fit` with a box of its own (`x1`, `x2`, `y1`, `y2`), which is rarely what you want.
|
|
155
|
+
|
|
156
|
+
## Events
|
|
157
|
+
|
|
158
|
+
Every marker takes handlers for the pointer:
|
|
159
|
+
|
|
160
|
+
```svelte
|
|
161
|
+
<LinePlot
|
|
162
|
+
...
|
|
163
|
+
markers={[
|
|
164
|
+
{
|
|
165
|
+
type: 'rect',
|
|
166
|
+
data: eras,
|
|
167
|
+
x1: 'from',
|
|
168
|
+
x2: 'to',
|
|
169
|
+
y1: 0,
|
|
170
|
+
y2: 100,
|
|
171
|
+
onclick: (event, era) => select(era)
|
|
172
|
+
}
|
|
173
|
+
]}
|
|
174
|
+
/>
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
- `onclick`, `ondblclick`, `oncontextmenu`, `onpointerdown`, `onpointerup`, `onpointerenter`, `onpointerleave`, `onpointermove`, `onmouseenter` and `onmouseleave` are called with the event, the row the shape draws and its index.
|
|
178
|
+
- Every marker that draws a svelteplot shape takes them (`brush`, `hover`, `inset`, `delta` and the map's `features` and `geo-hover` have events of their own). svelteplot documents them on all its marks, but its code wires them up on some only today: `rect`, `bar`, `cell`, `area`, `arrow`, `dot`, `trail`, `vector`, `link`, `line`, `delaunayLink` and `voronoi`. On the others they do nothing yet.
|
|
179
|
+
|
|
130
180
|
## Custom components
|
|
131
181
|
|
|
132
182
|
`{ type: 'component', component: MyMark, props: { ... } }` mounts a Svelte component inside the plot's SVG. It can read the plot it is in with [`usePlot()`](state.md), so it can draw from the plot's scales, margins, hover and rows.
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
# TreemapPlot
|
|
2
|
+
|
|
3
|
+
Part of [Plots](../../plots.md).
|
|
4
|
+
|
|
5
|
+
A part-to-whole made of rectangles: each row is a tile whose **area** is its `value`, and the tiles are nested by `grouping`, so a group's tiles sit together. `value` is the field (or function) giving a tile's size; the last level of `grouping` names it. The plot is the [`treemap` transform](../../transforms-and-statistics.md) drawn as `rect` markers, each with a `label`.
|
|
6
|
+
|
|
7
|
+
<!-- example: examples/Treemap.svelte -->
|
|
8
|
+
|
|
9
|
+
```svelte
|
|
10
|
+
<script lang="ts">
|
|
11
|
+
import { TreemapPlot } from '@fundar/data-chart-telling';
|
|
12
|
+
import { ACTIVITY_BRANCHES } from './datasets';
|
|
13
|
+
</script>
|
|
14
|
+
|
|
15
|
+
<!-- One tile per branch, sized by its value and colored by its sector. -->
|
|
16
|
+
<TreemapPlot
|
|
17
|
+
width={760}
|
|
18
|
+
height={440}
|
|
19
|
+
data={ACTIVITY_BRANCHES}
|
|
20
|
+
value="value"
|
|
21
|
+
grouping="sector.branch"
|
|
22
|
+
/>
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
<!-- /example -->
|
|
26
|
+
|
|
27
|
+

|
|
28
|
+
|
|
29
|
+
- A row without a positive `value` has no tile.
|
|
30
|
+
- `grouping` is the **whole path** of a tile, its fields joined by dots, outermost first: `grouping="sector.kind.branch"` nests the tiles by sector, then by kind, and names each one after its branch. A function is a single level. Rows with the same path are one tile, their values added up, so `grouping="sector"` alone makes three big tiles. The outermost level colors the tiles and is what the [legend](../../legend.md) lists; `scales.color` sets the colors, as in any plot. Without `grouping`, `color` groups the tiles, as it groups the series of any plot. `scales.color.depth` colors deeper levels as tones of their sector's color: `2` a tone per kind, `3` per branch (see [Scales](../../scales.md#color)).
|
|
31
|
+
- How a rectangle is split among its tiles is an option of the plot's own `treemap` transform: `transforms={[{ type: 'treemap', tile: 'binary' }]}` sets it over the one the plot builds from `value` and `grouping`. `tile` is `'squarify'` (the default, which keeps them close to squares), `'binary'`, `'slice'`, `'dice'` or `'sliceDice'`.
|
|
32
|
+
- Tiles have no axes.
|
|
33
|
+
|
|
34
|
+
## Labels
|
|
35
|
+
|
|
36
|
+
Each tile is labelled with its name and its **share of the whole**, in percent, as `styles.values` asks (`decimals`, `prefix`, `suffix`, `signDisplay`; one decimal and a `%` suffix unless you set otherwise, or `numbers.decimals` says). A label is fitted to the tile it is written on:
|
|
37
|
+
|
|
38
|
+
1. The name over the value, in as many lines as the tile has room for - at a smaller font size first, when that writes the whole name.
|
|
39
|
+
2. The name cut short with an ellipsis on its last line, when it still does not fit.
|
|
40
|
+
3. The value alone, when almost none of the name would show.
|
|
41
|
+
4. Nothing, when not even the value fits.
|
|
42
|
+
|
|
43
|
+
`styles.values.format(value, group, row, number)` writes the tile's whole text instead (`value` is the share, in percent; `number` writes it as the display fields ask), and `styles.values.show: false` leaves the tiles bare. The label's `fontStyle` sets `fontSize` (the biggest it takes), `fontWeight` and `fill`; `treemap` in the [configuration](../../theming.md) sets the lines between tiles, the label color and the room kept around it.
|
|
44
|
+
|
|
45
|
+
## Style
|
|
46
|
+
|
|
47
|
+
`styles.area` styles every tile - `fillOpacity`, `stroke`, `strokeWidth`, `strokeDasharray`, `borderRadius` - over the color of its group (a `fill` there wins over it). A group turned off in the [legend](../../legend.md) dims its tiles and their labels. With `disabled: { mode: 'omit' }` its tiles are gone and the rest keep their place and share, and with `{ mode: 'rescale' }` the rest fill the plot as the new whole, each share of what is left.
|
|
48
|
+
|
|
49
|
+
## Segments
|
|
50
|
+
|
|
51
|
+
`segments` are keyed by series - the outermost `grouping` level - or `default` for every one, and style a group's tiles together: a highlighted sector against the rest faded, an outlined one, a recolored one. A key can also be the **path** of a tile, its levels joined by dots - `'Tertiary.Finance'`, `'Tertiary.Finance.Insurance'` - and the most specific one wins. A segment sets no `areas`, as a tile has no position on an axis. A named key wins over `default`, and both over `styles.area` (see [Styles and segments](../../styles-and-segments.md)).
|
|
52
|
+
|
|
53
|
+
```svelte
|
|
54
|
+
<!-- Tertiary at some strength, its Finance tiles at full strength and outlined, every other sector faded. -->
|
|
55
|
+
<TreemapPlot
|
|
56
|
+
{data}
|
|
57
|
+
value="value"
|
|
58
|
+
grouping="sector.kind.branch"
|
|
59
|
+
segments={{
|
|
60
|
+
default: [{ styles: { fillOpacity: 0.25 } }],
|
|
61
|
+
Tertiary: [{ styles: { fillOpacity: 0.6 } }],
|
|
62
|
+
'Tertiary.Finance': [{ styles: { fillOpacity: 1, stroke: 'gold' } }]
|
|
63
|
+
}}
|
|
64
|
+
/>
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## Hover and tooltip
|
|
68
|
+
|
|
69
|
+
Hovering a tile matches it alone - an invisible `rect` over each tile drives the plot's hover - and `tooltip` shows its name and share. `tooltip.format(row, number, context)` writes it by hand: `row` is the tile's row, with the fields of every level and its summed `value`, and `context` what the library works out about it - its `series` (the outermost level) and its `share` of the whole, from 0 to 100. The share is worked out from the values, in whatever unit they are, so a dataset whose `value` is a percentage already reads the same.
|
|
@@ -55,5 +55,5 @@ Bars where one axis holds the categories and the other the values. Categories on
|
|
|
55
55
|
- Several series sharing a category sit side by side, each in its slice of the category band. The gap between them is `bar.seriesPadding` in the configuration.
|
|
56
56
|
- `transforms={[{ type: 'stackY' }]}` stacks the series instead. Stacking is always `stackY`, also for horizontal bars, because the value channel is the one stacked.
|
|
57
57
|
- `scales.x.paddingInner` / `paddingOuter` set the spacing between category bands.
|
|
58
|
-
- `styles.values.show` labels each bar; `styles.values.anchor` places the label (`'outside'`, `'
|
|
58
|
+
- `styles.values.show` labels each bar; `styles.values.anchor` places the label (`'outside'`, `'middle'`, `'top'`, `'bottom'`, `'left'`, `'right'`, a corner such as `'top-left'`, or `'tip'` and `'base'`, the ends of the bar away from zero and on it).
|
|
59
59
|
- The tooltip triggers anywhere over a bar's whole band, not just over the visible bar.
|
package/docs/plots.md
CHANGED
|
@@ -2,25 +2,26 @@
|
|
|
2
2
|
|
|
3
3
|
Every plot kind shares one set of props (see [Concepts](concepts.md)). They differ in what they draw, which channels they need and how they hover.
|
|
4
4
|
|
|
5
|
-
| Category
|
|
6
|
-
|
|
|
7
|
-
| Distribution
|
|
8
|
-
| Distribution
|
|
9
|
-
| Distribution
|
|
10
|
-
| Distribution
|
|
11
|
-
| Distribution
|
|
12
|
-
| Correlation
|
|
13
|
-
| Correlation
|
|
14
|
-
| Ranking
|
|
15
|
-
| Ranking
|
|
16
|
-
| Ranking
|
|
17
|
-
| Ranking
|
|
18
|
-
| Ranking
|
|
19
|
-
| Ranking
|
|
20
|
-
| Evolution
|
|
21
|
-
| Evolution
|
|
22
|
-
| Evolution
|
|
23
|
-
| Evolution
|
|
24
|
-
|
|
|
5
|
+
| Category | Plot | Draws | Needs |
|
|
6
|
+
| --------------- | ------------------------------------------------ | -------------------------------------------------------------- | ------------------------------------------------------- |
|
|
7
|
+
| Distribution | [DensityPlot](plots/distribution/density.md) | A smoothed distribution of a numeric field | `x` or `y` |
|
|
8
|
+
| Distribution | [HistogramPlot](plots/distribution/histogram.md) | Counts of a numeric field in bins | `x` or `y` |
|
|
9
|
+
| Distribution | [BoxPlot](plots/distribution/box.md) | The distribution of values per category | a category channel and a value channel |
|
|
10
|
+
| Distribution | [ViolinPlot](plots/distribution/violin.md) | The mirrored density of values per category, with a box inside | a category channel and a value channel |
|
|
11
|
+
| Distribution | [PyramidPlot](plots/distribution/pyramid.md) | Two series mirrored around zero | a category channel, a value channel, two series |
|
|
12
|
+
| Correlation | [HeatmapPlot](plots/correlation/heatmap.md) | A grid of colored cells | `x`, `y`, `color` |
|
|
13
|
+
| Correlation | [ScatterPlot](plots/correlation/scatter.md) | A point per row | `x`, `y` |
|
|
14
|
+
| Ranking | [BarPlot](plots/ranking/bar.md) | Bars, grouped, stacked or horizontal | a category channel and a value channel |
|
|
15
|
+
| Ranking | [BulletPlot](plots/ranking/bullet.md) | A bar against a target, over graded ranges | a category channel, a value channel, `target`, `ranges` |
|
|
16
|
+
| Ranking | [LollipopPlot](plots/ranking/lollipop.md) | One dot on a stem per category | a category channel and a value channel |
|
|
17
|
+
| Ranking | [DumbbellPlot](plots/ranking/dumbbell.md) | Two dots per category, joined | a category channel, a value channel, two series |
|
|
18
|
+
| Ranking | [ClevelandPlot](plots/ranking/cleveland.md) | Any number of dots per category, joined | a category channel, a value channel, a series per dot |
|
|
19
|
+
| Ranking | [ForestPlot](plots/ranking/forest.md) | One dot on an interval per row | a category channel, a value channel, `lower`/`upper` |
|
|
20
|
+
| Evolution | [LinePlot](plots/evolution/line.md) | A line per series | `x`, `y` |
|
|
21
|
+
| Evolution | [AreaPlot](plots/evolution/area.md) | A filled area per series | `x`, `y` |
|
|
22
|
+
| Evolution | [SparklinePlot](plots/evolution/sparkline.md) | A small line with its last value, no axes | `x`, `y` |
|
|
23
|
+
| Evolution | [SlopePlot](plots/evolution/slope.md) | A line per series between two positions | a category channel with two values, a value channel |
|
|
24
|
+
| Part of a whole | [TreemapPlot](plots/part-of-a-whole/treemap.md) | A tile per row, its area its value, nested by `grouping` | `value`, `grouping` |
|
|
25
|
+
| Map | [GeoPlot](geo.md) | A map from GeoJSON or TopoJSON | `data` (see [Maps](geo.md)) |
|
|
25
26
|
|
|
26
27
|
All of them accept `data` with `grouping`/`color`, or pre-built `series`.
|
package/docs/scales.md
CHANGED
|
@@ -80,9 +80,12 @@ A numeric axis takes `prefix`, `suffix`, `decimals` and `signDisplay` to write i
|
|
|
80
80
|
| `schemeRange` | The part of a named `scheme` to use, as `[from, to]` fractions of it (default `[0, 1]`): `[0.3, 1]` skips the near-white start of a ramp like `'blues'` |
|
|
81
81
|
| `pivot` | Splits an array `scheme` into two halves meeting at this value (a diverging ramp) |
|
|
82
82
|
| `unknown` | Color of a value outside the mapping (default `#ccc`) |
|
|
83
|
+
| `depth` | With a `grouping` of several levels, the level the colors reach (default `1`, a color per outermost value); deeper, each value down to it takes a tone of its outermost value's color |
|
|
83
84
|
|
|
84
85
|
A continuous ramp is set with `scheme: [colorA, colorB]`. Categorical colors come from the configuration's `palette` unless `scheme` is a category-to-color record. Series that follow one another (years, say) read better on a named sequential ramp, which is sampled across the series in order: `scheme: 'blues', schemeRange: [0.3, 1]`.
|
|
85
86
|
|
|
87
|
+
With `grouping: 'sector.kind.branch'`, `depth: 2` keeps each sector's color and gives every kind under it a tone of it; `depth: 3` gives every branch its own tone, those of one kind next to each other. A plot that splits its series by every level (a line per `'continent.country'`) colors them the same way, and a [treemap](plots/part-of-a-whole/treemap.md), which nests them, colors its tiles. The tones are `ColorTones` (`colorTones(color, count)` and `hierarchicalColors(paths, depth, colorOf)` in the package), for any page of your own that colors a hierarchy.
|
|
88
|
+
|
|
86
89
|
A marker can carry its own `scales.color`, independent of the plot's, so two ramps can coexist in one plot.
|
|
87
90
|
|
|
88
91
|
## Grouping
|
package/docs/state.md
CHANGED
|
@@ -7,7 +7,7 @@ A plot's state - its hover, legend, timeline, margins, scales, rows and size - c
|
|
|
7
7
|
Works anywhere inside a figure, including the `header`, `footer` and `content` snippets of a plot or composer. It returns:
|
|
8
8
|
|
|
9
9
|
- `hover` - `activeX`, `activeY`, `activeSeries`, `strategy`, `sync`, `source` (the id of the plot owning the hover).
|
|
10
|
-
- `legend` (or `null`) - `entries`, `range`, `off` (names of hidden series), `isOff(name)`, `turnOff(name, action)`, `turnOn(name)`, `toggle(name, action)`. `action` is `{ mode: 'dim' | 'hide' | 'omit' }`; `'omit'` removes the series and refits the axes
|
|
10
|
+
- `legend` (or `null`) - `entries`, `range`, `off` (names of hidden series), `isOff(name)`, `turnOff(name, action)`, `turnOn(name)`, `toggle(name, action)`. `action` is `{ mode: 'dim' | 'hide' | 'omit' | 'rescale' }`; `'omit'` removes the series and refits the axes, and `'rescale'` also makes the parts left of a whole (a stack, a treemap) the new 100%.
|
|
11
11
|
- `timeline` (or `null`) - `enabled`, `steps`, `value`, `index`, `progress`, `playing`, `loop`, `speed`, `speeds`, `controls`, and `seek`, `seekIndex`, `seekValue`, `next`, `previous`, `play`, `pause`, `toggle`, `setLoop`, `setSpeed`, `cycleSpeed`. On a timeline of dates, `steps` and `value` are `Date`s and `seekValue` takes a `Date` or a date string.
|
|
12
12
|
|
|
13
13
|
A footer that toggles series through the legend:
|
|
@@ -46,18 +46,18 @@
|
|
|
46
46
|
|
|
47
47
|

|
|
48
48
|
|
|
49
|
-
| Field | Meaning
|
|
50
|
-
| --------------------------------------------- |
|
|
51
|
-
| `show` | Draws the labels. Off by default, except on a heatmap
|
|
52
|
-
| `anchor` | `'outside'`, `'start'`, `'middle'`, `'end'
|
|
53
|
-
| `select` | Which row of each group is labelled: `'first'`, `'last'`, `'min'`, `'max'`, or a list of them. A group is a series on a line or area plot (default `'last'`), a category on the plots that join dots (default: every dot)
|
|
54
|
-
| `series` | Labels only these series, by name
|
|
55
|
-
| `color` | `'series'` writes each label in its series' color; any other CSS color writes them all in it (`fontStyle.fill` wins)
|
|
56
|
-
| `decimals`, `prefix`, `suffix`, `signDisplay` | How the value reads, over `numbers.decimals` ([Number format](theming.md#number-format)); `format` replaces them
|
|
57
|
-
| `format` | `(value, seriesName, row) => string`; `row` is the labelled row, for its other fields
|
|
58
|
-
| `hoverIsolate` | Hovering a label dims every other series
|
|
59
|
-
| `fontStyle` | Text style: `fontSize`, `fill`, `dx`, `dy`, `textAnchor`, `lineAnchor`, `rotate`, `class`, ... Overrides the anchor's placement field by field
|
|
60
|
-
| `strokeStyle` | Style of the connector lines drawn from labels that had to move apart
|
|
49
|
+
| Field | Meaning |
|
|
50
|
+
| --------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
51
|
+
| `show` | Draws the labels. Off by default, except on a heatmap |
|
|
52
|
+
| `anchor` | Where a label sits on its mark. On a line, area, slope or scatter plot: `'outside'`, `'start'`, `'middle'`, `'end'`, the side of its point the text is written on. On a bar, bullet, pyramid, histogram or heatmap - plots that label a shape - the label is in the shape: `'middle'`, an edge as the page draws it (`'top'`, `'bottom'`, `'left'`, `'right'`), a corner (`'top-left'`...), the end of the bar away from zero (`'tip'`) or the one on zero (`'base'`), whichever side of zero the value is; or beyond the tip, outside it: `'outside'` (the default). The labels are those of the shapes' own `label` - see [Markers](markers.md#a-label-in-each-shape) |
|
|
53
|
+
| `select` | Which row of each group is labelled: `'first'`, `'last'`, `'min'`, `'max'`, or a list of them. A group is a series on a line or area plot (default `'last'`), a category on the plots that join dots (default: every dot) |
|
|
54
|
+
| `series` | Labels only these series, by name |
|
|
55
|
+
| `color` | `'series'` writes each label in its series' color; any other CSS color writes them all in it (`fontStyle.fill` wins) |
|
|
56
|
+
| `decimals`, `prefix`, `suffix`, `signDisplay` | How the value reads, over `numbers.decimals` ([Number format](theming.md#number-format)); `format` replaces them |
|
|
57
|
+
| `format` | `(value, seriesName, row) => string`; `row` is the labelled row, for its other fields |
|
|
58
|
+
| `hoverIsolate` | Hovering a label dims every other series |
|
|
59
|
+
| `fontStyle` | Text style: `fontSize`, `fill`, `dx`, `dy`, `textAnchor`, `lineAnchor`, `rotate`, `class`, ... Overrides the anchor's placement field by field |
|
|
60
|
+
| `strokeStyle` | Style of the connector lines drawn from labels that had to move apart |
|
|
61
61
|
|
|
62
62
|
Where the labels go depends on the plot: the end of each series on a line or area plot, one per bar on a bar, pyramid or histogram, one per point on a scatter, one per cell on a heatmap. On lines, overlapping labels spread apart, share one column and are joined to their points by elbow connectors; the right margin grows to fit them when it is `'auto'`. The spread is tuned by `text.declutter` in the [configuration](theming.md).
|
|
63
63
|
|
|
@@ -121,12 +121,12 @@ A row whose value is `null`, `undefined` or `NaN` breaks a line. `styles.gaps` b
|
|
|
121
121
|
|
|
122
122
|
- A plot uses the ones its own marks are made of and ignores the rest, so one `styles` can be shared between plots:
|
|
123
123
|
|
|
124
|
-
| Plot
|
|
125
|
-
|
|
|
126
|
-
| `LinePlot`, `SlopePlot`, `SparklinePlot`
|
|
127
|
-
| `AreaPlot`, `BarPlot`, `BulletPlot`, `PyramidPlot`, `HistogramPlot`, `BoxPlot`, `DensityPlot`, `ViolinPlot`, `HeatmapPlot` | `area` |
|
|
128
|
-
| `ScatterPlot`
|
|
129
|
-
| `LollipopPlot`, `DumbbellPlot`, `ClevelandPlot`, `ForestPlot`
|
|
124
|
+
| Plot | Uses |
|
|
125
|
+
| ----------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------- |
|
|
126
|
+
| `LinePlot`, `SlopePlot`, `SparklinePlot` | `stroke` (the line), `dot` (a dot on every point; unset, none) |
|
|
127
|
+
| `AreaPlot`, `BarPlot`, `BulletPlot`, `PyramidPlot`, `HistogramPlot`, `BoxPlot`, `DensityPlot`, `ViolinPlot`, `HeatmapPlot`, `TreemapPlot` | `area` |
|
|
128
|
+
| `ScatterPlot` | `dot` |
|
|
129
|
+
| `LollipopPlot`, `DumbbellPlot`, `ClevelandPlot`, `ForestPlot` | `stroke` (the stems and connectors), `dot` |
|
|
130
130
|
|
|
131
131
|
`GeoPlot` has styles of its own and uses none of them.
|
|
132
132
|
|
|
@@ -161,6 +161,7 @@ The style shape depends on the plot:
|
|
|
161
161
|
| `AreaPlot`, `HistogramPlot` | `AreaStyle` | `fill`, `fillOpacity`, `stroke`, ... |
|
|
162
162
|
| `BarPlot`, `PyramidPlot` | `BarSegmentStyle` (`AreaStyle`) | `fill`, `fillOpacity`, `stroke`, ... |
|
|
163
163
|
| `HeatmapPlot` | `CellSegmentStyle` (`AreaStyle`) | `fill`, `fillOpacity`, `stroke`, `strokeWidth` |
|
|
164
|
+
| `TreemapPlot` | `BarSegmentStyle` (`AreaStyle`) | `fill`, `fillOpacity`, `stroke`, ... |
|
|
164
165
|
| `ScatterPlot` | `ScatterSegmentStyle` (`DotStyle`) | dot fill, stroke, radius, symbol |
|
|
165
166
|
| `GeoPlot` | `GeoSegmentStyle` | `fill`, `fillOpacity`, `stroke`, `strokeWidth` |
|
|
166
167
|
|
package/docs/theming.md
CHANGED
|
@@ -36,7 +36,7 @@ resetConfiguration(); // back to the shipped defaults
|
|
|
36
36
|
| `font`, `color`, `background` | Base text of every figure |
|
|
37
37
|
| `palette` | Categorical series colors, in order: a list of colors, or the name of a [d3-scale-chromatic](https://d3js.org/d3-scale-chromatic) scheme - a color list (`'dark2'`, `'tableau10'`) or a ramp (`'viridis'`, `'blues'`) - or `{ scheme, count, schemeRange }` for a ramp with its own number of colors (8 by default) and part of the ramp (`[0.3, 1]` skips the near-white start of `'blues'`). A name is turned into the list of colors when it is set |
|
|
38
38
|
| `symbols` | Shape cycle for the `symbol` channel |
|
|
39
|
-
| `continuous` | Default ramp endpoints
|
|
39
|
+
| `continuous` | Default ramp endpoints and opacity range for continuous color and opacity |
|
|
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 |
|
|
@@ -45,11 +45,12 @@ resetConfiguration(); // back to the shipped defaults
|
|
|
45
45
|
| `tooltip` | Tooltip background, color, font size, padding, radius, border |
|
|
46
46
|
| `margins` | Default margin per side (`'auto'` or a number) |
|
|
47
47
|
| `line`, `area`, `bar`, `pyramid`, `histogram`, `density`, `violin`, `box`, `lollipop`, `dumbbell`, `cleveland`, `forest`, `bullet`, `slope`, `sparkline`, `scatter` | Per-kind defaults: line curve (`'auto'`, straight segments), stroke width, dot radius, series padding, gap fills, fill opacity, inset, density stroke width, violin padding and box width, box, lollipop, dumbbell, Cleveland and forest padding, stem width, forest caps, bullet bar thickness, ranges and target tick, slope stroke width, dot radius and padding, sparkline stroke width and dot radius |
|
|
48
|
-
| `text` | `declutter` geometry of value labels and connectors
|
|
48
|
+
| `text` | `label` defaults (`gap`, `padding`, `minFontSize`, `minLetters`, and `contrast`, the colors a label inside its shape picks from) of the label a shape writes in itself, and `declutter` geometry of value labels and connectors |
|
|
49
49
|
| `connector` | What `styles.connector` falls back to on lollipop, dumbbell, Cleveland and forest plots: `sign` (`positive`, `negative`, `zero` colors), `lengthScheme` and `differenceScheme` (color ramps), `arrow` (`width`, `headLength`, `headAngle` of a connector drawn as an arrow), `outsideOpacity` (the part of a connector outside its `from`-`to` stretch), `capLength` (px, of a forest plot's end caps), `labelFontSize` and `labelGap` |
|
|
50
50
|
| `hover` | Look of the hover marker: `rule`, `dot`, `font`, `area` |
|
|
51
51
|
| `delta` | The `delta` marker's label, per axis the delta is taken on: `text.x` (beside a vertical delta: `dx: 12`, `textAnchor: 'start'`) and `text.y` (above a horizontal one: `dy: -10`, `textAnchor: 'middle'`). `lineAnchor` picks where along the delta the label sits and how it aligns there |
|
|
52
|
-
| `
|
|
52
|
+
| `treemap` | The tiles of a `TreemapPlot`: `stroke` (the line between tiles, white by default) and `strokeWidth`, `fontSize`, `padding` (the room kept around a label) and `lineHeight` |
|
|
53
|
+
| `timeline` | The rule (`rule`) and the player bar (`player`: controls, speeds, `stepDuration`, button, track, thumb, toggle); `snap` is how close to its last step (a fraction of the span, `1e-4` by default) a tweened timeline counts as being at it |
|
|
53
54
|
| `facet` | The position badge and prev/next buttons |
|
|
54
55
|
| `frameClip` | Tolerance for clipping marks to the plot frame |
|
|
55
56
|
|
|
@@ -98,7 +99,7 @@ A plot overrides it with `scales.x.edgeTicks` or `scales.y.edgeTicks` (see [Scal
|
|
|
98
99
|
|
|
99
100
|
## CSS variables
|
|
100
101
|
|
|
101
|
-
Some fields reach the DOM as CSS custom properties, which
|
|
102
|
+
Some fields reach the DOM as CSS custom properties, which the components read with a fallback. The configuration sets them once on the document root, as a rule with no specificity (`:where(:root)`), so plain CSS of your own overrides them - on a wrapping element, for one dashboard, or anywhere else:
|
|
102
103
|
|
|
103
104
|
```css
|
|
104
105
|
.my-dashboard {
|
|
@@ -225,14 +226,6 @@ The text blocks map `title`, `subtitle` and `caption` to `--dct-{block}-{font|si
|
|
|
225
226
|
| `--dct-player-toggle-size` | `timeline.player.toggle.fontSize` |
|
|
226
227
|
| `--dct-player-toggle-pad` | `timeline.player.toggle.padding` |
|
|
227
228
|
|
|
228
|
-
### heatmap ramp
|
|
229
|
-
|
|
230
|
-
| CSS variable | Config path |
|
|
231
|
-
| ----------------- | ----------------------- |
|
|
232
|
-
| `--dct-heat-min` | `continuous.min` |
|
|
233
|
-
| `--dct-heat-max` | `continuous.max` |
|
|
234
|
-
| `--dct-heat-text` | `continuous.labelColor` |
|
|
235
|
-
|
|
236
229
|
### facet
|
|
237
230
|
|
|
238
231
|
| CSS variable | Config path |
|
|
@@ -43,7 +43,7 @@ A plot becomes interactive when it is given a `tooltip`, a `{ type: 'hover' }` m
|
|
|
43
43
|
| `series` | Only these series appear in the tooltip |
|
|
44
44
|
| `anchorX`, `anchorY` | Preferred side of the cursor: `'left' \| 'middle' \| 'right'` (default `'right'`) and `'top' \| 'middle' \| 'bottom'` (default `'bottom'`). It moves to the other side when it would overflow |
|
|
45
45
|
|
|
46
|
-
`decimals`, `prefix`, `suffix` and `signDisplay` ([Number format](theming.md#number-format)) write the value the default text shows - the one on the value axis, the `x` of horizontal bars - and a heatmap's color value. A custom `format` gets a second argument, `number`, that writes a number the same way: `format: (row, number) => `${row.region}: ${number(row.value)}``.
|
|
46
|
+
`decimals`, `prefix`, `suffix` and `signDisplay` ([Number format](theming.md#number-format)) write the value the default text shows - the one on the value axis, the `x` of horizontal bars - and a heatmap's color value. A custom `format` gets a second argument, `number`, that writes a number the same way: `format: (row, number) => `${row.region}: ${number(row.value)}``. Its third, `context`, is what the plot knows of the row beyond its fields: the `series`it is drawn in, and what its kind works out (a [treemap](plots/part-of-a-whole/treemap.md)'s`share`).
|
|
47
47
|
|
|
48
48
|
<!-- example: examples/CustomTooltip.svelte -->
|
|
49
49
|
|
|
@@ -54,22 +54,23 @@ Both derive rows from the data before drawing. A **transform** reshapes the rows
|
|
|
54
54
|
|
|
55
55
|

|
|
56
56
|
|
|
57
|
-
| Family | `type` | Does
|
|
58
|
-
| --------- | --------------------------------------------------------------------------------------------- |
|
|
59
|
-
| Stack | `stackX`, `stackY`, `stackMosaicX`, `stackMosaicY` | Cumulative stacking. Options: `offset` (`'none'`, `'wiggle'`, `'center'`, `'normalize'`, `'diverging'`), `order`, `reverse`
|
|
60
|
-
| Bin | `binX`, `binY`, `bin` | Count or reduce rows into bins. Options: `thresholds` (a count, a list, or `'auto'`, `'scott'`, `'sturges'`, `'freedman-diaconis'`), `interval`, `domain`, `cumulative`; reducers by channel (`y: 'count'`, `fill: 'mean'`, ...)
|
|
61
|
-
| Group | `groupX`, `groupY`, `groupZ`, `group` | Reduce rows per category with named reducers (`count`, `sum`, `mean`, `p25`, ...) or functions
|
|
62
|
-
|
|
|
63
|
-
|
|
|
64
|
-
|
|
|
65
|
-
|
|
|
66
|
-
|
|
|
67
|
-
|
|
|
68
|
-
|
|
|
69
|
-
|
|
|
70
|
-
|
|
|
71
|
-
|
|
|
72
|
-
|
|
|
57
|
+
| Family | `type` | Does |
|
|
58
|
+
| --------- | --------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
59
|
+
| Stack | `stackX`, `stackY`, `stackMosaicX`, `stackMosaicY` | Cumulative stacking. Options: `offset` (`'none'`, `'wiggle'`, `'center'`, `'normalize'`, `'diverging'`), `order`, `reverse` |
|
|
60
|
+
| Bin | `binX`, `binY`, `bin` | Count or reduce rows into bins. Options: `thresholds` (a count, a list, or `'auto'`, `'scott'`, `'sturges'`, `'freedman-diaconis'`), `interval`, `domain`, `cumulative`; reducers by channel (`y: 'count'`, `fill: 'mean'`, ...) |
|
|
61
|
+
| Group | `groupX`, `groupY`, `groupZ`, `group` | Reduce rows per category with named reducers (`count`, `sum`, `mean`, `p25`, ...) or functions |
|
|
62
|
+
| Treemap | `treemap` | Lay rows out as tiles in the unit square, with d3-hierarchy. `value` (the area), `levels` (what the tiles nest by, outermost first; rows with the same path are one tile and their values add up), `tile` (`'squarify'`, `'binary'`, `'slice'`, `'dice'`, `'sliceDice'`), `aspect` (width over height of the box). Produces `x1`/`x2`/`y1`/`y2` for a `rect` marker and `x`/`y` at each tile's centre for a `text`; the tile's name, path, value and share are left on its row |
|
|
63
|
+
| Window | `windowX`, `windowY` | Sliding window: `k` (size), `reduce` (`'mean'`, `'median'`, `'sum'`, `'max'`, ...), `anchor`, `strict` |
|
|
64
|
+
| Bollinger | `bollingerX`, `bollingerY` | Moving average and band: `n`, `k` |
|
|
65
|
+
| Normalize | `normalizeX`, `normalizeY`, `normalizeParallelX`, `normalizeParallelY` | Rebase to a reference: `basis` (`'first'`, `'last'`, `'min'`, `'max'`, `'mean'`, `'median'`, `'sum'`, `'deviation'`) |
|
|
66
|
+
| Map | `mapX`, `mapY` | `map`: `'cumsum'`, `'rank'`, `'quantile'` or a function |
|
|
67
|
+
| Interval | `intervalX`, `intervalY` | Turn a value into an `[x1, x2]` interval of a given size |
|
|
68
|
+
| Jitter | `jitterX`, `jitterY` | Random offset: `width`, `std`, `distribution` (`'uniform'`, `'normal'`), `seed` |
|
|
69
|
+
| Shift | `shiftX`, `shiftY` | Move by `by` (a number, or a string offset) |
|
|
70
|
+
| Density | `densityX`, `densityY` | Kernel density estimate: `kernel`, `bandwidth` |
|
|
71
|
+
| Sort | `sort`, `shuffle`, `reverse` | Reorder rows (matters for the path a line takes and which dot lands on top) |
|
|
72
|
+
| Filter | `filter` | Keep rows a test holds for |
|
|
73
|
+
| Select | `select`, `selectFirst`, `selectLast`, `selectMinX`, `selectMaxX`, `selectMinY`, `selectMaxY` | Keep one row per group, such as each series' last point or peak |
|
|
73
74
|
|
|
74
75
|
Bar stacking is always `stackY`, also for horizontal bars. A transform on a `HistogramPlot` is merged over the plot's default binning, so `{ type: 'binX', thresholds: 20 }` changes the bins and the rest stays.
|
|
75
76
|
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { TreemapPlot } from '@fundar/data-chart-telling';
|
|
3
|
+
import { ACTIVITY_BRANCHES } from './datasets';
|
|
4
|
+
</script>
|
|
5
|
+
|
|
6
|
+
<!-- One tile per branch, sized by its value and colored by its sector. -->
|
|
7
|
+
<TreemapPlot
|
|
8
|
+
width={760}
|
|
9
|
+
height={440}
|
|
10
|
+
data={ACTIVITY_BRANCHES}
|
|
11
|
+
value="value"
|
|
12
|
+
grouping="sector.branch"
|
|
13
|
+
/>
|