@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
@@ -1,8 +1,10 @@
1
1
  import { merge } from "d3-array";
2
- import clickLegend from "./click.legend.js";
3
2
  import { legendLabel } from "../features/legendLabel.js";
4
3
  import { appendThresholdMembers } from "../features/thresholdMembers.js";
5
4
  import { leadTitleWithSwatch, pickSwatch } from "../features/tooltipSwatch.js";
5
+ import { setCursor } from "../viz/setCursor.js";
6
+ import { tooltipEnabled } from "../viz/tooltipEnabled.js";
7
+ import { hasOwnClick, hasUserClick } from "../viz/userClick.js";
6
8
  import { configPrep } from "../../utils/index.js";
7
9
  /**
8
10
  @module mouseMoveLegend
@@ -24,35 +26,29 @@ import { configPrep } from "../../utils/index.js";
24
26
  ];
25
27
  return id;
26
28
  })).length;
27
- if (d && this.schema.tooltip(d, i)) {
28
- let id = this._id(d, i);
29
- if (id instanceof Array) id = id[0];
30
- const t = this.schema.translate;
31
- const defaultClick = clickLegend.bind(this).toString();
32
- // does the legend have any user-defined click events?
33
- const hasUserClick = Object.keys(this.schema.on).some((e)=>// all valid click event keys,
34
- [
35
- "click",
36
- "click.legend"
37
- ].includes(e) && // truthy values (no nulls),
38
- this.schema.on[e] && // and it is not our default click.legend function
39
- this.schema.on[e].toString() !== defaultClick);
40
- // does the legend still have our default "click.legend" event?
41
- // (if the user only sets "click", both functions will fire)
42
- const hasDefaultClick = this.schema.on["click.legend"] && this.schema.on["click.legend"].toString() === defaultClick;
43
- // can the viz show deeper data?
44
- const hasDeeperLevel = this._drawDepth < this.schema.groupBy.length - 1;
45
- // only show the hand cursor when the shape has a click event
46
- this._select.style("cursor", hasUserClick || hasDefaultClick && hasDeeperLevel ? "pointer" : "auto");
47
- const invertedBehavior = this.schema.legendFilterInvert.bind(this)(this);
48
- const solo = this._solo.includes(id);
49
- const hidden = this._hidden.includes(id);
50
- this._tooltipClass.data([
51
- x || d
52
- ]).footer(hasDefaultClick ? invertedBehavior ? this._solo.length && !solo || hidden ? t("Click to Highlight") : this._solo.length === 1 && solo || this._hidden.length === dataLength - 1 ? t("Click to Show All") : `${t("Click to Highlight")}<br />${t("Shift+Click to Hide")}` : this._solo.length && !solo || hidden ? `${t("Click to Show")}<br />${t("Shift+Click to Highlight")}` : this._solo.length === 1 && solo || this._hidden.length === dataLength - 1 ? t("Click to Show All") : `${t("Click to Hide")}<br />${t("Shift+Click to Highlight")}` : false).title(this.schema.legendConfig.label ? this._legendClass.label() : legendLabel.bind(this)).titleSwatch(true).position(position).config(configPrep.bind(this)(this.schema.tooltipConfig)).config(configPrep.bind(this)(this.schema.legendTooltip));
53
- // A threshold bucket's entry lists what it holds.
54
- appendThresholdMembers(this._tooltipClass, this, d);
55
- // The title leads with the hovered entry's swatch, as on the chart.
56
- leadTitleWithSwatch(this._tooltipClass, pickSwatch(this, this._lastScenePick)).render();
57
- }
29
+ if (!d) return;
30
+ let id = this._id(d, i);
31
+ if (id instanceof Array) id = id[0];
32
+ const t = this.schema.translate;
33
+ // does the legend have any user-defined click events?
34
+ const userClick = hasUserClick(this, "click.legend");
35
+ // does the legend still have our default "click.legend" event?
36
+ // (if the user only sets "click", both functions will fire)
37
+ const hasDefaultClick = hasOwnClick(this, "click.legend");
38
+ // can the viz show deeper data?
39
+ const hasDeeperLevel = this._drawDepth < this.schema.groupBy.length - 1;
40
+ // only show the hand cursor when the entry has a click event, whether or
41
+ // not it shows a tooltip
42
+ setCursor(this, userClick || hasDefaultClick && hasDeeperLevel ? "pointer" : "auto");
43
+ if (!tooltipEnabled(this, d, i, true)) return;
44
+ const invertedBehavior = this.schema.legendFilterInvert.bind(this)(this);
45
+ const solo = this._solo.includes(id);
46
+ const hidden = this._hidden.includes(id);
47
+ this._tooltipClass.data([
48
+ x || d
49
+ ]).footer(hasDefaultClick ? invertedBehavior ? this._solo.length && !solo || hidden ? t("Click to Highlight") : this._solo.length === 1 && solo || this._hidden.length === dataLength - 1 ? t("Click to Show All") : `${t("Click to Highlight")}<br />${t("Shift+Click to Hide")}` : this._solo.length && !solo || hidden ? `${t("Click to Show")}<br />${t("Shift+Click to Highlight")}` : this._solo.length === 1 && solo || this._hidden.length === dataLength - 1 ? t("Click to Show All") : `${t("Click to Hide")}<br />${t("Shift+Click to Highlight")}` : false).title(this.schema.legendConfig.label ? this._legendClass.label() : legendLabel.bind(this)).titleSwatch(true).position(position).config(configPrep.bind(this)(this.schema.tooltipConfig)).config(configPrep.bind(this)(this.schema.legendTooltip));
50
+ // A threshold bucket's entry lists what it holds.
51
+ appendThresholdMembers(this._tooltipClass, this, d);
52
+ // The title leads with the hovered entry's swatch, as on the chart.
53
+ leadTitleWithSwatch(this._tooltipClass, pickSwatch(this, this._lastScenePick)).render();
58
54
  }
@@ -1,56 +1,56 @@
1
1
  import { configPrep } from "../../utils/index.js";
2
- import clickShape from "./click.shape.js";
3
2
  import { groupDepthOf, groupNarrows, groupPath } from "../viz/groupRow.js";
4
3
  import { appendThresholdMembers } from "../features/thresholdMembers.js";
4
+ import { leadWithColorScaleRows } from "../features/colorScaleTooltip.js";
5
5
  import { leadTitleWithSwatch, pickSwatch } from "../features/tooltipSwatch.js";
6
6
  import { pointTooltipAnchor } from "../viz/pointTooltipAnchor.js";
7
+ import { setCursor } from "../viz/setCursor.js";
8
+ import { tooltipEnabled } from "../viz/tooltipEnabled.js";
9
+ import { hasOwnClick, hasUserClick } from "../viz/userClick.js";
7
10
  /**
8
11
  @module mouseMoveShape
9
12
  Tooltip logic for a specified data point.
10
13
  @param config Optional configuration methods for the Tooltip class.
11
14
  @private
12
15
  */ export default function(d, i, x, event) {
13
- if (d && this.schema.tooltip(d, i)) {
14
- const defaultClick = clickShape.bind(this).toString();
15
- // does the shape have any user-defined click events?
16
- const hasUserClick = Object.keys(this.schema.on).some((e)=>// all valid click event keys,
17
- [
18
- "click",
19
- "click.shape"
20
- ].includes(e) && // truthy values (no nulls),
21
- this.schema.on[e] && // and it is not our default click.shape function
22
- this.schema.on[e].toString() !== defaultClick);
23
- // does the shape still have our default "click.shape" event?
24
- // (if the user only sets "click", both functions will fire)
25
- const hasDefaultClick = this.schema.on["click.shape"] && this.schema.on["click.shape"].toString() === defaultClick;
26
- // can the viz show deeper data? A group row zooms into its group.
27
- const groupDepth = groupDepthOf(d);
28
- const hasDeeperLevel = groupDepth === undefined ? this._drawDepth < this.schema.groupBy.length - 1 : groupNarrows(this.schema.groupBy, groupPath(this.schema.groupBy, d, groupDepth), this._filteredData ?? []);
29
- // only show the hand cursor when the shape has a click event
30
- this._select.style("cursor", hasUserClick || hasDefaultClick && hasDeeperLevel ? "pointer" : "auto");
31
- // Plot's snapped hover (shared or single) owns the tooltip while active.
32
- if (this._sharedHoverActive) return;
33
- // A point mark's tooltip points at the mark, wherever the pointer is
34
- // within reach of it; anything else follows the pointer.
35
- const position = pointTooltipAnchor(this, this._lastScenePick?.node) ?? (event.touches ? [
36
- event.touches[0].clientX,
37
- event.touches[0].clientY
38
- ] : [
39
- event.clientX,
40
- event.clientY
41
- ]);
42
- // Unwrap to the underlying source row so tooltip cell accessors (e.g.
43
- // the Treemap "share" column) resolve regardless of whether the hovered
44
- // scene node was the shape (datum = row) or its text label (datum = a
45
- // wrapper whose `.data` chain leads back to the row).
46
- let tooltipDatum = x || d;
47
- while(tooltipDatum && tooltipDatum.__d3plus__ && tooltipDatum.data)tooltipDatum = tooltipDatum.data;
48
- this._tooltipClass.data([
49
- tooltipDatum
50
- ]).footer(hasDefaultClick && hasDeeperLevel ? this.schema.translate("Click to Expand") : false).title((dd, ii)=>this._drawLabel(dd, ii)).titleSwatch(true).position(position).config(configPrep.bind(this)(this.schema.tooltipConfig));
51
- // A threshold bucket lists what it holds.
52
- appendThresholdMembers(this._tooltipClass, this, tooltipDatum);
53
- // The title leads with a swatch of the hovered mark, as in the legend.
54
- leadTitleWithSwatch(this._tooltipClass, pickSwatch(this, this._lastScenePick)).render();
55
- }
16
+ if (!d) return;
17
+ // does the shape have any user-defined click events?
18
+ const userClick = hasUserClick(this, "click.shape");
19
+ // does the shape still have our default "click.shape" event?
20
+ // (if the user only sets "click", both functions will fire)
21
+ const hasDefaultClick = hasOwnClick(this, "click.shape");
22
+ // can the viz show deeper data? A group row zooms into its group.
23
+ const groupDepth = groupDepthOf(d);
24
+ const hasDeeperLevel = groupDepth === undefined ? this._drawDepth < this.schema.groupBy.length - 1 : groupNarrows(this.schema.groupBy, groupPath(this.schema.groupBy, d, groupDepth), this._filteredData ?? []);
25
+ // only show the hand cursor when the shape has a click event, whether or
26
+ // not it shows a tooltip
27
+ setCursor(this, userClick || hasDefaultClick && hasDeeperLevel ? "pointer" : "auto");
28
+ if (!tooltipEnabled(this, d, i)) return;
29
+ // Plot's snapped hover (shared or single) owns the tooltip while active.
30
+ if (this._sharedHoverActive) return;
31
+ // A point mark's tooltip points at the mark, wherever the pointer is
32
+ // within reach of it; anything else follows the pointer.
33
+ const position = pointTooltipAnchor(this, this._lastScenePick?.node) ?? (event.touches ? [
34
+ event.touches[0].clientX,
35
+ event.touches[0].clientY
36
+ ] : [
37
+ event.clientX,
38
+ event.clientY
39
+ ]);
40
+ // Unwrap to the underlying source row so tooltip cell accessors (e.g.
41
+ // the Treemap "share" column) resolve regardless of whether the hovered
42
+ // scene node was the shape (datum = row) or its text label (datum = a
43
+ // wrapper whose `.data` chain leads back to the row).
44
+ let tooltipDatum = x || d;
45
+ while(tooltipDatum && tooltipDatum.__d3plus__ && tooltipDatum.data)tooltipDatum = tooltipDatum.data;
46
+ this._tooltipClass.data([
47
+ tooltipDatum
48
+ ]).footer(hasDefaultClick && hasDeeperLevel ? this.schema.translate("Click to Expand") : false).title((dd, ii)=>this._drawLabel(dd, ii)).titleSwatch(true).position(position).config(configPrep.bind(this)(this.schema.tooltipConfig));
49
+ // The row's colorScale value (or a bivariate colorScale's two) leads
50
+ // the rows.
51
+ leadWithColorScaleRows(this._tooltipClass, this, tooltipDatum, i);
52
+ // A threshold bucket lists what it holds.
53
+ appendThresholdMembers(this._tooltipClass, this, tooltipDatum);
54
+ // The title leads with a swatch of the hovered mark, as in the legend.
55
+ leadTitleWithSwatch(this._tooltipClass, pickSwatch(this, this._lastScenePick)).render();
56
56
  }
