@d3plus/core 4.9.0 → 4.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (236) hide show
  1. package/es/internal.js +3 -1
  2. package/es/src/charts/BoxWhisker/index.js +73 -4
  3. package/es/src/charts/BoxWhisker/outliers.js +68 -0
  4. package/es/src/charts/BoxWhisker/summary.js +83 -0
  5. package/es/src/charts/BoxWhisker/tooltip.js +122 -0
  6. package/es/src/charts/Bullet/index.js +2 -1
  7. package/es/src/charts/BumpChart/index.js +5 -0
  8. package/es/src/charts/Calendar/index.js +2 -1
  9. package/es/src/charts/Candlestick/aggregate.js +11 -1
  10. package/es/src/charts/Candlestick/index.js +5 -5
  11. package/es/src/charts/Chord/index.js +3 -2
  12. package/es/src/charts/Funnel/index.js +2 -1
  13. package/es/src/charts/Gauge/index.js +2 -1
  14. package/es/src/charts/Geomap/index.js +9 -3
  15. package/es/src/charts/Histogram/index.js +5 -1
  16. package/es/src/charts/Matrix/index.js +3 -2
  17. package/es/src/charts/Network/index.js +9 -4
  18. package/es/src/charts/Pack/index.js +2 -1
  19. package/es/src/charts/Pie/index.js +2 -1
  20. package/es/src/charts/Plot/axisHover.js +180 -0
  21. package/es/src/charts/Plot/axisHoverAnchors.js +174 -0
  22. package/es/src/charts/Plot/axisHoverScene.js +202 -0
  23. package/es/src/charts/Plot/barHitArea.js +81 -0
  24. package/es/src/charts/Plot/barLabelFit.js +123 -0
  25. package/es/src/charts/Plot/barWidth.js +2 -2
  26. package/es/src/charts/Plot/confidenceConfig.js +2 -2
  27. package/es/src/charts/Plot/draw.js +6 -2
  28. package/es/src/charts/Plot/index.js +25 -6
  29. package/es/src/charts/Plot/labelPlacement.js +9 -1
  30. package/es/src/charts/Plot/openDomainEnds.js +2 -5
  31. package/es/src/charts/Plot/pipeline.js +5 -3
  32. package/es/src/charts/Plot/pipelineAxisLayout.js +38 -8
  33. package/es/src/charts/Plot/pipelineDomains.js +7 -3
  34. package/es/src/charts/Plot/pipelineLineLabels.js +1 -1
  35. package/es/src/charts/Plot/plotInit.js +15 -0
  36. package/es/src/charts/Plot/plotZoom.js +15 -6
  37. package/es/src/charts/Plot/shapeDefaults.js +4 -4
  38. package/es/src/charts/Plot/sharedHoverScene.js +50 -31
  39. package/es/src/charts/Plot/sharedTooltip.js +19 -7
  40. package/es/src/charts/Plot/stackHelpers.js +13 -1
  41. package/es/src/charts/Plot/stackShareTooltip.js +9 -4
  42. package/es/src/charts/Plot/stackThreshold.js +154 -0
  43. package/es/src/charts/PolarArea/index.js +3 -2
  44. package/es/src/charts/Priestley/index.js +3 -2
  45. package/es/src/charts/Pyramid/index.js +4 -2
  46. package/es/src/charts/Radar/index.js +3 -2
  47. package/es/src/charts/RadialBar/index.js +2 -1
  48. package/es/src/charts/RadialMatrix/index.js +3 -2
  49. package/es/src/charts/Rings/index.js +5 -3
  50. package/es/src/charts/Sankey/index.js +3 -2
  51. package/es/src/charts/Treemap/applyLayout.js +14 -1
  52. package/es/src/charts/Treemap/emit.js +8 -2
  53. package/es/src/charts/Treemap/emitGroupHeaders.js +104 -0
  54. package/es/src/charts/Treemap/groupHeaders.js +95 -0
  55. package/es/src/charts/Treemap/index.js +15 -2
  56. package/es/src/charts/Treemap/thresholdFunction.js +11 -9
  57. package/es/src/charts/Waffle/index.js +4 -2
  58. package/es/src/charts/Waffle/tooltip.js +6 -2
  59. package/es/src/charts/Waterfall/index.js +4 -2
  60. package/es/src/charts/definition/makeChart.js +12 -5
  61. package/es/src/charts/drawSteps/saveChart.js +176 -0
  62. package/es/src/charts/drawSteps/saveControl.js +148 -0
  63. package/es/src/charts/drawSteps/saveControlMarkup.js +104 -0
  64. package/es/src/charts/drawSteps/tableViewMarkup.js +1 -1
  65. package/es/src/charts/drawSteps/topLeftControls.js +3 -1
  66. package/es/src/charts/drawSteps/topLeftControlsMarkup.js +1 -1
  67. package/es/src/charts/events/click.shape.js +30 -1
  68. package/es/src/charts/events/mouseenter.js +9 -0
  69. package/es/src/charts/events/mousemove.legend.js +3 -0
  70. package/es/src/charts/events/mousemove.shape.js +7 -2
  71. package/es/src/charts/facet/facetConfig.js +2 -2
  72. package/es/src/charts/facet/facetData.js +2 -2
  73. package/es/src/charts/features/axes.js +7 -6
  74. package/es/src/charts/features/axesFinal.js +23 -3
  75. package/es/src/charts/features/axesMeasure.js +54 -2
  76. package/es/src/charts/features/colorScaleBucket.js +17 -0
  77. package/es/src/charts/features/colorScaleHover.js +69 -0
  78. package/es/src/charts/features/features.js +13 -1
  79. package/es/src/charts/features/featuresColorScale.js +44 -4
  80. package/es/src/charts/features/featuresLegend.js +6 -8
  81. package/es/src/charts/features/plotPaint.js +4 -4
  82. package/es/src/charts/features/shapeEmit.js +23 -2
  83. package/es/src/charts/features/shareKey.js +15 -0
  84. package/es/src/charts/features/thresholdMembers.js +71 -0
  85. package/es/src/charts/helpers/densityChart.js +3 -1
  86. package/es/src/charts/helpers/valueTitle.js +6 -3
  87. package/es/src/charts/partition/chartFields.js +4 -3
  88. package/es/src/charts/partition/hierarchy.js +2 -0
  89. package/es/src/charts/pipeline/preDrawData.js +31 -10
  90. package/es/src/charts/pipeline/vizDraw.js +40 -29
  91. package/es/src/charts/pipeline/vizPreDraw.js +24 -15
  92. package/es/src/charts/viz/Viz.js +43 -8
  93. package/es/src/charts/viz/VizBase.js +32 -12
  94. package/es/src/charts/viz/dataPoller.js +52 -0
  95. package/es/src/charts/viz/groupRow.js +35 -0
  96. package/es/src/charts/viz/interactionOpacity.js +19 -5
  97. package/es/src/charts/viz/missingFields.js +122 -0
  98. package/es/src/charts/viz/reportHandlerError.js +10 -0
  99. package/es/src/charts/viz/shapeClassTargets.js +18 -2
  100. package/es/src/charts/viz/simpleHover.js +2 -0
  101. package/es/src/charts/viz/vizClassName.js +31 -0
  102. package/es/src/charts/viz/vizDataPolling.js +167 -0
  103. package/es/src/charts/viz/vizDefaults.js +66 -0
  104. package/es/src/charts/viz/vizFields.js +18 -2
  105. package/es/src/charts/viz/vizRender.js +8 -2
  106. package/es/src/components/Axis/Axis.js +28 -0
  107. package/es/src/components/Axis/axisDefaults.js +3 -1
  108. package/es/src/components/Axis/axisLabelAngle.js +175 -0
  109. package/es/src/components/Axis/axisLabelThinning.js +13 -4
  110. package/es/src/components/Axis/axisLayout.js +86 -19
  111. package/es/src/components/Axis/axisLayoutLabels.js +66 -13
  112. package/es/src/components/Axis/axisLayoutScale.js +3 -0
  113. package/es/src/components/Axis/axisRender.js +38 -9
  114. package/es/src/components/Axis/axisRounding.js +15 -4
  115. package/es/src/components/Axis/axisSlantWrap.js +39 -0
  116. package/es/src/components/Axis/powTicks.js +73 -0
  117. package/es/src/components/ColorScale/ColorScale.js +28 -28
  118. package/es/src/components/ColorScale/bucketBounds.js +35 -0
  119. package/es/src/components/ColorScale/colorScaleHoverMark.js +327 -0
  120. package/es/src/components/ColorScale/colorScaleRender.js +25 -1
  121. package/es/src/components/ColorScale/colorScaleScale.js +15 -9
  122. package/es/src/components/ColorScale/colorScaleType.js +26 -0
  123. package/es/src/components/TextBox.js +2 -0
  124. package/es/src/components/Timeline/Timeline.js +43 -52
  125. package/es/src/components/Timeline/brushSpan.js +78 -0
  126. package/es/src/components/Timeline/timelineConfig.js +7 -0
  127. package/es/src/components/Timeline/timelineRender.js +44 -6
  128. package/es/src/components/Tooltip.js +13 -8
  129. package/es/src/shapes/Box.js +66 -79
  130. package/es/src/shapes/boxOutlierShape.js +19 -0
  131. package/es/src/shapes/boxStats.js +35 -0
  132. package/es/src/shapes/boxStyle.js +78 -0
  133. package/es/src/shapes/boxSummary.js +174 -0
  134. package/es/src/shapes/shapeStandalone.js +2 -0
  135. package/es/src/utils/BaseClass.js +19 -0
  136. package/es/src/utils/className.js +78 -0
  137. package/es/src/utils/configWarnings.js +25 -0
  138. package/es/src/utils/fieldAccessor.js +31 -0
  139. package/es/src/utils/paintComponentScene.js +2 -0
  140. package/package.json +10 -9
  141. package/types/index.d.ts +3 -1
  142. package/types/internal.d.ts +3 -1
  143. package/types/src/charts/BoxWhisker/index.d.ts +3 -1
  144. package/types/src/charts/BoxWhisker/outliers.d.ts +25 -0
  145. package/types/src/charts/BoxWhisker/summary.d.ts +39 -0
  146. package/types/src/charts/BoxWhisker/tooltip.d.ts +36 -0
  147. package/types/src/charts/Candlestick/aggregate.d.ts +6 -0
  148. package/types/src/charts/Plot/axisHover.d.ts +68 -0
  149. package/types/src/charts/Plot/axisHoverAnchors.d.ts +88 -0
  150. package/types/src/charts/Plot/axisHoverScene.d.ts +88 -0
  151. package/types/src/charts/Plot/barHitArea.d.ts +59 -0
  152. package/types/src/charts/Plot/barLabelFit.d.ts +81 -0
  153. package/types/src/charts/Plot/index.d.ts +13 -0
  154. package/types/src/charts/Plot/labelPlacement.d.ts +5 -0
  155. package/types/src/charts/Plot/plotInit.d.ts +9 -2
  156. package/types/src/charts/Plot/plotZoom.d.ts +2 -0
  157. package/types/src/charts/Plot/sharedHoverScene.d.ts +3 -3
  158. package/types/src/charts/Plot/sharedTooltip.d.ts +11 -4
  159. package/types/src/charts/Plot/stackHelpers.d.ts +5 -0
  160. package/types/src/charts/Plot/stackThreshold.d.ts +75 -0
  161. package/types/src/charts/Treemap/emit.d.ts +2 -1
  162. package/types/src/charts/Treemap/emitGroupHeaders.d.ts +16 -0
  163. package/types/src/charts/Treemap/groupHeaders.d.ts +91 -0
  164. package/types/src/charts/Treemap/index.d.ts +2 -0
  165. package/types/src/charts/Treemap/thresholdFunction.d.ts +5 -2
  166. package/types/src/charts/definition/ChartDefinition.d.ts +14 -2
  167. package/types/src/charts/definition/makeChart.d.ts +4 -3
  168. package/types/src/charts/drawSteps/saveChart.d.ts +47 -0
  169. package/types/src/charts/drawSteps/saveControl.d.ts +9 -0
  170. package/types/src/charts/drawSteps/saveControlMarkup.d.ts +44 -0
  171. package/types/src/charts/drawSteps/tableViewMarkup.d.ts +1 -0
  172. package/types/src/charts/drawSteps/topLeftControls.d.ts +1 -1
  173. package/types/src/charts/drawSteps/topLeftControlsMarkup.d.ts +1 -1
  174. package/types/src/charts/facet/facetData.d.ts +1 -1
  175. package/types/src/charts/features/axesMeasure.d.ts +9 -1
  176. package/types/src/charts/features/colorScaleBucket.d.ts +9 -0
  177. package/types/src/charts/features/colorScaleHover.d.ts +32 -0
  178. package/types/src/charts/features/features.d.ts +8 -0
  179. package/types/src/charts/features/plotPaint.d.ts +2 -0
  180. package/types/src/charts/features/shapeEmit.d.ts +2 -0
  181. package/types/src/charts/features/shareKey.d.ts +9 -0
  182. package/types/src/charts/features/thresholdMembers.d.ts +38 -0
  183. package/types/src/charts/helpers/valueTitle.d.ts +4 -2
  184. package/types/src/charts/pipeline/stages.d.ts +2 -0
  185. package/types/src/charts/pipeline/vizDraw.d.ts +8 -3
  186. package/types/src/charts/pipeline/vizPreDraw.d.ts +3 -2
  187. package/types/src/charts/viz/Viz.d.ts +28 -4
  188. package/types/src/charts/viz/VizBase.d.ts +12 -3
  189. package/types/src/charts/viz/dataPoller.d.ts +28 -0
  190. package/types/src/charts/viz/groupRow.d.ts +24 -0
  191. package/types/src/charts/viz/interactionOpacity.d.ts +3 -1
  192. package/types/src/charts/viz/missingFields.d.ts +57 -0
  193. package/types/src/charts/viz/reportHandlerError.d.ts +7 -0
  194. package/types/src/charts/viz/shapeClassTargets.d.ts +6 -0
  195. package/types/src/charts/viz/simpleHover.d.ts +2 -1
  196. package/types/src/charts/viz/vizClassName.d.ts +23 -0
  197. package/types/src/charts/viz/vizDataPolling.d.ts +48 -0
  198. package/types/src/charts/viz/vizDefaults.d.ts +49 -0
  199. package/types/src/charts/viz/vizFields.d.ts +15 -0
  200. package/types/src/charts/viz/vizTypes.d.ts +33 -1
  201. package/types/src/components/Axis/Axis.d.ts +36 -8
  202. package/types/src/components/Axis/axisLabelAngle.d.ts +110 -0
  203. package/types/src/components/Axis/axisLabelThinning.d.ts +3 -7
  204. package/types/src/components/Axis/axisLayout.d.ts +5 -0
  205. package/types/src/components/Axis/axisLayoutLabels.d.ts +13 -0
  206. package/types/src/components/Axis/axisRounding.d.ts +6 -3
  207. package/types/src/components/Axis/axisSlantWrap.d.ts +22 -0
  208. package/types/src/components/Axis/powTicks.d.ts +29 -0
  209. package/types/src/components/ColorScale/ColorScale.d.ts +13 -0
  210. package/types/src/components/ColorScale/bucketBounds.d.ts +14 -0
  211. package/types/src/components/ColorScale/colorScaleHoverMark.d.ts +86 -0
  212. package/types/src/components/ColorScale/colorScaleScale.d.ts +3 -0
  213. package/types/src/components/ColorScale/colorScaleType.d.ts +17 -0
  214. package/types/src/components/Timeline/brushSpan.d.ts +41 -0
  215. package/types/src/components/Timeline/timelineConfig.d.ts +6 -0
  216. package/types/src/components/Timeline/timelineRender.d.ts +8 -0
  217. package/types/src/components/Tooltip.d.ts +8 -0
  218. package/types/src/shapes/Box.d.ts +1 -8
  219. package/types/src/shapes/boxOutlierShape.d.ts +9 -0
  220. package/types/src/shapes/boxStats.d.ts +19 -0
  221. package/types/src/shapes/boxStyle.d.ts +25 -0
  222. package/types/src/shapes/boxSummary.d.ts +66 -0
  223. package/types/src/shapes/emitLabels.d.ts +1 -1
  224. package/types/src/shapes/shapeConfig.d.ts +42 -4
  225. package/types/src/utils/BaseClass.d.ts +23 -0
  226. package/types/src/utils/D3Scale.d.ts +3 -0
  227. package/types/src/utils/D3plusConfig.d.ts +261 -5
  228. package/types/src/utils/className.d.ts +64 -0
  229. package/types/src/utils/configWarnings.d.ts +21 -2
  230. package/types/src/utils/fieldAccessor.d.ts +24 -0
  231. package/types/src/utils/index.d.ts +1 -1
  232. package/types/src/utils/paintComponentScene.d.ts +3 -1
  233. package/umd/d3plus-core.full.js +6405 -1068
  234. package/umd/d3plus-core.full.min.js +2 -2
  235. package/umd/d3plus-core.js +5328 -1002
  236. package/umd/d3plus-core.min.js +2 -2
