@fundar/data-chart-telling 0.0.13 → 0.0.15

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 (141) hide show
  1. package/README.md +121 -17
  2. package/dist/charts/{Chart.svelte.d.ts → BaseChart.svelte.d.ts} +3 -3
  3. package/dist/charts/bar/Chart.svelte +5 -5
  4. package/dist/charts/bar/Chart.svelte.d.ts +1 -2
  5. package/dist/charts/heatmap/Chart.svelte +8 -7
  6. package/dist/charts/heatmap/Chart.svelte.d.ts +2 -3
  7. package/dist/charts/line/Chart.svelte +5 -5
  8. package/dist/charts/line/Chart.svelte.d.ts +1 -2
  9. package/dist/charts/pyramid/Chart.svelte +7 -6
  10. package/dist/charts/pyramid/Chart.svelte.d.ts +2 -3
  11. package/dist/configuration/config.svelte.js +1 -1
  12. package/dist/configuration/themes/index.d.ts +56 -40
  13. package/dist/index.d.ts +26 -12
  14. package/dist/index.js +12 -7
  15. package/dist/layout/facet/FacetLayout.svelte +1 -1
  16. package/dist/layout/facet/FacetLayout.svelte.d.ts +1 -1
  17. package/dist/layout/geo/GeoLayout.svelte +47 -0
  18. package/dist/layout/geo/GeoLayout.svelte.d.ts +22 -0
  19. package/dist/layout/geo/resolveProjection.d.ts +10 -0
  20. package/dist/layout/geo/resolveProjection.js +48 -0
  21. package/dist/layout/legend/DiscreteSection.svelte +1 -1
  22. package/dist/layout/plot/AxisLayout.svelte +95 -0
  23. package/dist/layout/plot/AxisLayout.svelte.d.ts +39 -0
  24. package/dist/layout/plot/BasePlotLayout.svelte +302 -0
  25. package/dist/layout/plot/BasePlotLayout.svelte.d.ts +95 -0
  26. package/dist/layout/plot/GridLayout.svelte +30 -0
  27. package/dist/layout/plot/GridLayout.svelte.d.ts +27 -0
  28. package/dist/layout/plot/RuleLayout.svelte +111 -0
  29. package/dist/layout/plot/RuleLayout.svelte.d.ts +40 -0
  30. package/dist/layout/plot/margins.d.ts +34 -0
  31. package/dist/layout/plot/margins.js +26 -0
  32. package/dist/layout/timeline/TimelineLayout.svelte +1 -1
  33. package/dist/layout/timeline/TimelineLayout.svelte.d.ts +1 -1
  34. package/dist/layout/tooltip/Tooltip.svelte +15 -0
  35. package/dist/layout/tooltip/Tooltip.svelte.d.ts +7 -0
  36. package/dist/layout/tooltip/TooltipLayout.svelte +45 -0
  37. package/dist/layout/tooltip/TooltipLayout.svelte.d.ts +41 -0
  38. package/dist/layout/tooltip/controller.svelte.d.ts +4 -3
  39. package/dist/layout/tooltip/controller.svelte.js +5 -6
  40. package/dist/layout/tooltip/hover.svelte.d.ts +1 -1
  41. package/dist/layout/tooltip/hover.svelte.js +1 -1
  42. package/dist/layout/tooltip/utils.d.ts +2 -2
  43. package/dist/markers/ContourClipMarker.svelte +77 -0
  44. package/dist/markers/ContourClipMarker.svelte.d.ts +10 -0
  45. package/dist/{plots/markers → markers}/DeltaMarker.svelte +4 -4
  46. package/dist/{plots/markers → markers}/DeltaMarker.svelte.d.ts +3 -3
  47. package/dist/{plots/markers → markers}/DotMarker.svelte +3 -3
  48. package/dist/{plots/markers → markers}/DotMarker.svelte.d.ts +3 -3
  49. package/dist/markers/HoverMarker.svelte +136 -0
  50. package/dist/{plots/markers → markers}/HoverMarker.svelte.d.ts +4 -4
  51. package/dist/{plots/markers → markers}/PeakMarker.svelte +2 -2
  52. package/dist/{plots/markers → markers}/PeakMarker.svelte.d.ts +2 -2
  53. package/dist/{plots/markers → markers}/TextMarker.svelte +11 -4
  54. package/dist/{plots/markers → markers}/TextMarker.svelte.d.ts +3 -3
  55. package/dist/markers/inset/InsetMarker.svelte +170 -0
  56. package/dist/markers/inset/InsetMarker.svelte.d.ts +51 -0
  57. package/dist/markers/inset/insetLayout.d.ts +25 -0
  58. package/dist/markers/inset/insetLayout.js +39 -0
  59. package/dist/markers/inset/insetProjection.d.ts +8 -0
  60. package/dist/markers/inset/insetProjection.js +39 -0
  61. package/dist/plots/bar/BarSegments.svelte +66 -0
  62. package/dist/plots/bar/BarSegments.svelte.d.ts +36 -0
  63. package/dist/plots/bar/Plot.svelte +132 -76
  64. package/dist/plots/bar/Plot.svelte.d.ts +7 -3
  65. package/dist/plots/bar/ValueLabels.svelte +89 -0
  66. package/dist/plots/bar/ValueLabels.svelte.d.ts +39 -0
  67. package/dist/plots/bar/hoverPoints.d.ts +15 -0
  68. package/dist/plots/bar/hoverPoints.js +35 -0
  69. package/dist/plots/bar/layout.svelte.d.ts +37 -0
  70. package/dist/plots/bar/layout.svelte.js +132 -0
  71. package/dist/plots/geo/Plot.svelte +548 -0
  72. package/dist/plots/geo/Plot.svelte.d.ts +29 -0
  73. package/dist/plots/geo/TileLayer.svelte +77 -0
  74. package/dist/plots/geo/TileLayer.svelte.d.ts +11 -0
  75. package/dist/plots/geo/projections/argentina.d.ts +8 -0
  76. package/dist/plots/geo/projections/argentina.js +35 -0
  77. package/dist/plots/geo/projections/fit.d.ts +8 -0
  78. package/dist/plots/geo/projections/fit.js +14 -0
  79. package/dist/plots/geo/rotate.svelte.d.ts +26 -0
  80. package/dist/plots/geo/rotate.svelte.js +79 -0
  81. package/dist/plots/geo/zoom.svelte.d.ts +32 -0
  82. package/dist/plots/geo/zoom.svelte.js +50 -0
  83. package/dist/plots/heatmap/Plot.svelte +129 -47
  84. package/dist/plots/heatmap/Plot.svelte.d.ts +7 -3
  85. package/dist/plots/line/Plot.svelte +44 -16
  86. package/dist/plots/line/Plot.svelte.d.ts +7 -3
  87. package/dist/plots/pyramid/Plot.svelte +70 -25
  88. package/dist/plots/pyramid/Plot.svelte.d.ts +7 -3
  89. package/dist/plots/utils/delta.d.ts +1 -1
  90. package/dist/plots/utils/geoAccessors.d.ts +64 -0
  91. package/dist/plots/utils/geoAccessors.js +188 -0
  92. package/dist/plots/utils/geoSegments.d.ts +14 -0
  93. package/dist/plots/utils/geoSegments.js +17 -0
  94. package/dist/plots/utils/segments.d.ts +14 -5
  95. package/dist/plots/utils/segments.js +25 -13
  96. package/dist/plots/utils/tiles.d.ts +89 -0
  97. package/dist/plots/utils/tiles.js +159 -0
  98. package/dist/plots/utils/topojson.d.ts +9 -0
  99. package/dist/plots/utils/topojson.js +30 -0
  100. package/dist/types/charts/common.d.ts +2 -1
  101. package/dist/types/charts/legend.d.ts +1 -1
  102. package/dist/types/charts/props.d.ts +9 -6
  103. package/dist/types/configuration/styling.d.ts +11 -5
  104. package/dist/types/layout/tooltip.d.ts +14 -21
  105. package/dist/types/{plots/markers.d.ts → markers/common.d.ts} +2 -18
  106. package/dist/types/markers/geo.d.ts +237 -0
  107. package/dist/types/markers/props.d.ts +11 -0
  108. package/dist/types/plots/axis.d.ts +55 -0
  109. package/dist/types/plots/axis.js +1 -0
  110. package/dist/types/plots/constants.d.ts +30 -0
  111. package/dist/types/plots/constants.js +1 -0
  112. package/dist/types/plots/data/common.d.ts +40 -0
  113. package/dist/types/plots/data/common.js +1 -0
  114. package/dist/types/plots/data/geo.d.ts +74 -0
  115. package/dist/types/plots/data/geo.js +1 -0
  116. package/dist/types/plots/delta.d.ts +2 -2
  117. package/dist/types/plots/props.d.ts +105 -16
  118. package/dist/types/plots/scales/geo.d.ts +44 -0
  119. package/dist/types/plots/scales/geo.js +1 -0
  120. package/dist/types/plots/segments/common.d.ts +25 -0
  121. package/dist/types/plots/segments/common.js +1 -0
  122. package/dist/types/plots/segments/config.d.ts +51 -0
  123. package/dist/types/plots/segments/config.js +1 -0
  124. package/dist/types/plots/styles/common.d.ts +37 -0
  125. package/dist/types/plots/styles/common.js +1 -0
  126. package/dist/types/plots/styles/geo.d.ts +42 -0
  127. package/dist/types/plots/styles/geo.js +1 -0
  128. package/dist/types/plots/styling.d.ts +45 -0
  129. package/dist/types/plots/styling.js +1 -0
  130. package/dist/utils/grouping.d.ts +2 -1
  131. package/dist/utils/interpolate.d.ts +2 -1
  132. package/package.json +27 -13
  133. package/dist/layout/plot/PlotLayout.svelte +0 -237
  134. package/dist/layout/plot/PlotLayout.svelte.d.ts +0 -70
  135. package/dist/plots/markers/HoverMarker.svelte +0 -98
  136. package/dist/types/plots/common.d.ts +0 -100
  137. package/dist/types/plots/styles.d.ts +0 -187
  138. /package/dist/charts/{Chart.svelte → BaseChart.svelte} +0 -0
  139. /package/dist/types/{plots → markers}/common.js +0 -0
  140. /package/dist/types/{plots/markers.js → markers/geo.js} +0 -0
  141. /package/dist/types/{plots/styles.js → markers/props.js} +0 -0
