@d3plus/core 4.9.0 → 4.10.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 (236) hide show
  1. package/es/internal.js +3 -1
  2. package/es/src/charts/BoxWhisker/index.js +73 -4
  3. package/es/src/charts/BoxWhisker/outliers.js +68 -0
  4. package/es/src/charts/BoxWhisker/summary.js +83 -0
  5. package/es/src/charts/BoxWhisker/tooltip.js +122 -0
  6. package/es/src/charts/Bullet/index.js +2 -1
  7. package/es/src/charts/BumpChart/index.js +5 -0
  8. package/es/src/charts/Calendar/index.js +2 -1
  9. package/es/src/charts/Candlestick/aggregate.js +11 -1
  10. package/es/src/charts/Candlestick/index.js +5 -5
  11. package/es/src/charts/Chord/index.js +3 -2
  12. package/es/src/charts/Funnel/index.js +2 -1
  13. package/es/src/charts/Gauge/index.js +2 -1
  14. package/es/src/charts/Geomap/index.js +9 -3
  15. package/es/src/charts/Histogram/index.js +5 -1
  16. package/es/src/charts/Matrix/index.js +3 -2
  17. package/es/src/charts/Network/index.js +9 -4
  18. package/es/src/charts/Pack/index.js +2 -1
  19. package/es/src/charts/Pie/index.js +2 -1
  20. package/es/src/charts/Plot/axisHover.js +180 -0
  21. package/es/src/charts/Plot/axisHoverAnchors.js +174 -0
  22. package/es/src/charts/Plot/axisHoverScene.js +202 -0
  23. package/es/src/charts/Plot/barHitArea.js +81 -0
  24. package/es/src/charts/Plot/barLabelFit.js +123 -0
  25. package/es/src/charts/Plot/barWidth.js +2 -2
  26. package/es/src/charts/Plot/confidenceConfig.js +2 -2
  27. package/es/src/charts/Plot/draw.js +6 -2
  28. package/es/src/charts/Plot/index.js +25 -6
  29. package/es/src/charts/Plot/labelPlacement.js +9 -1
  30. package/es/src/charts/Plot/openDomainEnds.js +2 -5
  31. package/es/src/charts/Plot/pipeline.js +5 -3
  32. package/es/src/charts/Plot/pipelineAxisLayout.js +38 -8
  33. package/es/src/charts/Plot/pipelineDomains.js +7 -3
  34. package/es/src/charts/Plot/pipelineLineLabels.js +1 -1
  35. package/es/src/charts/Plot/plotInit.js +15 -0
  36. package/es/src/charts/Plot/plotZoom.js +15 -6
  37. package/es/src/charts/Plot/shapeDefaults.js +4 -4
  38. package/es/src/charts/Plot/sharedHoverScene.js +50 -31
  39. package/es/src/charts/Plot/sharedTooltip.js +19 -7
  40. package/es/src/charts/Plot/stackHelpers.js +13 -1
  41. package/es/src/charts/Plot/stackShareTooltip.js +9 -4
  42. package/es/src/charts/Plot/stackThreshold.js +154 -0
  43. package/es/src/charts/PolarArea/index.js +3 -2
  44. package/es/src/charts/Priestley/index.js +3 -2
  45. package/es/src/charts/Pyramid/index.js +4 -2
  46. package/es/src/charts/Radar/index.js +3 -2
  47. package/es/src/charts/RadialBar/index.js +2 -1
  48. package/es/src/charts/RadialMatrix/index.js +3 -2
  49. package/es/src/charts/Rings/index.js +5 -3
  50. package/es/src/charts/Sankey/index.js +3 -2
  51. package/es/src/charts/Treemap/applyLayout.js +14 -1
  52. package/es/src/charts/Treemap/emit.js +8 -2
  53. package/es/src/charts/Treemap/emitGroupHeaders.js +104 -0
  54. package/es/src/charts/Treemap/groupHeaders.js +95 -0
  55. package/es/src/charts/Treemap/index.js +15 -2
  56. package/es/src/charts/Treemap/thresholdFunction.js +11 -9
  57. package/es/src/charts/Waffle/index.js +4 -2
  58. package/es/src/charts/Waffle/tooltip.js +6 -2
  59. package/es/src/charts/Waterfall/index.js +4 -2
  60. package/es/src/charts/definition/makeChart.js +12 -5
  61. package/es/src/charts/drawSteps/saveChart.js +176 -0
  62. package/es/src/charts/drawSteps/saveControl.js +148 -0
  63. package/es/src/charts/drawSteps/saveControlMarkup.js +104 -0
  64. package/es/src/charts/drawSteps/tableViewMarkup.js +1 -1
  65. package/es/src/charts/drawSteps/topLeftControls.js +3 -1
  66. package/es/src/charts/drawSteps/topLeftControlsMarkup.js +1 -1
  67. package/es/src/charts/events/click.shape.js +30 -1
  68. package/es/src/charts/events/mouseenter.js +9 -0
  69. package/es/src/charts/events/mousemove.legend.js +3 -0
  70. package/es/src/charts/events/mousemove.shape.js +7 -2
  71. package/es/src/charts/facet/facetConfig.js +2 -2
  72. package/es/src/charts/facet/facetData.js +2 -2
  73. package/es/src/charts/features/axes.js +7 -6
  74. package/es/src/charts/features/axesFinal.js +23 -3
  75. package/es/src/charts/features/axesMeasure.js +54 -2
  76. package/es/src/charts/features/colorScaleBucket.js +17 -0
  77. package/es/src/charts/features/colorScaleHover.js +69 -0
  78. package/es/src/charts/features/features.js +13 -1
  79. package/es/src/charts/features/featuresColorScale.js +44 -4
  80. package/es/src/charts/features/featuresLegend.js +6 -8
  81. package/es/src/charts/features/plotPaint.js +4 -4
  82. package/es/src/charts/features/shapeEmit.js +23 -2
  83. package/es/src/charts/features/shareKey.js +15 -0
  84. package/es/src/charts/features/thresholdMembers.js +71 -0
  85. package/es/src/charts/helpers/densityChart.js +3 -1
  86. package/es/src/charts/helpers/valueTitle.js +6 -3
  87. package/es/src/charts/partition/chartFields.js +4 -3
  88. package/es/src/charts/partition/hierarchy.js +2 -0
  89. package/es/src/charts/pipeline/preDrawData.js +31 -10
  90. package/es/src/charts/pipeline/vizDraw.js +40 -29
  91. package/es/src/charts/pipeline/vizPreDraw.js +24 -15
  92. package/es/src/charts/viz/Viz.js +43 -8
  93. package/es/src/charts/viz/VizBase.js +32 -12
  94. package/es/src/charts/viz/dataPoller.js +52 -0
  95. package/es/src/charts/viz/groupRow.js +35 -0
  96. package/es/src/charts/viz/interactionOpacity.js +19 -5
  97. package/es/src/charts/viz/missingFields.js +122 -0
  98. package/es/src/charts/viz/reportHandlerError.js +10 -0
  99. package/es/src/charts/viz/shapeClassTargets.js +18 -2
  100. package/es/src/charts/viz/simpleHover.js +2 -0
  101. package/es/src/charts/viz/vizClassName.js +31 -0
  102. package/es/src/charts/viz/vizDataPolling.js +167 -0
  103. package/es/src/charts/viz/vizDefaults.js +66 -0
  104. package/es/src/charts/viz/vizFields.js +18 -2
  105. package/es/src/charts/viz/vizRender.js +8 -2
  106. package/es/src/components/Axis/Axis.js +28 -0
  107. package/es/src/components/Axis/axisDefaults.js +3 -1
  108. package/es/src/components/Axis/axisLabelAngle.js +175 -0
  109. package/es/src/components/Axis/axisLabelThinning.js +13 -4
  110. package/es/src/components/Axis/axisLayout.js +86 -19
  111. package/es/src/components/Axis/axisLayoutLabels.js +66 -13
  112. package/es/src/components/Axis/axisLayoutScale.js +3 -0
  113. package/es/src/components/Axis/axisRender.js +38 -9
  114. package/es/src/components/Axis/axisRounding.js +15 -4
  115. package/es/src/components/Axis/axisSlantWrap.js +39 -0
  116. package/es/src/components/Axis/powTicks.js +73 -0
  117. package/es/src/components/ColorScale/ColorScale.js +28 -28
  118. package/es/src/components/ColorScale/bucketBounds.js +35 -0
  119. package/es/src/components/ColorScale/colorScaleHoverMark.js +327 -0
  120. package/es/src/components/ColorScale/colorScaleRender.js +25 -1
  121. package/es/src/components/ColorScale/colorScaleScale.js +15 -9
  122. package/es/src/components/ColorScale/colorScaleType.js +26 -0
  123. package/es/src/components/TextBox.js +2 -0
  124. package/es/src/components/Timeline/Timeline.js +43 -52
  125. package/es/src/components/Timeline/brushSpan.js +78 -0
  126. package/es/src/components/Timeline/timelineConfig.js +7 -0
  127. package/es/src/components/Timeline/timelineRender.js +44 -6
  128. package/es/src/components/Tooltip.js +13 -8
  129. package/es/src/shapes/Box.js +66 -79
  130. package/es/src/shapes/boxOutlierShape.js +19 -0
  131. package/es/src/shapes/boxStats.js +35 -0
  132. package/es/src/shapes/boxStyle.js +78 -0
  133. package/es/src/shapes/boxSummary.js +174 -0
  134. package/es/src/shapes/shapeStandalone.js +2 -0
  135. package/es/src/utils/BaseClass.js +19 -0
  136. package/es/src/utils/className.js +78 -0
  137. package/es/src/utils/configWarnings.js +25 -0
  138. package/es/src/utils/fieldAccessor.js +31 -0
  139. package/es/src/utils/paintComponentScene.js +2 -0
  140. package/package.json +10 -9
  141. package/types/index.d.ts +3 -1
  142. package/types/internal.d.ts +3 -1
  143. package/types/src/charts/BoxWhisker/index.d.ts +3 -1
  144. package/types/src/charts/BoxWhisker/outliers.d.ts +25 -0
  145. package/types/src/charts/BoxWhisker/summary.d.ts +39 -0
  146. package/types/src/charts/BoxWhisker/tooltip.d.ts +36 -0
  147. package/types/src/charts/Candlestick/aggregate.d.ts +6 -0
  148. package/types/src/charts/Plot/axisHover.d.ts +68 -0
  149. package/types/src/charts/Plot/axisHoverAnchors.d.ts +88 -0
  150. package/types/src/charts/Plot/axisHoverScene.d.ts +88 -0
  151. package/types/src/charts/Plot/barHitArea.d.ts +59 -0
  152. package/types/src/charts/Plot/barLabelFit.d.ts +81 -0
  153. package/types/src/charts/Plot/index.d.ts +13 -0
  154. package/types/src/charts/Plot/labelPlacement.d.ts +5 -0
  155. package/types/src/charts/Plot/plotInit.d.ts +9 -2
  156. package/types/src/charts/Plot/plotZoom.d.ts +2 -0
  157. package/types/src/charts/Plot/sharedHoverScene.d.ts +3 -3
  158. package/types/src/charts/Plot/sharedTooltip.d.ts +11 -4
  159. package/types/src/charts/Plot/stackHelpers.d.ts +5 -0
  160. package/types/src/charts/Plot/stackThreshold.d.ts +75 -0
  161. package/types/src/charts/Treemap/emit.d.ts +2 -1
  162. package/types/src/charts/Treemap/emitGroupHeaders.d.ts +16 -0
  163. package/types/src/charts/Treemap/groupHeaders.d.ts +91 -0
  164. package/types/src/charts/Treemap/index.d.ts +2 -0
  165. package/types/src/charts/Treemap/thresholdFunction.d.ts +5 -2
  166. package/types/src/charts/definition/ChartDefinition.d.ts +14 -2
  167. package/types/src/charts/definition/makeChart.d.ts +4 -3
  168. package/types/src/charts/drawSteps/saveChart.d.ts +47 -0
  169. package/types/src/charts/drawSteps/saveControl.d.ts +9 -0
  170. package/types/src/charts/drawSteps/saveControlMarkup.d.ts +44 -0
  171. package/types/src/charts/drawSteps/tableViewMarkup.d.ts +1 -0
  172. package/types/src/charts/drawSteps/topLeftControls.d.ts +1 -1
  173. package/types/src/charts/drawSteps/topLeftControlsMarkup.d.ts +1 -1
  174. package/types/src/charts/facet/facetData.d.ts +1 -1
  175. package/types/src/charts/features/axesMeasure.d.ts +9 -1
  176. package/types/src/charts/features/colorScaleBucket.d.ts +9 -0
  177. package/types/src/charts/features/colorScaleHover.d.ts +32 -0
  178. package/types/src/charts/features/features.d.ts +8 -0
  179. package/types/src/charts/features/plotPaint.d.ts +2 -0
  180. package/types/src/charts/features/shapeEmit.d.ts +2 -0
  181. package/types/src/charts/features/shareKey.d.ts +9 -0
  182. package/types/src/charts/features/thresholdMembers.d.ts +38 -0
  183. package/types/src/charts/helpers/valueTitle.d.ts +4 -2
  184. package/types/src/charts/pipeline/stages.d.ts +2 -0
  185. package/types/src/charts/pipeline/vizDraw.d.ts +8 -3
  186. package/types/src/charts/pipeline/vizPreDraw.d.ts +3 -2
  187. package/types/src/charts/viz/Viz.d.ts +28 -4
  188. package/types/src/charts/viz/VizBase.d.ts +12 -3
  189. package/types/src/charts/viz/dataPoller.d.ts +28 -0
  190. package/types/src/charts/viz/groupRow.d.ts +24 -0
  191. package/types/src/charts/viz/interactionOpacity.d.ts +3 -1
  192. package/types/src/charts/viz/missingFields.d.ts +57 -0
  193. package/types/src/charts/viz/reportHandlerError.d.ts +7 -0
  194. package/types/src/charts/viz/shapeClassTargets.d.ts +6 -0
  195. package/types/src/charts/viz/simpleHover.d.ts +2 -1
  196. package/types/src/charts/viz/vizClassName.d.ts +23 -0
  197. package/types/src/charts/viz/vizDataPolling.d.ts +48 -0
  198. package/types/src/charts/viz/vizDefaults.d.ts +49 -0
  199. package/types/src/charts/viz/vizFields.d.ts +15 -0
  200. package/types/src/charts/viz/vizTypes.d.ts +33 -1
  201. package/types/src/components/Axis/Axis.d.ts +36 -8
  202. package/types/src/components/Axis/axisLabelAngle.d.ts +110 -0
  203. package/types/src/components/Axis/axisLabelThinning.d.ts +3 -7
  204. package/types/src/components/Axis/axisLayout.d.ts +5 -0
  205. package/types/src/components/Axis/axisLayoutLabels.d.ts +13 -0
  206. package/types/src/components/Axis/axisRounding.d.ts +6 -3
  207. package/types/src/components/Axis/axisSlantWrap.d.ts +22 -0
  208. package/types/src/components/Axis/powTicks.d.ts +29 -0
  209. package/types/src/components/ColorScale/ColorScale.d.ts +13 -0
  210. package/types/src/components/ColorScale/bucketBounds.d.ts +14 -0
  211. package/types/src/components/ColorScale/colorScaleHoverMark.d.ts +86 -0
  212. package/types/src/components/ColorScale/colorScaleScale.d.ts +3 -0
  213. package/types/src/components/ColorScale/colorScaleType.d.ts +17 -0
  214. package/types/src/components/Timeline/brushSpan.d.ts +41 -0
  215. package/types/src/components/Timeline/timelineConfig.d.ts +6 -0
  216. package/types/src/components/Timeline/timelineRender.d.ts +8 -0
  217. package/types/src/components/Tooltip.d.ts +8 -0
  218. package/types/src/shapes/Box.d.ts +1 -8
  219. package/types/src/shapes/boxOutlierShape.d.ts +9 -0
  220. package/types/src/shapes/boxStats.d.ts +19 -0
  221. package/types/src/shapes/boxStyle.d.ts +25 -0
  222. package/types/src/shapes/boxSummary.d.ts +66 -0
  223. package/types/src/shapes/emitLabels.d.ts +1 -1
  224. package/types/src/shapes/shapeConfig.d.ts +42 -4
  225. package/types/src/utils/BaseClass.d.ts +23 -0
  226. package/types/src/utils/D3Scale.d.ts +3 -0
  227. package/types/src/utils/D3plusConfig.d.ts +261 -5
  228. package/types/src/utils/className.d.ts +64 -0
  229. package/types/src/utils/configWarnings.d.ts +21 -2
  230. package/types/src/utils/fieldAccessor.d.ts +24 -0
  231. package/types/src/utils/index.d.ts +1 -1
  232. package/types/src/utils/paintComponentScene.d.ts +3 -1
  233. package/umd/d3plus-core.full.js +6405 -1068
  234. package/umd/d3plus-core.full.min.js +2 -2
  235. package/umd/d3plus-core.js +5328 -1002
  236. package/umd/d3plus-core.min.js +2 -2