@@ -0,0 +1,81 @@
1
+ /**
2
+ Bar hit areas: a transparent hover target behind each side-by-side bar
3
+ that fills the bar's slot along the discrete axis and the whole plot along
4
+ the value axis, so a short bar is as easy to hover and click as a tall
5
+ one. Grouped bars each take their own column of the slot. Stacked bars
6
+ already fill their slot and take none. `shapeConfig.Bar.hitArea: false`
7
+ turns them off.
8
+
9
+ @module
10
+ */ /**
11
+ A bar's column of its slot along the discrete axis, as offsets from the
12
+ bar's own center. A lone bar takes the whole slot. Grouped bars split it
13
+ at the midpoints between their centers, and the outermost reach the
14
+ slot's edges, so no column overlaps a neighboring bar.
15
+ @param step The slot's width: the distance between neighboring categories.
16
+ @param count How many bars share the slot.
17
+ @param index The bar's position in the slot.
18
+ @param reach How far the outermost bars' centers sit from the slot's center.
19
+ */ export function hitColumn(step, count, index, reach) {
20
+ const half = step / 2;
21
+ if (count < 2) return [
22
+ -half,
23
+ half
24
+ ];
25
+ const gap = 2 * reach / (count - 1);
26
+ const center = -reach + index * gap;
27
+ const lo = index <= 0 ? -half : center - gap / 2;
28
+ const hi = index >= count - 1 ? half : center + gap / 2;
29
+ return [
30
+ lo - center,
31
+ hi - center
32
+ ];
33
+ }
34
+ /**
35
+ A bar's hit rect in its own coordinates: its `column` along the discrete
36
+ axis, and the plot's `valueExtent` along the value axis, both sides of
37
+ the baseline.
38
+ @param discrete The discrete axis.
39
+ @param column The column, as offsets from the bar's center (see `hitColumn`).
40
+ @param valueExtent The value axis's pixel span, in shape coordinates.
41
+ @param origin The bar's transform.
42
+ */ export function hitBounds(discrete, column, valueExtent, origin) {
43
+ const [lo, hi] = column;
44
+ const [vlo, vhi] = valueExtent;
45
+ return discrete === "x" ? {
46
+ x: lo,
47
+ y: vlo - (origin.y ?? 0),
48
+ width: hi - lo,
49
+ height: vhi - vlo
50
+ } : {
51
+ x: vlo - (origin.x ?? 0),
52
+ y: lo,
53
+ width: vhi - vlo,
54
+ height: hi - lo
55
+ };
56
+ }
57
+ /**
58
+ Gives a Bar shape its slot-filling hit areas (see `hitBounds`). Set
59
+ before the user's `shapeConfig`, so `hitArea` there (or `false`) wins.
60
+ @param s The Bar shape.
61
+ @param discrete The discrete axis.
62
+ @param valueExtent The value axis's pixel span, in shape coordinates.
63
+ @param column Each bar's column (see `hitColumn`).
64
+ */ export function applyBarHitArea(s, discrete, valueExtent, column) {
65
+ if (!valueExtent) return;
66
+ s.config({
67
+ hitArea: (d, i)=>hitBounds(discrete, column(d, i), valueExtent, s._sceneTransform(d, i))
68
+ });
69
+ }
70
+ /** Whether a scene node is a Bar's hit area. */ const isBarHit = (node)=>node.shapeType === "Bar" && String(node.key).endsWith("::hit");
71
+ /**
72
+ `nodes` with every Bar hit area moved to the front (painted first), so
73
+ each sits behind every mark: a bar's slot never covers another bar, nor
74
+ the lines, points, and areas drawn over it.
75
+ */ export function barHitsFirst(nodes) {
76
+ if (!nodes.some(isBarHit)) return nodes;
77
+ return [
78
+ ...nodes.filter(isBarHit),
79
+ ...nodes.filter((node)=>!isBarHit(node))
80
+ ];
81
+ }
@@ -0,0 +1,123 @@
1
+ /**
2
+ Whether a Plot's in-bar category labels fit their bars. A BarChart whose
3
+ bars are labeled with their own categories hides the category axis's
4
+ tick labels; when the bars are too narrow for those labels, the axis
5
+ keeps its ticks instead (and the bars drop theirs), so every category
6
+ stays named. Decided during the axis measure, before the category axis
7
+ is measured, by fitting each label the way its bar would: the same
8
+ TextBox fitting, in the room the bar will have along the category axis
9
+ and at least half the plot along the value axis.
10
+
11
+ @module
12
+ */ import { max } from "d3-array";
13
+ import TextBox from "../../components/TextBox.js";
14
+ import { computeTextBoxDatum } from "../../components/textBoxLayout.js";
15
+ import { shapeConfigFor } from "../features/emitHelpers.js";
16
+ /** The label config keys that decide whether a label fits. */ const FIT_KEYS = [
17
+ "ellipsis",
18
+ "fontFamily",
19
+ "fontMax",
20
+ "fontMin",
21
+ "fontResize",
22
+ "fontSize",
23
+ "fontWeight",
24
+ "lineHeight",
25
+ "maxLines",
26
+ "overflow",
27
+ "padding",
28
+ "split"
29
+ ];
30
+ /**
31
+ The room each bar has for its label, in pixels: along the category axis,
32
+ the axis length split evenly among its `categories` (less `groupPadding`),
33
+ then among the `perCategory` bars sharing a category (less
34
+ `barPadding`); along the value axis, half the plot, which a bar's label
35
+ always has inside or beyond it.
36
+ @param discrete The category axis.
37
+ @param plot The plot area's size.
38
+ @param categories How many categories the axis holds.
39
+ @param perCategory How many bars share a category.
40
+ @param padding `groupPadding` and `barPadding`.
41
+ */ export function barLabelRoom(discrete, plot, categories, perCategory, padding) {
42
+ const along = discrete === "x" ? plot.width : plot.height;
43
+ const across = (discrete === "x" ? plot.height : plot.width) / 2;
44
+ let band = along / Math.max(1, categories);
45
+ if (padding.group < band) band -= padding.group;
46
+ if (perCategory > 1) band = (band - padding.bar * perCategory - 1) / perCategory;
47
+ band = Math.max(0, band);
48
+ return discrete === "x" ? {
49
+ width: band,
50
+ height: across
51
+ } : {
52
+ width: across,
53
+ height: band
54
+ };
55
+ }
56
+ /**
57
+ A TextBox configured with the fitting keys of a bar `labelConfig`; each
58
+ function value is read per row, against the row's source data.
59
+ */ function fitBox(labelConfig, rows) {
60
+ const box = new TextBox();
61
+ for (const key of FIT_KEYS){
62
+ const value = labelConfig[key];
63
+ if (value === undefined) continue;
64
+ if (key === "split" || typeof value !== "function") box[key](value);
65
+ else {
66
+ const fn = value;
67
+ box[key]((_, i)=>fn(rows[i].data, rows[i].i));
68
+ }
69
+ }
70
+ return box;
71
+ }
72
+ /**
73
+ Whether every label in `labels` (one per row in `rows`) fits, whole and
74
+ untruncated, in a `room`-sized box laid out with the bar `labelConfig`.
75
+ @param labels Each row's label text.
76
+ @param rows The rows the labels belong to.
77
+ @param room The box each label has (see `barLabelRoom`).
78
+ @param labelConfig The bars' resolved `labelConfig`.
79
+ */ export function barLabelsFit(labels, rows, room, labelConfig) {
80
+ if (!labels.length) return true;
81
+ const box = fitBox(labelConfig, rows);
82
+ return labels.every((text, i)=>{
83
+ const fitted = computeTextBoxDatum(box, {
84
+ text,
85
+ width: room.width,
86
+ height: room.height
87
+ }, i);
88
+ return !!fitted && !fitted.truncated && fitted.lines.join("") !== "";
89
+ });
90
+ }
91
+ /**
92
+ Whether the bars of `rows` have room for their category `labels` in a
93
+ plot of `plot` size (see `barLabelRoom` and `barLabelsFit`).
94
+ @param viz The chart.
95
+ @param rows The bar rows the labels belong to.
96
+ @param labels Each row's label text.
97
+ @param plot The plot area's size.
98
+ @param labelConfig The bars' resolved `labelConfig`.
99
+ */ export function barCategoryLabelsFit(viz, rows, labels, plot, labelConfig) {
100
+ const discrete = viz.schema.discrete === "y" ? "y" : "x";
101
+ const byCategory = new Map();
102
+ for (const row of rows){
103
+ const key = String(row[discrete]);
104
+ byCategory.set(key, (byCategory.get(key) ?? 0) + 1);
105
+ }
106
+ const perCategory = viz.schema.stacked ? 1 : max(Array.from(byCategory.values())) ?? 1;
107
+ const room = barLabelRoom(discrete, plot, byCategory.size, perCategory, {
108
+ group: viz._groupPadding ?? 0,
109
+ bar: viz.schema.barPadding ?? 0
110
+ });
111
+ return barLabelsFit(labels, rows, room, labelConfig);
112
+ }
113
+ /**
114
+ Whether a category axis keeps the tick labels its bars carry (see
115
+ `BarLabelCheck`): when the bars, in a plot of `plot` size, have no room
116
+ for those labels.
117
+ @param viz The chart.
118
+ @param check The bars' category labels.
119
+ @param plot The plot area's size.
120
+ */ export function barLabelsNeedAxis(viz, check, plot) {
121
+ const labelConfig = shapeConfigFor(viz, "Bar").labelConfig || {};
122
+ return !barCategoryLabelsFit(viz, check.rows, check.labels, plot, labelConfig);
123
+ }
@@ -6,7 +6,7 @@
6
6
  labeled at its bar's center, the way a category axis is.
