@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
@@ -7,6 +7,8 @@ import { Rect } from "../../shapes/index.js";
7
7
  import { BaseClass } from "../../utils/index.js";
8
8
  import type { D3Scale } from "../../utils/index.js";
9
9
  import Legend from "../Legend/Legend.js";
10
+ import type { ColorScaleType } from "./colorScaleType.js";
11
+ import type { ColorScaleBarGeometry } from "./colorScaleHoverMark.js";
10
12
  /**
11
13
  Creates an SVG color scale based on an array of data.
12
14
  */
@@ -24,6 +26,12 @@ export default class ColorScale extends BaseClass {
24
26
  _legendClass: Legend;
25
27
  _outerBounds: Record<string, number>;
26
28
  _rectClass: Rect;
29
+ /** The scale the last render built, with a `scale` function resolved. */
30
+ _scaleType: ColorScaleType;
31
+ /** Where the color bar sits, set when the bar variant renders (see colorScaleHoverMark). */
32
+ _barGeometry?: ColorScaleBarGeometry;
33
+ /** The value marked on the scale, set with `hover()`. */
34
+ _hoverValue?: number | false;
27
35
  /** Smooth-gradient fill token (`gradient:<json>`), set by renderGradientStops. */
28
36
  _gradientFill?: string;
29
37
  _sceneRenderer?: SvgRenderer;
@@ -61,6 +69,11 @@ export default class ColorScale extends BaseClass {
61
69
  */
62
70
  data(): DataPoint[];
63
71
  data(_: DataPoint[]): this;
72
+ /**
73
+ Marks a value on the scale: an extra axis tick where the value falls on the color bar and a badge reading it where that tick's label would sit, plus an outline around its bucket on a bucketed bar (`bucketAxis`). A scale drawn as discrete swatches draws no mark. A chart sets this while one of its shapes is hovered. Pass `false` to clear it. Turned off with `hoverMark(false)`.
74
+ */
75
+ hover(): number | false | undefined;
76
+ hover(_: number | false): this;
64
77
  /**
65
78
  A pass-through for the TextBox class used to style the labelMin and labelMax text.
66
79
  */
@@ -0,0 +1,14 @@
1
+ /**
2
+ The number of decimal places `value` is written with, read at 15
3
+ significant digits so float noise (`0.1 + 0.2`) doesn't count.
4
+ */
5
+ export declare function decimalPlaces(value: number): number;
6
+ /**
7
+ The `[lower, upper]` values a ColorScale label shows for the bucket
8
+ `[ticks[i], ticks[i + 1])`: the first and last values the data's own
9
+ precision can write inside it, so integer data reads "1 - 2", "3 - 4".
10
+ When `format` prints the upper bound the same as the next bucket's lower
11
+ one (an abbreviation like "1.5k"), the upper bound drops a decimal place
12
+ at a time until it reads differently ("1.49k").
13
+ */
14
+ export declare function bucketBounds(tick: number, i: number, ticks: number[], allValues: number[], format: (v: number) => string): [number, number];
@@ -0,0 +1,86 @@
1
+ import type { Bounds } from "@d3plus/math";
2
+ import type { GroupNode } from "@d3plus/render";
3
+ import type ColorScale from "./ColorScale.js";
4
+ /** A style value: a constant, or a function of the hovered value. */
5
+ type Style<T> = T | ((value: number) => T);
6
+ /** The `hoverMarkConfig` options. */
7
+ export interface ColorScaleHoverMarkConfig {
8
+ /** The tick at the value: `stroke` and `strokeWidth` default to the axis ticks' own, and `length` to the axis's `tickSize`. */
9
+ tickConfig?: {
10
+ length?: Style<number>;
11
+ stroke?: Style<string>;
12
+ strokeWidth?: Style<number>;
13
+ };
14
+ /** The value's badge: `fill` defaults to the value's color, `stroke` to the text color that reads on the background, and `fontColor` to a color contrasting the fill. */
15
+ badgeConfig?: {
16
+ fill?: Style<string>;
17
+ fontColor?: Style<string>;
18
+ fontFamily?: Style<string>;
19
+ fontSize?: Style<number>;
20
+ fontWeight?: Style<number | string>;
21
+ padding?: Style<number>;
22
+ rx?: Style<number>;
23
+ stroke?: Style<string>;
24
+ strokeWidth?: Style<number>;
25
+ };
26
+ /** The outline around the value's bucket on a bucketed bar (`bucketAxis`): `stroke` defaults to the text color that reads on the background. */
27
+ outlineConfig?: {
28
+ stroke?: Style<string>;
29
+ strokeWidth?: Style<number>;
30
+ };
31
+ }
32
+ /** `hoverMarkConfig`'s defaults. */
33
+ export declare function hoverMarkDefaults(): ColorScaleHoverMarkConfig;
34
+ /** The side of the bar the axis labels sit on. */
35
+ export type ColorScaleOrient = "bottom" | "left" | "right" | "top";
36
+ /**
37
+ Where the color bar sits in the ColorScale, recorded when a bar renders:
38
+ its axis maps a value to a pixel along the bar, and the bar spans `cross`
39
+ across it. `ticks` holds a bucketed bar's bucket starts.
40
+ */
41
+ export interface ColorScaleBarGeometry {
42
+ orient: ColorScaleOrient;
43
+ position: (value: number) => number;
44
+ /** The bar's start and end along its length. */
45
+ range: [number, number];
46
+ /** The bar's edges across its length. */
47
+ cross: [number, number];
48
+ /** The values at the bar's two ends, low first. */
49
+ domain: [number, number];
50
+ ticks?: number[];
51
+ }
52
+ /** `value` held within `[min, max]` (in either order). */
53
+ export declare function clampTo(value: number, [a, b]: [number, number]): number;
54
+ /**
55
+ The hovered value's pixel along the bar: a value outside the bar's domain
56
+ clamps to its nearer end. Null for a value that isn't a finite number.
57
+ */
58
+ export declare function barPosition(geometry: ColorScaleBarGeometry, value: number): number | null;
59
+ /**
60
+ The tick at `at` along a bar whose labels face `orient`: from the bar's
61
+ edge on the labels' side, `length` out toward them.
62
+ @returns The tick's two ends, on the bar first.
63
+ */
64
+ export declare function tickPoints(orient: ColorScaleOrient, at: number, cross: [number, number], length: number): [number, number][];
65
+ /**
66
+ The value badge's box: centered on `at` along the bar (held within
67
+ `[0, limit]`), its near edge `offset` past the bar's edge on the labels'
68
+ side, where the tick ends.
69
+ */
70
+ export declare function badgeBox(orient: ColorScaleOrient, at: number, cross: [number, number], size: {
71
+ width: number;
72
+ height: number;
73
+ }, limit: number, offset: number): Bounds;
74
+ /**
75
+ The span `[start, end]` of the bucket holding `value` on a bucketed bar
76
+ whose buckets start at `ticks`, the last running to `domainEnd`; null
77
+ when the value is below the first bucket.
78
+ */
79
+ export declare function bucketSpan(ticks: number[], value: number, domainEnd: number): [number, number] | null;
80
+ /**
81
+ Adds the hover mark for the ColorScale's hovered value to its scene
82
+ `group` (changed in place): nothing when no finite value is hovered,
83
+ `hoverMark` is off, or the scale draws discrete swatches.
84
+ */
85
+ export declare function addHoverMark(cs: ColorScale, group: GroupNode): void;
86
+ export {};
@@ -1,6 +1,9 @@
1
1
  import type ColorScale from "./ColorScale.js";
2
+ import type { ColorScaleType } from "./colorScaleType.js";
2
3
  /** Computed values shared between the scale solve and the render branches. */
3
4
  export interface ColorScaleCompute {
5
+ /** The scale this render builds, with a `scale` function resolved. */
6
+ scale: ColorScaleType;
4
7
  allValues: number[];
5
8
  domain: number[];
6
9
  ticks: number[] | undefined;
@@ -0,0 +1,17 @@
1
+ /** The kinds of scale a ColorScale can build. */
2
+ export type ColorScaleType = "buckets" | "jenks" | "linear" | "log" | "quantile";
3
+ /**
4
+ A ColorScale `scale` setting: a scale name, or a function that picks one
5
+ from the values the scale is built from (sorted ascending) and their
6
+ `[min, max]` extent, called with the ColorScale as `this`.
7
+ */
8
+ export type ColorScaleTypeSetting = ColorScaleType | ((this: unknown, values: number[], extent: [number, number] | [undefined, undefined]) => ColorScaleType);
9
+ export declare const colorScaleTypes: readonly ColorScaleType[];
10
+ /** Whether a scale draws as discrete swatches (one per bucket) rather than a bar. */
11
+ export declare const isBucketScale: (scale: ColorScaleType) => boolean;
12
+ /**
13
+ Resolves a `scale` setting to a scale name for one render. A function is
14
+ called with the sorted `values` and their extent, with `context` as
15
+ `this`. An unknown name warns and falls back to `"linear"`.
16
+ */
17
+ export declare function resolveColorScaleType(setting: unknown, values: number[], context?: unknown): ColorScaleType;
@@ -0,0 +1,41 @@
1
+ /** The fewest and most ticks a Timeline's brush selection may span. */
2
+ export interface BrushSpan {
3
+ min: number;
4
+ max: number;
5
+ }
6
+ /**
7
+ The fewest and most ticks a brush selection may span, from `brushMin` and
8
+ `brushMax` (each a number, or a function returning one). An unset or
9
+ non-finite `brushMax` is unlimited and a fractional one rounds down; one
10
+ below `brushMin` rises to it, so `brushMin` wins when they conflict.
11
+ */
12
+ export declare function brushSpan(brushMin: unknown, brushMax: unknown): BrushSpan;
13
+ /**
14
+ A selection's end tick indices (`lo` to `hi`, out of `count` ticks), moved
15
+ so it spans `span.min` to `span.max` ticks. Too short, it keeps its `fixed`
16
+ end and moves the other out, then the fixed end too where the ticks run
17
+ out. Too long, it keeps the `anchor` end (the one being dragged) and pulls
18
+ the other in.
19
+ */
20
+ export declare function spanIndices(lo: number, hi: number, count: number, span: BrushSpan, anchor?: "lo" | "hi", fixed?: "lo" | "hi"): [number, number];
21
+ /**
22
+ The end a selection keeps while it grows to `brushMin`: the end being
23
+ dragged (`anchor`), or its first when it is a single period (a click).
24
+ */
25
+ export declare const growFrom: (lo: number, hi: number, anchor: "lo" | "hi") => "lo" | "hi";
26
+ /**
27
+ A Timeline's brush span (see `brushSpan`); a single-period Timeline
28
+ (`brushing: false`) has no `brushMin` to meet.
29
+ */
30
+ export declare function timelineBrushSpan(schema: Record<string, unknown>): BrushSpan;
31
+ /**
32
+ A brushed selection fitted to `span`. `edges` are the period indices
33
+ (earliest first) under the brush's left and right edges, which a
34
+ reversed timeline holds latest first; `anchor` is the edge being dragged.
35
+ Pulled in, the dragged end stays put. Pushed out, the first period does,
36
+ or with `keepDragged` the dragged end (a click's period). Returns the
37
+ fitted indices, earliest first.
38
+ */
39
+ export declare function fitBrush(edges: [number, number], count: number, span: BrushSpan, anchor: "lo" | "hi", keepDragged?: boolean): [number, number];
40
+ /** The index of the value in `values` nearest `value`. */
41
+ export declare function nearestIndex(values: number[], value: number): number;
@@ -1,4 +1,10 @@
1
1
  import type Timeline from "./Timeline.js";
2
+ /**
3
+ A copy of `values` (dates, years or pixel positions) in ascending order.
4
+ A `reverse` timeline lays its ticks out from latest to earliest, but its
5
+ selections, defaults and playback run from earliest to latest.
6
+ */
7
+ export declare function byValue<T>(values: T[]): T[];
2
8
  /**
3
9
  Sets the Timeline-specific defaults that override the inherited Axis config,
4
10
  mirroring the original constructor body exactly.
@@ -18,6 +18,14 @@ export declare function prepareTicks(tl: Timeline): {
18
18
  export declare function measureTicksWidth(tl: Timeline, ticks: unknown[], tickFormat: (d: Date) => string): void;
19
19
  /** Resolves button-vs-tick behavior and sets the scale/domain/range. */
20
20
  export declare function configureScale(tl: Timeline, ticks: unknown[], playButtonWidth: number): boolean;
21
+ /**
22
+ Holds a starting `selection` to `brushMin` to `brushMax` periods, in
23
+ place, keeping its later end (or, at the first period, its earlier one),
24
+ and stores what remains as the Timeline's selection. `periods` are where
25
+ each period sits in `selection`'s terms (tick dates, or button positions)
26
+ and `dates` the periods themselves, both earliest first.
27
+ */
28
+ export declare function clampSelection(tl: Timeline, selection: unknown[], periods: unknown[], dates?: unknown[]): void;
21
29
  /** Builds the d3-brush, computes the active selection, and mounts the brush group. */
22
30
  export declare function setupBrush(tl: Timeline, hiddenHandles: boolean, height: string, y: string): void;
23
31
  /** Renders the play button TextBox into its own group. */
@@ -33,6 +33,14 @@ export default class Tooltip extends BaseClass {
33
33
  @private
34
34
  */
35
35
  render(callback?: (...args: unknown[]) => unknown): this;
36
+ /**
37
+ CSS classes added to each tooltip element, next to its fixed
38
+ `d3plus-tooltip` class, so page CSS can style these tooltips (a chart
39
+ passes its `tooltipConfig.className`). Takes a space-separated string or
40
+ an array; a new value replaces the classes the previous one added.
41
+ */
42
+ className(): string | string[] | undefined;
43
+ className(_: string | string[] | undefined): this;
36
44
  /**
37
45
  CSS styles applied to the arrow element.
38
46
  */
@@ -2,18 +2,11 @@ import type { DataPoint } from "@d3plus/data";
2
2
  import type { D3Selection } from "@d3plus/dom";
3
3
  import type { GroupNode } from "@d3plus/render";
4
4
  import { BaseClass } from "../utils/index.js";
5
- import Circle from "./Circle.js";
5
+ import type Circle from "./Circle.js";
6
6
  import Rect from "./Rect.js";
7
7
  import type { BoxConfig } from "./shapeConfig.js";
8
8
  import type { Owned } from "./shapeOwners.js";
9
9
  import Whisker from "./Whisker.js";
10
- /**
11
- The box Rect's config: `rectConfig`, plus the Box's own `texture`,
12
- `textureDefault`, `backgroundImage`, and `backgroundImageFit` where
13
- `rectConfig` leaves them unset. Accessors resolve against the box's merged
14
- datum, the same one `orient` and `rectWidth` see.
15
- */
16
- export declare function boxRectConfig(schema: Record<string, unknown>, rectConfig: Record<string, unknown>): Record<string, unknown>;
17
10
  /**
18
11
  Creates SVG box-and-whisker plots based on an array of data, one per group of values.
19
12
  */
@@ -0,0 +1,9 @@
1
+ import Circle from "./Circle.js";
2
+ import Rect from "./Rect.js";
3
+ /**
4
+ The shape class a Box's `outlier` setting names: `"Circle"` or `"Rect"`.
5
+ Undefined for `false`, or any other value, which draws no point.
6
+ */
7
+ export declare function outlierShape(value: unknown): typeof Circle | typeof Rect | undefined;
8
+ /** Whether a Box's `outlier` setting draws a point. */
9
+ export declare const drawsOutlier: (value: unknown) => boolean;
@@ -0,0 +1,19 @@
1
+ /** A Box's `whiskerMode` for each end: `"tukey"`, `"extent"`, or a quantile. */
2
+ export type WhiskerMode = (string | number)[];
3
+ /** The statistics a Box draws from its values. */
4
+ export interface BoxStats {
5
+ first: number | undefined;
6
+ median: number | undefined;
7
+ third: number | undefined;
8
+ lowerLimit: number | undefined;
9
+ upperLimit: number | undefined;
10
+ }
11
+ /** A `whiskerMode` setting as a `[lower, upper]` pair. */
12
+ export declare function whiskerPair(mode: unknown): WhiskerMode;
13
+ /**
14
+ The quartiles and whisker ends of ascending `values`. Each whisker end
15
+ follows its side of `mode`: `"tukey"` reaches 1.5 interquartile ranges
16
+ past its quartile, stopping at the extreme value; `"extent"` reaches the
17
+ extreme value; a number reaches that quantile.
18
+ */
19
+ export declare function boxStats(values: number[], mode: WhiskerMode): BoxStats;
@@ -0,0 +1,25 @@
1
+ /**
2
+ The box Rect's config: `rectConfig`, plus the Box's own `fill`, `stroke`,
3
+ `texture`, `textureDefault`, `backgroundImage`, and `backgroundImageFit`
4
+ where `rectConfig` leaves them unset, and a white fill and black stroke
5
+ where neither sets them. Accessors resolve against the box's merged datum,
6
+ the same one `orient` and `rectWidth` see.
7
+ */
8
+ export declare function boxRectConfig(schema: Record<string, unknown>, rectConfig: Record<string, unknown>): Record<string, unknown>;
9
+ /**
10
+ Black or white, whichever reads better over `fill`; black when `fill`
11
+ isn't an opaque color.
12
+ */
13
+ export declare function boxMedianInk(fill: unknown): string;
14
+ /**
15
+ The median Rect's config: `medianConfig`, with a fill that contrasts with
16
+ the box's `boxFill` (resolved on the same box datum) where `medianConfig`
17
+ leaves it unset.
18
+ */
19
+ export declare function boxMedianConfig(boxFill: unknown, medianConfig: Record<string, unknown>): Record<string, unknown>;
20
+ /**
21
+ An outlier shape's config: `outlierConfig`, plus the Box's own `fill`
22
+ resolved against each outlier's observation where `outlierConfig` leaves
23
+ it unset.
24
+ */
25
+ export declare function boxOutlierConfig(schema: Record<string, unknown>, outlierConfig: Record<string, unknown>): Record<string, unknown>;
@@ -0,0 +1,66 @@
1
+ /**
2
+ Precomputed boxes: when a Box is given its statistics (`boxMin`,
3
+ `boxQ1`, `boxMedian`, `boxQ3`, `boxMax`, and optionally `boxOutliers`),
4
+ each data row draws one box from them and nothing is computed.
5
+ */
6
+ import type { DataPoint } from "@d3plus/data";
7
+ import type { Owned } from "./shapeOwners.js";
8
+ /** A row accessor. */
9
+ type RowFn = (d: DataPoint, i: number) => unknown;
10
+ /** The config keys that give a box its five statistics, lowest first. */
11
+ export declare const boxStatKeys: readonly ["boxMin", "boxQ1", "boxMedian", "boxQ3", "boxMax"];
12
+ /** One row's statistics, each a finite number. */
13
+ export interface BoxSummary {
14
+ min: number;
15
+ q1: number;
16
+ median: number;
17
+ q3: number;
18
+ max: number;
19
+ outliers: number[];
20
+ }
21
+ /**
22
+ A statistic setting as a row accessor: unset for `undefined`, `null`, or
23
+ `false`, a data key for a string, a function as given, and any other
24
+ value as a constant.
25
+ */
26
+ export declare function toStatAccessor(value: unknown): RowFn | undefined;
27
+ /** Whether `config` sets any of the five statistics, which draws precomputed boxes. */
28
+ export declare function hasBoxStats(config: Record<string, unknown>): boolean;
29
+ /** The statistics `config` leaves unset, when it sets at least one. */
30
+ export declare function missingBoxStats(config: Record<string, unknown>): string[];
31
+ /** Warns, once, that a precomputed box config leaves some statistics unset. */
32
+ export declare function warnMissingBoxStats(owner: string, config: Record<string, unknown>): void;
33
+ /**
34
+ Reads one row's statistics from `config`'s accessors. The five values are
35
+ sorted, so `min` is the smallest and `max` the largest even when they
36
+ arrive in reverse (as pixels on a top-down axis do). Null when a
37
+ statistic is unset or isn't a finite number.
38
+ */
39
+ export declare function readBoxSummary(config: Record<string, unknown>, d: DataPoint, i: number): BoxSummary | null;
40
+ /**
41
+ Every value a row's statistics place on the value axis, for widening its
42
+ domain: each set statistic that is a finite number, then the outliers
43
+ unless `outliers` is false (the row draws none). An incomplete set still
44
+ contributes, so the axis holds its values even though the row draws no
45
+ box.
46
+ */
47
+ export declare function boxSummaryValues(config: Record<string, unknown>, d: DataPoint, i: number, outliers?: boolean): number[];
48
+ /**
49
+ Stamps a box datum's rect geometry from its quartiles (`first` and
50
+ `third`): centered between them along the value axis, `rectWidth` across
51
+ it, at `key` on the category axis.
52
+ */
53
+ export declare function placeBox(d: DataPoint, key: unknown, rectWidth: number): void;
54
+ /** What a precomputed Box reads from its host. */
55
+ export interface SummaryBoxHost {
56
+ schema: Record<string, unknown>;
57
+ _data: DataPoint[];
58
+ _owned: Map<object, Owned>;
59
+ }
60
+ /**
61
+ Builds one box per row from its statistics, appending its outliers to
62
+ `outlierData` (none when its `outlier` setting draws no point) and recording which box owns each record in `host._owned`.
63
+ Rows without a complete set of statistics draw nothing.
64
+ */
65
+ export declare function computeSummaryBoxes(host: SummaryBoxHost, outlierData: DataPoint[]): DataPoint[];
66
+ export {};
@@ -19,7 +19,7 @@ export declare const shapeLabelDefaults: {
19
19
  textAnchor: string;
20
20
  verticalAlign: string;
21
21
  rotate(d: DataPoint): number;
22
- rotateAnchor(d: DataPoint): number[] | (string & any[]) | (number & any[]) | (false & any[]) | (true & any[]) | (DataPoint & any[]);
22
+ rotateAnchor(d: DataPoint): number[] | (string & any[]) | (number & any[]) | (true & any[]) | (DataPoint & any[]) | (false & any[]);
23
23
  fontColor(this: {
24
24
  _fill?: ((d: DataPoint, i: number) => unknown) | string;
25
25
  }, d: DataPoint, i: number): string;
@@ -92,8 +92,17 @@ export interface BaseShapeConfig {
92
92
  hoverOpacity?: number;
93
93
  /** Style overrides for hovered data points. */
94
94
  hoverStyle?: Record<string, unknown>;
95
- /** Hit-area shape: function returning bounds or static bounds. */
96
- hitArea?: ((d: DataPoint, i: number, aes: unknown) => Record<string, unknown>) | Record<string, unknown>;
95
+ /**
96
+ An invisible hover and click target drawn behind each mark: bounds
97
+ (`x`, `y`, `width`, `height`, relative to the mark's position), or a
98
+ function returning them per datum. A Line takes a wide transparent
99
+ stroke along its path. Side-by-side bars in a Plot (a BarChart that
100
+ isn't stacked, or a Histogram) fill their whole slot by default, from
101
+ one edge of the plot to the other, so a short bar is as easy to hover
102
+ as a tall one; `shapeConfig: {Bar: {hitArea: false}}` limits them to
103
+ the bars themselves.
104
+ */
105
+ hitArea?: ((d: DataPoint, i: number, aes: unknown) => Record<string, unknown> | false | null) | Record<string, unknown> | false;
97
106
  /** Unique-id accessor per datum (used for keyed enter/update/exit). */
98
107
  id?: AccessorFn;
99
108
  /** Label text(s) per datum. False/undefined skips. */
@@ -216,18 +225,47 @@ export interface BoxConfig {
216
225
  backgroundImage?: ConstOrAccessor<string>;
217
226
  /** How the box's `backgroundImage` fits it: `"cover"` (default) or `"contain"`. */
218
227
  backgroundImageFit?: ConstOrAccessor<"cover" | "contain">;
228
+ /** Precomputed boxes: each row's upper whisker end, a data key or accessor in the same units as the value axis's `x` or `y`. See `boxMedian`. */
229
+ boxMax?: string | ((d: DataPoint, i: number) => number);
230
+ /**
231
+ Precomputed boxes: each row's median, a data key or accessor in the
232
+ same units as the value axis's `x` or `y`. Setting it, `boxMin`,
233
+ `boxQ1`, `boxQ3`, or `boxMax` makes each row one box drawn from those
234
+ values, with nothing computed and `whiskerMode` unused. All five are
235
+ needed (a warning names any left unset), and a row whose values aren't
236
+ all numbers draws no box.
237
+ */
238
+ boxMedian?: string | ((d: DataPoint, i: number) => number);
239
+ /** Precomputed boxes: each row's lower whisker end. See `boxMedian`. */
240
+ boxMin?: string | ((d: DataPoint, i: number) => number);
241
+ /** Precomputed boxes: each row's outliers, a data key or accessor returning an array of values drawn past the whiskers. See `boxMedian`. */
242
+ boxOutliers?: string | ((d: DataPoint, i: number) => number[]);
243
+ /** Precomputed boxes: each row's lower quartile, where the box starts. See `boxMedian`. */
244
+ boxQ1?: string | ((d: DataPoint, i: number) => number);
245
+ /** Precomputed boxes: each row's upper quartile, where the box ends. See `boxMedian`. */
246
+ boxQ3?: string | ((d: DataPoint, i: number) => number);
219
247
  data?: DataPoint[];
248
+ /** Each box's fill, resolved against its merged datum (white when unset); `rectConfig.fill` overrides it. Outliers take it too, resolved against each observation, and the median line defaults to black or white, whichever contrasts with it. */
249
+ fill?: ConstOrAccessor<string>;
220
250
  /** Each box's id, read from its first row; keys every part the box draws. Defaults to the box's x (vertical) or y (horizontal) value. */
221
251
  id?: ConstOrAccessor<string | number>;
222
252
  medianConfig?: Record<string, unknown>;
223
253
  /** Orientation: "vertical" or "horizontal". */
224
254
  orient?: ConstOrAccessor<Orient>;
225
- /** Outlier accessor (per-datum predicate). */
226
- outlier?: ConstOrAccessor<string>;
255
+ /**
256
+ The shape each outlier draws as: `"Circle"` (default) or `"Rect"`, or
257
+ `false` to draw no point. An accessor receives each outlier's
258
+ observation (a precomputed box's row). In BoxWhisker, the value axis
259
+ leaves out the outliers it hides and reaches only as far as the
260
+ whiskers.
261
+ */
262
+ outlier?: ConstOrAccessor<"Circle" | "Rect" | false>;
227
263
  outlierConfig?: Record<string, unknown>;
228
264
  rectConfig?: Record<string, unknown>;
229
265
  rectWidth?: ConstOrAccessor<number>;
230
266
  select?: string | HTMLElement | SVGElement | null;
267
+ /** Each box's outline color, resolved against its merged datum (black when unset); `rectConfig.stroke` overrides it. */
268
+ stroke?: ConstOrAccessor<string>;
231
269
  /** Texture (per textures.js) filling each box; `rectConfig.texture` overrides it. */
232
270
  texture?: ConstOrAccessor<string | Record<string, unknown>>;
233
271
  /** Default texture config merged into the box's texture. */
@@ -50,6 +50,29 @@ export default class BaseClass {
50
50
  */
51
51
  locale(): string;
52
52
  locale(_: string | object): this;
53
+ /**
54
+ CSS classes added to the outermost element this chart or component draws
55
+ into, next to its fixed d3plus classes, so page CSS can target it: a
56
+ chart's root `<svg class="d3plus-viz">` (its `<canvas>` with the Canvas
57
+ renderer) and a standalone component's `<svg>`. Takes a space-separated
58
+ string or an array. A new value replaces the classes the previous one
59
+ added; unset adds none. Tooltips take their own `tooltipConfig.className`.
60
+
61
+ @example
62
+ new d3plus.BarChart().className("revenue-chart dark");
63
+ */
64
+ className(): string | string[] | undefined;
65
+ className(_: string | string[] | undefined): this;
66
+ /**
67
+ The elements `className` adds its classes to, with the fixed classes
68
+ each one keeps: the drawing surface of the instance's scene renderer,
69
+ once it has rendered.
70
+ @private
71
+ */
72
+ _classNameTargets(): {
73
+ el: Element;
74
+ keep?: string[];
75
+ }[];
53
76
  /**
54
77
  Overrides the default colors used when assigning fills from data and choosing legible text colors: `dark` and `light` (the text colors picked for contrast against a background), `missing` (null/undefined values), `on`/`off` (`true`/`false` values), `sequential` (the anchor hue for magnitude ramps), and `scale` (the categorical palette, given as a d3 ordinal scale or an array of colors). Keys are merged into the current defaults, and a Viz passes its overrides down to the shapes and components it draws.
55
78
 
@@ -32,6 +32,9 @@ export interface D3Scale<Out = number> {
32
32
  /** Continuous scales only: get/set output clamping. */
33
33
  clamp?(): boolean;
34
34
  clamp?(clamp: boolean): D3Scale<Out>;
35
+ /** Power scales only: get/set the exponent. */
36
+ exponent?(): number;
37
+ exponent?(exponent: number): D3Scale<Out>;
35
38
  /** Band / point scales only: width of one band. */
36
39
  bandwidth?(): number;
37
40
  /** Band / point scales only: distance between band starts. */