@@ -0,0 +1,88 @@
1
+ /**
2
+ The points a Plot's axis hover (#782) can snap to: a Line/Area's points, a
3
+ Circle's center, and a Bar's end, read from the painted chart scene.
4
+ */
5
+ import type { DataPoint } from "@d3plus/data";
6
+ import type { VizInstance } from "../viz/vizTypes.js";
7
+ import type { ShapeNode } from "./sharedHover.js";
8
+ /** One of a Plot's four axes. */
9
+ export type AxisName = "x" | "x2" | "y" | "y2";
10
+ /** A plotted record as Plot wraps it: its axis values plus the source row. */
11
+ export type AnchorDatum = DataPoint & {
12
+ data?: DataPoint;
13
+ i?: number;
14
+ id?: unknown;
15
+ x?: unknown;
16
+ x2?: unknown;
17
+ y?: unknown;
18
+ y2?: unknown;
19
+ };
20
+ /** A point a mark draws a value at, in chart content space. */
21
+ export interface AxisHoverAnchor {
22
+ x: number;
23
+ y: number;
24
+ datum: AnchorDatum;
25
+ color?: string;
26
+ shape?: string;
27
+ /** A bar's extent along its value axis, from its base to its end. */
28
+ span?: [number, number];
29
+ }
30
+ /**
31
+ Which edge of a bar's rect is its end: the edge farther from the bar's
32
+ base, which its transform sits on (a negative bar runs the other way).
33
+ @param offset The rect's start along the value axis, relative to the base.
34
+ @param length The rect's size along the value axis.
35
+ */
36
+ export declare function barEndOffset(offset: number, length: number): number;
37
+ /**
38
+ Moves an anchor along its value axis to `end`, spanning from where it was
39
+ (an Area's points sit on its baseline; its value is drawn at its top edge).
40
+ @param anchor The anchor.
41
+ @param end Its end along the value axis.
42
+ @param valueAxis The axis the mark's values run along.
43
+ */
44
+ export declare function liftAnchor(anchor: AxisHoverAnchor, end: number, valueAxis: "x" | "y"): AxisHoverAnchor;
45
+ /**
46
+ The anchors one mark node draws: each of a Line/Area's interaction points
47
+ (an Area's sit on its baseline, see `liftAnchor`), a circle's center, a Bar's end (along `valueAxis`), or another rect's
48
+ center. Nodes without a source datum, and those drawn for another mark,
49
+ have none.
50
+ @param node The mark's scene node.
51
+ @param valueAxis The axis a Bar's length runs along.
52
+ @param color The mark's color.
53
+ */
54
+ export declare function markAnchors(node: ShapeNode, valueAxis: "x" | "y", color?: string): AxisHoverAnchor[];
55
+ /** Whether a scene node is a data mark the axis hover reads. */
56
+ export declare function isAnchorMark(node: ShapeNode | undefined): node is ShapeNode;
57
+ /** Every anchor the chart's marks draw (see `markAnchors`). */
58
+ export declare function collectAnchors(viz: VizInstance): AxisHoverAnchor[];
59
+ /**
60
+ The anchor nearest `target` along one axis. A bar holding the target
61
+ within its span counts as no distance away.
62
+ @param anchors The candidates.
63
+ @param axis The axis the distance is measured along.
64
+ @param target The position, in chart content space.
65
+ */
66
+ export declare function nearestAnchor(anchors: AxisHoverAnchor[], axis: "x" | "y", target: number): AxisHoverAnchor | null;
67
+ /**
68
+ The anchor nearest a point in both directions.
69
+ @param anchors The candidates.
70
+ @param point The position, in chart content space.
71
+ */
72
+ export declare function closestAnchor(anchors: AxisHoverAnchor[], point: [number, number]): AxisHoverAnchor | null;
73
+ /**
74
+ The axes a hovered anchor gets a guide and badge on: x and y, each the
75
+ secondary axis when the record is plotted against it. A bar leaves out its
76
+ discrete axis (its band is labeled already), a swarm leaves out the axis
77
+ its circles are packed along, and `only` keeps just one direction.
78
+ @param datum The anchor's record.
79
+ @param options `discrete`: the chart's discrete axis; `bar`: whether the
80
+ anchor is a Bar's end; `cross`: a swarm's packing axis; `only`: the one
81
+ direction to keep (`axisHover: "x"` or `"y"`).
82
+ */
83
+ export declare function anchorAxes(datum: AnchorDatum, options: {
84
+ discrete?: "x" | "y";
85
+ bar?: boolean;
86
+ cross?: "x" | "y";
87
+ only?: "x" | "y";
88
+ }): AxisName[];
@@ -0,0 +1,88 @@
1
+ import type { DataPoint } from "@d3plus/data";
2
+ import type { SceneNode } from "@d3plus/render";
3
+ import type { VizInstance } from "../viz/vizTypes.js";
4
+ import type { AxisHoverState } from "./axisHover.js";
5
+ import type { AxisName } from "./axisHoverAnchors.js";
6
+ /** The plot area's edges in chart content space, where each axis line sits. */
7
+ export interface PlotEdges {
8
+ left: number;
9
+ right: number;
10
+ top: number;
11
+ bottom: number;
12
+ }
13
+ /** A badge's box, in chart content space. */
14
+ export interface BadgeBox {
15
+ x: number;
16
+ y: number;
17
+ width: number;
18
+ height: number;
19
+ }
20
+ /** A style value: a constant, or an accessor of the hovered row. */
21
+ type Style<T> = T | ((d: DataPoint, i: number) => T);
22
+ /** The `axisHoverConfig` options. */
23
+ export interface AxisHoverConfig {
24
+ /** Paint for the guide lines; `stroke` defaults to the hovered mark's color. */
25
+ guideConfig?: {
26
+ stroke?: Style<string>;
27
+ strokeDasharray?: Style<string | number[]>;
28
+ strokeOpacity?: Style<number>;
29
+ strokeWidth?: Style<number>;
30
+ };
31
+ /** The value badges; `fill` defaults to the hovered mark's color, `fontColor` to a contrasting ink. */
32
+ badgeConfig?: {
33
+ fill?: Style<string>;
34
+ fontColor?: Style<string>;
35
+ fontFamily?: Style<string>;
36
+ fontSize?: Style<number>;
37
+ fontWeight?: Style<number | string>;
38
+ padding?: Style<number>;
39
+ rx?: Style<number>;
40
+ };
41
+ }
42
+ /** `axisHoverConfig`'s defaults. */
43
+ export declare function axisHoverDefaults(): AxisHoverConfig;
44
+ /**
45
+ The plot area's edges: the x axis along the bottom, x2 along the top, y
46
+ on the left, and y2 on the right.
47
+ @param area The plot area.
48
+ */
49
+ export declare function plotEdges(area: {
50
+ x: number;
51
+ y: number;
52
+ width: number;
53
+ height: number;
54
+ }): PlotEdges;
55
+ /**
56
+ The guide from a point straight across to an axis line.
57
+ @param axis The axis the guide runs to.
58
+ @param point The hovered point.
59
+ @param edges The plot area's edges.
60
+ */
61
+ export declare function guidePoints(axis: AxisName, point: {
62
+ x: number;
63
+ y: number;
64
+ }, edges: PlotEdges): [number, number][];
65
+ /**
66
+ A badge's box: centered on `at` along its axis, and set just outside the
67
+ axis line, over the tick labels.
68
+ @param axis The axis the badge labels.
69
+ @param at The badge's center along the axis.
70
+ @param size The badge's width and height.
71
+ @param edges The plot area's edges.
72
+ */
73
+ export declare function badgeBox(axis: AxisName, at: number, size: {
74
+ width: number;
75
+ height: number;
76
+ }, edges: PlotEdges): BadgeBox;
77
+ /**
78
+ The axis hover's scene nodes, in chart content space: `guides` to draw
79
+ with the plot's marks (inside its zoom clip), and `badges` to draw over
80
+ the axes.
81
+ @param viz The Plot, with the hovered panel's state in place.
82
+ @param state The active axis hover.
83
+ */
84
+ export declare function axisHoverNodes(viz: VizInstance, state: AxisHoverState): {
85
+ guides: SceneNode[];
86
+ badges: SceneNode[];
87
+ };
88
+ export {};
@@ -0,0 +1,59 @@
1
+ /**
2
+ Bar hit areas: a transparent hover target behind each side-by-side bar
3
+ that fills the bar's slot along the discrete axis and the whole plot along
4
+ the value axis, so a short bar is as easy to hover and click as a tall
5
+ one. Grouped bars each take their own column of the slot. Stacked bars
6
+ already fill their slot and take none. `shapeConfig.Bar.hitArea: false`
7
+ turns them off.
8
+
9
+ @module
10
+ */
11
+ import type { DataPoint } from "@d3plus/data";
12
+ import type { SceneNode } from "@d3plus/render";
13
+ import type { Shape } from "../../shapes/index.js";
14
+ /** Rect bounds in a bar's own coordinates (relative to its transform). */
15
+ export interface HitBounds {
16
+ x: number;
17
+ y: number;
18
+ width: number;
19
+ height: number;
20
+ }
21
+ /**
22
+ A bar's column of its slot along the discrete axis, as offsets from the
23
+ bar's own center. A lone bar takes the whole slot. Grouped bars split it
24
+ at the midpoints between their centers, and the outermost reach the
25
+ slot's edges, so no column overlaps a neighboring bar.
26
+ @param step The slot's width: the distance between neighboring categories.
27
+ @param count How many bars share the slot.
28
+ @param index The bar's position in the slot.
29
+ @param reach How far the outermost bars' centers sit from the slot's center.
30
+ */
31
+ export declare function hitColumn(step: number, count: number, index: number, reach: number): [number, number];
32
+ /**
33
+ A bar's hit rect in its own coordinates: its `column` along the discrete
34
+ axis, and the plot's `valueExtent` along the value axis, both sides of
35
+ the baseline.
36
+ @param discrete The discrete axis.
37
+ @param column The column, as offsets from the bar's center (see `hitColumn`).
38
+ @param valueExtent The value axis's pixel span, in shape coordinates.
39
+ @param origin The bar's transform.
40
+ */
41
+ export declare function hitBounds(discrete: "x" | "y", column: [number, number], valueExtent: [number, number], origin: {
42
+ x?: number;
43
+ y?: number;
44
+ }): HitBounds;
45
+ /**
46
+ Gives a Bar shape its slot-filling hit areas (see `hitBounds`). Set
47
+ before the user's `shapeConfig`, so `hitArea` there (or `false`) wins.
48
+ @param s The Bar shape.
49
+ @param discrete The discrete axis.
50
+ @param valueExtent The value axis's pixel span, in shape coordinates.
51
+ @param column Each bar's column (see `hitColumn`).
52
+ */
53
+ export declare function applyBarHitArea(s: Shape, discrete: "x" | "y", valueExtent: [number, number] | undefined, column: (d: DataPoint, i: number) => [number, number]): void;
54
+ /**
55
+ `nodes` with every Bar hit area moved to the front (painted first), so
56
+ each sits behind every mark: a bar's slot never covers another bar, nor
57
+ the lines, points, and areas drawn over it.
58
+ */
59
+ export declare function barHitsFirst(nodes: SceneNode[]): SceneNode[];
@@ -0,0 +1,81 @@
1
+ import type { VizInstance } from "../viz/vizTypes.js";
2
+ /** A formatted Plot row: its source `data`, index, and positions. */
3
+ type Row = Record<string, unknown>;
4
+ /** The category labels a Plot's bars carry in place of an axis's tick labels. */
5
+ export interface BarLabelCheck {
6
+ /** The category axis. */
7
+ axis: "x" | "y";
8
+ /** Each bar's label text. */
9
+ labels: string[];
10
+ /** The rows the labels belong to. */
11
+ rows: Row[];
12
+ }
13
+ /** The fields of the viz this module reads. */
14
+ interface FitViz {
15
+ schema: {
16
+ discrete?: string;
17
+ stacked?: unknown;
18
+ barPadding?: number;
19
+ };
20
+ _groupPadding?: number;
21
+ }
22
+ /**
23
+ The room each bar has for its label, in pixels: along the category axis,
24
+ the axis length split evenly among its `categories` (less `groupPadding`),
25
+ then among the `perCategory` bars sharing a category (less
26
+ `barPadding`); along the value axis, half the plot, which a bar's label
27
+ always has inside or beyond it.
28
+ @param discrete The category axis.
29
+ @param plot The plot area's size.
30
+ @param categories How many categories the axis holds.
31
+ @param perCategory How many bars share a category.
32
+ @param padding `groupPadding` and `barPadding`.
33
+ */
34
+ export declare function barLabelRoom(discrete: "x" | "y", plot: {
35
+ width: number;
36
+ height: number;
37
+ }, categories: number, perCategory: number, padding: {
38
+ group: number;
39
+ bar: number;
40
+ }): {
41
+ width: number;
42
+ height: number;
43
+ };
44
+ /**
45
+ Whether every label in `labels` (one per row in `rows`) fits, whole and
46
+ untruncated, in a `room`-sized box laid out with the bar `labelConfig`.
47
+ @param labels Each row's label text.
48
+ @param rows The rows the labels belong to.
49
+ @param room The box each label has (see `barLabelRoom`).
50
+ @param labelConfig The bars' resolved `labelConfig`.
51
+ */
52
+ export declare function barLabelsFit(labels: string[], rows: Row[], room: {
53
+ width: number;
54
+ height: number;
55
+ }, labelConfig: Record<string, unknown>): boolean;
56
+ /**
57
+ Whether the bars of `rows` have room for their category `labels` in a
58
+ plot of `plot` size (see `barLabelRoom` and `barLabelsFit`).
59
+ @param viz The chart.
60
+ @param rows The bar rows the labels belong to.
61
+ @param labels Each row's label text.
62
+ @param plot The plot area's size.
63
+ @param labelConfig The bars' resolved `labelConfig`.
64
+ */
65
+ export declare function barCategoryLabelsFit(viz: FitViz, rows: Row[], labels: string[], plot: {
66
+ width: number;
67
+ height: number;
68
+ }, labelConfig: Record<string, unknown>): boolean;
69
+ /**
70
+ Whether a category axis keeps the tick labels its bars carry (see
71
+ `BarLabelCheck`): when the bars, in a plot of `plot` size, have no room
72
+ for those labels.
73
+ @param viz The chart.
74
+ @param check The bars' category labels.
75
+ @param plot The plot area's size.
76
+ */
77
+ export declare function barLabelsNeedAxis(viz: VizInstance, check: BarLabelCheck, plot: {
78
+ width: number;
79
+ height: number;
80
+ }): boolean;
81
+ export {};
@@ -27,6 +27,18 @@ export default class Plot extends Viz {
27
27
  @private
28
28
  */
29
29
  _preDraw(): void;
30
+ /**
31
+ The legend rows with a stacked chart's threshold bucket folded into
32
+ one entry (see `stackThreshold.ts`).
33
+ @private
34
+ */
35
+ _thresholdLegend(legendData: DataPoint[]): DataPoint[];
36
+ /**
37
+ Folds a stacked chart's small series into one threshold bucket (see
38
+ `stackThreshold.ts`).
39
+ @private
40
+ */
41
+ _thresholdFunction(data: DataPoint[], _tree?: unknown, all?: DataPoint[]): DataPoint[];
30
42
  /**
31
43
  Composes the chart's scene graph: the native shape scenes from Viz.toScene
32
44
  (bars/lines/areas + labels) plus snapshots of the rendered axes, so a Plot
@@ -79,6 +91,7 @@ export default class Plot extends Viz {
79
91
  inside the plot area, snaps to the nearest discrete position and, when
80
92
  two or more series share it, shows them all in one tooltip (suppressing
81
93
  the single-shape tooltip). Clears on leaving the plot area or the chart.
94
+ Then tracks the hovered point's axis guides and badges (`axisHover`).
82
95
  @private
83
96
  */
84
97
  _sharedHover(event: SceneEvent): void;
@@ -9,6 +9,11 @@ import type { VizInstance } from "../viz/vizTypes.js";
9
9
  Default shape size, routed through the chart's internal sizeScale.
10
10
  */
11
11
  export declare function defaultSize(this: VizInstance, d: DataPoint): number;
12
+ /**
13
+ Whether a bar grows back along its value axis: a negative value, or a
14
+ positive one on a `reverse` axis (down a y axis, left along an x axis).
15
+ */
16
+ export declare function growsBack(viz: VizInstance, valueAxis: string, d: DataPoint, i: number): boolean;
12
17
  /**
13
18
  Determines if a Bar label should be placed outside of the Bar.
14
19
  */
@@ -1,4 +1,5 @@
1
1
  import type Plot from "./index.js";
2
+ import { axisHoverDefaults } from "./axisHoverScene.js";
2
3
  import { fillBetweenDefaults } from "./fillBetween.js";
3
4
  /**
4
5
  Plot's identity-coerce accessor schema. `installFluent` installs it on
@@ -7,13 +8,19 @@ import { fillBetweenDefaults } from "./fillBetween.js";
7
8
  export declare const plotSchema: ({
8
9
  key: string;
9
10
  coerce: "identity";
10
- default?: undefined;
11
+ default: boolean;
11
12
  merge?: undefined;
12
13
  factory?: undefined;
14
+ } | {
15
+ key: string;
16
+ merge: boolean;
17
+ factory: typeof axisHoverDefaults;
18
+ coerce?: undefined;
19
+ default?: undefined;
13
20
  } | {
14
21
  key: string;
15
22
  coerce: "identity";
16
- default: boolean;
23
+ default?: undefined;
17
24
  merge?: undefined;
18
25
  factory?: undefined;
19
26
  } | {
@@ -44,6 +44,8 @@ export interface PlotZoomBase {
44
44
  labelSpace: Partial<Record<AxisName, number>>;
45
45
  /** Axes drawn with a baseline break; a zoom keeps the break only on these. */
46
46
  breaks: Partial<Record<AxisName, boolean>>;
47
+ /** Axes drawn `reverse`d, whose scales run the other way to their domains. */
48
+ reversed: Partial<Record<AxisName, boolean>>;
47
49
  }