7
7
  */ import { merge } from "@d3plus/data";
8
8
  import { formatAbbreviate, formatDate } from "@d3plus/format";
9
- import accessor from "../../utils/accessor.js";
9
+ import { fieldAccessor } from "../../utils/fieldAccessor.js";
10
10
  /** Labels for `barWidth` accessors that aren't a plain data key. */ const accessorLabels = new WeakMap();
11
11
  /** `discreteExtent` functions installed by this module, so others are left alone. */ const ownExtents = new WeakSet();
12
12
  /** A discrete value's identity: dates by time, everything else by its string. */ export const barKey = (v)=>v instanceof Date ? String(v.getTime()) : String(v);
@@ -17,7 +17,7 @@ import accessor from "../../utils/accessor.js";
17
17
  */ export function barWidthAccessor(value) {
18
18
  if (typeof value === "function") return value;
19
19
  if (typeof value === "string" && value) {
20
- const fn = accessor(value);
20
+ const fn = fieldAccessor(value);
21
21
  accessorLabels.set(fn, {
22
22
  key: value
23
23
  });
@@ -2,7 +2,7 @@
2
2
  The `confidence` and `confidenceConfig` settings' input handling: the
3
3
  `[lower, upper]` accessor pair, and which keys `confidenceConfig` accepts.
4
4
  */ import validateShapeConfig from "../../shapes/validateShapeConfig.js";
5
- import accessor from "../../utils/accessor.js";
5
+ import { fieldAccessor } from "../../utils/fieldAccessor.js";
6
6
  /**
7
7
  The shapes `confidenceConfig` styles: a line's band (an Area) and a bar's
8
8
  error bar (a Path), each also configurable alone under its own key.
@@ -38,7 +38,7 @@ import accessor from "../../utils/accessor.js";
38
38
  or `false` when neither side has one.
39
39
  @param value The setter's argument.
40
40
  */ export function resolveConfidence(value) {
41
- const bound = (b)=>typeof b === "function" ? b : typeof b === "string" && b ? accessor(b) : false;
41
+ const bound = (b)=>typeof b === "function" ? b : typeof b === "string" && b ? fieldAccessor(b) : false;
42
42
  const pair = Array.isArray(value) ? [
43
43
  bound(value[0]),
44
44
  bound(value[1])
@@ -130,7 +130,8 @@ const superDraw = (viz, callback)=>Viz.prototype._draw.call(viz, callback);
130
130
  x2Ticks: prepCtx.plotX2Ticks,
131
131
  yTicks: prepCtx.plotYTicks,
132
132
  y2Ticks: prepCtx.plotY2Ticks,
133
- barLabels: prepCtx.plotBarLabels
133
+ barLabels: prepCtx.plotBarLabels,
134
+ barLabelCheck: prepCtx.plotBarLabelCheck
134
135
  };
135
136
  }
136
137
  /** Assembles the joint axis solve's inputs (see `measureAxes`). */ function plotAxisMeasureInputs(testAxes, prep, configScales, frame) {
@@ -159,7 +160,8 @@ const superDraw = (viz, callback)=>Viz.prototype._draw.call(viz, callback);
159
160
  height,
160
161
  width,
161
162
  xData,
162
- xScalePadding: x.padding ? x.padding() : 0
163
+ xScalePadding: x.padding ? x.padding() : 0,
164
+ barLabelCheck: prep.barLabelCheck
163
165
  };
164
166
  }
165
167
  /** Builds the line-label width measure callback for the four-axis margin solve. */ function makePlotLineLabelMeasure(viz, data, layoutCtx, y2Exists, testAxes) {
@@ -190,6 +192,8 @@ const superDraw = (viz, callback)=>Viz.prototype._draw.call(viz, callback);
190
192
  };
191
193
  }
