@d3plus/core 4.11.0 → 4.12.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 (287) hide show
  1. package/es/internal.js +15 -5
  2. package/es/src/charts/Alluvial/emit.js +2 -2
  3. package/es/src/charts/Alluvial/index.js +7 -1
  4. package/es/src/charts/Alluvial/titles.js +24 -4
  5. package/es/src/charts/ArcDiagram/emit.js +27 -13
  6. package/es/src/charts/ArcDiagram/events.js +6 -2
  7. package/es/src/charts/ArcDiagram/index.js +2 -0
  8. package/es/src/charts/BarChart/index.js +3 -10
  9. package/es/src/charts/Calendar/index.js +2 -0
  10. package/es/src/charts/Candlestick/index.js +4 -10
  11. package/es/src/charts/Gantt/applyLayout.js +2 -4
  12. package/es/src/charts/Geomap/flowEmit.js +11 -6
  13. package/es/src/charts/Hexbin/index.js +2 -0
  14. package/es/src/charts/Icicle/index.js +3 -1
  15. package/es/src/charts/Matrix/applyLayout.js +20 -9
  16. package/es/src/charts/Matrix/index.js +19 -1
  17. package/es/src/charts/Network/applyLayout.js +36 -5
  18. package/es/src/charts/Network/bundle.js +5 -4
  19. package/es/src/charts/Network/emit.js +39 -40
  20. package/es/src/charts/Network/graph.js +34 -5
  21. package/es/src/charts/Network/graphFluent.js +5 -3
  22. package/es/src/charts/Network/index.js +6 -1
  23. package/es/src/charts/Pack/applyLayout.js +16 -5
  24. package/es/src/charts/Pack/emit.js +15 -8
  25. package/es/src/charts/Pack/groupRows.js +61 -0
  26. package/es/src/charts/Pack/index.js +3 -0
  27. package/es/src/charts/Pack/neutralPaint.js +20 -0
  28. package/es/src/charts/Pack/nodeNames.js +35 -0
  29. package/es/src/charts/ParallelCoordinates/axes.js +22 -22
  30. package/es/src/charts/ParallelCoordinates/chrome.js +18 -0
  31. package/es/src/charts/ParallelCoordinates/index.js +3 -1
  32. package/es/src/charts/ParallelCoordinates/titles.js +17 -9
  33. package/es/src/charts/Pie/emit.js +9 -1
  34. package/es/src/charts/Pie/index.js +10 -0
  35. package/es/src/charts/Plot/areaEnter.js +68 -0
  36. package/es/src/charts/Plot/draw.js +26 -12
  37. package/es/src/charts/Plot/index.js +4 -10
  38. package/es/src/charts/Plot/lineMarkerKeys.js +19 -0
  39. package/es/src/charts/Plot/plotInit.js +6 -0
  40. package/es/src/charts/Plot/shapeLabelLegend.js +67 -0
  41. package/es/src/charts/Plot/sharedHover.js +2 -1
  42. package/es/src/charts/Plot/sharedTooltip.js +13 -3
  43. package/es/src/charts/PolarArea/index.js +2 -1
  44. package/es/src/charts/Priestley/applyLayout.js +11 -7
  45. package/es/src/charts/Priestley/index.js +0 -2
  46. package/es/src/charts/Priestley/timeAxis.js +11 -8
  47. package/es/src/charts/Pyramid/gutter.js +52 -16
  48. package/es/src/charts/Pyramid/index.js +55 -7
  49. package/es/src/charts/Pyramid/scene.js +4 -4
  50. package/es/src/charts/Radar/applyLayout.js +31 -33
  51. package/es/src/charts/Radar/axisDecorations.js +29 -17
  52. package/es/src/charts/Radar/curvedLabels.js +43 -2
  53. package/es/src/charts/Radar/emit.js +30 -15
  54. package/es/src/charts/Radar/index.js +41 -2
  55. package/es/src/charts/Radar/points.js +85 -0
  56. package/es/src/charts/RadialBar/emit.js +6 -1
  57. package/es/src/charts/RadialBar/index.js +10 -0
  58. package/es/src/charts/RadialMatrix/applyLayout.js +115 -31
  59. package/es/src/charts/RadialMatrix/index.js +15 -2
  60. package/es/src/charts/Rings/applyLayout.js +11 -150
  61. package/es/src/charts/Rings/emit.js +80 -40
  62. package/es/src/charts/Rings/index.js +27 -4
  63. package/es/src/charts/Rings/ringsCurves.js +156 -0
  64. package/es/src/charts/Rings/ringsParallel.js +20 -3
  65. package/es/src/charts/Rings/ringsPlacement.js +152 -0
  66. package/es/src/charts/Rings/ringsSizing.js +61 -38
  67. package/es/src/charts/Sankey/applyLayout.js +18 -4
  68. package/es/src/charts/Sankey/index.js +7 -1
  69. package/es/src/charts/Sunburst/emit.js +9 -1
  70. package/es/src/charts/Sunburst/index.js +13 -1
  71. package/es/src/charts/Tree/applyLayout.js +44 -14
  72. package/es/src/charts/Tree/emit.js +5 -5
  73. package/es/src/charts/Tree/index.js +10 -12
  74. package/es/src/charts/Tree/keys.js +33 -0
  75. package/es/src/charts/Tree/nodeLabel.js +15 -0
  76. package/es/src/charts/Treemap/emitGroupHeaders.js +3 -5
  77. package/es/src/charts/definition/makeChart.js +6 -2
  78. package/es/src/charts/drawSteps/minimap.js +4 -20
  79. package/es/src/charts/drawSteps/zoomActions.js +36 -0
  80. package/es/src/charts/drawSteps/zoomControls.js +31 -18
  81. package/es/src/charts/drawSteps/zoomControlsMarkup.js +23 -4
  82. package/es/src/charts/drawSteps/zoomDrag.js +188 -0
  83. package/es/src/charts/drawSteps/zoomFit.js +69 -0
  84. package/es/src/charts/events/click.legend.js +4 -2
  85. package/es/src/charts/events/click.shape.js +5 -3
  86. package/es/src/charts/events/mouseenter.js +6 -16
  87. package/es/src/charts/events/mouseleave.js +9 -2
  88. package/es/src/charts/events/mousemove.legend.js +28 -32
  89. package/es/src/charts/events/mousemove.shape.js +44 -44
  90. package/es/src/charts/features/axes.js +15 -4
  91. package/es/src/charts/features/axesFinal.js +7 -2
  92. package/es/src/charts/features/axesMeasure.js +26 -8
  93. package/es/src/charts/features/axisTooltip.js +138 -0
  94. package/es/src/charts/features/centerLabel.js +177 -0
  95. package/es/src/charts/features/colorScaleBivariate.js +83 -0
  96. package/es/src/charts/features/colorScaleBucket.js +18 -0
  97. package/es/src/charts/features/colorScaleHover.js +30 -5
  98. package/es/src/charts/features/colorScaleLimit.js +73 -0
  99. package/es/src/charts/features/colorScaleTooltip.js +77 -0
  100. package/es/src/charts/features/colorScaleTop.js +61 -0
  101. package/es/src/charts/features/curvedArrows.js +33 -0
  102. package/es/src/charts/features/depthKey.js +26 -0
  103. package/es/src/charts/features/edgeArrows.js +61 -2
  104. package/es/src/charts/features/featuresColorScale.js +57 -16
  105. package/es/src/charts/features/hoverTicks.js +41 -0
  106. package/es/src/charts/features/idleQueue.js +72 -0
  107. package/es/src/charts/features/linkInteraction.js +59 -7
  108. package/es/src/charts/features/networkMeasures.js +241 -0
  109. package/es/src/charts/features/nodeStats.js +309 -0
  110. package/es/src/charts/features/plotEndLabels.js +28 -7
  111. package/es/src/charts/features/plotPaint.js +9 -2
  112. package/es/src/charts/features/shapeEmit.js +7 -1
  113. package/es/src/charts/features/textHalo.js +3 -2
  114. package/es/src/charts/partition/chartFields.js +12 -3
  115. package/es/src/charts/partition/interaction.js +10 -5
  116. package/es/src/charts/pipeline/insetPlacement.js +8 -3
  117. package/es/src/charts/polar/chrome.js +81 -9
  118. package/es/src/charts/polar/config.js +4 -0
  119. package/es/src/charts/polar/wedgeLayout.js +2 -1
  120. package/es/src/charts/viz/Viz.js +24 -15
  121. package/es/src/charts/viz/VizBase.js +39 -4
  122. package/es/src/charts/viz/backgroundInk.js +10 -0
  123. package/es/src/charts/viz/emphasis.js +14 -0
  124. package/es/src/charts/viz/fillStroke.js +10 -0
  125. package/es/src/charts/viz/interactionOpacity.js +115 -32
  126. package/es/src/charts/viz/reportDrawError.js +15 -0
  127. package/es/src/charts/viz/setCursor.js +29 -0
  128. package/es/src/charts/viz/tooltipEnabled.js +38 -0
  129. package/es/src/charts/viz/userClick.js +34 -0
  130. package/es/src/charts/viz/vizDataPolling.js +0 -1
  131. package/es/src/charts/viz/vizDefaults.js +13 -34
  132. package/es/src/charts/viz/vizFields.js +6 -1
  133. package/es/src/charts/viz/vizRender.js +35 -5
  134. package/es/src/charts/viz/vizVisibility.js +12 -2
  135. package/es/src/components/Axis/Axis.js +29 -2
  136. package/es/src/components/Axis/axisBreak.js +29 -7
  137. package/es/src/components/Axis/axisDefaults.js +11 -0
  138. package/es/src/components/Axis/axisLabelKinds.js +36 -0
  139. package/es/src/components/Axis/axisLabelLineHeight.js +19 -0
  140. package/es/src/components/Axis/axisLabelRoom.js +37 -0
  141. package/es/src/components/Axis/axisLabelSize.js +171 -0
  142. package/es/src/components/Axis/axisLabelThinning.js +98 -4
  143. package/es/src/components/Axis/axisLayout.js +71 -46
  144. package/es/src/components/Axis/axisLayoutLabels.js +82 -140
  145. package/es/src/components/Axis/axisLayoutScale.js +9 -10
  146. package/es/src/components/Axis/axisLimit.js +27 -0
  147. package/es/src/components/Axis/axisMaxSize.js +39 -0
  148. package/es/src/components/Axis/axisRender.js +20 -8
  149. package/es/src/components/Axis/axisRounding.js +16 -1
  150. package/es/src/components/Axis/axisScene.js +11 -2
  151. package/es/src/components/Axis/axisTitle.js +53 -0
  152. package/es/src/components/Axis/axisTooltipTargets.js +128 -0
  153. package/es/src/components/ColorScale/ColorScale.js +62 -18
  154. package/es/src/components/ColorScale/bivariateRender.js +353 -0
  155. package/es/src/components/ColorScale/bivariateScale.js +150 -0
  156. package/es/src/components/ColorScale/colorScaleRender.js +32 -2
  157. package/es/src/components/ColorScale/colorScaleSwatchTooltips.js +77 -0
  158. package/es/src/components/Legend/Legend.js +10 -2
  159. package/es/src/components/Legend/legendCut.js +108 -0
  160. package/es/src/components/Legend/legendRender.js +38 -13
  161. package/es/src/components/TextBox.js +5 -2
  162. package/es/src/components/Timeline/timelineRender.js +2 -1
  163. package/es/src/components/textBoxScene.js +3 -0
  164. package/es/src/components/textEllipsis.js +7 -0
  165. package/es/src/components/tooltipDom.js +8 -5
  166. package/es/src/fluent.js +48 -0
  167. package/es/src/utils/BaseClass.js +7 -2
  168. package/es/src/utils/configValue.js +9 -0
  169. package/package.json +10 -10
  170. package/types/index.d.ts +1 -1
  171. package/types/internal.d.ts +22 -5
  172. package/types/src/charts/Alluvial/titles.d.ts +16 -3
  173. package/types/src/charts/ArcDiagram/emit.d.ts +3 -2
  174. package/types/src/charts/ArcDiagram/events.d.ts +2 -1
  175. package/types/src/charts/Geomap/flowEmit.d.ts +3 -2
  176. package/types/src/charts/Matrix/applyLayout.d.ts +4 -2
  177. package/types/src/charts/Network/applyLayout.d.ts +11 -0
  178. package/types/src/charts/Network/bundle.d.ts +3 -1
  179. package/types/src/charts/Network/graph.d.ts +12 -4
  180. package/types/src/charts/Pack/applyLayout.d.ts +2 -0
  181. package/types/src/charts/Pack/groupRows.d.ts +46 -0
  182. package/types/src/charts/Pack/index.d.ts +3 -0
  183. package/types/src/charts/Pack/neutralPaint.d.ts +14 -0
  184. package/types/src/charts/Pack/nodeNames.d.ts +23 -0
  185. package/types/src/charts/ParallelCoordinates/chrome.d.ts +12 -0
  186. package/types/src/charts/ParallelCoordinates/index.d.ts +1 -0
  187. package/types/src/charts/ParallelCoordinates/titles.d.ts +7 -2
  188. package/types/src/charts/Plot/areaEnter.d.ts +34 -0
  189. package/types/src/charts/Plot/index.d.ts +4 -10
  190. package/types/src/charts/Plot/lineMarkerKeys.d.ts +11 -0
  191. package/types/src/charts/Plot/shapeLabelLegend.d.ts +19 -0
  192. package/types/src/charts/Plot/sharedTooltip.d.ts +7 -1
  193. package/types/src/charts/Priestley/timeAxis.d.ts +7 -4
  194. package/types/src/charts/Pyramid/gutter.d.ts +28 -6
  195. package/types/src/charts/Pyramid/scene.d.ts +1 -1
  196. package/types/src/charts/Radar/applyLayout.d.ts +2 -3
  197. package/types/src/charts/Radar/axisDecorations.d.ts +5 -2
  198. package/types/src/charts/Radar/curvedLabels.d.ts +35 -0
  199. package/types/src/charts/Radar/emit.d.ts +5 -2
  200. package/types/src/charts/Radar/index.d.ts +7 -2
  201. package/types/src/charts/Radar/points.d.ts +50 -0
  202. package/types/src/charts/RadialMatrix/applyLayout.d.ts +6 -4
  203. package/types/src/charts/Rings/emit.d.ts +24 -2
  204. package/types/src/charts/Rings/index.d.ts +4 -2
  205. package/types/src/charts/Rings/ringsCurves.d.ts +50 -0
  206. package/types/src/charts/Rings/ringsGraph.d.ts +29 -5
  207. package/types/src/charts/Rings/ringsParallel.d.ts +4 -2
  208. package/types/src/charts/Rings/ringsPlacement.d.ts +47 -0
  209. package/types/src/charts/Rings/ringsSizing.d.ts +36 -9
  210. package/types/src/charts/Tree/applyLayout.d.ts +20 -0
  211. package/types/src/charts/Tree/keys.d.ts +25 -0
  212. package/types/src/charts/Tree/nodeLabel.d.ts +11 -0
  213. package/types/src/charts/definition/ChartDefinition.d.ts +13 -0
  214. package/types/src/charts/definition/makeChart.d.ts +2 -2
  215. package/types/src/charts/drawSteps/zoomActions.d.ts +30 -0
  216. package/types/src/charts/drawSteps/zoomControls.d.ts +15 -0
  217. package/types/src/charts/drawSteps/zoomControlsMarkup.d.ts +16 -1
  218. package/types/src/charts/drawSteps/zoomDrag.d.ts +71 -0
  219. package/types/src/charts/drawSteps/zoomFit.d.ts +30 -0
  220. package/types/src/charts/features/axisTooltip.d.ts +49 -0
  221. package/types/src/charts/features/centerLabel.d.ts +75 -0
  222. package/types/src/charts/features/colorScaleBivariate.d.ts +50 -0
  223. package/types/src/charts/features/colorScaleBucket.d.ts +10 -0
  224. package/types/src/charts/features/colorScaleHover.d.ts +13 -3
  225. package/types/src/charts/features/colorScaleLimit.d.ts +60 -0
  226. package/types/src/charts/features/colorScaleTooltip.d.ts +43 -0
  227. package/types/src/charts/features/colorScaleTop.d.ts +30 -0
  228. package/types/src/charts/features/curvedArrows.d.ts +14 -0
  229. package/types/src/charts/features/depthKey.d.ts +19 -0
  230. package/types/src/charts/features/edgeArrows.d.ts +29 -2
  231. package/types/src/charts/features/hoverTicks.d.ts +30 -0
  232. package/types/src/charts/features/idleQueue.d.ts +46 -0
  233. package/types/src/charts/features/linkInteraction.d.ts +13 -4
  234. package/types/src/charts/features/networkMeasures.d.ts +53 -0
  235. package/types/src/charts/features/nodeStats.d.ts +93 -0
  236. package/types/src/charts/features/plotEndLabels.d.ts +14 -1
  237. package/types/src/charts/features/textHalo.d.ts +4 -3
  238. package/types/src/charts/partition/chartFields.d.ts +6 -1
  239. package/types/src/charts/pipeline/insetPlacement.d.ts +6 -0
  240. package/types/src/charts/polar/chrome.d.ts +19 -6
  241. package/types/src/charts/viz/Viz.d.ts +10 -3
  242. package/types/src/charts/viz/VizBase.d.ts +31 -2
  243. package/types/src/charts/viz/backgroundInk.d.ts +8 -0
  244. package/types/src/charts/viz/emphasis.d.ts +17 -0
  245. package/types/src/charts/viz/fillStroke.d.ts +7 -0
  246. package/types/src/charts/viz/reportDrawError.d.ts +12 -0
  247. package/types/src/charts/viz/setCursor.d.ts +26 -0
  248. package/types/src/charts/viz/tooltipEnabled.d.ts +31 -0
  249. package/types/src/charts/viz/userClick.d.ts +35 -0
  250. package/types/src/charts/viz/vizFields.d.ts +5 -0
  251. package/types/src/charts/viz/vizTypes.d.ts +16 -0
  252. package/types/src/charts/viz/vizVisibility.d.ts +7 -0
  253. package/types/src/components/Axis/Axis.d.ts +33 -3
  254. package/types/src/components/Axis/axisBreak.d.ts +19 -3
  255. package/types/src/components/Axis/axisDefaults.d.ts +12 -0
  256. package/types/src/components/Axis/axisLabelKinds.d.ts +22 -0
  257. package/types/src/components/Axis/axisLabelLineHeight.d.ts +27 -0
  258. package/types/src/components/Axis/axisLabelRoom.d.ts +17 -0
  259. package/types/src/components/Axis/axisLabelSize.d.ts +82 -0
  260. package/types/src/components/Axis/axisLabelThinning.d.ts +38 -2
  261. package/types/src/components/Axis/axisLayout.d.ts +9 -2
  262. package/types/src/components/Axis/axisLayoutLabels.d.ts +28 -33
  263. package/types/src/components/Axis/axisLayoutScale.d.ts +3 -1
  264. package/types/src/components/Axis/axisLimit.d.ts +18 -0
  265. package/types/src/components/Axis/axisMaxSize.d.ts +48 -0
  266. package/types/src/components/Axis/axisRounding.d.ts +8 -0
  267. package/types/src/components/Axis/axisTitle.d.ts +30 -0
  268. package/types/src/components/Axis/axisTooltipTargets.d.ts +82 -0
  269. package/types/src/components/ColorScale/ColorScale.d.ts +21 -11
  270. package/types/src/components/ColorScale/bivariateRender.d.ts +53 -0
  271. package/types/src/components/ColorScale/bivariateScale.d.ts +92 -0
  272. package/types/src/components/ColorScale/colorScaleSwatchTooltips.d.ts +48 -0
  273. package/types/src/components/Legend/Legend.d.ts +5 -0
  274. package/types/src/components/Legend/legendCut.d.ts +31 -0
  275. package/types/src/components/Legend/legendRender.d.ts +6 -1
  276. package/types/src/components/TextBox.d.ts +4 -0
  277. package/types/src/components/textEllipsis.d.ts +6 -0
  278. package/types/src/fluent.d.ts +18 -0
  279. package/types/src/shapes/emitLabels.d.ts +1 -1
  280. package/types/src/utils/D3plusConfig.d.ts +485 -609
  281. package/types/src/utils/configValue.d.ts +8 -0
  282. package/types/src/utils/index.d.ts +1 -1
  283. package/types/umd-entry.d.ts +4 -0
  284. package/umd/d3plus-core.full.js +22930 -17936
  285. package/umd/d3plus-core.full.min.js +2 -2
  286. package/umd/d3plus-core.js +21240 -16404
  287. package/umd/d3plus-core.min.js +2 -2