@@ -35,6 +35,7 @@
35
35
 
36
36
  @module
37
37
  */ import { max } from "d3-array";
38
+ import { defaultMaxSize, pinMaxSize } from "../../components/Axis/axisMaxSize.js";
38
39
  import { frozenAxis } from "./frozenAxis.js";
39
40
  import { alignAxisLine, placeEndLabels } from "./plotEndLabels.js";
40
41
  import { bumpLineLabels } from "./lineLabels.js";
@@ -101,11 +102,15 @@ import { solveFinalAxes } from "./axesFinal.js";
101
102
  // Plot sets these before the axis pass runs.
102
103
  const xAxis = viz._xAxis;
103
104
  const x2Axis = viz._x2Axis;
105
+ const xPlotConfig = plotAxisConfig(viz, "x");
104
106
  xAxis.renderMode("compute").select(null).domain(xDomain).height(height - (x2Height + topOffset + verticalMargin)).maxSize(height / 2).range(xRange).ticks(xTicks).width(width)// Rotate the labels as the test axis did when it claimed their height.
105
107
  .labelRotation(testRotation(pCtx.xTest)).config({
106
108
  ...UNZOOMED_AXIS,
107
109
  ...xC
108
- }).config(plotAxisConfig(viz, "x")).config(pCtx.zoomAxes?.x ?? {}).scale(xConfigScale);
110
+ }).config(xPlotConfig).config(pCtx.zoomAxes?.x ?? {}).scale(xConfigScale);
111
+ defaultMaxSize(xAxis, xC, xPlotConfig);
112
+ // A `maxSize` function reads the height the test axis measured with.
113
+ pinMaxSize(xAxis, height);
109
114
  // Labeling its ends, the axis draws only its gridlines, up from the plot's bottom edge.