192
194
  export function drawPlot(viz, callback) {
195
+ // The axis hover's positions belong to the previous layout.
196
+ viz._axisHoverState = null;
193
197
  // A small-multiples chrome pass lays out the chrome only.
194
198
  if (viz._facetStep === "chrome" || !viz._filteredData.length && !viz._annotations?.length) {
195
199
  // Empty data: still run super._draw so the chart shell (title /
@@ -1,6 +1,7 @@
1
1
  /* eslint no-cond-assign: 0*/ import { zoomTransform } from "d3-zoom";
2
2
  import { assign } from "@d3plus/dom";
3
- import { accessor, constant } from "../../utils/index.js";
3
+ import { constant } from "../../utils/index.js";
4
+ import { fieldAccessor } from "../../utils/fieldAccessor.js";
4
5
  import { installFluent, mergeConfigBag, resolvesReset } from "../../fluent.js";
5
6
  import { baselineValue, setBaseline } from "./baselineDomain.js";
6
7
  import { initPlotAxes, initPlotDefaults, plotSchema } from "./plotInit.js";
@@ -12,10 +13,12 @@ import { validateConfidenceConfig } from "./confidenceConfig.js";
12
13
  import { resolveConfidenceBands } from "./confidenceBands.js";
13
14
  import { trendLineDefaults } from "./trendLines.js";
14
15
  import { contentPoint, handleSharedHover } from "./sharedHover.js";
16
+ import { handleAxisHover } from "./axisHover.js";
15
17
  import { appendSharedHoverNodes } from "./sharedHoverScene.js";
16
18
  import Viz from "../viz/Viz.js";
17
19
  import { plotInsetRegion } from "./insetRegion.js";
18
20
  import { plotFacetHooks } from "./plotFacet.js";
21
+ import { plotStackThreshold, plotStackThresholdLegend } from "./stackThreshold.js";
19
22
  import { defaultBuffers } from "../plotBuffers/defaultBuffers.js";
20
23
  /** A y-axis config patch with its `domain` array reversed (y scales run top-down). */ function reverseDomain(patch) {
21
24
  const domain = patch?.domain;
@@ -71,6 +74,20 @@ import { defaultBuffers } from "../plotBuffers/defaultBuffers.js";
71
74
  });
72
75
  super._preDraw();
73
76
  }