@@ -0,0 +1,82 @@
1
+ /**
2
+ What an axis's title and tick labels carry for a chart's axis tooltips
3
+ (see `charts/features/axisTooltip.ts`): each label's scene nodes are
4
+ stamped with the label's value, its whole text, whether it is drawn cut
5
+ short, and the axis's `titleTooltip` or `tickTooltip`. A label no tooltip
6
+ could show for is left unstamped.
7
+ */
8
+ import type { SceneNode } from "@d3plus/render";
9
+ /** The label a pointer can show an axis tooltip for. */
10
+ export interface AxisTooltipTarget {
11
+ /** Which part of the axis the label is. */
12
+ part: "title" | "tick";
13
+ /** The tick's value, or the title. */
14
+ value: unknown;
15
+ /** The tick's index among the axis's labels, from the start of its domain (0 for a title). */
16
+ index: number;
17
+ /** The label's whole text. */
18
+ text: string;
19
+ /** Whether the label is drawn cut short. */
20
+ truncated: boolean;
21
+ /** The axis's `titleTooltip` or `tickTooltip`. */
22
+ option: unknown;
23
+ }
24
+ /**
25
+ The axis label a scene node was stamped as, if any.
26
+ @param node A picked scene node.
27
+ */
28
+ export declare function axisTooltipTarget(node: SceneNode | null | undefined): AxisTooltipTarget | undefined;
29
+ /**
30
+ Whether a text node draws less than `text`: its layout cut it short (see
31
+ `TextNode.truncated`) and its lines don't spell the whole text.
32
+ @param node A label's scene node.
33
+ @param text The label's whole text.
34
+ */
35
+ export declare function labelCut(node: SceneNode, text: string): boolean;
36
+ /**
37
+ Whether a label with `option` for its tooltip option could show one.
38
+ @param option An axis's `titleTooltip` or `tickTooltip`.
39
+ @param truncated Whether the label is drawn cut short.
40
+ */
41
+ export declare const canShow: (option: unknown, truncated: boolean) => boolean;
42
+ /** What `tickRank` reads of an axis. */
43
+ export interface RankedAxis {
44
+ schema: {
45
+ scale?: unknown;
46
+ };
47
+ _domainEndFirst?: boolean;
48
+ _givenDomain(): unknown[];
49
+ }
50
+ /**
51
+ Where a tick's value falls along an axis's domain, counted from the
52
+ domain's start: the lowest value of a value or time axis, the first
53
+ category of a categorical one (its last when the axis holds its domain
54
+ end first). Neither `reverse` nor a descending domain moves a value's
55
+ place.
56
+ @param axis A laid-out axis.
57
+ */
58
+ export declare function tickRank(axis: RankedAxis): (value: unknown) => number;
59
+ /**
60
+ Stamps an axis's tick label nodes (each label's text, and its hitbox when
61
+ it has one) with their tooltip target.
62
+ @param nodes The tick labels' scene nodes.
63
+ @param option The axis's `tickTooltip`.
64
+ @param rank Each tick value's place along the axis (see `tickRank`):
65
+ labels are indexed in that order, or in the order of `nodes` without it.
66
+ */
67
+ export declare function stampTickTooltips(nodes: SceneNode[], option: unknown, rank?: (value: unknown) => number): void;
68
+ /**
69
+ Stamps an axis's title nodes with their tooltip target.
70
+ @param nodes The title's scene nodes.
71
+ @param title The axis's title.
72
+ @param option The axis's `titleTooltip`.
73
+ */
74
+ export declare function stampTitleTooltip(nodes: SceneNode[], title: unknown, option: unknown): void;
75
+ /**
76
+ An axis's scene as chrome under a chart's marks: every node takes the
77
+ "axis" interaction group, and each one that draws leaves hit-testing
78
+ unless it is stamped with a tooltip target, so the pointer reaches the
79
+ axis only on a label with a tooltip to show.
80
+ @param node An axis's scene, or a node in it.
81
+ */
82
+ export declare function inertAxis(node: SceneNode): SceneNode;
@@ -1,6 +1,6 @@
1
1
  import type { D3Selection } from "@d3plus/dom";
