@fundar/data-chart-telling 1.17.0 → 1.18.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 (205) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/dist/configuration/config.svelte.js +3 -2
  3. package/dist/index.d.ts +7 -2
  4. package/dist/index.js +2 -0
  5. package/dist/layout/geometry/GeometryLayout.svelte +188 -54
  6. package/dist/layout/hover/HoverDefaults.d.ts +52 -0
  7. package/dist/layout/hover/HoverDefaults.js +96 -0
  8. package/dist/layout/hover/HoverLayers.d.ts +35 -0
  9. package/dist/layout/hover/HoverLayers.js +122 -0
  10. package/dist/layout/hover/HoverSettings.d.ts +1 -3
  11. package/dist/layout/hover/HoverSettings.js +3 -2
  12. package/dist/layout/hover/HoverShapes.d.ts +44 -0
  13. package/dist/layout/hover/HoverShapes.js +103 -0
  14. package/dist/layout/hover/PlotHover.svelte.d.ts +18 -0
  15. package/dist/layout/hover/PlotHover.svelte.js +54 -1
  16. package/dist/layout/legend/LegendState.svelte.d.ts +2 -0
  17. package/dist/layout/legend/LegendState.svelte.js +5 -0
  18. package/dist/layout/plot/Core.svelte +2 -2
  19. package/dist/layout/plot/PublicPlotContext.d.ts +6 -0
  20. package/dist/layout/plot/PublicPlotContext.js +8 -0
  21. package/dist/layout/styles/ValueLabels.d.ts +12 -4
  22. package/dist/layout/styles/ValueLabels.js +22 -13
  23. package/dist/layout/tooltip/TooltipState.svelte.d.ts +8 -9
  24. package/dist/layout/tooltip/TooltipState.svelte.js +28 -29
  25. package/dist/markers/MarkerKinds.d.ts +5 -0
  26. package/dist/markers/MarkerKinds.js +1 -0
  27. package/dist/markers/band/BandMarker.svelte +74 -0
  28. package/dist/markers/band/BandMarker.svelte.d.ts +7 -0
  29. package/dist/markers/band/Bands.d.ts +16 -0
  30. package/dist/markers/band/Bands.js +48 -0
  31. package/dist/markers/bar/BarMarker.svelte +23 -66
  32. package/dist/markers/hover/HoverMarker.svelte +7 -265
  33. package/dist/markers/hover/HoverMarker.svelte.d.ts +4 -27
  34. package/dist/markers/utils/PointPixel.d.ts +37 -0
  35. package/dist/markers/utils/PointPixel.js +44 -0
  36. package/dist/phases/Pipeline.d.ts +7 -7
  37. package/dist/phases/Pipeline.js +12 -9
  38. package/dist/phases/context/ContextPhase.d.ts +22 -0
  39. package/dist/phases/context/ContextPhase.js +23 -0
  40. package/dist/phases/context/RowContext.d.ts +35 -0
  41. package/dist/phases/context/RowContext.js +95 -0
  42. package/dist/phases/data/DataPhase.d.ts +4 -4
  43. package/dist/phases/data/DataPhase.js +7 -7
  44. package/dist/phases/hover/HoverPhase.d.ts +6 -7
  45. package/dist/phases/hover/HoverPhase.js +28 -23
  46. package/dist/phases/mapping/MappingPhase.d.ts +4 -4
  47. package/dist/phases/mapping/MappingPhase.js +2 -2
  48. package/dist/phases/markers/MarkerStyles.d.ts +8 -0
  49. package/dist/phases/markers/MarkerStyles.js +15 -0
  50. package/dist/phases/markers/MarkersPhase.d.ts +4 -4
  51. package/dist/phases/markers/MarkersPhase.js +4 -4
  52. package/dist/phases/scales/ScalesPhase.d.ts +4 -4
  53. package/dist/phases/scales/ScalesPhase.js +4 -4
  54. package/dist/phases/sharedScales/SharedScalesPhase.d.ts +2 -2
  55. package/dist/phases/sharedScales/SharedScalesPhase.js +2 -2
  56. package/dist/phases/statistics/MarkerGrouping.d.ts +0 -9
  57. package/dist/phases/statistics/MarkerGrouping.js +0 -16
  58. package/dist/phases/styles/StylesPhase.d.ts +3 -3
  59. package/dist/phases/styles/StylesPhase.js +2 -2
  60. package/dist/phases/tooltip/TooltipPhase.d.ts +4 -4
  61. package/dist/phases/tooltip/TooltipPhase.js +10 -7
  62. package/dist/phases/transforms/TransformsPhase.d.ts +3 -3
  63. package/dist/phases/transforms/TransformsPhase.js +2 -2
  64. package/dist/plots/correlation/heatmap/defaults.d.ts +2 -2
  65. package/dist/plots/correlation/heatmap/defaults.js +21 -6
  66. package/dist/plots/correlation/heatmap/markers.d.ts +2 -2
  67. package/dist/plots/correlation/heatmap/markers.js +4 -3
  68. package/dist/plots/correlation/scatter/defaults.d.ts +2 -2
  69. package/dist/plots/correlation/scatter/defaults.js +9 -3
  70. package/dist/plots/correlation/scatter/markers.d.ts +2 -2
  71. package/dist/plots/correlation/scatter/markers.js +4 -3
  72. package/dist/plots/distribution/box/BoxSummaries.d.ts +17 -8
  73. package/dist/plots/distribution/box/BoxSummaries.js +90 -40
  74. package/dist/plots/distribution/box/defaults.d.ts +2 -2
  75. package/dist/plots/distribution/box/defaults.js +9 -6
  76. package/dist/plots/distribution/box/markers.d.ts +2 -2
  77. package/dist/plots/distribution/box/markers.js +3 -3
  78. package/dist/plots/distribution/density/defaults.d.ts +2 -2
  79. package/dist/plots/distribution/density/defaults.js +17 -1
  80. package/dist/plots/distribution/density/markers.d.ts +2 -2
  81. package/dist/plots/distribution/density/markers.js +4 -4
  82. package/dist/plots/distribution/histogram/defaults.d.ts +2 -2
  83. package/dist/plots/distribution/histogram/defaults.js +20 -25
  84. package/dist/plots/distribution/histogram/markers.d.ts +2 -2
  85. package/dist/plots/distribution/histogram/markers.js +5 -4
  86. package/dist/plots/distribution/pyramid/defaults.d.ts +2 -2
  87. package/dist/plots/distribution/pyramid/defaults.js +4 -1
  88. package/dist/plots/distribution/pyramid/markers.d.ts +2 -2
  89. package/dist/plots/distribution/pyramid/markers.js +4 -3
  90. package/dist/plots/distribution/violin/defaults.d.ts +2 -2
  91. package/dist/plots/distribution/violin/defaults.js +9 -7
  92. package/dist/plots/distribution/violin/markers.d.ts +2 -2
  93. package/dist/plots/distribution/violin/markers.js +3 -3
  94. package/dist/plots/evolution/area/defaults.d.ts +2 -2
  95. package/dist/plots/evolution/area/defaults.js +1 -1
  96. package/dist/plots/evolution/area/markers.d.ts +2 -2
  97. package/dist/plots/evolution/area/markers.js +4 -4
  98. package/dist/plots/evolution/line/defaults.d.ts +2 -2
  99. package/dist/plots/evolution/line/defaults.js +1 -1
  100. package/dist/plots/evolution/line/markers.d.ts +2 -2
  101. package/dist/plots/evolution/line/markers.js +3 -3
  102. package/dist/plots/evolution/slope/defaults.d.ts +2 -2
  103. package/dist/plots/evolution/slope/defaults.js +8 -4
  104. package/dist/plots/evolution/slope/markers.d.ts +2 -2
  105. package/dist/plots/evolution/slope/markers.js +3 -3
  106. package/dist/plots/evolution/sparkline/defaults.d.ts +2 -2
  107. package/dist/plots/evolution/sparkline/defaults.js +5 -2
  108. package/dist/plots/evolution/sparkline/markers.d.ts +2 -2
  109. package/dist/plots/evolution/sparkline/markers.js +3 -3
  110. package/dist/plots/map/geo/Core.svelte +3 -3
  111. package/dist/plots/map/geo/defaults.d.ts +2 -2
  112. package/dist/plots/map/geo/phases/data.d.ts +1 -1
  113. package/dist/plots/map/geo/phases/data.js +1 -1
  114. package/dist/plots/map/geo/phases/hover.d.ts +2 -2
  115. package/dist/plots/map/geo/phases/hover.js +3 -3
  116. package/dist/plots/map/geo/phases/markers.d.ts +2 -2
  117. package/dist/plots/map/geo/phases/markers.js +3 -3
  118. package/dist/plots/map/geo/phases/scales.d.ts +2 -2
  119. package/dist/plots/map/geo/phases/scales.js +2 -2
  120. package/dist/plots/part-of-a-whole/treemap/defaults.d.ts +2 -2
  121. package/dist/plots/part-of-a-whole/treemap/defaults.js +37 -21
  122. package/dist/plots/ranking/bar/defaults.d.ts +2 -2
  123. package/dist/plots/ranking/bar/defaults.js +13 -7
  124. package/dist/plots/ranking/bar/markers.d.ts +3 -3
  125. package/dist/plots/ranking/bar/markers.js +8 -7
  126. package/dist/plots/ranking/bullet/defaults.d.ts +2 -2
  127. package/dist/plots/ranking/bullet/defaults.js +4 -4
  128. package/dist/plots/ranking/bullet/markers.d.ts +3 -3
  129. package/dist/plots/ranking/bullet/markers.js +9 -9
  130. package/dist/plots/ranking/cleveland/ClevelandMarkers.d.ts +3 -3
  131. package/dist/plots/ranking/cleveland/ClevelandMarkers.js +11 -10
  132. package/dist/plots/ranking/cleveland/defaults.d.ts +2 -2
  133. package/dist/plots/ranking/cleveland/defaults.js +7 -4
  134. package/dist/plots/ranking/dumbbell/defaults.d.ts +2 -2
  135. package/dist/plots/ranking/forest/defaults.d.ts +2 -2
  136. package/dist/plots/ranking/lollipop/defaults.d.ts +2 -2
  137. package/dist/types/configuration/styling.d.ts +4 -0
  138. package/dist/types/layout/context.d.ts +21 -0
  139. package/dist/types/layout/context.js +1 -0
  140. package/dist/types/layout/hover.d.ts +3 -0
  141. package/dist/types/layout/styles/values.d.ts +8 -2
  142. package/dist/types/layout/tooltip.d.ts +5 -10
  143. package/dist/types/markers/axis/axisBasedMarkersConfig.d.ts +2 -1
  144. package/dist/types/markers/axis/band.d.ts +24 -0
  145. package/dist/types/markers/axis/band.js +1 -0
  146. package/dist/types/markers/axis/bar.d.ts +2 -2
  147. package/dist/types/markers/axis/hover.d.ts +60 -15
  148. package/dist/types/markers/channels/commonMarkerConfig.d.ts +6 -2
  149. package/dist/types/markers/common.d.ts +1 -0
  150. package/dist/types/markers/common.js +1 -0
  151. package/dist/types/phases/context/phase.d.ts +7 -0
  152. package/dist/types/phases/context/phase.js +1 -0
  153. package/dist/types/phases/data/phase.d.ts +2 -2
  154. package/dist/types/phases/hover/phase.d.ts +10 -7
  155. package/dist/types/phases/index.d.ts +2 -1
  156. package/dist/types/phases/kind.d.ts +11 -8
  157. package/dist/types/phases/mapping/phase.d.ts +2 -2
  158. package/dist/types/phases/markers/phase.d.ts +3 -3
  159. package/dist/types/phases/scales/phase.d.ts +4 -4
  160. package/dist/types/phases/stage.d.ts +3 -3
  161. package/dist/types/phases/state.d.ts +1 -1
  162. package/dist/types/phases/styles/phase.d.ts +3 -2
  163. package/dist/types/phases/transforms/phase.d.ts +2 -2
  164. package/dist/types/plots/constants.d.ts +3 -5
  165. package/dist/types/plots/correlation/heatmap/state.d.ts +2 -2
  166. package/dist/types/plots/correlation/scatter/state.d.ts +2 -2
  167. package/dist/types/plots/distribution/box/props.d.ts +23 -1
  168. package/dist/types/plots/distribution/box/state.d.ts +6 -17
  169. package/dist/types/plots/distribution/density/state.d.ts +2 -2
  170. package/dist/types/plots/distribution/histogram/props.d.ts +14 -1
  171. package/dist/types/plots/distribution/histogram/state.d.ts +2 -2
  172. package/dist/types/plots/distribution/pyramid/state.d.ts +2 -2
  173. package/dist/types/plots/distribution/violin/props.d.ts +2 -1
  174. package/dist/types/plots/distribution/violin/state.d.ts +2 -2
  175. package/dist/types/plots/evolution/area/state.d.ts +2 -2
  176. package/dist/types/plots/evolution/line/state.d.ts +2 -2
  177. package/dist/types/plots/evolution/slope/state.d.ts +2 -2
  178. package/dist/types/plots/evolution/sparkline/state.d.ts +2 -2
  179. package/dist/types/plots/map/geo/state.d.ts +1 -1
  180. package/dist/types/plots/part-of-a-whole/treemap/props.d.ts +14 -4
  181. package/dist/types/plots/part-of-a-whole/treemap/state.d.ts +2 -2
  182. package/dist/types/plots/props.d.ts +3 -0
  183. package/dist/types/plots/ranking/bar/state.d.ts +2 -2
  184. package/dist/types/plots/ranking/bullet/state.d.ts +2 -2
  185. package/dist/types/plots/ranking/cleveland/state.d.ts +2 -2
  186. package/dist/types/plots/ranking/dumbbell/state.d.ts +2 -2
  187. package/dist/types/plots/ranking/forest/state.d.ts +2 -2
  188. package/dist/types/plots/ranking/lollipop/state.d.ts +2 -2
  189. package/docs/markers.md +34 -2
  190. package/docs/plots/evolution/line.md +1 -1
  191. package/docs/plots/evolution/slope.md +1 -1
  192. package/docs/plots/part-of-a-whole/treemap.md +36 -2
  193. package/docs/plots/ranking/bar.md +1 -0
  194. package/docs/plots/ranking/cleveland.md +1 -1
  195. package/docs/state.md +33 -0
  196. package/docs/styles-and-segments.md +2 -2
  197. package/docs/theming.md +2 -1
  198. package/docs/tooltip-and-hover.md +81 -3
  199. package/examples/LineDates.svelte +1 -1
  200. package/examples/ResponsiveLine.svelte +3 -1
  201. package/examples/TreemapHover.svelte +25 -0
  202. package/examples/ValueLabels.svelte +1 -1
  203. package/llms-full.txt +8 -6
  204. package/llms.txt +2 -1
  205. package/package.json +1 -1