110
115
  const gridOnly = Boolean(pCtx.xLabelMode && pCtx.xLabelMode !== "axis");
111
116
  if (gridOnly) alignAxisLine(xAxis, plotBottom);
@@ -122,7 +127,8 @@ import { solveFinalAxes } from "./axesFinal.js";
122
127
  x2Axis.renderMode("compute").select(null).domain(x2Domain).height(height - (pCtx.xHeight + topOffset + verticalMargin)).range(xRange).ticks(x2Ticks).width(width).labelRotation(testRotation(pCtx.x2Test)).config({
123
128
  ...UNZOOMED_AXIS,
124
129
  ...xC
125
- }).config(defaultX2Config).config(viz._x2Config).config(pCtx.zoomAxes?.x2 ?? {}).scale(x2ConfigScale).render();
130
+ }).config(defaultX2Config).config(viz._x2Config).config(pCtx.zoomAxes?.x2 ?? {}).scale(x2ConfigScale);
131
+ pinMaxSize(x2Axis, height).render();
126
132
  axisSceneQueue.push({
127
133
  key: "plot-x2-axis",
128
134
  transform: axisRelativeTransform("x2"),
@@ -152,10 +158,14 @@ import { solveFinalAxes } from "./axesFinal.js";
152
158
  // Plot sets these before the axis pass runs.
153
159
  const yAxis = viz._yAxis;
154
160
  const y2Axis = viz._y2Axis;
161
+ const yPlotConfig = plotAxisConfig(viz, "y");
155
162
  yAxis.renderMode("compute").select(null).domain(yDomain).height(height).maxSize(width / 2).range(yRange).ticks(yTicks).width(xRange[xRange.length - 1]).config({
156
163
  ...UNZOOMED_AXIS,
157
164
  ...yC
158
- }).config(plotAxisConfig(viz, "y")).config(pCtx.zoomAxes?.y ?? {}).scale(yConfigScale).render();
165
+ }).config(yPlotConfig).config(pCtx.zoomAxes?.y ?? {}).scale(yConfigScale);
166
+ defaultMaxSize(yAxis, yC, yPlotConfig);
167
+ // A `maxSize` function reads the width the test axis measured with.
168
+ pinMaxSize(yAxis, width).render();
159
169
  if (showY) {
160
170
  axisSceneQueue.push({
161
171
  key: "plot-y-axis",
@@ -170,7 +180,8 @@ import { solveFinalAxes } from "./axesFinal.js";
170
180
  }).domain(y2Exists ? y2Domain : yDomain).gridSize(0).height(height).range(yRange).width(width - max([
171
181
  0,
172
182
  xOffsetRight - y2Width
173
- ])).title(false).config(viz._y2Config).config(defaultY2Config).config(pCtx.zoomAxes?.y2 ?? {}).scale(y2ConfigScale).render();
183
+ ])).title(false).config(viz._y2Config).config(defaultY2Config).config(pCtx.zoomAxes?.y2 ?? {}).scale(y2ConfigScale);
184
+ pinMaxSize(y2Axis, width).render();
174
185
  axisSceneQueue.push({
175
186
  key: "plot-y2-axis",
176
187
  transform: axisRelativeTransform("y2"),
@@ -6,6 +6,7 @@
6
6
 
7
7
  @module
8
8
  */ import { max } from "d3-array";
9
+ import { defaultMaxSize, pinMaxSize } from "../../components/Axis/axisMaxSize.js";
9
10
  import { plotAxisConfig } from "../Plot/baselineBreak.js";
10
11
  /**
11
12
  The room the plot leaves on its right for the y2 axis and for the x/x2
@@ -43,7 +44,9 @@ import { plotAxisConfig } from "../Plot/baselineBreak.js";
43
44
  const { yTest, y2Test } = pCtx;
44
45
  let { xOffsetRight } = pCtx;
45
46
  if (showY) {
46
- yTest.domain(yDomain).height(height).maxSize(width / 2).range(yRange).ticks(yTicks).width(width).config(yC).config(plotAxisConfig(viz, "y")).scale(yConfigScale).measure();
47
+ const yPlotConfig = plotAxisConfig(viz, "y");
48
+ yTest.domain(yDomain).height(height).maxSize(width / 2).range(yRange).ticks(yTicks).width(width).config(yC).config(yPlotConfig).scale(yConfigScale);
49
+ defaultMaxSize(yTest, yC, yPlotConfig).measure();
47
50
  }
48
51
  const yBounds = yTest.outerBounds();
49
52
  const yWidth = yBounds.width ? yBounds.width + yTest.padding() : undefined;
@@ -60,7 +63,9 @@ import { plotAxisConfig } from "../Plot/baselineBreak.js";
60
63
  y2Test.config(yC).domain(y2Domain).gridSize(0).height(height).range(yRange).width(width - max([
61
64
  0,
62
65
  xOffsetRight - pCtx.y2Width
63
- ])).title(false).config(viz._y2Config).config(defaultY2Config).scale(y2ConfigScale).measure();
66
+ ])).title(false).config(viz._y2Config).config(defaultY2Config).scale(y2ConfigScale);
67
+ // A `maxSize` function reads the width the axis first measured with.
68
+ pinMaxSize(y2Test, width).measure();
64
69
  }
65
70
  const y2Bounds = y2Test.outerBounds();
66
71
  const y2Width = y2Bounds.width ? y2Bounds.width + y2Test.padding() : undefined;
@@ -5,7 +5,9 @@
5
5
  `viz._padding.*`. Runs BEFORE the base `Viz` draw finalizes margins.
6
6
  */ import { max } from "d3-array";
7
7
  import AxisBottom from "../../components/Axis/AxisBottom.js";
8
+ import configValue from "../../utils/configValue.js";
8
9
  import { barLabelsNeedAxis } from "../Plot/barLabelFit.js";
10
+ import { defaultMaxSize } from "../../components/Axis/axisMaxSize.js";
9
11
  import { plotAxisConfig } from "../Plot/baselineBreak.js";
10
12
  import { xRightInset } from "./axesFinal.js";
11
13
  import { cornerControlsHeight } from "./features.js";
@@ -14,10 +16,12 @@ import { buildXConfig } from "./xAxisConfig.js";
14
16
  /** Measure the y/y2 test axes and report their bounds + claimed widths. */ function measureYTestAxes(viz, inputs) {
15
17
  const { yTest, y2Test, yDomain, y2Domain, yTicks, y2Ticks, yConfigScale, y2ConfigScale, defaultY2Config, yC, showY, y2Exists, height, width } = inputs;
16
18
  if (showY) {
19
+ const yPlotConfig = plotAxisConfig(viz, "y");
17
20
  yTest.domain(yDomain).height(height).maxSize(width / 2).range([
18
21
  undefined,
19
22
  undefined
20
- ]).ticks(yTicks).width(width).config(yC).config(plotAxisConfig(viz, "y")).scale(yConfigScale).measure();
23
+ ]).ticks(yTicks).width(width).config(yC).config(yPlotConfig).scale(yConfigScale);
24
+ defaultMaxSize(yTest, yC, yPlotConfig).measure();
21
25
  }
22
26
  const yBounds = yTest.outerBounds();
23
27
  const yWidth = yBounds.width ? yBounds.width + yTest.padding() : undefined;
@@ -44,18 +48,22 @@ import { buildXConfig } from "./xAxisConfig.js";
44
48
  let xRangeMax = undefined;
45
49
  const xOverrides = ends ? END_LABEL_AXIS_CONFIG : {};
46
50
  if (showX) {
51
+ const xPlotConfig = plotAxisConfig(viz, "x");
47
52
  xTest.domain(xDomain).height(height).maxSize(height / 2).range([
48
53
  undefined,
49
54
  xRangeMax
50
- ]).ticks(xTicks).width(width).config(xC).config(plotAxisConfig(viz, "x")).config(xOverrides).scale(xConfigScale).measure();
55
+ ]).ticks(xTicks).width(width).config(xC).config(xPlotConfig).config(xOverrides).scale(xConfigScale);
56
+ defaultMaxSize(xTest, xC, xPlotConfig, xOverrides).measure();
51
57
  }