77
+ /**
78
+ The legend rows with a stacked chart's threshold bucket folded into
79
+ one entry (see `stackThreshold.ts`).
80
+ @private
81
+ */ _thresholdLegend(legendData) {
82
+ return plotStackThresholdLegend(this, legendData);
83
+ }
84
+ /**
85
+ Folds a stacked chart's small series into one threshold bucket (see
86
+ `stackThreshold.ts`).
87
+ @private
88
+ */ _thresholdFunction(data, _tree, all) {
89
+ return plotStackThreshold(this, data, all);
90
+ }
74
91
  /**
75
92
  Composes the chart's scene graph: the native shape scenes from Viz.toScene
76
93
  (bars/lines/areas + labels) plus snapshots of the rendered axes, so a Plot
@@ -185,9 +202,11 @@ import { defaultBuffers } from "../plotBuffers/defaultBuffers.js";
185
202
  inside the plot area, snaps to the nearest discrete position and, when
186
203
  two or more series share it, shows them all in one tooltip (suppressing
187
204
  the single-shape tooltip). Clears on leaving the plot area or the chart.
205
+ Then tracks the hovered point's axis guides and badges (`axisHover`).
188
206
  @private
189
207
  */ _sharedHover(event) {
190
208
  handleSharedHover(this, event);
209
+ handleAxisHover(this, event);
191
210
  }