48
50
  /**
49
51
  Paints a Plot at its natural (unzoomed) scale and records what a zoom
@@ -1,8 +1,8 @@
1
1
  import type { Scene } from "@d3plus/render";
2
2
  import type { VizInstance } from "../viz/vizTypes.js";
3
3
  /**
4
- Adds the snapped hover's scene nodes (see `decorateBody`) to the chart
5
- body group (content space, so they track zoom) — to each panel's body
6
- when the chart is drawn as small multiples.
4
+ Adds the hover's scene nodes (see `decorateBody`) to the chart body group
5
+ (content space, so they track zoom) — to each panel's body when the chart
6
+ is drawn as small multiples.
7
7
  */
8
8
  export declare function appendSharedHoverNodes(viz: VizInstance, scene: Scene): void;
@@ -12,7 +12,7 @@ export declare function axisName(viz: VizInstance, k: Axis): string;
12
12
  axis of years, matching its tick labels), and anything else (e.g. a numeric
13
13
  year on the discrete axis) as-is.
14
14
  */
15
- export declare function axisValue(viz: VizInstance, k: Axis, value: unknown): string;
15
+ export declare function axisValue(viz: VizInstance, k: Axis | "x2" | "y2", value: unknown): string;
16
16
  /**
17
17
  Holds the tooltip's own arrow/thead/tbody to restore once the snapped
18
18
  hover ends (see `restoreTooltip`), so the next legend or default tooltip
@@ -23,19 +23,26 @@ export declare function axisValue(viz: VizInstance, k: Axis, value: unknown): st
23
23
  export declare function prepareTooltip(viz: VizInstance): any;
24
24
  /** Puts back what `prepareTooltip` held. */