@@ -1,98 +0,0 @@
1
- <script lang="ts">
2
- import { RuleX, RuleY } from 'svelteplot';
3
- import DotMarker from './DotMarker.svelte';
4
- import TextMarker from './TextMarker.svelte';
5
- import { getConfiguration } from '../../configuration/config.svelte';
6
- import type { MarkerProps } from '../../types/plots/markers';
7
- import type { AxisValue } from '../../types/plots/common';
8
- import type { DotStyle, FontStyle, StrokeStyle } from '../../types/plots/styles';
9
- import type { HoverDisplayPoint } from '../../types/layout/tooltip';
10
-
11
- /**
12
- * In-SVG hover highlight, rendered *inside* a `<Plot>`. Because it positions
13
- * itself through the host plot's scales, it places the same coordinate
14
- * correctly in every facet — that is what makes cross-facet sync work without
15
- * any pixel math. Draws optional x/y crosshair rules plus a dot + value label
16
- * for each matched point.
17
- */
18
- interface Props extends MarkerProps<HoverDisplayPoint> {
19
- ruleX?: AxisValue | null;
20
- ruleY?: AxisValue | null;
21
- showLabels?: boolean;
22
- format?: (point: HoverDisplayPoint) => string;
23
- ruleStyle?: StrokeStyle;
24
- dotStyle?: DotStyle;
25
- fontStyle?: FontStyle;
26
- }
27
-
28
- let {
29
- data = [],
30
- ruleX = null,
31
- ruleY = null,
32
- showLabels = true,
33
- format,
34
- ruleStyle,
35
- dotStyle,
36
- fontStyle,
37
- seriesColor,
38
- }: Props = $props();
39
-
40
- const cfg = $derived(getConfiguration());
41
-
42
- /** Explicit style wins; otherwise fall back to the series color, then the point's own resolved color. */
43
- const resolveColor = (explicit: string | undefined, point: HoverDisplayPoint) =>
44
- explicit ?? seriesColor ?? point.color;
45
- </script>
46
-
47
- {#if ruleX != null}
48
- <RuleX
49
- data={[{ v: ruleX }]}
50
- x={(d) => d.v}
51
- stroke={ruleStyle?.stroke ?? cfg.hover.rule.stroke}
52
- strokeOpacity={ruleStyle?.strokeOpacity ?? cfg.hover.rule.strokeOpacity}
53
- strokeWidth={ruleStyle?.strokeWidth ?? cfg.hover.rule.strokeWidth}
54
- strokeDasharray={ruleStyle?.strokeDasharray ?? cfg.hover.rule.strokeDasharray}
55
- />
56
- {/if}
57
-
58
- {#if ruleY != null}
59
- <RuleY
60
- data={[{ v: ruleY }]}
61
- y={(d) => d.v}
62
- stroke={ruleStyle?.stroke ?? cfg.hover.rule.stroke}
63
- strokeOpacity={ruleStyle?.strokeOpacity ?? cfg.hover.rule.strokeOpacity}
64
- strokeWidth={ruleStyle?.strokeWidth ?? cfg.hover.rule.strokeWidth}
65
- strokeDasharray={ruleStyle?.strokeDasharray ?? cfg.hover.rule.strokeDasharray}
66
- />
67
- {/if}
68
-
69
- {#if data.length > 0}
70
- {#each data as point (point.series ?? `${point.x}_${point.y}`)}
71
- <DotMarker
72
- data={[point]}
73
- x={(d) => d.x}
74
- y={(d) => d.y}
75
- style={{
76
- ...cfg.hover.dot,
77
- ...dotStyle,
78
- dotFill: resolveColor(dotStyle?.dotFill, point),
79
- dotStroke: resolveColor(dotStyle?.dotStroke, point),
80
- }}
81
- />
82
- {/each}
83
- {#if showLabels}
84
- {#each data as point (point.series ?? `${point.x}_${point.y}`)}
85
- <TextMarker
86
- data={[point]}
87
- x={(d) => d.x}
88
- y={(d) => d.y}
89
- text={(d) => format ? format(d) : (d.label ?? '')}
90
- style={{
91
- ...cfg.hover.font,
92
- ...fontStyle,
93
- fill: resolveColor(fontStyle?.fill, point),
94
- }}
95
- />
96
- {/each}
97
- {/if}
98
- {/if}
@@ -1,100 +0,0 @@
1
- export type AxisValue = number | string | Date;
2
- /** Partial margin override — only the sides you specify are overridden; the rest come from the theme. */
3
- export type MarginConfig = Partial<{
4
- top: number;
5
- right: number;
6
- bottom: number;
7
- left: number;
8
- }>;
9
- /**
10
- * Author-facing scale overrides for a plot axis. Mirrors svelteplot's
11
- * `ScaleOptions` + `XScaleOptions` in full — `type`, `padding`, `domain`,
12
- * `nice`, `reverse`, `label`, `tickFormat`, `labelAnchor`, etc.
13
- *
14
- * Used for both `x` and `y` entries in {@link ScalesConfig}. X-specific
15
- * fields (`labelAnchor`, `tickRotate`) are accepted on `y` too; svelteplot
16
- * silently ignores any inapplicable options.
17
- */
18
- export type AxisScale = {
19
- type?: 'auto' | 'linear' | 'pow' | 'sqrt' | 'log' | 'symlog' | 'time' | 'utc' | 'point' | 'ordinal' | 'sequential' | 'band' | 'categorical' | 'cyclical' | 'threshold' | 'quantile-cont' | 'quantile' | 'quantize' | 'diverging' | 'diverging-log' | 'diverging-pow' | 'diverging-sqrt' | 'diverging-symlog';
20
- domain?: (number | string | boolean | Date | null)[];
21
- range?: (number | string | boolean | Date | null)[];
22
- reverse?: boolean;
23
- label?: string | false;
24
- interval?: string | number;
25
- clamp?: boolean;
26
- nice?: boolean;
27
- zero?: boolean;
28
- round?: boolean;
29
- percent?: boolean;
30
- padding?: number;
31
- align?: number;
32
- paddingInner?: number;
33
- paddingOuter?: number;
34
- insetLeft?: number;
35
- insetRight?: number;
36
- insetTop?: number;
37
- insetBottom?: number;
38
- ticks?: (number | string | boolean | Date | null)[];
39
- tickSpacing?: number;
40
- tickSize?: number;
41
- tickPadding?: number;
42
- titleFontSize?: number;
43
- base?: number;
44
- constant?: number;
45
- sort?: ((a: unknown, b: unknown) => number) | {
46
- channel: string;
47
- order: 'ascending' | 'descending';
48
- };
49
- grid?: boolean;
50
- tickRotate?: number;
51
- tickFormat?: false | Intl.NumberFormatOptions | Intl.DateTimeFormatOptions | ((d: unknown, index: number, ticks: unknown[]) => string | string[]);
52
- };
53
- /**
54
- * Per-axis scale overrides, passed as a single `scales` prop to every plot
55
- * kind.
56
- */
57
- export type ScalesConfig = {
58
- x?: AxisScale;
59
- y?: AxisScale;
60
- z?: AxisScale;
61
- };
62
- /**
63
- * A field key or accessor function. Mirrors the shorthand used across plots
64
- * so chart-level encodings (`x`, `y`, `z`, facet, timeline) feel consistent
65
- * with the plot-level series definitions.
66
- */
67
- export type Accessor<TRow extends Record<string, unknown>, V> = keyof TRow | ((d: TRow) => V);
68
- /**
69
- * A plot series: a name, x/y accessors and the rows it draws. Shared as-is by
70
- * every mark (line, bar, …) — none of them need anything beyond this shape;
71
- * visual styling lives separately in `segments`.
72
- */
73
- export type Series<T extends Record<string, unknown> = Record<string, unknown>> = {
74
- name: string;
75
- x: Accessor<T, AxisValue>;
76
- y: Accessor<T, AxisValue>;
77
- z?: Accessor<T, unknown>;
78
- data: T[];
79
- };
80
- /**
81
- * Pre-built series. Mutually exclusive with {@link DataProps} — takes
82
- * precedence when both could apply.
83
- */
84
- export type SeriesProps<T extends Record<string, unknown>> = {
85
- series: Series<T>[];
86
- data?: never;
87
- x?: never;
88
- y?: never;
89
- z?: never;
90
- };
91
- /**
92
- * Flat rows to group into series, as an alternative to {@link SeriesProps}.
93
- */
94
- export type DataProps<T extends Record<string, unknown>> = {
95
- series?: never;
96
- data: T[];
97
- x: Accessor<T, AxisValue>;
98
- y: Accessor<T, AxisValue>;
99
- z?: Accessor<T, unknown>;
100
- };
@@ -1,187 +0,0 @@
1
- import type { AxisValue, Series } from './common';
2
- /**
3
- * Unified positional anchor for value labels across all plot kinds.
4
- *
5
- * - `'outside'` — beyond the tip of the mark (above a vertical bar, to the
6
- * far end of a horizontal bar or line). This is the only value with no
7
- * direct svelteplot equivalent; the plot computes dx/dy internally.
8
- * - `'start'` — at the tip of the mark, just inside (top of a bar, far end
9
- * of a pyramid bar from zero, right of a line's last point).
10
- * - `'middle'` — centred on the mark.
11
- * - `'end'` — at the baseline/zero end of the mark.
12
- */
13
- export type ValueAnchor = 'outside' | 'start' | 'middle' | 'end';
14
- /**
15
- * Controls if and how value labels are rendered on a plot. The high-level
16
- * `anchor` sets sensible defaults for placement; the low-level svelteplot
17
- * Text-mark fields (`dx`, `dy`, `textAnchor`, `lineAnchor`, `lineHeight`,
18
- * `rotate`, `class`, `textClass`) override those defaults when provided.
19
- */
20
- export type ValuesStyle = {
21
- show?: boolean;
22
- anchor?: ValueAnchor;
23
- /** Called with the numeric value and the series name. Return a string to render. */
24
- format?: (value: number, seriesName: string) => string;
25
- dx?: number;
26
- dy?: number;
27
- textAnchor?: 'start' | 'end' | 'middle';
28
- lineAnchor?: 'top' | 'bottom' | 'middle';
29
- lineHeight?: number;
30
- rotate?: number;
31
- class?: string;
32
- textClass?: string;
33
- };
34
- /**
35
- * Color overrides for plots that derive their palette from data.
36
- * Each plot uses only the fields relevant to its kind; unused fields are
37
- * silently ignored.
38
- *
39
- * - `min` / `max` — sequential colour ramp endpoints (heatmap).
40
- * - `left` / `right` — diverging bar sides (pyramid).
41
- */
42
- export type ColorsStyle = {
43
- min?: string;
44
- max?: string;
45
- left?: string;
46
- right?: string;
47
- };
48
- /**
49
- * Top-level rendering style overrides shared by all plot kinds. Passed as the
50
- * `styles` prop. Each plot reads only the fields it cares about.
51
- */
52
- export type PlotStyles = {
53
- values?: ValuesStyle;
54
- colors?: ColorsStyle;
55
- };
56
- export type SymbolType = 'circle' | 'square' | 'triangle' | 'line';
57
- export type LineStyle = 'solid' | 'dashed' | 'dotted' | 'dashdot';
58
- export type LineCap = 'butt' | 'round' | 'square';
59
- export type LineJoin = 'arcs' | 'bevel' | 'miter' | 'miter-clip' | 'round';
60
- /** Stroke styling for any line-ish mark — a line, a rule, a marker's connector. */
61
- export type StrokeStyle = {
62
- stroke?: string;
63
- strokeWidth?: number;
64
- strokeOpacity?: number;
65
- strokeDasharray?: string | LineStyle;
66
- strokeLinecap?: LineCap;
67
- strokeLinejoin?: LineJoin;
68
- };
69
- /**
70
- * Dot styling for any point mark — a line's endpoint dots, a marker's dot.
71
- * Carries its own `dotStroke*` fields rather than nesting a {@link StrokeStyle},
72
- * because a dot's outline is a distinct style from the stroke of the line (or
73
- * other mark) it sits next to — e.g. a {@link LineSegmentStyle} styles its
74
- * line's stroke and its dots' outline independently.
75
- */
76
- export type DotStyle = {
77
- dotRadius?: number;
78
- dotFill?: string;
79
- dotFillOpacity?: number;
80
- dotSymbol?: SymbolType;
81
- dotStroke?: string;
82
- dotStrokeWidth?: number;
83
- dotStrokeOpacity?: number;
84
- dotStrokeDasharray?: string | LineStyle;
85
- };
86
- /** Text/label styling for any text mark — a marker's label, an annotation. */
87
- export type FontStyle = {
88
- fill?: string;
89
- fontSize?: number;
90
- fontWeight?: 'normal' | 'bold';
91
- fontStyle?: 'normal' | 'italic';
92
- textAnchor?: 'start' | 'middle' | 'end';
93
- lineAnchor?: 'top' | 'middle' | 'bottom';
94
- stroke?: string;
95
- strokeWidth?: number;
96
- paintOrder?: string;
97
- dx?: number;
98
- dy?: number;
99
- };
100
- /** Per-segment styling for a line: its stroke and/or its endpoint dots. */
101
- export type LineSegmentStyle = {
102
- stroke?: StrokeStyle;
103
- dots?: DotStyle;
104
- };
105
- /** Per-segment styling for a bar: its fill. */
106
- export type BarSegmentStyle = {
107
- fill?: string;
108
- fillOpacity?: number;
109
- };
110
- /** Per-cell styling override for a heatmap cell. */
111
- export type CellSegmentStyle = {
112
- fill?: string;
113
- fillOpacity?: number;
114
- stroke?: string;
115
- strokeWidth?: number;
116
- };
117
- /** A half-open interval on one axis. Both bounds are inclusive; omit either to leave that end open. */
118
- export type Range = {
119
- from?: AxisValue;
120
- to?: AxisValue;
121
- };
122
- /**
123
- * A 2-D rectangular area on the plot, addressed by optional x and y intervals.
124
- * Omitting an interval leaves that axis unrestricted (matches all values).
125
- *
126
- * - For line/bar/pyramid plots only the `x` interval is used (the series' primary
127
- * axis); `y` is evaluated but filters by the series' value axis.
128
- * - For heatmaps both `x` (column) and `y` (row) are used to address cells.
129
- */
130
- export type Area = {
131
- x?: Range;
132
- y?: Range;
133
- };
134
- /**
135
- * One styled rule for a plot. A data point (or cell) is styled when it falls
136
- * inside **any** of the listed `areas`. Omitting `areas` (or passing an empty
137
- * array) makes the segment a catch-all that matches every data point — useful
138
- * as a baseline style. `TStyle` is the per-mark shape ({@link LineSegmentStyle},
139
- * {@link BarSegmentStyle}, {@link CellSegmentStyle}, …).
140
- *
141
- * Catch-alls are evaluated last so that area-specific segments always take
142
- * priority, regardless of their position in the list. A catch-all placed first
143
- * therefore acts as a fallback baseline that area-specific segments override.
144
- */
145
- export type Segment<TStyle> = {
146
- areas?: Area[];
147
- style?: TStyle;
148
- };
149
- /**
150
- * The `segments` prop accepted by every plot kind.
151
- *
152
- * A record mapping series names (or `'default'` for all series) to lists of
153
- * {@link Segment}s. Segments in a named key apply only to that series;
154
- * segments under `'default'` apply to every series.
155
- *
156
- * ```ts
157
- * segments: {
158
- * female: [{ style: { stroke: { stroke: 'tomato' } } }], // catch-all for female
159
- * male: [{ style: { stroke: { stroke: 'steelblue' } } }], // catch-all for male
160
- * default: [{ areas: [{ x: { from: 2012, to: 2014 } }], style: { dots: { dotSymbol: 'circle' } } }],
161
- * }
162
- * ```
163
- *
164
- * Within each resolved series list, catch-alls (no `areas`) are evaluated last
165
- * so that area-specific segments always override them, regardless of position.
166
- * Area-specific segments also inherit any style key absent from their own style
167
- * by merging the catch-all as a baseline — the area's own style wins on conflict.
168
- * This lets you set a series colour once in a catch-all and add per-range dots
169
- * or dash patterns without repeating the colour on every area segment.
170
- */
171
- export type Segments<TStyle> = Record<string, Segment<TStyle>[]>;
172
- /** One contiguous, styled slice of a series' data — ready to draw as its own mark. */
173
- export type VisualSegment<T extends Record<string, unknown>, TStyle = LineSegmentStyle> = {
174
- data: T[];
175
- style: TStyle;
176
- };
177
- /**
178
- * A series split into its styled visual segments. `S` is the full series
179
- * type Series<T> — its row type is read off `S['data']`
180
- * rather than taken as a separate parameter, since TypeScript can't reliably
181
- * infer a type parameter that only appears inside another parameter's
182
- * constraint.
183
- */
184
- export type VisualGroup<S extends Series<any>, TStyle = LineSegmentStyle> = {
185
- series: S;
186
- visualSegments: VisualSegment<S['data'][number], TStyle>[];
187
- };
File without changes
File without changes
File without changes