192
211
  /**
193
212
  Extends the draw behavior of the abstract Viz class.
@@ -383,7 +402,7 @@ Stacked charts always fit one line to the stack totals.
383
402
  Sets the size of bubbles to the given Number, data key, or function.
384
403
  */ size(_) {
385
404
  if (!arguments.length) return this._size;
386
- this._size = typeof _ === "function" || !_ ? _ : accessor(_);
405
+ this._size = typeof _ === "function" || !_ ? _ : fieldAccessor(_);
387
406
  this._sizeKey = typeof _ === "string" ? _ : undefined;
388
407
  return this;
389
408
  }
@@ -418,7 +437,7 @@ Stacked charts always fit one line to the stack totals.
418
437
  if (arguments.length) {
419
438
  if (typeof _ === "function") this._x = _;
420
439
  else {
421
- this._x = accessor(_);
440
+ this._x = fieldAccessor(_);
422
441
  this._xKey = _;
423
442
  }
424
443
  return this;
@@ -430,7 +449,7 @@ Stacked charts always fit one line to the stack totals.
430
449
  if (arguments.length) {
431
450
  if (typeof _ === "function") this._x2 = _;
432
451
  else {
433
- this._x2 = accessor(_);
452
+ this._x2 = fieldAccessor(_);
434
453
  this._x2Key = _;
435
454
  }
436
455
  return this;
@@ -452,7 +471,7 @@ Stacked charts always fit one line to the stack totals.
452
471
  if (arguments.length) {
453
472
  if (typeof _ === "function") this._y = _;
454
473
  else {
455
- this._y = accessor(_);
474
+ this._y = fieldAccessor(_);
456
475
  this._yKey = _;
457
476
  }
458
477
  return this;
@@ -464,7 +483,7 @@ Stacked charts always fit one line to the stack totals.
464
483
  if (arguments.length) {
465
484
  if (typeof _ === "function") this._y2 = _;
466
485
  else {
467
- this._y2 = accessor(_);
486
+ this._y2 = fieldAccessor(_);
468
487
  this._y2Key = _;
469
488
  }
470
489
  return this;
@@ -9,6 +9,14 @@
9
9
  // so the `null` argument is ignored (cast to satisfy the scale signature).
10
10
  return this._sizeScaleD3(this._size ? this._size(d) : null);
11
11
  }
12
+ /**
13
+ Whether a bar grows back along its value axis: a negative value, or a
14
+ positive one on a `reverse` axis (down a y axis, left along an x axis).
15
+ */ export function growsBack(viz, valueAxis, d, i) {
16
+ const value = (valueAxis === "y" ? viz._y : viz._x)(d, i);
17
+ const axis = valueAxis === "y" ? viz._yAxis : viz._xAxis;
18
+ return value < 0 !== Boolean(axis?.schema?.reverse);
19
+ }
12
20
  /**
13
21
  Determines if a Bar label should be placed outside of the Bar.
14
22
  */ export function outside(d, i) {
@@ -25,7 +33,7 @@
25
33
  const accessor = nonDiscrete === "y" ? this._y : this._x;
26
34
  const range = axis._d3Scale.range();
27
35
  const value = accessor(d, i);
28
- const negative = value < 0;
36
+ const negative = growsBack(this, nonDiscrete, d, i);
29
37
  const zero = axis._getPosition(0);
30
38
  const space = nonDiscrete === "y" ? negative ? range[1] - zero : zero - range[0] : negative ? zero - range[0] : range[1] - zero;
31
39
  const pos = axis._getPosition(value);
@@ -8,7 +8,7 @@
8
8
  rounded. Time axes aren't rounded either way.
9
9
 
10
10
  @module
11
- */ import { roundedDomain } from "../../components/Axis/axisRounding.js";
11
+ */ import { roundedDomain, roundingScales } from "../../components/Axis/axisRounding.js";
12
12
  import { isOneSided } from "./baselineDomain.js";
13
13
  /**
14
14
  The open end of an axis's user domain, when it leaves one: which end the
@@ -75,10 +75,7 @@ import { isOneSided } from "./baselineDomain.js";
75
75
  const open = plotOpenEnds[axis];
76
76
  const scale = plotConfigScales[`${axis}ConfigScale`];
77
77
  const rounding = axisRounding(viz, axis);
78
- if (!open || ![
79
- "linear",
80
- "log"
81
- ].includes(scale) || rounding === "none") continue;
78
+ if (!open || !roundingScales.includes(scale) || rounding === "none") continue;
82
79
  const current = scales[axis];
83
80
  // The y scale runs high to low.
84
81
  const flip = (d)=>axis === "y" ? d.slice().reverse() : d;
@@ -192,13 +192,15 @@ export { preparePlotAxisLayout } from "./pipelineAxisLayout.js";
192
192
  const axisData = plotAxisData || [];
193
193
  function getAxisValues(axis) {
194
194
  const timeData = viz[`_${axis}Time`];
195
- const localData = timeData ? data : axisData;
195
+ const rows = timeData ? data : axisData;
196
+ const localData = viz._plotAxisRows ? viz._plotAxisRows(rows, axis) : rows;
196
197
  const filteredData = localData.filter((d)=>![
197
198
  NaN,
198
199
  undefined,
199
200
  false
200
201
  ].includes(d[axis]));
201
- if (!filteredData.length) return [];
202
+ const extra = viz._plotAxisValues ? viz._plotAxisValues(localData, axis) : [];
203
+ if (!filteredData.length) return extra;
202
204
  const numericValue = typeof filteredData[0][axis] === "number";
203
205
  let myData = viz.schema.discrete === axis ? rollups(filteredData, (leaves)=>leaves.length === 1 ? leaves[0].data : d3plusMerge(leaves.map((d)=>d.data), viz.schema.aggs), (d)=>d[axis]).sort((a, b)=>{
204
206
  if (viz.schema[`${axis}Sort`]) return viz.schema[`${axis}Sort`](a[1], b[1]);
@@ -211,7 +213,7 @@ export { preparePlotAxisLayout } from "./pipelineAxisLayout.js";
211
213
  if (viz._confidence[1]) myData = myData.concat(localData.map((d)=>d.hci));
212
214
  myData = myData.concat(extraBandValues(viz, localData));
213
215
  }
214
- return myData;
216
+ return extra.length ? myData.concat(extra) : myData;
215
217
  }
216
218
  return {
217
219
  xData: getAxisValues("x"),
@@ -8,6 +8,8 @@
8
8
  - `barLabels` (used to suppress redundant ticks)
9
9
  - `xTicks`/`yTicks`/`x2Ticks`/`y2Ticks` (null when ticks should display,
10
10
  empty array when ticks are redundant with bar labels)
11
+ - `barLabelCheck` (the category labels the bars carry in place of the
12
+ axis's ticks, which the axis measure checks they have room for)
11
13
 
12
14
  Pure compute. No DOM, no side effects on viz.
13
15
  */ import { unique } from "@d3plus/data";
@@ -64,10 +66,23 @@ import { xAxisRounding } from "../features/xAxisConfig.js";
64
66
  }
65
67
  return yC;
66
68
  }
67
- /** The Bar labels drawn for the rows, as strings — used to suppress redundant axis ticks. */ function plotBarLabels(viz, axisData) {
69
+ /** The Bar labels drawn for the rows, as strings, with the rows they label. */ function plotBarLabels(viz, axisData) {
68
70
  const barConfig = shapeConfigFor(viz, "Bar");
69
71
  const barLabelFunction = barConfig.label !== undefined ? typeof barConfig.label === "function" ? barConfig.label : ()=>barConfig.label : viz._drawLabel;
70
- return axisData.map((d)=>barLabelFunction(d.data, d.i)).filter((d)=>typeof d === "number" || d).map(String);
72
+ const labels = [];
73
+ const rows = [];
74
+ // A Box draws no label, so its rows never make a tick redundant.
75
+ for (const d of axisData){
76
+ if (d.shape === "Box") continue;
77
+ const label = barLabelFunction(d.data, d.i);
78
+ if (typeof label !== "number" && !label) continue;
79
+ labels.push(String(label));
80
+ rows.push(d);
81
+ }
82
+ return {
83
+ labels,
84
+ rows
85
+ };
71
86
  }
72
87
  export const preparePlotAxisLayout = ({ viz, plotAxisData, plotScales, x2Exists, y2Exists, x2Data, y2Data, yData })=>{
73
88
  const axisData = plotAxisData || [];
@@ -106,12 +121,26 @@ export const preparePlotAxisLayout = ({ viz, plotAxisData, plotScales, x2Exists,
106
121
  showX,
107
122
  showY
108
123
  });
109
- const barLabels = plotBarLabels(viz, axisData);
124
+ const bar = plotBarLabels(viz, axisData);
125
+ const barLabels = bar.labels;
126
+ let barLabelCheck;
110
127
  const tickFor = (axis, axisScale)=>{
111
128
  if (isSpanAxis(viz, axis)) return spanEdges(viz, axisData);
112
129
  const ticks = unique(axisData.map((d)=>d[axis]));
113
- return axisScale === "Point" && ticks.every((t)=>barLabels.includes(`${t}`)) ? [] : null;
130
+ if (axisScale !== "Point" || !ticks.every((t)=>barLabels.includes(`${t}`))) return null;
131
+ // The axis measure checks that the bars have room for these labels.
132
+ if (axis === "x" || axis === "y") {
133
+ if (axis === viz.schema.discrete && (axis === "x" ? showX : showY)) barLabelCheck = {
134
+ axis,
135
+ ...bar
136
+ };
137
+ }
138
+ return [];
114
139
  };
140
+ const xTicks = tickFor("x", xScale);
141
+ const x2Ticks = tickFor("x2", x2Scale);
142
+ const yTicks = tickFor("y", yScale);
143
+ const y2Ticks = tickFor("y2", y2Scale);
115
144
  return {
116
145
  plotDefaultConfig: defaultConfig,
117
146
  plotDefaultX2Config: withAxisInk(viz, defaultX2Config),
@@ -120,10 +149,11 @@ export const preparePlotAxisLayout = ({ viz, plotAxisData, plotScales, x2Exists,
120
149
  plotShowY: showY,
121
150
  plotYC: withAxisInk(viz, yC),
122
151
  plotBarLabels: barLabels,
123
- plotXTicks: tickFor("x", xScale),
124
- plotX2Ticks: tickFor("x2", x2Scale),
125
- plotYTicks: tickFor("y", yScale),
126
- plotY2Ticks: tickFor("y2", y2Scale),
152
+ plotBarLabelCheck: barLabelCheck,
153
+ plotXTicks: xTicks,
154
+ plotX2Ticks: x2Ticks,
155
+ plotYTicks: yTicks,
156
+ plotY2Ticks: y2Ticks,
127
157
  plotXDomain: xDomain,
128
158
  plotX2Domain: x2Domain,
129
159
  plotYDomain: yDomain,
@@ -23,6 +23,7 @@ import * as d3Shape from "d3-shape";
23
23
  import { stampShare } from "../features/shareKey.js";
24
24
  import { stackedConfidenceValues } from "./barConfidence.js";
25
25
  import { isSpanAxis, spanDomain } from "./discreteSpan.js";
26
+ import { orderLast } from "./stackHelpers.js";
26
27
  import { trendDomainValues } from "./trendLines.js";
27
28
  /**
28
29
  Pushes zero-value filler points for any Area series missing from a discrete
@@ -101,16 +102,18 @@ import { trendDomainValues } from "./trendLines.js";
101
102
  /**
102
103
  Runs d3-stack over the discrete groups with the configured order and
103
104
  offset. Sorts `stackKeys` in place when the order is an explicit key array.
104
- */ function runStack(viz, stackKeys, stackGroupsData, opp) {
105
+ A threshold bucket (see `stackThreshold.ts`) stacks last, on top.
106
+ */ function runStack(viz, stackKeys, stackGroupsData, opp, bucketKeys) {
105
107
  const order = viz._stackOrder;
106
108
  // An explicit key array orders `stackKeys` directly (then d3-stack keeps
107
109
  // that order via `stackOrderNone`); every other order is a comparator that
108
110
  // reranks the series d3-stack builds, so `stackKeys` is left in input order.
109
111
  if (Array.isArray(order)) stackKeys.sort((a, b)=>order.indexOf(a) - order.indexOf(b));
112
+ const stackOrder = Array.isArray(order) ? d3Shape.stackOrderNone : order;
110
113
  // d3-stack's generics don't model d3plus's dynamically-keyed rows; the
111
114
  // order/offset/value accessors are cast (`as never`) at the boundary, and
112
115
  // the configured stack is invoked as a `Row[][] -> number[][][]` function.
113
- return d3Shape.stack().keys(stackKeys).offset(viz._stackOffset).order(Array.isArray(order) ? d3Shape.stackOrderNone : order).value((group, key)=>{
116
+ return d3Shape.stack().keys(stackKeys).offset(viz._stackOffset).order(bucketKeys.size ? orderLast(stackOrder, bucketKeys) : stackOrder).value((group, key)=>{
114
117
  const d = group.filter((g)=>g.id === key);
115
118
  return d.length ? d[0][opp] : 0;
116
119
  })(stackGroupsData);
@@ -135,7 +138,8 @@ import { trendDomainValues } from "./trendLines.js";
135
138
  } else {
136
139
  data.sort((a, b)=>a[viz.schema.discrete] - b[viz.schema.discrete]);
137
140
  }
138
- const stackData = runStack(viz, stackKeys, stackGroupsData, opp);
141
+ const bucketKeys = new Set(axisData.filter((d)=>d.data?._isAggregation).map((d)=>d.id));
142
+ const stackData = runStack(viz, stackKeys, stackGroupsData, opp, bucketKeys);
139
143
  const discreteData = viz.schema.discrete === "x" ? xData : yData;
140
144
  // Trend fits and bar error bars (on their stacked ends) widen the stack's extent.
141
145
  const widen = trendDomainValues(viz._trendFits || []);
@@ -87,7 +87,7 @@ import { shapeConfigFor } from "../features/emitHelpers.js";
87
87
  to the scale's nearest end instead.
88
88
  */ function axisEstimate(test, configScale, domain) {
89
89
  return (d)=>{
90
- if (configScale === "log" && d === 0) d = domain[0] < 0 ? test._d3Scale.domain()[1] : test._d3Scale.domain()[0];
90
+ if (configScale === "log" && d === 0) d = test._givenDomain()[domain[0] < 0 ? 1 : 0];
91
91
  return test._getPosition.bind(test)(d);
92
92
  };
93
93
  }
@@ -9,15 +9,27 @@ import { gridStroke } from "../../components/Axis/gridStroke.js";
9
9
  import { accessor, constant } from "../../utils/index.js";
10
10
  import { defaultBuffers } from "../plotBuffers/defaultBuffers.js";
11
11
  import { linkedColorDefaults } from "../viz/linkGroup.js";
12
+ import { axisHoverDefaults } from "./axisHoverScene.js";
12
13
  import { fillBetweenDefaults } from "./fillBetween.js";
13
14
  import { forecastDefaults } from "./forecast.js";
14
15
  import { plotDef } from "./pipeline.js";
15
16
  import { plotShapeDefaults } from "./shapeDefaults.js";
17
+ import { axisValue } from "./sharedTooltip.js";
16
18
  import { stackOffsetDiverging, stackOrderTotalDescending } from "./stackHelpers.js";
17
19
  /**
18
20
  Plot's identity-coerce accessor schema. `installFluent` installs it on
19
21
  the instance's prototype alongside vizSchema's accessors.
20
22
  */ export const plotSchema = [
23
+ {
24
+ key: "axisHover",
25
+ coerce: "identity",
26
+ default: true
27
+ },
28
+ {
29
+ key: "axisHoverConfig",
30
+ merge: true,
31
+ factory: axisHoverDefaults
32
+ },
21
33
  {
22
34
  key: "barPadding",
23
35
  coerce: "identity"
@@ -200,6 +212,9 @@ import { stackOffsetDiverging, stackOrderTotalDescending } from "./stackHelpers.
200
212
  viz.schema.sizeScale = "sqrt";
201
213
  viz._stackOffset = stackOffsetDiverging;
202
214
  viz._stackOrder = stackOrderTotalDescending;
215
+ // Off until set: a stacked Plot's threshold folds whole series.
216
+ viz.schema.threshold = constant(0);
217
+ viz._thresholdMemberFormat = (v)=>axisValue(viz, viz.schema.discrete === "y" ? "x" : "y", v);
203
218
  viz.schema.timelineConfig = assign(viz.schema.timelineConfig, {
204
219
  brushMin: ()=>viz._xTime || viz._yTime || viz._x2Time || viz._y2Time ? 2 : 1
205
220
  });