25
25
  export declare function restoreTooltip(viz: VizInstance): void;
26
+ /**
27
+ How many of a threshold bucket's series the shared tooltip lists under
28
+ its row: fewer than a single-mark tooltip, since every other series has
29
+ a row of its own beside them.
30
+ */
31
+ export declare const SHARED_MEMBER_LIMIT = 5;
26
32
  /**
27
33
  The shared tooltip: title from the continuous axis, a header row naming
28
34
  the hovered discrete value, then one `[name, value]` row per series, the
29
35
  name led by a swatch in its series stroke and the value followed by its
30
- `confidence` range. User `tooltipConfig` styles apply first; the shared
31
- title/rows win.
36
+ `confidence` range, and a threshold bucket's series listed under its row.
37
+ User `tooltipConfig` styles apply first; the shared title/rows win.
32
38
  */
33
39
  export declare function renderSharedTooltip(viz: VizInstance, hover: SharedHover, event: SceneEvent): void;
34
40
  /**
35
41
  The single-mark tooltip (one series, `tooltipShared(false)`, or a
36
42
  side-by-side bar): the default title (the mark's label, unless
37
43
  `tooltipConfig` sets one), its x and y values, its `confidence` bounds,
38
- then any rows the chart's `tooltipConfig` adds.
44
+ then any rows the chart's `tooltipConfig` adds, and a threshold bucket's
45
+ series.
39
46
  */