2
2
  import type { DataPoint } from "@d3plus/data";
3
- import type { GroupNode } from "@d3plus/render";
3
+ import type { GroupNode, SceneNode } from "@d3plus/render";
4
4
  import type { SvgRenderer } from "@d3plus/render";
5
5
  import { Axis, TextBox } from "../index.js";
6
6
  import { Rect } from "../../shapes/index.js";
@@ -8,6 +8,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
10
  import type { ColorScaleType } from "./colorScaleType.js";
11
+ import type { SwatchBucket } from "./colorScaleSwatchTooltips.js";
11
12
  import type { ColorScaleBarGeometry } from "./colorScaleHoverMark.js";
12
13
  /**
13
14
  Creates an SVG color scale based on an array of data.
@@ -31,8 +32,14 @@ export default class ColorScale extends BaseClass {
31
32
  _scaleType: ColorScaleType;
32
33
  /** Where the color bar sits, set when the bar variant renders (see colorScaleHoverMark). */
33
34
  _barGeometry?: ColorScaleBarGeometry;
34
- /** The value marked on the scale, set with `hover()`. */
35
- _hoverValue?: number | false;
35
+ /** The value marked on the scale, set with `hover()`: a pair of values on a bivariate scale. */
36
+ _hoverValue?: number | [number, number] | false;
37
+ /** The names a chart gives a bivariate scale's two variables (its field names), under `bivariateLabels`. */
38
+ _bivariateFields?: string[];
39
+ /** The bivariate key's nodes, laid out by the last render. */
40
+ _bivariateNodes?: SceneNode[];
41
+ /** Each swatch's legend row, with its bucket, set when the swatch variant renders. */
42
+ _swatchBuckets: Map<unknown, SwatchBucket>;
36
43
  /** Smooth-gradient fill token (`gradient:<json>`), set by renderGradientStops. */