52
58
  const { labelWidths, largestLabel, xRangeMax: measuredXRangeMax, startLabelSpace = 0 } = measureLineLabels();
53
59
  if (measuredXRangeMax !== undefined) xRangeMax = measuredXRangeMax;
54
60
  if (showX && xRangeMax) {
61
+ const xPlotConfig = plotAxisConfig(viz, "x");
55
62
  xTest.domain(xDomain).height(height).maxSize(height / 2).range([
56
63
  undefined,
57
64
  xRangeMax
58
- ]).ticks(xTicks).width(width).config(xC).config(plotAxisConfig(viz, "x")).config(xOverrides).scale(xConfigScale).measure();
65
+ ]).ticks(xTicks).width(width).config(xC).config(xPlotConfig).config(xOverrides).scale(xConfigScale);
66
+ defaultMaxSize(xTest, xC, xPlotConfig, xOverrides).measure();
59
67
  }
60
68
  if (x2Exists) {
61
69
  x2Test.domain(x2Domain).height(height).range([
@@ -87,8 +95,7 @@ import { buildXConfig } from "./xAxisConfig.js";
87
95
  viz._plotMinLeft?.(),
88
96
  startLabelSpace && (yWidth ?? 0) + startLabelSpace
89
97
  ]);
90
- const yLabelConfig = yTest.shapeConfig().labelConfig;
91
- const topOffset = (showY ? yLabelConfig.fontSize() / 2 : 0) + (viz._plotInsetTop ?? 0);
98
+ const topOffset = yLabelTopOffset(viz, yTest, showY);
92
99
  const xOffsetRight = xRightInset({
93
100
  xTest,
94
101
  x2Test,
@@ -179,15 +186,26 @@ import { buildXConfig } from "./xAxisConfig.js";
179
186
  */ function provisionalTopOffset(viz, inputs) {
180
187
  const { yTest, yC, showY } = inputs;
181
188
  if (showY) yTest.config(yC).config(plotAxisConfig(viz, "y"));
182
- const labelConfig = yTest.shapeConfig().labelConfig;
183
- return (showY ? labelConfig.fontSize() / 2 : 0) + (viz._plotInsetTop ?? 0);
189
+ return yLabelTopOffset(viz, yTest, showY);
190
+ }
191
+ /**
192
+ The room above the plot for half of the y axis's top label: its font
193
+ size (a constant or a function, as label config accepts) over 2, plus
194
+ the chart's own top inset.
195
+ */ function yLabelTopOffset(viz, yTest, showY) {
196
+ const { fontSize } = yTest.shapeConfig().labelConfig;
197
+ const half = showY ? configValue(fontSize) / 2 : 0;
198
+ return half + (viz._plotInsetTop ?? 0);
184
199
  }
185
200
  /** The x axis's height, from a throwaway measure ahead of the joint solve. */ function provisionalXHeight(viz, inputs) {
186
201
  if (!inputs.showX) return 0;
187
202
  const axis = new AxisBottom().align("end").gridSize(0);
203
+ const xC = buildXConfig(viz, inputs);
204
+ const xPlotConfig = plotAxisConfig(viz, "x");
188
205
  axis.domain(inputs.xDomain).height(inputs.height).maxSize(inputs.height / 2).range([
189
206
  undefined,
190
207
  undefined
191
- ]).ticks(inputs.xTicks).width(inputs.width).config(buildXConfig(viz, inputs)).config(plotAxisConfig(viz, "x")).scale(inputs.xConfigScale).measure();
208
+ ]).ticks(inputs.xTicks).width(inputs.width).config(xC).config(xPlotConfig).scale(inputs.xConfigScale);
209
+ defaultMaxSize(axis, xC, xPlotConfig).measure();
192
210
  return axis.outerBounds().height + axis.padding();
193
211
  }
@@ -0,0 +1,138 @@
1
+ /**
2
+ Axis tooltips: hovering an axis's title or one of its tick labels shows
3
+ the chart's tooltip, with the text the axis's `titleTooltip` or
4
+ `tickTooltip` gives. A label drawn cut short heads the tooltip with its
5
+ whole text, so an axis that sets neither option still shows what its
6
+ cut labels say.
7
+ */ import { axisTooltipTarget } from "../../components/Axis/axisTooltipTargets.js";
8
+ import { isPlainObject } from "../../fluent.js";
9
+ import { configPrep } from "../../utils/index.js";
10
+ import { constantValue } from "../../utils/constant.js";
11
+ /**
12
+ A copy of a config value whose functions, at any depth, are called with
13
+ `args` whatever they are passed.
14
+ @param value A config object, or any value in one.
15
+ @param args What every function in it receives.
16
+ */ export function bindAccessors(value, args) {
17
+ if (typeof value === "function") return function() {
18
+ return value.apply(this, args);
19
+ };
20
+ if (Array.isArray(value)) return value.map((v)=>bindAccessors(v, args));
21
+ if (isPlainObject(value)) return Object.fromEntries(Object.entries(value).map(([k, v])=>[
22
+ k,
23
+ bindAccessors(v, args)
24
+ ]));
25
+ return value;
26
+ }
27
+ /** Whether a function's result is text to show. */ const hasText = (text)=>text !== undefined && text !== null && text !== false && text !== "";
28
+ /**
29
+ What hovering an axis label shows, from the axis's `titleTooltip` or
30
+ `tickTooltip`: a string is the body, a function returns it (given the
31
+ title, or the tick's value and index), and an object is a tooltip config
32
+ whose accessors receive the same. A label drawn cut short adds its whole
33
+ text as the title. Null when there is nothing to show: the option is
34
+ `false`, its function returns `false`, or the label is drawn whole and
35
+ the option is unset or its function returns nothing.
36
+ @param target The hovered label.
37
+ @param fullText Whether a cut label shows its whole text.
38
+ @param self The `this` the option's function is called with.
39
+ */ export function resolveAxisTooltip(target, fullText = true, self) {
40
+ const { option, part, value, index } = target;
41
+ if (option === false) return null;
42
+ const title = target.truncated && fullText ? target.text : false;
43
+ const args = part === "title" ? [
44
+ value
45
+ ] : [
46
+ value,
47
+ index
48
+ ];
49
+ if (isPlainObject(option)) return {
50
+ title,
51
+ body: false,
52
+ config: bindAccessors(option, args)
53
+ };
54
+ const text = typeof option === "function" ? option.apply(self, args) : typeof option === "string" ? option : undefined;
55
+ if (text === false) return null;
56
+ const body = hasText(text) ? `${text}` : false;
57
+ return title === false && body === false ? null : {
58
+ title,
59
+ body
60
+ };
61
+ }
62
+ /** The data of the axis tooltips shown, which tell them from a mark's or legend's. */ const shownData = new WeakSet();
63
+ /**
64
+ Whether a tooltip datum is an axis tooltip's.
65
+ @param d The first of a tooltip's data.
66
+ */ export function isAxisTooltipDatum(d) {
67
+ return typeof d === "object" && d !== null && shownData.has(d);
68
+ }
69
+ /** Whether the chart's tooltip is showing an axis tooltip. */ function showing(viz) {
70
+ return isAxisTooltipDatum(viz._tooltipClass?.data()[0]);
71
+ }
72
+ /** The client position of a pointer event: the tooltip's anchor. */ function pointer(event) {
73
+ const native = event.nativeEvent;
74
+ return native && native.touches && native.touches.length ? [
75
+ native.touches[0].clientX,
76
+ native.touches[0].clientY
77
+ ] : native ? [
78
+ native.clientX,
79
+ native.clientY
80
+ ] : event.point;
81
+ }
82
+ /**
83
+ Shows the chart's tooltip for an axis label at the pointer: the chart's
84
+ `tooltipConfig` for its styles, then the label's title and body in place
85
+ of a mark's, then the axis option's own config. The tooltip's settings
86
+ are put back once it is drawn, so a mark's or legend's tooltip never
87
+ inherits them.
88
+ */ function renderAxisTooltip(viz, target, content, event) {
89
+ const tip = viz._tooltipClass;
90
+ const prep = configPrep.bind(viz);
91
+ const { part, value, index, text } = target;
92
+ const datum = {
93
+ part,
94
+ value,
95
+ index,
96
+ text
97
+ };
98
+ shownData.add(datum);
99
+ const saved = {
100
+ ...tip.schema
101
+ };
102
+ tip.data([
103
+ datum
104
+ ]).config(prep(viz.schema.tooltipConfig)).title(content.title).body(content.body).footer(false).thead([]).tbody([]).position(pointer(event));
105
+ // A title with nothing under it needs no gap below.
106
+ if (!content.config && content.body === false) tip.titleStyle({
107
+ "margin-bottom": "0"
108
+ });
109
+ if (content.config) tip.config(prep(content.config));
110
+ tip.render();
111
+ for (const key of Object.keys(tip.schema))if (!(key in saved)) delete tip.schema[key];
112
+ Object.assign(tip.schema, saved);
113
+ }
114
+ /**
115
+ Shows, moves, or hides the axis tooltip for a pointer event. Moving onto
116
+ a label with something to show (see `resolveAxisTooltip`) shows it at the
117
+ pointer; moving anywhere else, or leaving the chart, hides it when it is
118
+ still the tooltip showing. Charts with `tooltip: false` skip the whole
119
+ text of cut labels, and show only what an axis option gives. Labels show
120
+ nothing while a transition is in flight.
121
+ @param viz The chart.
122
+ @param event The pointer event.
123
+ @returns Whether an axis tooltip is showing for the event.
124
+ */ export function handleAxisTooltip(viz, event) {
125
+ if (!viz._tooltipClass) return false;
126
+ const moving = event.type === "mousemove" || event.type === "mouseenter";
127
+ if (!moving && event.type !== "mouseleave") return false;
128
+ const settled = !viz._transitionEndsAt || Date.now() >= viz._transitionEndsAt;
129
+ const target = moving && settled ? axisTooltipTarget(event.pick?.node) : undefined;
130
+ const fullText = constantValue(viz.schema.tooltip)?.value !== false;
131
+ const content = target && resolveAxisTooltip(target, fullText, viz);
132
+ if (target && content) {
133
+ renderAxisTooltip(viz, target, content, event);
134
+ return true;
135
+ }
136
+ if (showing(viz)) viz._tooltipClass.data([]).render();
137
+ return false;
138
+ }