40
47
  export declare function renderSingleTooltip(viz: VizInstance, hover: SharedHover, event: SceneEvent): void;
41
48
  export {};
@@ -57,6 +57,11 @@ export declare const stackOrderKeyReverse: StackOrderFn;
57
57
  than only the plotted one. `value` receives each series' original datum.
58
58
  */
59
59
  export declare function stackOrderField(value: ValueAccessor, order?: "ascending" | "descending"): StackOrderFn;
60
+ /**
61
+ Wraps a stack order so the series in `last` sit at the top of the stack,
62
+ in the order `order` gives them, above every other series.
63
+ */
64
+ export declare function orderLast(order: (series: Series[]) => number[], last: Set<string>): (series: Series[]) => number[];
60
65
  /** The named orders accepted by `Plot.stackOrder`, for docs/validation. */
61
66
  export declare const stackOrderNames: string[];
62
67
  /**
@@ -0,0 +1,75 @@
1
+ /**
2
+ `threshold` on stacked Plot charts: the series whose summed value, over
3
+ every position on the discrete axis, is under `threshold` of the chart's
4
+ total fold into one bucket series. Membership is decided once for the
5
+ whole chart, so a series is in the bucket at every position or at none.
6
+ */
7
+ import { merge } from "@d3plus/data";
8
+ import type { DataPoint } from "@d3plus/data";
9
+ import type { VizInstance } from "../viz/vizTypes.js";
10
+ type Accessor = (d: DataPoint, i: number) => unknown;
11
+ type Aggs = Parameters<typeof merge>[1];
12
+ /** What `stackThresholdBucket` and `foldStackRows` read off the chart. */
13
+ export interface StackThresholdInputs {
14
+ /** Per-key aggregations `merge` applies when folding rows. */
15
+ aggs?: Aggs;
16
+ /** The series a row belongs to. */
17
+ id: Accessor;
18
+ /** Accessors for a row's position: the discrete axis, and the time. */
19
+ position: Accessor[];
20
+ /** Returns the threshold, a 0..1 share of the total, for the rows. */
21
+ threshold: (rows: DataPoint[]) => number;
22
+ /** The value a row adds to its series' total. */
23
+ value: Accessor;
24
+ /** Names a series in the bucket's member list (default: its id). */
25
+ label?: Accessor;
26
+ /** The value a member lists in tooltips (default: `value`). */
27
+ measure?: Accessor;
28
+ }
29
+ /** The series one bucket folds together. */
30
+ export interface StackThresholdBucket {
31
+ /** The series keys (`${id}`) the bucket holds. */
32
+ members: Set<string>;
33
+ /** The threshold the bucket was cut at, a 0..1 share. */
34
+ percent: number;
35
+ /** The series-level fields every bucket row carries (see `seriesIdentity`). */
36
+ identity: DataPoint;
37
+ }
38
+ /**
39
+ The fields that name a series rather than a point on it, merged over the
40
+ bucket's series: every non-numeric field that holds one value along each
41
+ series and is not a row's position. Every bucket row carries them, so the
42
+ bucket keeps one id, label, and color at every position, whichever of
43
+ its series have a row there.
44
+ */
45
+ export declare function seriesIdentity(series: DataPoint[][], position: Accessor[], aggs?: Aggs): DataPoint;
46
+ /**
47
+ The bucket for `rows`: the series whose summed absolute `value` is under
48
+ `threshold` of the summed absolute value of every row. Null when the
49
+ threshold is off (0 or not a number) or fewer than two series fall
50
+ under it: a lone small series stays as itself.
51
+ */
52
+ export declare function stackThresholdBucket(rows: DataPoint[], inputs: StackThresholdInputs): StackThresholdBucket | null;
53
+ /**
54
+ Replaces the rows of the bucket's series with one bucket row per
55
+ position: their merged values at that position, the bucket's
56
+ series-level fields, the `_isAggregation` / `_threshold` flags the
57
+ threshold label reads, and its series' values there (largest first,
58
+ under `MEMBERS_KEY`). The bucket rows come after every kept row.
59
+ */
60
+ export declare function foldStackRows(rows: DataPoint[], bucket: StackThresholdBucket, inputs: Pick<StackThresholdInputs, "aggs" | "id" | "label" | "measure" | "position" | "value">): DataPoint[];
61
+ /** The bucket inputs a stacked Plot reads: its series, positions, and stacked value. */
62
+ export declare function plotStackInputs(viz: VizInstance): StackThresholdInputs;
63
+ /**
64
+ A stacked Plot's `threshold`: folds `data` (the drawn rows) into a bucket
65
+ series, deciding the bucket's series from `all` (every row, legend-hidden
66
+ ones included, so hiding a series doesn't move others in or out of the
67
+ bucket). Returns `data` unchanged when the chart isn't stacked.
68
+ */
69
+ export declare function plotStackThreshold(viz: VizInstance, data: DataPoint[], all?: DataPoint[]): DataPoint[];
70
+ /**
71
+ The legend rows of a stacked Plot with its threshold bucket folded into
72
+ one entry, so the legend shows the bucket instead of its series.
73
+ */
74
+ export declare function plotStackThresholdLegend(viz: VizInstance, legendData: DataPoint[]): DataPoint[];
75
+ export {};
@@ -1,6 +1,7 @@
1
1
  /**
2
2
  `treemapEmit` — scene nodes for a laid-out Treemap: one rect per cell
3
- plus the title + share-% text labels for each cell, both as flat data.
3
+ plus the title + share-% text labels for each cell, both as flat data,
4
+ then the group header strips above them.
4
5
  */