37
44
  _gradientFill?: string;
38
45
  _sceneRenderer?: SvgRenderer;
@@ -49,10 +56,13 @@ export default class ColorScale extends BaseClass {
49
56
  /**
50
57
  Produces a backend-agnostic scene graph for this ColorScale with no DOM
51
58
  dependency. The discrete variant (jenks/buckets/quantile) delegates to the
52
- internal Legend's toScene(); the gradient variant composes the Rect, Axis,
53
- and label TextBox scenes. The scaleGroup's translate (set by the chart's
54
- colorScale feature on `g.d3plus-viz-colorScale`) is read off `_select` so
55
- the content lands at its on-screen position.
59
+ internal Legend's toScene(), its title and swatch labels taking the axis
60
+ tooltips (see `swatchTooltips`); the gradient variant composes the Rect,
61
+ Axis, and label TextBox scenes, all as chrome (see `inertAxis`): only an
62
+ axis label with a tooltip takes the pointer. The scaleGroup's
63
+ translate (set by the chart's colorScale feature on
64
+ `g.d3plus-viz-colorScale`) is read off `_select` so the content lands at
65
+ its on-screen position.
56
66
 
57
67
  A smooth (non-bucketed) gradient paints its Rect with a `gradient:<json>`
58
68
  fill token (see renderGradientStops); the backend materializes it into a
@@ -61,7 +71,7 @@ export default class ColorScale extends BaseClass {
61
71
  */
62
72
  toScene(): GroupNode;
63
73
  /**
64
- The ColorScale is constructed by combining an Axis for the ticks/labels and a Rect for the actual color box (or multiple boxes, as in a jenks scale). Because of this, there are separate configs for the Axis class used to display the text (axisConfig) and the Rect class used to draw the color breaks (rectConfig). This method acts as a pass-through to the config method of the Axis.
74
+ The ColorScale is constructed by combining an Axis for the ticks/labels and a Rect for the actual color box (or multiple boxes, as in a jenks scale). Because of this, there are separate configs for the Axis class used to display the text (axisConfig) and the Rect class used to draw the color breaks (rectConfig). This method acts as a pass-through to the config method of the Axis. A scale drawn as swatches has no Axis: its `title` and `titleTooltip` apply to the swatches' title, and its `tickTooltip` to each swatch's label, given the value and index of the label at that bucket's start on a `bucketAxis` bar.
65
75
  */
66
76
  axisConfig(): Record<string, unknown>;
67
77
  axisConfig(_: Record<string, unknown>): this;
@@ -71,10 +81,10 @@ export default class ColorScale extends BaseClass {
71
81
  data(): DataPoint[];
72
82
  data(_: DataPoint[]): this;
73
83
  /**
74
- 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)`.
84
+ 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, and a bivariate scale takes a pair of values. A chart sets this while one of its shapes is hovered. Pass `false` to clear it. Turned off with `hoverMark(false)`.
75
85
  */
76
- hover(): number | false | undefined;
77
- hover(_: number | false): this;
86
+ hover(): number | [number, number] | false | undefined;
87
+ hover(_: number | [number, number] | false): this;
78
88
  /**
79
89
  A pass-through for the TextBox class used to style the labelMin and labelMax text.
80
90
  */
@@ -0,0 +1,53 @@
1
+ import type { SceneNode } from "@d3plus/render";
2
+ import type { DataPoint } from "@d3plus/data";
3
+ import type ColorScale from "./ColorScale.js";
4
+ import type { BivariateScale } from "./bivariateScale.js";
5
+ /** A bivariate key cell's datum: a colorScale bucket that is one cell of the grid. */
6
+ export interface BivariateCell extends DataPoint {
7
+ color: string;
8
+ id: string;
9
+ _isColorScaleBucket: true;
10
+ /** The cell's column: the first variable's bin. */
11
+ _bivariateX: number;
12
+ /** The cell's row: the second variable's bin. */
13
+ _bivariateY: number;
14
+ }
15
+ /** Where a laid-out bivariate key draws, in its own space. */
16
+ export interface BivariateLayout {
17
+ nodes: SceneNode[];
18
+ bounds: {
19
+ x: number;
20
+ y: number;
21
+ width: number;
22
+ height: number;
23
+ };
24
+ }
25
+ /**
26
+ The names the key gives its two variables: `bivariateLabels`, else the
27
+ names the chart passes (its field names).
28
+ @param cs The ColorScale.
29
+ */
30
+ export declare function bivariateAxisLabels(cs: ColorScale): [string, string];
31
+ /**
32
+ How a ColorScale's values read in a bivariate key's ranges and in a
33
+ chart's tooltip: `axisConfig.tickFormat`, else a variable whose values
34
+ all read as years as years, else abbreviated (`formatAbbreviate`).
35
+ @param cs The ColorScale.
36
+ @param values The variable's values.
37
+ */
38
+ export declare function colorScaleValueFormat(cs: ColorScale, values: number[]): (v: number) => string;
39
+ /**
40
+ Lays the key out within the ColorScale's `width` × `height`: its grid
41
+ shrinks from its full size to fit, and it sits along the side its labels
42
+ face (`orient`) at its `align`ment, as the swatch legend does.
43
+ @param cs The ColorScale.
44
+ @param scale Its bivariate scale.
45
+ */
46
+ export declare function layoutBivariate(cs: ColorScale, scale: BivariateScale): BivariateLayout;
47
+ /**
48
+ Builds a bivariate ColorScale's scale from its data (each row's `value`
49
+ a pair of numbers), assigns it as the ColorScale's `_colorScale`, and
50
+ lays out its diamond key.
51
+ @param cs The ColorScale.
52
+ */
53
+ export declare function renderBivariate(cs: ColorScale): BivariateLayout;
@@ -0,0 +1,92 @@
1
+ /**
2
+ Joshua Stevens' blue–red 3×3 scheme, from "Bivariate Choropleth Maps: A
3
+ How-to Guide" (joshuastevens.net/cartography/make-a-bivariate-choropleth-map/),
4
+ with the hex values as published in the R `pals` package
5
+ (`stevens.bluered`). Row-major from the low/low corner: each row is one
6
+ bin of the second variable (low to high), each column one bin of the
7
+ first (low to high). The first variable rises toward red (#c85a5a), the
8
+ second toward blue (#64acbe), and both together toward #574249. Each
9
+ inner color is the two ramps multiplied over the shared #e8e8e8 base.
10
+ */
11
+ export declare const BIVARIATE_COLORS: readonly string[];
12
+ /** The fewest and most bins a bivariate ColorScale splits each variable into. */
13
+ export declare const BIVARIATE_MIN_BUCKETS = 2;
14
+ export declare const BIVARIATE_MAX_BUCKETS = 4;
15
+ /** The bins per variable when none is set. */
16
+ export declare const BIVARIATE_BUCKETS = 3;
17
+ /**
18
+ The number of bins per variable: `value` rounded and held within 2–4, or
19
+ 3 when it isn't a number.
20
+ @param value The configured bin count.
21
+ */
22
+ export declare function bivariateBucketCount(value: unknown): number;
23
+ /**
24
+ Resamples a square grid of colors (row-major, `k×k`) to `n×n`: a grid
25
+ already `n×n` is returned as given, and any other is blended
26
+ bilinearly between its nearest colors, so its corners stay put. A 3×3
27
+ scheme resampled to 4×4 keeps its corners and blends its middle colors
28
+ across the new cells; one resampled to 2×2 keeps only its corners.
29
+ @param grid The colors, row-major.
30
+ @param n The side of the grid to return.
31
+ */
32
+ export declare function resampleGrid(grid: readonly string[], n: number): string[];
33
+ /**
34
+ The `n×n` colors a bivariate ColorScale paints with (row-major, as
35
+ `BIVARIATE_COLORS`): `colors` when it is a square grid of at least 2×2
36
+ color strings, resampled to `n×n` (see `resampleGrid`), else Stevens'
37
+ 3×3 scheme resampled the same way.
38
+ @param colors The configured grid.
39
+ @param n The bins per variable.
40
+ */
41
+ export declare function bivariatePalette(colors: unknown, n: number): string[];
42
+ /** One variable's bins, as `bivariateBins` returns them. */
43
+ export interface BivariateBins {
44
+ /** The bin (0 to `n - 1`) a value falls in. */
45
+ bin: (value: number) => number;
46
+ /** Each bin's lowest and highest value in the data, or null for a bin holding none. */
47
+ ranges: ([number, number] | null)[];
48
+ }
49
+ /**
50
+ Splits one variable's values into `n` quantile bins by rank: a value's
51
+ bin is its share of the values ranked below it (ties counted at their
52
+ middle rank), so each bin holds about as many values as the next, and
53
+ equal values always share a bin. A value outside the data ranks by
54
+ where it would sort.
55
+ @param values The variable's values (non-finite ones are ignored).
56
+ @param n The number of bins.
57
+ */
58
+ export declare function bivariateBins(values: number[], n: number): BivariateBins;
59
+ /** A value pair a bivariate ColorScale can place: two finite numbers. */
60
+ export type BivariatePair = [number, number];
61
+ /** Whether `value` is a pair of finite numbers. */
62
+ export declare function isBivariatePair(value: unknown): value is BivariatePair;
63
+ /**
64
+ A bivariate color scale: called with a value pair, it returns the color
65
+ of the cell the pair's bins pick (undefined for anything else).
66
+ */
67
+ export interface BivariateScale {
68
+ (value: unknown): string | undefined;
69
+ /** The cell `[column, row]` a pair falls in: its first variable's bin, then its second's. */
70
+ cell(value: unknown): [number, number] | null;
71
+ /** The bins per variable. */
72
+ size: number;
73
+ /** The first variable's bins. */
74
+ x: BivariateBins;
75
+ /** The second variable's bins. */
76
+ y: BivariateBins;
77
+ /** The `n×n` colors, row-major (see `BIVARIATE_COLORS`). */
78
+ colors: string[];
79
+ /** Every value pair the scale was built from. */
80
+ domain(): BivariatePair[];
81
+ /** The colors, as a d3 scale's `range`. */
82
+ range(): string[];
83
+ }
84
+ /**
85
+ Builds a bivariate color scale from the value pairs in the data: each
86
+ variable binned into `n` quantiles (see `bivariateBins`), colored from
87
+ `colors`, an `n×n` grid (see `bivariatePalette`).
88
+ @param pairs The data's value pairs.
89
+ @param n The bins per variable.
90
+ @param colors The `n×n` colors, row-major.
91
+ */
92
+ export declare function bivariateScale(pairs: BivariatePair[], n: number, colors: string[]): BivariateScale;
@@ -0,0 +1,48 @@
1
+ /**
2
+ The axis tooltips of a color scale drawn as swatches: the legend's title
3
+ takes the scale's `axisConfig.titleTooltip`, and each swatch label its
4
+ `axisConfig.tickTooltip`, given the same value and index as the label at
5
+ that bucket's start on a `bucketAxis` bar. A label drawn cut short shows
6
+ its whole text. The swatches keep their bucket's tooltip and highlight,
7
+ and a label showing its tooltip lights its bucket too (see
8
+ `handleSwatchLabelHover`).
9
+ */
10
+ import type { SceneNode } from "@d3plus/render";
11
+ /** The bucket a swatch stands for. */
12
+ export interface SwatchBucket {
13
+ /** The tick the bucket starts at. */
14
+ value: number;
15
+ /** The bucket's place from the lowest. */
16
+ index: number;
17
+ }
18
+ /** What a swatch-drawn scale's labels take their tooltips from. */
19
+ export interface SwatchTooltipOptions {
20
+ /** The legend's title. */
21
+ title: unknown;
22
+ /** The datum the legend's title nodes carry. */
23
+ titleDatum: unknown;
24
+ /** The scale's `axisConfig.titleTooltip`. */
25
+ titleTooltip: unknown;
26
+ /** The scale's `axisConfig.tickTooltip`. */
27
+ tickTooltip: unknown;
28
+ /** Each swatch's legend row, with its bucket. */
29
+ buckets: Map<unknown, SwatchBucket>;
30
+ }
31
+ /**
32
+ Stamps swatch label nodes with their tooltip target: the bucket's tick for
33
+ the value, its place from the lowest for the index, and the label's whole
34
+ text. A label no tooltip could show for is left unstamped.
35
+ @param nodes The swatch labels' text nodes.
36
+ @param option The scale's `axisConfig.tickTooltip`.
37
+ @param buckets Each swatch's legend row, with its bucket.
38
+ */
39
+ export declare function stampSwatchLabels(nodes: SceneNode[], option: unknown, buckets: Map<unknown, SwatchBucket>): void;
40
+ /**
41
+ A swatch-drawn scale's legend scene with its axis tooltips: the title is
42
+ chrome (see `inertAxis`) that takes the pointer only to show its tooltip,
43
+ a swatch label with a tooltip to show takes the pointer as axis chrome,
44
+ and every other node is left as the legend drew it.
45
+ @param scene The legend's scene.
46
+ @param options What the labels take their tooltips from.
47
+ */
48
+ export declare function swatchTooltips(scene: SceneNode, options: SwatchTooltipOptions): SceneNode;
@@ -23,6 +23,11 @@ export default class Legend extends BaseClass {
23
23
  _titleHeight: number;
24
24
  _titleWidth: number;
25
25
  _wrapLines: (() => void) | undefined;
26
+ /**
27
+ Whether labels that don't fit whole are cut short with "..." rather
28
+ than left out, as a ColorScale's swatches are (see `legendCut.ts`).
29
+ */
30
+ _cutLabels: boolean;
26
31
  _wrapRows: (() => void) | undefined;
27
32
  _sceneRenderer?: SvgRenderer;
28
33
  /**
@@ -0,0 +1,31 @@
1
+ import type Legend from "./Legend.js";
2
+ /** The room each label has in one layout of the swatches. */
3
+ interface Room {
4
+ width: number;
5
+ height: number;
6
+ }
7
+ /**
8
+ The room each label of `legend` has with its swatches in `rows` rows of
9
+ as many each as fit (`rows` 1 to the count of swatches), or in one
10
+ column.
11
+ */
12
+ export declare function labelRoom(legend: Legend, availableWidth: number, availableHeight: number, rows?: number): Room;
13
+ /**
14
+ The lines the TextBox of the label `d` paints in the room it was given:
15
+ wrapped with the line height and ellipsis of the legend's labels (a
16
+ TextBox's own by default), as `renderLegendShapes` draws it.
17
+ */
18
+ export declare function paintedLines(legend: Legend, d: Record<string, unknown>): string[];
19
+ /**
20
+ Gives each label of `legend` the room it has in the layout of its
21
+ swatches that shows the most of its labels, its whole text when that
22
+ fits there and else as many lines as fit, marking it `cut`, with the
23
+ lines it paints there. In a row, the swatches try each count of rows
24
+ within the height, keeping the layout that cuts the fewest labels short,
25
+ then shows the most of their text, then is the shortest. In a column,
26
+ they keep to one column, which reads in order from top to bottom.
27
+ Returns false, changing nothing, when no layout can hold a line of a
28
+ few letters.
29
+ */
30
+ export declare function cutLegendLabels(legend: Legend, availableWidth: number, availableHeight: number): boolean;
31
+ export {};
@@ -1,5 +1,10 @@
1
1
  import type Legend from "./Legend.js";
2
- /** Wraps + measures the title, setting `_titleHeight` / `_titleWidth`. */
2
+ /**
3
+ Wraps + measures the title, setting `_titleHeight` / `_titleWidth`: it
4
+ wraps within the width the title is drawn in, the legend's less its
5
+ padding on both sides, and is left out (both zero) when it doesn't fit
6
+ there whole.
7
+ */
3
8
  export declare function measureLegendTitle(legend: Legend): void;
4
9
  /** Measures each datum's swatch + wrapped label into the `_lineData` array. */
5
10
  export declare function computeLegendLineData(legend: Legend, availableHeight: number): Record<string, unknown>[];
@@ -3,6 +3,10 @@ import type { D3Selection } from "@d3plus/dom";
3
3
  import type { GroupNode } from "@d3plus/render";
4
4
  import { BaseClass } from "../utils/index.js";
5
5
  import type { TextBoxDatum } from "./textBoxLayout.js";
6
+ /** The ellipsis a TextBox ends a cut line with by default: none for a line with nothing kept. */
7
+ export declare const textBoxEllipsis: (text: string, line: number) => string;
8
+ /** A TextBox's default line height, as a multiple of its font size. */
9
+ export declare const TEXTBOX_LINE_HEIGHT = 1.2;
6
10
  /**
7
11
  Creates a wrapped text box for each point in an array of data.
8
12
  */
@@ -0,0 +1,6 @@
1
+ /**
2
+ Ends cut text with "...", first dropping its trailing periods, commas, and
3
+ spaces, so a decimal or an abbreviation inside the text survives.
4
+ @param text The text kept before the ellipsis.
5
+ */
6
+ export declare function textEllipsis(text: string): string;
@@ -116,6 +116,13 @@ class Shape extends BaseClass {
116
116
  resolvesReset(Shape.prototype, "labelConfig");
117
117
  */
118
118
  export declare function mergeConfigBag(host: FluentHost, key: string, patch: unknown, current?: unknown): Record<string, unknown>;
119
+ /**
120
+ The `config()` argument that restores each of `keys` that `host` has a
121
+ setter for to its default, as `RESET` does: a component that a chart
122
+ configures again on every render starts from its defaults, so config the
123
+ chart gave it before and no longer gives it is dropped.
124
+ */
125
+ export declare function resetKeys(host: object, keys: Iterable<string>): Record<string, string>;
119
126
  /**
120
127
  Tags hand-written setters that resolve `RESET` themselves (typically via
121
128
  `mergeConfigBag`), so `BaseClass.config()` passes their argument through
@@ -125,6 +132,17 @@ export declare function mergeConfigBag(host: FluentHost, key: string, patch: unk
125
132
  @param keys The setter names.
126
133
  */
127
134
  export declare function resolvesReset<T extends object>(proto: T, ...keys: (keyof T & string)[]): void;
135
+ /**
136
+ Whether the user has set `entry` of the config-bag field `key` (such as
137
+ `tooltipConfig`'s `tbody`) through its setter, as opposed to the value a
138
+ chart seeds by default. Cleared by setting the entry to `RESET` or
139
+ `undefined`, or the whole field to `RESET`.
140
+ @param host The chart or component.
141
+ @param key The config-bag field.
142
+ @param entry The entry within it.
143
+ @private
144
+ */
145
+ export declare function isSetEntry(host: object, key: string, entry: string): boolean;
128
146
  /**
129
147
  Whether `value` is an accessor generated by `installFluent`, as opposed to
130
148
  a hand-written method.
@@ -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[]) | (true & any[]) | (DataPoint & any[]) | (false & any[]);
22
+ rotateAnchor(d: DataPoint): number[] | (string & any[]) | (number & any[]) | (false & any[]) | (true & any[]) | (DataPoint & any[]);
23
23
  fontColor(this: {
24
24
  _fill?: ((d: DataPoint, i: number) => unknown) | string;
25
25
  }, d: DataPoint, i: number): string;