@@ -25,8 +25,8 @@ export class ClevelandMarkers {
25
25
  warned.clear();
26
26
  }
27
27
  /** The plot's connectors, then its dots, which draw on top of them. */
28
- marks = (state, ctx) => {
29
- const { cfg, interaction } = ctx;
28
+ marks = (state, env) => {
29
+ const { cfg, interaction } = env;
30
30
  const style = cfg[this.#options.config];
31
31
  const { isHorizontal } = ClevelandMarkers.#geometry(state);
32
32
  const ranges = ClevelandRanges.of(state, this.#options.fromBaseline ?? false, ClevelandConnector.ends(state), this.#options.interval ?? false);
@@ -187,6 +187,7 @@ export class ClevelandMarkers {
187
187
  type: 'dot',
188
188
  series: name,
189
189
  data: segment.data,
190
+ hover: 'style',
190
191
  ...(isHorizontal ? { x: value, y: category } : { x: category, y: value }),
191
192
  r,
192
193
  styles: {
@@ -206,7 +207,7 @@ export class ClevelandMarkers {
206
207
  ...caps,
207
208
  ...arrows,
208
209
  ...dots,
209
- ...this.#connectorLabels(state, ctx, connector, looks, isHorizontal)
210
+ ...this.#connectorLabels(state, env, connector, looks, isHorizontal)
210
211
  ];
211
212
  };
212
213
  /** The dash, cap and join a connector is drawn with, leaving out what is not set. */
@@ -243,7 +244,7 @@ export class ClevelandMarkers {
243
244
  }));
244
245
  }
245
246
  /** The label on each connector, when `styles.connector.label` asks for one: written at its middle, beside it or on it. */
246
- #connectorLabels(state, ctx, connector, looks, isHorizontal) {
247
+ #connectorLabels(state, env, connector, looks, isHorizontal) {
247
248
  const label = connector.label;
248
249
  if (!label)
249
250
  return [];
@@ -255,7 +256,7 @@ export class ClevelandMarkers {
255
256
  return [];
256
257
  const font = label.fontStyle;
257
258
  // Beside a connector: clear of half its thickest, and a few px.
258
- const clear = Math.max(...data.map((row) => Number(row.strokeWidth))) / 2 + ctx.cfg.connector.labelGap;
259
+ const clear = Math.max(...data.map((row) => Number(row.strokeWidth))) / 2 + env.cfg.connector.labelGap;
259
260
  const inside = label.anchor === 'middle';
260
261
  const at = inside
261
262
  ? { dx: 0, dy: 0, textAnchor: 'middle', lineAnchor: 'middle' }
@@ -271,7 +272,7 @@ export class ClevelandMarkers {
271
272
  styles: {
272
273
  ...font,
273
274
  fill: font?.fill ?? 'currentColor',
274
- fontSize: font?.fontSize ?? ctx.cfg.connector.labelFontSize,
275
+ fontSize: font?.fontSize ?? env.cfg.connector.labelFontSize,
275
276
  dx: font?.dx ?? at.dx,
276
277
  dy: font?.dy ?? at.dy,
277
278
  textAnchor: font?.textAnchor && font.textAnchor !== 'outside' ? font.textAnchor : at.textAnchor,
@@ -286,7 +287,7 @@ export class ClevelandMarkers {
286
287
  * of it), past the bottom end (below, or left of it) and, for the dots
287
288
  * between, beside it - and per series, when they take their series' color.
288
289
  */
289
- valueLabels = (labels, state, ctx) => {
290
+ valueLabels = (labels, state, env) => {
290
291
  if (!state.processedData?.data.length)
291
292
  return [];
292
293
  const { isHorizontal } = ClevelandMarkers.#geometry(state);
@@ -294,7 +295,7 @@ export class ClevelandMarkers {
294
295
  const { font, format } = labels;
295
296
  const read = ValueLabels.valueOf(state);
296
297
  const valueOf = ProcessedPositions.of(state.processedData, PlotAxes.valueOf(state))[PlotAxes.valueOf(state)];
297
- const gap = labels.offset(isHorizontal ? 'x' : 'y', ctx.cfg[this.#options.config].labelGap);
298
+ const gap = labels.offset(isHorizontal ? 'x' : 'y', env.cfg[this.#options.config].labelGap);
298
299
  const nameOf = (d) => String(d[SERIES_KEY]);
299
300
  const picked = this.#picked(state);
300
301
  // Where a label sits from its dot, by role: along the range (past an end) or across it (between).
@@ -329,7 +330,7 @@ export class ClevelandMarkers {
329
330
  type: 'text',
330
331
  data,
331
332
  ...(isHorizontal ? { x: value, y: category } : { x: category, y: value }),
332
- text: (d) => format(Number(read(d) ?? valueOf(d)), nameOf(d), d),
333
+ text: (d) => format(Number(read(d) ?? valueOf(d)), d, nameOf(d)),
333
334
  styles: {
334
335
  ...font,
335
336
  fill: fillOf(name),
@@ -358,7 +359,7 @@ export class ClevelandMarkers {
358
359
  return [labels.edgeBox('0', { x: 'middle', y: 'before' }, at, ['top'])];
359
360
  }
360
361
  const at = { x: labels.offset('x', gap) };
361
- const texts = new Set(top.map(({ dot }) => labels.format(dot.value, dot.series, dot.row)));
362
+ const texts = new Set(top.map(({ dot }) => labels.format(dot.value, dot.row, dot.series)));
362
363
  return [...texts].map((text) => labels.edgeBox(text, { x: 'after', y: 'middle' }, at, ['right']));
363
364
  };
364
365
  /**
@@ -1,5 +1,5 @@
1
1
  import type { AxisPlotDefaults } from '../../../types/phases';
2
- import type { ClevelandOptions, ClevelandPlotState, ClevelandPlotCtx } from '../../../types/plots/ranking/cleveland/state';
2
+ import type { ClevelandOptions, ClevelandPlotState, ClevelandPlotEnv } from '../../../types/plots/ranking/cleveland/state';
3
3
  /**
4
4
  * ClevelandPlot on the shared pipeline, and the base of its wrappers: per
5
5
  * category along one category axis - `x`, or `y` for sideways rows, as the
@@ -10,4 +10,4 @@ import type { ClevelandOptions, ClevelandPlotState, ClevelandPlotCtx } from '../
10
10
  * what it checks about the series before drawing. Its plot defaults to hover
11
11
  * along the category axis.
12
12
  */
13
- export declare function buildClevelandDefaults<TData extends Record<string, unknown>>(options?: ClevelandOptions): AxisPlotDefaults<ClevelandPlotState<TData>, ClevelandPlotCtx>;
13
+ export declare function buildClevelandDefaults<TData extends Record<string, unknown>>(options?: ClevelandOptions): AxisPlotDefaults<ClevelandPlotState<TData>, ClevelandPlotEnv>;
@@ -1,4 +1,5 @@
1
1
  import { ClevelandMarkers } from './ClevelandMarkers';
2
+ import { HoverDefaults } from '../../../layout/hover/HoverDefaults';
2
3
  import { ClevelandRanges } from './ClevelandRanges';
3
4
  import { NiceTicks } from '../../../layout/scales/NiceTicks';
4
5
  import { PlotAxes } from '../../../phases/data/PlotAxes';
@@ -53,16 +54,18 @@ export function buildClevelandDefaults(options = { name: 'ClevelandPlot', config
53
54
  fit: options.interval
54
55
  ? (state) => fitInterval(state, options.fromBaseline ?? false)
55
56
  : undefined,
56
- defaults: (_state, ctx) => ({
57
+ defaults: (_state, env) => ({
57
58
  category: {
58
- paddingInner: ctx.cfg[options.config].paddingInner,
59
- paddingOuter: ctx.cfg[options.config].paddingOuter
59
+ paddingInner: env.cfg[options.config].paddingInner,
60
+ paddingOuter: env.cfg[options.config].paddingOuter
60
61
  }
61
62
  })
62
63
  },
63
64
  // A dot is labelled by what its category's dots say: the first, the highest... of each.
64
65
  transforms: { labels: { group: 'category', skip: ClevelandRanges.skipGaps } },
65
66
  styles: { values: { reach: markers.reach } },
66
- markers: { marks: markers.marks, valueLabels: markers.valueLabels }
67
+ markers: { marks: markers.marks, valueLabels: markers.valueLabels },
68
+ // A rule along the value axis at the hovered dot, and a dot and a label on each one of its category.
69
+ hover: { marker: (state) => HoverDefaults.valueRule(PlotAxes.valueOf(state)) }
67
70
  };
68
71
  }
@@ -1,9 +1,9 @@
1
1
  import type { AxisPlotDefaults } from '../../../types/phases';
2
- import type { DumbbellPlotState, DumbbellPlotCtx } from '../../../types/plots/ranking/dumbbell/state';
2
+ import type { DumbbellPlotState, DumbbellPlotEnv } from '../../../types/plots/ranking/dumbbell/state';
3
3
  /**
4
4
  * DumbbellPlot on the shared pipeline: a ClevelandPlot of exactly two series,
5
5
  * so every category is two dots joined by a connector - the change, or the gap,
6
6
  * between them. It warns when it has another number of series, which
7
7
  * `LollipopPlot` (one) and `ClevelandPlot` (any) are for.
8
8
  */
9
- export declare function buildDumbbellDefaults<TData extends Record<string, unknown>>(): AxisPlotDefaults<DumbbellPlotState<TData>, DumbbellPlotCtx>;
9
+ export declare function buildDumbbellDefaults<TData extends Record<string, unknown>>(): AxisPlotDefaults<DumbbellPlotState<TData>, DumbbellPlotEnv>;
@@ -1,5 +1,5 @@
1
1
  import type { AxisPlotDefaults } from '../../../types/phases';
2
- import type { ForestPlotState, ForestPlotCtx } from '../../../types/plots/ranking/forest/state';
2
+ import type { ForestPlotState, ForestPlotEnv } from '../../../types/plots/ranking/forest/state';
3
3
  /**
4
4
  * ForestPlot on the shared pipeline: a ClevelandPlot whose dot is an estimate
5
5
  * and whose stem is its interval - each row's `lower` and `upper`, or `error`
@@ -8,4 +8,4 @@ import type { ForestPlotState, ForestPlotCtx } from '../../../types/plots/rankin
8
8
  * for - or `facet`, to compare the series side by side. The value axis fits the
9
9
  * intervals' ends.
10
10
  */
11
- export declare function buildForestDefaults<TData extends Record<string, unknown>>(): AxisPlotDefaults<ForestPlotState<TData>, ForestPlotCtx>;
11
+ export declare function buildForestDefaults<TData extends Record<string, unknown>>(): AxisPlotDefaults<ForestPlotState<TData>, ForestPlotEnv>;
@@ -1,9 +1,9 @@
1
1
  import type { AxisPlotDefaults } from '../../../types/phases';
2
- import type { LollipopPlotState, LollipopPlotCtx } from '../../../types/plots/ranking/lollipop/state';
2
+ import type { LollipopPlotState, LollipopPlotEnv } from '../../../types/plots/ranking/lollipop/state';
3
3
  /**
4
4
  * LollipopPlot on the shared pipeline: a ClevelandPlot of one value per
5
5
  * category, whose stem rises from the baseline - zero, or the nearest end of a
6
6
  * pinned value domain - to the dot. It warns when a category has values in
7
7
  * several series, which `DumbbellPlot` and `ClevelandPlot` are for.
8
8
  */
9
- export declare function buildLollipopDefaults<TData extends Record<string, unknown>>(): AxisPlotDefaults<LollipopPlotState<TData>, LollipopPlotCtx>;
9
+ export declare function buildLollipopDefaults<TData extends Record<string, unknown>>(): AxisPlotDefaults<LollipopPlotState<TData>, LollipopPlotEnv>;
@@ -243,6 +243,8 @@ export type PlotStylesConfig = {
243
243
  dot: DotStyle;
244
244
  font: FontStyle;
245
245
  area: AreaStyle;
246
+ /** How a hovered shape looks on a plot whose hover only restyles its shapes (a treemap's tile, a heatmap's cell). */
247
+ active: StrokeStyle;
246
248
  };
247
249
  facet: {
248
250
  /** Position badge shown in `carousel`/`paginated` facet modes. */
@@ -379,6 +381,8 @@ export type PlotStylesConfig = {
379
381
  /** Gap, in px, between a connector and its label when it is written beside it. */
380
382
  labelGap: number;
381
383
  };
384
+ /** The `band` marker's style, under its own `styles`. */
385
+ band: AreaStyle;
382
386
  /** The `delta` marker's label offset and anchor, per axis the delta is taken on. A marker's own `text` wins. */
383
387
  delta: {
384
388
  text: Record<'x' | 'y', {
@@ -0,0 +1,21 @@
1
+ /**
2
+ * What a plot knows of one of the rows it draws: the series it is drawn in, where it sits, and the value it shows
3
+ * - the dataset's own, or the one the plot works out for it (a density's estimate, a bin's count). It is worked
4
+ * out once per row, as the plot reads its data, and every place that writes about a row reads it: a tooltip's
5
+ * `format`, a hover's points and labels, the value labels, and an author's own markers (see `RowContext.of`).
6
+ * A plot kind that works out more about a row gives a type that extends this one.
7
+ */
8
+ export type PlotRowContext<TRow = Record<string, unknown>> = {
9
+ /** The name of the series the row is drawn in, on the plots that have series. */
10
+ series?: string;
11
+ /** The row's value on `x`: its own (not a stack's running total), else where the plot's transforms put it. */
12
+ x?: unknown;
13
+ /** The row's value on `y`, as `x`. */
14
+ y?: unknown;
15
+ /** The value the row shows, on the plot's value axis, when it is a number. */
16
+ value?: number;
17
+ /** The row itself, as the plot drew it: the data's fields, plus whatever its transforms added. */
18
+ row?: TRow;
19
+ };
20
+ /** A plot kind's own context of a row: the shared one, with what the kind works out for it. */
21
+ export type KindRowContext<TExtra extends object, TRow = Record<string, unknown>> = PlotRowContext<TRow> & TExtra;
@@ -0,0 +1 @@
1
+ export {};
@@ -1,3 +1,4 @@
1
+ import type { PlotRowContext } from './context';
1
2
  import type { AxisValue } from './mapping';
2
3
  /**
3
4
  * How the hover highlight finds related points within a facet.
@@ -41,6 +42,8 @@ export type HoverDisplayPoint = {
41
42
  color?: string;
42
43
  /** A 'grouped' series' own slice of the category band, as start/end fractions (0-1) of the whole band. `undefined` means the whole band. */
43
44
  areaInset?: BandSlice;
45
+ /** What the plot knows of the point's row: its series, where it sits, its value and whatever its kind works out - see {@link PlotRowContext}. */
46
+ context?: PlotRowContext;
44
47
  };
45
48
  /** A candidate point for hover matching/highlighting - also carries its source row. */
46
49
  export type HoverPoint<T> = HoverDisplayPoint & {
@@ -1,6 +1,7 @@
1
1
  import type { ValueAnchor } from '../../plots/constants';
2
2
  import type { FontStyle, StrokeStyle } from '../../plots/styling';
3
3
  import type { NumberDisplay } from '../numbers';
4
+ import type { PlotRowContext } from '../context';
4
5
  /**
5
6
  * Which of a group's rows get a value label: its first or last, or the one
6
7
  * with the lowest or highest value (read on the plot's value axis). The group
@@ -38,8 +39,13 @@ export type ValuesStyle = NumberDisplay & {
38
39
  * CSS color writes them all in it. `fontStyle.fill` wins when it is set.
39
40
  */
40
41
  color?: 'series' | (string & {});
41
- /** A label's text, in place of the value as `decimals`, `prefix`, `suffix` and `signDisplay` write it, from its row's own value (a histogram bin's count) and its series - and, on the plots that label one row each, that row, for the other fields of the data. */
42
- format?: (value: number, seriesName: string, row?: Record<string, unknown>, number?: (value: number) => string) => string;
42
+ /**
43
+ * A label's text, in place of the value as `decimals`, `prefix`, `suffix` and `signDisplay` write it: from the
44
+ * value it shows (a histogram bin's count, a tile's share), `number`, which writes a value as those fields ask,
45
+ * and `context`, what the plot knows of the labelled row - its `series`, `x`, `y`, whatever its kind works out
46
+ * and, where the label has one, the `row` itself, for the other fields of the data (see {@link PlotRowContext}).
47
+ */
48
+ format?: (value: number, number: (value: number) => string, context: PlotRowContext) => string;
43
49
  /** Hovering a label dims every other series, like toggling them off in the legend. */
44
50
  hoverIsolate?: boolean;
45
51
  fontStyle?: FontStyle;
@@ -1,6 +1,7 @@
1
1
  import type { Snippet } from 'svelte';
2
2
  import type { HoverStrategy } from './hover';
3
3
  import type { NumberDisplay } from './numbers';
4
+ import type { PlotRowContext } from './context';
4
5
  /**
5
6
  * Preferred horizontal placement of the tooltip beside the cursor; it moves
6
7
  * to the other side when it would overflow. Defaults to `'right'`.
@@ -12,15 +13,8 @@ export type TooltipAnchorY = 'top' | 'middle' | 'bottom';
12
13
  export type TooltipRow<TRow> = TRow & {
13
14
  seriesColor?: string;
14
15
  };
15
- /**
16
- * What a plot knows of a hovered row beyond its own fields, the third argument of a tooltip's `format`:
17
- * the series it is drawn in, on the plots that have series. A plot kind that works out more about a row
18
- * gives a type that extends this one.
19
- */
20
- export type TooltipContext = {
21
- /** The name of the series the row is drawn in. */
22
- series?: string;
23
- };
16
+ /** What a plot knows of a hovered row, the third argument of a tooltip's `format` - see {@link PlotRowContext}. */
17
+ export type TooltipContext = PlotRowContext;
24
18
  /**
25
19
  * Author-facing tooltip option on the chart kinds. `true` = enable with defaults. `decimals`, `prefix`,
26
20
  * `suffix` and `signDisplay` write the value the default text shows - the one on the plot's value axis (the
@@ -33,7 +27,8 @@ export type TooltipOptions<TRow extends Record<string, unknown>, TContext extend
33
27
  sync?: boolean;
34
28
  /**
35
29
  * Custom tooltip text for a row (supports `\n`). Defaults per chart kind. `number` writes a value as the display
36
- * fields above ask, and `context` is what the plot knows of the row - see {@link TooltipContext}.
30
+ * fields above ask, and `context` is what the plot knows of the row: its series, `x`, `y`, the value it shows and
31
+ * whatever its kind works out (a tile's share, a box's quartiles) - see {@link PlotRowContext}.
37
32
  */
38
33
  format?: (row: TRow, number: (value: number) => string, context: TContext) => string;
39
34
  /** Named subset of crossing series to include. Omitted = all matched. */
@@ -23,8 +23,9 @@ import type { TrailMarkerConfig } from './trail';
23
23
  import type { WaffleMarkerConfig } from './waffle';
24
24
  import type { ViolinMarkerConfig } from './violin';
25
25
  import type { RuleMarkerConfig } from './rule';
26
+ import type { BandMarkerConfig } from './band';
26
27
  import type { HoverMarkerConfig } from './hover';
27
28
  import type { CustomComponentMarkerConfig } from './component';
28
29
  import type { DeltaMarkerConfig } from './delta';
29
30
  /** Every marker kind an axis-based plot can render. */
30
- export type AxisBasedMarkersConfig = BasicMarkersConfig | LineMarkerConfig | BarMarkerConfig | CellMarkerConfig | RectMarkerConfig | RegressionMarkerConfig | BollingerMarkerConfig | AreaMarkerConfig | DensityMarkerConfig | BoxMarkerConfig | HullMarkerConfig | DifferenceMarkerConfig | ArrowMarkerConfig | BrushMarkerConfig | DelaunayLinkMarkerConfig | DelaunayMeshMarkerConfig | VoronoiMarkerConfig | VoronoiMeshMarkerConfig | ImageMarkerConfig | RasterMarkerConfig | TickMarkerConfig | TrailMarkerConfig | WaffleMarkerConfig | ViolinMarkerConfig | RuleMarkerConfig | HoverMarkerConfig | CustomComponentMarkerConfig | DeltaMarkerConfig;
31
+ export type AxisBasedMarkersConfig = BasicMarkersConfig | LineMarkerConfig | BarMarkerConfig | CellMarkerConfig | RectMarkerConfig | RegressionMarkerConfig | BollingerMarkerConfig | AreaMarkerConfig | DensityMarkerConfig | BoxMarkerConfig | HullMarkerConfig | DifferenceMarkerConfig | ArrowMarkerConfig | BrushMarkerConfig | DelaunayLinkMarkerConfig | DelaunayMeshMarkerConfig | VoronoiMarkerConfig | VoronoiMeshMarkerConfig | ImageMarkerConfig | RasterMarkerConfig | TickMarkerConfig | TrailMarkerConfig | WaffleMarkerConfig | ViolinMarkerConfig | RuleMarkerConfig | BandMarkerConfig | HoverMarkerConfig | CustomComponentMarkerConfig | DeltaMarkerConfig;
@@ -0,0 +1,24 @@
1
+ import type { AxisValue } from '../../layout/mapping';
2
+ import type { BandSlice } from '../../layout/hover';
3
+ import type { AreaStyle, PerRow } from '../../plots/styling';
4
+ import type { CommonMarkerConfig } from '../channels/commonMarkerConfig';
5
+ /**
6
+ * The band of a category on a band axis, across the whole of the other axis: one per category, however many rows
7
+ * name it. On an axis that is not a band scale it draws nothing.
8
+ */
9
+ export type BandMarkerConfig = {
10
+ type: 'band';
11
+ axis: 'x' | 'y';
12
+ /**
13
+ * Which band. A list draws one at each category (without `data`); with `data`, a field key or a function of the
14
+ * row gives each row's own.
15
+ */
16
+ value: AxisValue | string | (AxisValue | string)[] | ((d: any) => AxisValue);
17
+ /**
18
+ * The part of the band it fills, as the fractions of its width left out at its start and its end (a grouped
19
+ * bar's series' slice). A function of the row gives each row's own; a band several rows share fills what all of
20
+ * them do. Unset, the whole band.
21
+ */
22
+ slice?: BandSlice | ((d: any) => BandSlice | undefined);
23
+ styles?: PerRow<AreaStyle>;
24
+ } & Omit<CommonMarkerConfig, 'x' | 'y'>;
@@ -0,0 +1 @@
1
+ export {};
@@ -3,10 +3,10 @@ import type { AreaStyle, PerRow, InsetStyle } from '../../plots/styling';
3
3
  import type { CommonMarkerConfigWithLabel } from '../channels/commonMarkerConfigWithLabel';
4
4
  import type { CommonMarkerConfigWithColor } from '../channels/commonMarkerConfigWithColor';
5
5
  import type { CommonMarkerConfigWithInterval } from '../channels/commonMarkerConfigWithInterval';
6
- /** A bar mark; `role` tells a visible segment from the hover hit area and highlight. */
6
+ /** A bar mark; `role` tells a visible segment from the hover hit area. */
7
7
  export type BarMarkerConfig = {
8
8
  type: 'bar';
9
- role: 'segment' | 'hitArea' | 'highlight';
9
+ role: 'segment' | 'hitArea';
10
10
  isHorizontal: boolean;
11
11
  thickness?: number;
12
12
  styles?: PerRow<AreaStyle> & InsetStyle;
@@ -1,10 +1,54 @@
1
- import type { AreaStyle, DotStyle, FontStyle, StrokeStyle } from '../../plots/styling';
1
+ import type { AxisBasedMarkersConfig } from './axisBasedMarkersConfig';
2
2
  import type { HoverDisplayPoint, HoverStrategy } from '../../layout/hover';
3
3
  import type { NumberDisplay } from '../../layout/numbers';
4
+ import type { LineStyle } from '../../plots/constants';
5
+ /** A style value: the same for every shape, or a function of the row a shape draws. */
6
+ type ShapeStyleValue<T> = T | ((row: any) => T);
4
7
  /**
5
- * In-SVG hover highlight: crosshair, dot and label. The label is the hovered value as `decimals`, `prefix`,
6
- * `suffix` and `signDisplay` write it - as the plot writes it while none of them (nor `numbers.decimals`) is set -
7
- * unless `format` writes it.
8
+ * How the shapes of a marker linked to the hover (`hover: true` or `'style'`) look while the hover is on: the
9
+ * hovered ones under `active`, the rest under `others`. Each value replaces the shape's own, and may be a
10
+ * function of its row.
11
+ */
12
+ export type HoverShapeStyle = {
13
+ fill?: ShapeStyleValue<string>;
14
+ fillOpacity?: ShapeStyleValue<number>;
15
+ stroke?: ShapeStyleValue<string>;
16
+ strokeWidth?: ShapeStyleValue<number>;
17
+ strokeOpacity?: ShapeStyleValue<number>;
18
+ strokeDasharray?: string | LineStyle;
19
+ };
20
+ /** `T` with its `K` fields left to be set. */
21
+ type Optional<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
22
+ /** A marker as the hover takes it: a `rule`'s and a `band`'s `value` and a `text`'s `text` default to the point's. */
23
+ type InHover<T> = T extends {
24
+ type: 'rule' | 'band';
25
+ } ? Optional<T, 'value' & keyof T> : T extends {
26
+ type: 'text';
27
+ } ? Optional<T, 'text' & keyof T> : T;
28
+ /**
29
+ * A marker the hover draws: any marker but another hover, over the hovered points. Without `data` of its own its
30
+ * rows are the points - each its `x`, `y`, `label` (written as the hover marker's number fields ask), `series`,
31
+ * `color` (its series'), `areaInset` (its slice of the band) and `row` (the row it stands for) - and its `x` and
32
+ * `y` default to the point's. What it leaves unset comes from the hover: a `rule` sits at each point along its
33
+ * `axis`, a `band` around it (in its series' slice), a `text` writes its label; each in the configuration's `hover`
34
+ * look (a `rect` in its `area`), and a `dot` and a `text` in the point's series color.
35
+ */
36
+ export type HoverLayerMarker = InHover<Exclude<AxisBasedMarkersConfig, {
37
+ type: 'hover';
38
+ }>> & {
39
+ /**
40
+ * Which points it draws: every one the hover matches (the default), only the one under the pointer, or those a
41
+ * function of the point keeps.
42
+ */
43
+ points?: 'all' | 'active' | ((point: HoverDisplayPoint) => boolean);
44
+ };
45
+ /**
46
+ * The plot's hover, inside the plot: how the hovered shapes look (`active`) and the rest (`others`), and the
47
+ * markers it draws behind the plot's shapes (`back`) and in front of them (`front`) - a rule, a band, a dot, a
48
+ * label, a component. Each plot kind has a hover of its own that this one is laid over: `active` and `others`
49
+ * field by field, `back` and `front` replacing the kind's lists when set (`back: []` draws nothing behind).
50
+ * The points' label is the hovered value as `decimals`, `prefix`, `suffix` and `signDisplay` write it - as the
51
+ * plot writes it while none of them (nor `numbers.decimals`) is set - unless `format` writes it.
8
52
  */
9
53
  export type HoverMarkerConfig = NumberDisplay & {
10
54
  type: 'hover';
@@ -12,16 +56,17 @@ export type HoverMarkerConfig = NumberDisplay & {
12
56
  scope?: 'series' | 'segment';
13
57
  strategy?: HoverStrategy;
14
58
  sync?: boolean;
15
- ruleX?: boolean;
16
- ruleY?: boolean;
17
- /** A thickened highlight area in place of a thin crosshair; meaningful on band scales only. */
18
- areaX?: boolean;
19
- areaY?: boolean;
20
- showLabels?: boolean;
21
- /** The label's text for a point, in place of the value. `number` writes a value as the display fields above ask. */
59
+ /** How the hovered shapes of every marker linked to the hover look - the plot's own tiles, bars and cells among them. */
60
+ active?: HoverShapeStyle;
61
+ /** How the shapes the hover does not reach look, while it is on. */
62
+ others?: HoverShapeStyle;
63
+ /** The markers drawn behind every other one of the plot, over the hovered points. */
64
+ back?: HoverLayerMarker[];
65
+ /** The markers drawn in front of the plot's shapes, over the hovered points. */
66
+ front?: HoverLayerMarker[];
67
+ /** A point's label, in place of its value. `number` writes a value as the display fields above ask. */
22
68
  format?: (point: HoverDisplayPoint, number: (value: number) => string) => string;
23
- rule?: StrokeStyle;
24
- area?: AreaStyle;
25
- dot?: DotStyle;
26
- text?: FontStyle;
27
69
  };
70
+ /** What a plot kind's own hover is made of, which an author's `hover` marker is laid over. */
71
+ export type HoverLook = Pick<HoverMarkerConfig, 'active' | 'others' | 'back' | 'front'>;
72
+ export {};
@@ -28,6 +28,10 @@ export type CommonMarkerConfig = CommonMarkerEvents & {
28
28
  clip?: boolean;
29
29
  /** Names the marker on its plot's automatic legend - see {@link MarkLegend}. `false` keeps a decorative marker out of it, and out of how the plot's series look there. */
30
30
  legend?: MarkLegend | false;
31
- /** Makes the marker a hit area of the plot's hover: the pointer entering any of its shapes hovers its `data` rows. */
32
- hover?: boolean;
31
+ /**
32
+ * Links the marker to the plot's hover. `'trigger'` makes it a hit area: the pointer entering any of its shapes
33
+ * hovers its `data` rows. `'style'` has its shapes take the hover marker's `active` and `others` styles.
34
+ * `true` does both.
35
+ */
36
+ hover?: boolean | 'trigger' | 'style';
33
37
  };
@@ -22,6 +22,7 @@ export * from './axis/trail';
22
22
  export * from './axis/waffle';
23
23
  export * from './axis/violin';
24
24
  export * from './axis/rule';
25
+ export * from './axis/band';
25
26
  export * from './axis/hover';
26
27
  export * from './axis/component';
27
28
  export * from './axis/axisBasedMarkersConfig';
@@ -22,6 +22,7 @@ export * from './axis/trail';
22
22
  export * from './axis/waffle';
23
23
  export * from './axis/violin';
24
24
  export * from './axis/rule';
25
+ export * from './axis/band';
25
26
  export * from './axis/hover';
26
27
  export * from './axis/component';
27
28
  export * from './axis/axisBasedMarkersConfig';
@@ -0,0 +1,7 @@
1
+ /**
2
+ * What a plot kind works out for each of its processed rows beyond the shared context (its series, `x`, `y` and
3
+ * value): a tile's share, a bin's edges, a box's quartiles. Given the state once, it returns a function of a row,
4
+ * so whatever the rows share (a total, a box's summary) is worked out once. What it returns is laid over the
5
+ * shared context, so it can also replace the `value` a row shows.
6
+ */
7
+ export type ContextStageOptions<TState, TEnv = unknown> = (state: TState, env: TEnv) => (row: never) => object | undefined;
@@ -0,0 +1 @@
1
+ export {};
@@ -15,7 +15,7 @@ export type SegmentsStageOptions = {
15
15
  * which channels the author set, what each axis is, which way the plot runs,
16
16
  * whether `color` groups - the stage reads off the data itself.
17
17
  */
18
- export type DataStageOptions<TState, TCtx> = {
18
+ export type DataStageOptions<TState, TEnv> = {
19
19
  /** How many axes the kind lays out as categories: 0 (line), 1 (bar) or 2 (heatmap). Defaults to 0. */
20
20
  discreteAxes?: DiscreteAxesCount;
21
21
  /** How the kind's own mark splits into visual segments. */
@@ -30,5 +30,5 @@ export type DataStageOptions<TState, TCtx> = {
30
30
  */
31
31
  nested?: boolean;
32
32
  /** The plot's own extra "data" output, once the shared one is in place. */
33
- extend?: (state: TState, ctx: TCtx) => TState;
33
+ extend?: (state: TState, env: TEnv) => TState;
34
34
  };
@@ -1,5 +1,6 @@
1
1
  import type { HoverDisplayPoint, HoverStrategy } from '../../layout/hover';
2
2
  import type { HoverConfig, PointMatchingStrategy } from '../../plots/props';
3
+ import type { HoverLook } from '../../markers/common';
3
4
  /** Where a row sits for hover matching and the hover controller: its `x` and `y`. */
4
5
  export type HoverPosition = {
5
6
  x: (row: never) => unknown;
@@ -11,7 +12,7 @@ export type HoverPosition = {
11
12
  * row or a cell outside the legend's range can't), the rows themselves and
12
13
  * their series' colors - the stage reads off the plot's own state.
13
14
  */
14
- export type HoverStageOptions<TState, TCtx = unknown> = {
15
+ export type HoverStageOptions<TState, TEnv = unknown> = {
15
16
  /**
16
17
  * The hover strategy, when the plot's axes don't say it: along the axis
17
18
  * that isn't measured, or `'punctual'` with both axes holding categories.
@@ -27,16 +28,18 @@ export type HoverStageOptions<TState, TCtx = unknown> = {
27
28
  position?: (state: TState) => HoverPosition;
28
29
  /** The short label drawn next to a hovered row. Defaults to its value. */
29
30
  label?: (state: TState) => (row: never) => string;
30
- /** What a hovered row reads as, e.g. with derived fields added. Defaults to the processed row. */
31
- row?: (state: TState) => (row: never) => unknown;
32
31
  /** Fields a candidate carries besides its place, label and series color (a grouped bar's `dx`/`dy`). */
33
- decorate?: (state: TState, ctx: TCtx) => (row: never) => Partial<Omit<HoverDisplayPoint, 'x' | 'y' | 'label'>>;
32
+ decorate?: (state: TState, env: TEnv) => (row: never) => Partial<Omit<HoverDisplayPoint, 'x' | 'y' | 'label'>>;
34
33
  /** Invisible markers that drive the plot's hover themselves (a bar's band), given its resolved hover config. */
35
- hitAreas?: (state: TState, hover: HoverConfig<any>, ctx: TCtx) => {
34
+ hitAreas?: (state: TState, hover: HoverConfig<any>, env: TEnv) => {
36
35
  type: string;
37
36
  }[];
38
- /** What the kind knows of a row beyond its series, which an author's own tooltip `format` gets in its third argument. */
39
- context?: (state: TState) => (row: never) => object;
40
37
  /** How a pointer event resolves to a candidate. Defaults to the nearest one. */
41
38
  pointMatching?: PointMatchingStrategy;
39
+ /**
40
+ * The kind's own hover, which an author's `hover` marker is laid over - one look, or one for each strategy, as
41
+ * the strategy in force can change while the plot is shown (a composer's, a scrolly step's). Defaults to a
42
+ * crosshair along the axes the strategy matches along, and a dot and a label on each point.
43
+ */
44
+ marker?: (state: TState, env: TEnv) => HoverLook | ((strategy: HoverStrategy) => HoverLook);
42
45
  };
@@ -1,10 +1,11 @@
1
1
  export type { PlotPhase, PhaseStage } from './stage';
2
- export type { AxisPlotState, AxisPlotCtx } from './state';
2
+ export type { AxisPlotState, AxisPlotEnv } from './state';
3
3
  export type { AxisPlotKind, AxisPlotDefaults, SharedScalesOptions } from './kind';
4
4
  export type { DataRunState } from './pipeline';
5
5
  export type { DataStageOptions } from './data/phase';
6
6
  export type { MappingStageOptions } from './mapping/phase';
7
7
  export type { ProcessedRow, ProcessedChannel, ProcessedChannelName, ProcessedData, TransformsStageState, TransformsStageOptions } from './transforms/phase';
8
+ export type { ContextStageOptions } from './context/phase';
8
9
  export type { StatisticsStageState, StatisticsStageOptions } from './statistics/phase';
9
10
  export type { SharedAxisValues } from './sharedScales/phase';
10
11
  export type { AxisFit, ScalesStageOptions } from './scales/phase';
@@ -4,6 +4,7 @@ import type { TransformsStageOptions, TransformsStageState } from './transforms/
4
4
  import type { StatisticsStageOptions, StatisticsStageState } from './statistics/phase';
5
5
  import type { ScalesStageOptions } from './scales/phase';
6
6
  import type { HoverStageOptions } from './hover/phase';
7
+ import type { ContextStageOptions } from './context/phase';
7
8
  import type { StylesStageOptions } from './styles/phase';
8
9
  import type { MarkersStageOptions } from './markers/phase';
9
10
  import type { AxisChannelName, ChannelName } from '../layout/mapping';
@@ -12,15 +13,17 @@ import type { AxisRole } from './data/axes';
12
13
  * What one axis-based plot kind adds to the shared pipeline: options for each
13
14
  * shared stage - its own marks and value labels among them.
14
15
  */
15
- export type AxisPlotKind<TState extends TransformsStageState & StatisticsStageState, TCtx> = {
16
- data?: DataStageOptions<TState, TCtx>;
17
- mapping?: MappingStageOptions<TState, TCtx>;
18
- transforms?: TransformsStageOptions<TState, TCtx>;
16
+ export type AxisPlotKind<TState extends TransformsStageState & StatisticsStageState, TEnv> = {
17
+ data?: DataStageOptions<TState, TEnv>;
18
+ mapping?: MappingStageOptions<TState, TEnv>;
19
+ transforms?: TransformsStageOptions<TState, TEnv>;
20
+ /** What the kind works out for each of its rows, for everything that writes about a row to read - see `RowContext`. */
21
+ context?: ContextStageOptions<TState, TEnv>;
19
22
  statistics?: StatisticsStageOptions<TState>;
20
- scales?: ScalesStageOptions<TState, TCtx>;
23
+ scales?: ScalesStageOptions<TState, TEnv>;
21
24
  styles?: StylesStageOptions<TState>;
22
- markers: MarkersStageOptions<TState, TCtx>;
23
- hover?: HoverStageOptions<TState, TCtx>;
25
+ markers: MarkersStageOptions<TState, TEnv>;
26
+ hover?: HoverStageOptions<TState, TEnv>;
24
27
  /**
25
28
  * How the slices of a plot (facet panels, timeline steps) share their
26
29
  * domains. Every axis kind shares them - bands from its axes, zero from its
@@ -42,7 +45,7 @@ export type SharedScalesOptions = {
42
45
  * runs with: the options for each pipeline phase (its hover among them),
43
46
  * plus how its plot tweens a timeline unless the author says otherwise.
44
47
  */
45
- export type AxisPlotDefaults<TState extends TransformsStageState & StatisticsStageState, TCtx> = AxisPlotKind<TState, TCtx> & {
48
+ export type AxisPlotDefaults<TState extends TransformsStageState & StatisticsStageState, TEnv> = AxisPlotKind<TState, TEnv> & {
46
49
  timeline?: {
47
50
  /** Default for `timeline.filterMode`. */
48
51
  filterMode?: 'exact' | 'upTo';
@@ -1,5 +1,5 @@
1
1
  /** What differs between plots in the shared "mapping" stage. */
2
- export type MappingStageOptions<TState, TCtx> = {
2
+ export type MappingStageOptions<TState, TEnv> = {
3
3
  /** The plot's own extra "mapping" output, once every channel is resolved. */
4
- extend?: (state: TState, ctx: TCtx) => TState;
4
+ extend?: (state: TState, env: TEnv) => TState;
5
5
  };