5
6
  import type { ChartEmit } from "../definition/ChartDefinition.js";
6
7
  export declare const treemapEmit: ChartEmit;
@@ -0,0 +1,16 @@
1
+ /**
2
+ Scene nodes for the Treemap's group headers: a strip rect per header and
3
+ its left-aligned, single-line name.
4
+ */
5
+ import type { DataPoint } from "@d3plus/data";
6
+ import type { SceneNode } from "@d3plus/render";
7
+ import type { VizInstance } from "../viz/vizTypes.js";
8
+ import type { GroupLabelStyle, TreemapGroupHeader } from "./groupHeaders.js";
9
+ /**
10
+ A header strip's default fill: a darker shade of its group's color, or,
11
+ when a colorScale colors the tiles by value, a neutral tone between the
12
+ chart's background and its ink.
13
+ */
14
+ export declare function defaultGroupFill(viz: VizInstance, row: DataPoint, i: number): string;
15
+ /** The strip rects and name labels for `headers`. */
16
+ export declare function groupHeaderNodes(viz: VizInstance, headers: TreemapGroupHeader[], style: GroupLabelStyle): SceneNode[];
@@ -0,0 +1,91 @@
1
+ /**
2
+ Treemap group headers: with a nested `groupBy`, each group above the drawn
3
+ tiles gets a strip across its top naming it, and its tiles sit below the
4
+ strip. Every level above the tiles gets its own strip, nested inside its
5
+ parent's. A group too small for a readable strip gets none, and its tiles
6
+ fill it.
7
+
8
+ The layout reserves a strip through d3-hierarchy's `paddingTop`, which
9
+ sees each group's box before its children are tiled into it.
10
+ */
11
+ import type { HierarchyRectangularNode } from "d3-hierarchy";
12
+ import { merge } from "@d3plus/data";
13
+ import type { DataPoint } from "@d3plus/data";
14
+ import type { VizInstance } from "../viz/vizTypes.js";
15
+ type Accessor<T> = T | ((d: DataPoint, i: number) => T);
16
+ /** The resolved `groupLabelConfig` for one draw. */
17
+ export interface GroupLabelStyle {
18
+ fill?: Accessor<string>;
19
+ fontColor?: Accessor<string>;
20
+ label?: (d: DataPoint, i: number) => unknown;
21
+ fontFamily?: string | string[];
22
+ fontSize: number;
23
+ fontWeight: number | string;
24
+ padding: number;
25
+ }
26
+ /** `groupLabelConfig` defaults, under the user's config. */
27
+ export declare const groupLabelDefaults: {
28
+ fontSize: number;
29
+ fontWeight: number;
30
+ padding: number;
31
+ };
32
+ /** A laid-out group's header strip, stamped on its hierarchy node. */
33
+ export interface TreemapGroupHeader {
34
+ __d3plus__: true;
35
+ /** The group's rows merged into one, stamped with its `groupBy` level. */
36
+ data: DataPoint;
37
+ /** The group's `groupBy` level. */
38
+ depth: number;
39
+ /** Unique across the chart: the group's key at each level. */
40
+ id: string;
41
+ x0: number;
42
+ y0: number;
43
+ x1: number;
44
+ y1: number;
45
+ }
46
+ type GroupNode = HierarchyRectangularNode<unknown> & {
47
+ data: {
48
+ key?: unknown;
49
+ };
50
+ groupHeader?: TreemapGroupHeader;
51
+ };
52
+ /** The groups that reserved a strip, with each strip's height. */
53
+ export type GroupStrips = Map<GroupNode, number>;
54
+ /**
55
+ The chart's group-header style, or null when headers are off
56
+ (`groupLabels: false`).
57
+ */
58
+ export declare function groupLabelStyle(viz: VizInstance): GroupLabelStyle | null;
59
+ /** A strip's height: one line of text plus its padding above and below. */
60
+ export declare function groupStripHeight(style: Pick<GroupLabelStyle, "fontSize" | "padding">): number;
61
+ /**
62
+ Whether a group `width` × `height` pixels gets a strip: it keeps at least
63
+ a strip's height for its tiles below the strip, and is wide enough for a
64
+ few characters of its name.
65
+ */
66
+ export declare function groupStripFits(width: number, height: number, style: Pick<GroupLabelStyle, "fontSize" | "padding">): boolean;
67
+ /**
68
+ The treemap's `paddingTop`: a group above the drawn tiles (hierarchy depth
69
+ 1 through `drawDepth`) that fits a strip reserves it, and is recorded in
70
+ `strips` with the strip's height; every other node keeps `padding`.
71
+ */
72
+ export declare function groupPaddingTop(opts: {
73
+ drawDepth: number;
74
+ padding: number;
75
+ style: GroupLabelStyle | null;
76
+ }, strips: GroupStrips): (node: HierarchyRectangularNode<unknown>) => number;
77
+ /**
78
+ Stamps each group that reserved a strip with its header: the strip's box
79
+ (in the group's final, rounded position) and the group's merged row,
80
+ carrying its share of `total` and, when `label` gives one, its own label.
81
+ */
82
+ export declare function attachGroupHeaders(strips: GroupStrips, opts: {
83
+ aggs: Parameters<typeof merge>[1];
84
+ label?: GroupLabelStyle["label"];
85
+ total: number;
86
+ }): void;
87
+ /** The headers above the laid-out tiles, shallowest level first. */
88
+ export declare function collectGroupHeaders(leaves: {
89
+ parent: object | null;
90
+ }[]): TreemapGroupHeader[];
91
+ export {};
@@ -5,6 +5,8 @@
5
5
  - `applyLayout.ts` — chart-specific `TransformStage`.
6
6
  - `emit.ts` — rect + label scene nodes from the laid-out data.
7
7
  - `thresholdFunction.ts` — pure threshold-merge algorithm.
8
+ - `groupHeaders.ts` / `emitGroupHeaders.ts` — the header strip above
9
+ each group of a nested `groupBy`.
8
10
 
9
11
  The default export is the chart class via `makeChart(def)`; the named
10
12
  export is the def itself.