@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.
- package/es/internal.js +3 -1
- package/es/src/charts/BoxWhisker/index.js +73 -4
- package/es/src/charts/BoxWhisker/outliers.js +68 -0
- package/es/src/charts/BoxWhisker/summary.js +83 -0
- package/es/src/charts/BoxWhisker/tooltip.js +122 -0
- package/es/src/charts/Bullet/index.js +2 -1
- package/es/src/charts/BumpChart/index.js +5 -0
- package/es/src/charts/Calendar/index.js +2 -1
- package/es/src/charts/Candlestick/aggregate.js +11 -1
- package/es/src/charts/Candlestick/index.js +5 -5
- package/es/src/charts/Chord/index.js +3 -2
- package/es/src/charts/Funnel/index.js +2 -1
- package/es/src/charts/Gauge/index.js +2 -1
- package/es/src/charts/Geomap/index.js +9 -3
- package/es/src/charts/Histogram/index.js +5 -1
- package/es/src/charts/Matrix/index.js +3 -2
- package/es/src/charts/Network/index.js +9 -4
- package/es/src/charts/Pack/index.js +2 -1
- package/es/src/charts/Pie/index.js +2 -1
- package/es/src/charts/Plot/axisHover.js +180 -0
- package/es/src/charts/Plot/axisHoverAnchors.js +174 -0
- package/es/src/charts/Plot/axisHoverScene.js +202 -0
- package/es/src/charts/Plot/barHitArea.js +81 -0
- package/es/src/charts/Plot/barLabelFit.js +123 -0
- package/es/src/charts/Plot/barWidth.js +2 -2
- package/es/src/charts/Plot/confidenceConfig.js +2 -2
- package/es/src/charts/Plot/draw.js +6 -2
- package/es/src/charts/Plot/index.js +25 -6
- package/es/src/charts/Plot/labelPlacement.js +9 -1
- package/es/src/charts/Plot/openDomainEnds.js +2 -5
- package/es/src/charts/Plot/pipeline.js +5 -3
- package/es/src/charts/Plot/pipelineAxisLayout.js +38 -8
- package/es/src/charts/Plot/pipelineDomains.js +7 -3
- package/es/src/charts/Plot/pipelineLineLabels.js +1 -1
- package/es/src/charts/Plot/plotInit.js +15 -0
- package/es/src/charts/Plot/plotZoom.js +15 -6
- package/es/src/charts/Plot/shapeDefaults.js +4 -4
- package/es/src/charts/Plot/sharedHoverScene.js +50 -31
- package/es/src/charts/Plot/sharedTooltip.js +19 -7
- package/es/src/charts/Plot/stackHelpers.js +13 -1
- package/es/src/charts/Plot/stackShareTooltip.js +9 -4
- package/es/src/charts/Plot/stackThreshold.js +154 -0
- package/es/src/charts/PolarArea/index.js +3 -2
- package/es/src/charts/Priestley/index.js +3 -2
- package/es/src/charts/Pyramid/index.js +4 -2
- package/es/src/charts/Radar/index.js +3 -2
- package/es/src/charts/RadialBar/index.js +2 -1
- package/es/src/charts/RadialMatrix/index.js +3 -2
- package/es/src/charts/Rings/index.js +5 -3
- package/es/src/charts/Sankey/index.js +3 -2
- package/es/src/charts/Treemap/applyLayout.js +14 -1
- package/es/src/charts/Treemap/emit.js +8 -2
- package/es/src/charts/Treemap/emitGroupHeaders.js +104 -0
- package/es/src/charts/Treemap/groupHeaders.js +95 -0
- package/es/src/charts/Treemap/index.js +15 -2
- package/es/src/charts/Treemap/thresholdFunction.js +11 -9
- package/es/src/charts/Waffle/index.js +4 -2
- package/es/src/charts/Waffle/tooltip.js +6 -2
- package/es/src/charts/Waterfall/index.js +4 -2
- package/es/src/charts/definition/makeChart.js +12 -5
- package/es/src/charts/drawSteps/saveChart.js +176 -0
- package/es/src/charts/drawSteps/saveControl.js +148 -0
- package/es/src/charts/drawSteps/saveControlMarkup.js +104 -0
- package/es/src/charts/drawSteps/tableViewMarkup.js +1 -1
- package/es/src/charts/drawSteps/topLeftControls.js +3 -1
- package/es/src/charts/drawSteps/topLeftControlsMarkup.js +1 -1
- package/es/src/charts/events/click.shape.js +30 -1
- package/es/src/charts/events/mouseenter.js +9 -0
- package/es/src/charts/events/mousemove.legend.js +3 -0
- package/es/src/charts/events/mousemove.shape.js +7 -2
- package/es/src/charts/facet/facetConfig.js +2 -2
- package/es/src/charts/facet/facetData.js +2 -2
- package/es/src/charts/features/axes.js +7 -6
- package/es/src/charts/features/axesFinal.js +23 -3
- package/es/src/charts/features/axesMeasure.js +54 -2
- package/es/src/charts/features/colorScaleBucket.js +17 -0
- package/es/src/charts/features/colorScaleHover.js +69 -0
- package/es/src/charts/features/features.js +13 -1
- package/es/src/charts/features/featuresColorScale.js +44 -4
- package/es/src/charts/features/featuresLegend.js +6 -8
- package/es/src/charts/features/plotPaint.js +4 -4
- package/es/src/charts/features/shapeEmit.js +23 -2
- package/es/src/charts/features/shareKey.js +15 -0
- package/es/src/charts/features/thresholdMembers.js +71 -0
- package/es/src/charts/helpers/densityChart.js +3 -1
- package/es/src/charts/helpers/valueTitle.js +6 -3
- package/es/src/charts/partition/chartFields.js +4 -3
- package/es/src/charts/partition/hierarchy.js +2 -0
- package/es/src/charts/pipeline/preDrawData.js +31 -10
- package/es/src/charts/pipeline/vizDraw.js +40 -29
- package/es/src/charts/pipeline/vizPreDraw.js +24 -15
- package/es/src/charts/viz/Viz.js +43 -8
- package/es/src/charts/viz/VizBase.js +32 -12
- package/es/src/charts/viz/dataPoller.js +52 -0
- package/es/src/charts/viz/groupRow.js +35 -0
- package/es/src/charts/viz/interactionOpacity.js +19 -5
- package/es/src/charts/viz/missingFields.js +122 -0
- package/es/src/charts/viz/reportHandlerError.js +10 -0
- package/es/src/charts/viz/shapeClassTargets.js +18 -2
- package/es/src/charts/viz/simpleHover.js +2 -0
- package/es/src/charts/viz/vizClassName.js +31 -0
- package/es/src/charts/viz/vizDataPolling.js +167 -0
- package/es/src/charts/viz/vizDefaults.js +66 -0
- package/es/src/charts/viz/vizFields.js +18 -2
- package/es/src/charts/viz/vizRender.js +8 -2
- package/es/src/components/Axis/Axis.js +28 -0
- package/es/src/components/Axis/axisDefaults.js +3 -1
- package/es/src/components/Axis/axisLabelAngle.js +175 -0
- package/es/src/components/Axis/axisLabelThinning.js +13 -4
- package/es/src/components/Axis/axisLayout.js +86 -19
- package/es/src/components/Axis/axisLayoutLabels.js +66 -13
- package/es/src/components/Axis/axisLayoutScale.js +3 -0
- package/es/src/components/Axis/axisRender.js +38 -9
- package/es/src/components/Axis/axisRounding.js +15 -4
- package/es/src/components/Axis/axisSlantWrap.js +39 -0
- package/es/src/components/Axis/powTicks.js +73 -0
- package/es/src/components/ColorScale/ColorScale.js +28 -28
- package/es/src/components/ColorScale/bucketBounds.js +35 -0
- package/es/src/components/ColorScale/colorScaleHoverMark.js +327 -0
- package/es/src/components/ColorScale/colorScaleRender.js +25 -1
- package/es/src/components/ColorScale/colorScaleScale.js +15 -9
- package/es/src/components/ColorScale/colorScaleType.js +26 -0
- package/es/src/components/TextBox.js +2 -0
- package/es/src/components/Timeline/Timeline.js +43 -52
- package/es/src/components/Timeline/brushSpan.js +78 -0
- package/es/src/components/Timeline/timelineConfig.js +7 -0
- package/es/src/components/Timeline/timelineRender.js +44 -6
- package/es/src/components/Tooltip.js +13 -8
- package/es/src/shapes/Box.js +66 -79
- package/es/src/shapes/boxOutlierShape.js +19 -0
- package/es/src/shapes/boxStats.js +35 -0
- package/es/src/shapes/boxStyle.js +78 -0
- package/es/src/shapes/boxSummary.js +174 -0
- package/es/src/shapes/shapeStandalone.js +2 -0
- package/es/src/utils/BaseClass.js +19 -0
- package/es/src/utils/className.js +78 -0
- package/es/src/utils/configWarnings.js +25 -0
- package/es/src/utils/fieldAccessor.js +31 -0
- package/es/src/utils/paintComponentScene.js +2 -0
- package/package.json +10 -9
- package/types/index.d.ts +3 -1
- package/types/internal.d.ts +3 -1
- package/types/src/charts/BoxWhisker/index.d.ts +3 -1
- package/types/src/charts/BoxWhisker/outliers.d.ts +25 -0
- package/types/src/charts/BoxWhisker/summary.d.ts +39 -0
- package/types/src/charts/BoxWhisker/tooltip.d.ts +36 -0
- package/types/src/charts/Candlestick/aggregate.d.ts +6 -0
- package/types/src/charts/Plot/axisHover.d.ts +68 -0
- package/types/src/charts/Plot/axisHoverAnchors.d.ts +88 -0
- package/types/src/charts/Plot/axisHoverScene.d.ts +88 -0
- package/types/src/charts/Plot/barHitArea.d.ts +59 -0
- package/types/src/charts/Plot/barLabelFit.d.ts +81 -0
- package/types/src/charts/Plot/index.d.ts +13 -0
- package/types/src/charts/Plot/labelPlacement.d.ts +5 -0
- package/types/src/charts/Plot/plotInit.d.ts +9 -2
- package/types/src/charts/Plot/plotZoom.d.ts +2 -0
- package/types/src/charts/Plot/sharedHoverScene.d.ts +3 -3
- package/types/src/charts/Plot/sharedTooltip.d.ts +11 -4
- package/types/src/charts/Plot/stackHelpers.d.ts +5 -0
- package/types/src/charts/Plot/stackThreshold.d.ts +75 -0
- package/types/src/charts/Treemap/emit.d.ts +2 -1
- package/types/src/charts/Treemap/emitGroupHeaders.d.ts +16 -0
- package/types/src/charts/Treemap/groupHeaders.d.ts +91 -0
- package/types/src/charts/Treemap/index.d.ts +2 -0
- package/types/src/charts/Treemap/thresholdFunction.d.ts +5 -2
- package/types/src/charts/definition/ChartDefinition.d.ts +14 -2
- package/types/src/charts/definition/makeChart.d.ts +4 -3
- package/types/src/charts/drawSteps/saveChart.d.ts +47 -0
- package/types/src/charts/drawSteps/saveControl.d.ts +9 -0
- package/types/src/charts/drawSteps/saveControlMarkup.d.ts +44 -0
- package/types/src/charts/drawSteps/tableViewMarkup.d.ts +1 -0
- package/types/src/charts/drawSteps/topLeftControls.d.ts +1 -1
- package/types/src/charts/drawSteps/topLeftControlsMarkup.d.ts +1 -1
- package/types/src/charts/facet/facetData.d.ts +1 -1
- package/types/src/charts/features/axesMeasure.d.ts +9 -1
- package/types/src/charts/features/colorScaleBucket.d.ts +9 -0
- package/types/src/charts/features/colorScaleHover.d.ts +32 -0
- package/types/src/charts/features/features.d.ts +8 -0
- package/types/src/charts/features/plotPaint.d.ts +2 -0
- package/types/src/charts/features/shapeEmit.d.ts +2 -0
- package/types/src/charts/features/shareKey.d.ts +9 -0
- package/types/src/charts/features/thresholdMembers.d.ts +38 -0
- package/types/src/charts/helpers/valueTitle.d.ts +4 -2
- package/types/src/charts/pipeline/stages.d.ts +2 -0
- package/types/src/charts/pipeline/vizDraw.d.ts +8 -3
- package/types/src/charts/pipeline/vizPreDraw.d.ts +3 -2
- package/types/src/charts/viz/Viz.d.ts +28 -4
- package/types/src/charts/viz/VizBase.d.ts +12 -3
- package/types/src/charts/viz/dataPoller.d.ts +28 -0
- package/types/src/charts/viz/groupRow.d.ts +24 -0
- package/types/src/charts/viz/interactionOpacity.d.ts +3 -1
- package/types/src/charts/viz/missingFields.d.ts +57 -0
- package/types/src/charts/viz/reportHandlerError.d.ts +7 -0
- package/types/src/charts/viz/shapeClassTargets.d.ts +6 -0
- package/types/src/charts/viz/simpleHover.d.ts +2 -1
- package/types/src/charts/viz/vizClassName.d.ts +23 -0
- package/types/src/charts/viz/vizDataPolling.d.ts +48 -0
- package/types/src/charts/viz/vizDefaults.d.ts +49 -0
- package/types/src/charts/viz/vizFields.d.ts +15 -0
- package/types/src/charts/viz/vizTypes.d.ts +33 -1
- package/types/src/components/Axis/Axis.d.ts +36 -8
- package/types/src/components/Axis/axisLabelAngle.d.ts +110 -0
- package/types/src/components/Axis/axisLabelThinning.d.ts +3 -7
- package/types/src/components/Axis/axisLayout.d.ts +5 -0
- package/types/src/components/Axis/axisLayoutLabels.d.ts +13 -0
- package/types/src/components/Axis/axisRounding.d.ts +6 -3
- package/types/src/components/Axis/axisSlantWrap.d.ts +22 -0
- package/types/src/components/Axis/powTicks.d.ts +29 -0
- package/types/src/components/ColorScale/ColorScale.d.ts +13 -0
- package/types/src/components/ColorScale/bucketBounds.d.ts +14 -0
- package/types/src/components/ColorScale/colorScaleHoverMark.d.ts +86 -0
- package/types/src/components/ColorScale/colorScaleScale.d.ts +3 -0
- package/types/src/components/ColorScale/colorScaleType.d.ts +17 -0
- package/types/src/components/Timeline/brushSpan.d.ts +41 -0
- package/types/src/components/Timeline/timelineConfig.d.ts +6 -0
- package/types/src/components/Timeline/timelineRender.d.ts +8 -0
- package/types/src/components/Tooltip.d.ts +8 -0
- package/types/src/shapes/Box.d.ts +1 -8
- package/types/src/shapes/boxOutlierShape.d.ts +9 -0
- package/types/src/shapes/boxStats.d.ts +19 -0
- package/types/src/shapes/boxStyle.d.ts +25 -0
- package/types/src/shapes/boxSummary.d.ts +66 -0
- package/types/src/shapes/emitLabels.d.ts +1 -1
- package/types/src/shapes/shapeConfig.d.ts +42 -4
- package/types/src/utils/BaseClass.d.ts +23 -0
- package/types/src/utils/D3Scale.d.ts +3 -0
- package/types/src/utils/D3plusConfig.d.ts +261 -5
- package/types/src/utils/className.d.ts +64 -0
- package/types/src/utils/configWarnings.d.ts +21 -2
- package/types/src/utils/fieldAccessor.d.ts +24 -0
- package/types/src/utils/index.d.ts +1 -1
- package/types/src/utils/paintComponentScene.d.ts +3 -1
- package/umd/d3plus-core.full.js +6405 -1068
- package/umd/d3plus-core.full.min.js +2 -2
- package/umd/d3plus-core.js +5328 -1002
- package/umd/d3plus-core.min.js +2 -2
|
@@ -16,9 +16,13 @@
|
|
|
16
16
|
import { unwrapBreakMasks } from "./plotBreaks.js";
|
|
17
17
|
import { unwrapDomainClips } from "./domainClip.js";
|
|
18
18
|
/**
|
|
19
|
-
Whether an axis zooms: a linear axis over a continuous scale, or
|
|
20
|
-
axis. Point (category) axes and log axes don't.
|
|
21
|
-
*/ const zoomable = (plotScale, configScale)=>configScale === "time" || plotScale === "Linear" &&
|
|
19
|
+
Whether an axis zooms: a linear or power axis over a continuous scale, or
|
|
20
|
+
a time axis. Point (category) axes and log axes don't.
|
|
21
|
+
*/ const zoomable = (plotScale, configScale)=>configScale === "time" || plotScale === "Linear" && [
|
|
22
|
+
"linear",
|
|
23
|
+
"pow",
|
|
24
|
+
"sqrt"
|
|
25
|
+
].includes(configScale);
|
|
22
26
|
/** Which of the plot's axes are simple linear or time axes (the zoomable ones). */ function zoomableAxes(pCtx) {
|
|
23
27
|
const axes = [];
|
|
24
28
|
if (zoomable(pCtx.xScale, pCtx.xConfigScale)) axes.push("x");
|
|
@@ -45,6 +49,7 @@ import { unwrapDomainClips } from "./domainClip.js";
|
|
|
45
49
|
const scales = {};
|
|
46
50
|
const labelSpace = {};
|
|
47
51
|
const breaks = {};
|
|
52
|
+
const reversed = {};
|
|
48
53
|
for (const axis of zoomableAxes(pCtx)){
|
|
49
54
|
const axisInstance = viz[`_${axis}Axis`];
|
|
50
55
|
const d3Scale = axisInstance?._d3Scale;
|
|
@@ -52,6 +57,7 @@ import { unwrapDomainClips } from "./domainClip.js";
|
|
|
52
57
|
scales[axis] = d3Scale.copy();
|
|
53
58
|
labelSpace[axis] = axisInstance?._labelSpace;
|
|
54
59
|
breaks[axis] = Boolean(axisInstance?._baselineBreak);
|
|
60
|
+
reversed[axis] = Boolean(axisInstance?.schema.reverse);
|
|
55
61
|
}
|
|
56
62
|
}
|
|
57
63
|
// Shape sizes for the automatic `zoomMax` come from the unzoomed paint.
|
|
@@ -67,7 +73,8 @@ import { unwrapDomainClips } from "./domainClip.js";
|
|
|
67
73
|
},
|
|
68
74
|
scales,
|
|
69
75
|
labelSpace,
|
|
70
|
-
breaks
|
|
76
|
+
breaks,
|
|
77
|
+
reversed
|
|
71
78
|
};
|
|
72
79
|
if (current && (current.k !== 1 || current.x || current.y)) {
|
|
73
80
|
const zoomed = rescalePlot(viz, current);
|
|
@@ -91,9 +98,11 @@ import { unwrapDomainClips } from "./domainClip.js";
|
|
|
91
98
|
const shift = vertical ? t.y : t.x;
|
|
92
99
|
const offset = vertical ? -pCtx.x2Height : 0;
|
|
93
100
|
const domain = scale.range().map((r)=>scale.invert((r + offset + origin - shift) / t.k - origin - offset));
|
|
94
|
-
// Keep the base domain's orientation
|
|
101
|
+
// Keep the base domain's orientation, handing a reversed axis its
|
|
102
|
+
// domain the way round the axis reverses.
|
|
95
103
|
const [b0, b1] = scale.domain();
|
|
96
|
-
|
|
104
|
+
const flip = (+b1 - +b0) * (+domain[1] - +domain[0]) < 0;
|
|
105
|
+
return flip !== Boolean(base.reversed[axis]) ? domain.reverse() : domain;
|
|
97
106
|
};
|
|
98
107
|
const zoomed = {};
|
|
99
108
|
for (const axis of Object.keys(scales))zoomed[`${axis}Domain`] = rescale(axis);
|
|
@@ -13,7 +13,7 @@ import { largestRect } from "@d3plus/math";
|
|
|
13
13
|
import { isValidDate } from "../../components/Axis/timeValues.js";
|
|
14
14
|
import { constant } from "../../utils/index.js";
|
|
15
15
|
import { outsideBaselineBreak } from "./baselineBreak.js";
|
|
16
|
-
import { defaultSize, outside } from "./labelPlacement.js";
|
|
16
|
+
import { defaultSize, growsBack, outside } from "./labelPlacement.js";
|
|
17
17
|
import { axisValue } from "./sharedTooltip.js";
|
|
18
18
|
/** Builds the `Area` shape config; `self` is the Plot instance. */ function areaConfig(self) {
|
|
19
19
|
return {
|
|
@@ -88,7 +88,7 @@ import { axisValue } from "./sharedTooltip.js";
|
|
|
88
88
|
const other = this.schema.discrete.charAt(0) === "x" ? "y" : "x";
|
|
89
89
|
const invert = other === "y";
|
|
90
90
|
const nonDiscrete = this.schema.discrete.replace(this.schema.discrete.charAt(0), other);
|
|
91
|
-
const negative = (
|
|
91
|
+
const negative = growsBack(this, nonDiscrete, d, i);
|
|
92
92
|
const anchor = invert ? "middle" : outside.bind(this)(d, i) ? negative ? "end" : "start" : negative ? "start" : "end";
|
|
93
93
|
return rtl() ? anchor === "start" ? "end" : anchor === "end" ? "start" : anchor : anchor;
|
|
94
94
|
},
|
|
@@ -96,7 +96,7 @@ import { axisValue } from "./sharedTooltip.js";
|
|
|
96
96
|
const other = this.schema.discrete.charAt(0) === "x" ? "y" : "x";
|
|
97
97
|
const invert = other === "y";
|
|
98
98
|
const nonDiscrete = this.schema.discrete.replace(this.schema.discrete.charAt(0), other);
|
|
99
|
-
const negative = (
|
|
99
|
+
const negative = growsBack(this, nonDiscrete, d, i);
|
|
100
100
|
return invert ? outside.bind(this)(d, i) ? negative ? "top" : "bottom" : negative ? "bottom" : "top" : "middle";
|
|
101
101
|
}
|
|
102
102
|
};
|
|
@@ -113,7 +113,7 @@ import { axisValue } from "./sharedTooltip.js";
|
|
|
113
113
|
const axis = nonDiscrete === "y" ? this._yAxis : this._xAxis;
|
|
114
114
|
const range = axis._d3Scale.range();
|
|
115
115
|
const space = Math.abs(range[1] - range[0]);
|
|
116
|
-
const negative = (
|
|
116
|
+
const negative = growsBack(this, nonDiscrete, d, i);
|
|
117
117
|
if (outside.bind(this)(d, i)) {
|
|
118
118
|
return {
|
|
119
119
|
[width]: space - s[width],
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
Scene nodes for Plot's shared tooltip (#779): the transparent hover surface,
|
|
3
3
|
the crosshair (drawn as a Line annotation), and markers on the hovered Line
|
|
4
|
-
points.
|
|
4
|
+
points; and the axis hover's guides and badges (#782).
|
|
5
5
|
*/ import { collectComputed, makeShape } from "../features/emitHelpers.js";
|
|
6
6
|
import { collectAnnotationGroup, renderPlotAnnotation } from "../features/plotAnnotations.js";
|
|
7
7
|
import { PLOT_ZOOM_CONTENT_KEY } from "../features/plotPaint.js";
|
|
8
8
|
import { hasSharedMarks } from "./sharedHover.js";
|
|
9
|
+
import { axisHoverNodes } from "./axisHoverScene.js";
|
|
9
10
|
import { isDomainClip } from "./domainClip.js";
|
|
10
11
|
import { withFacetPanel } from "../facet/facetPanel.js";
|
|
11
12
|
import { prefixKeys } from "../facet/facetScene.js";
|
|
@@ -75,34 +76,38 @@ import { prefixKeys } from "../facet/facetScene.js";
|
|
|
75
76
|
return !!n.shapeType && !n.interactionGroup && n.interactive !== false && !!datum && datum.id !== undefined;
|
|
76
77
|
};
|
|
77
78
|
/**
|
|
78
|
-
Places the
|
|
79
|
-
mark ("front"), then the markers
|
|
80
|
-
be `_chartScene` itself, which
|
|
81
|
-
|
|
79
|
+
Places the guides (the crosshair and any axis-hover guides) behind the
|
|
80
|
+
first data mark ("back") or after every mark ("front"), then the markers
|
|
81
|
+
on top. Returns a fresh array — `nodes` may be `_chartScene` itself, which
|
|
82
|
+
must not accumulate per-paint nodes.
|
|
83
|
+
*/ function layer(nodes, guides, markers, side) {
|
|
82
84
|
const out = [
|
|
83
85
|
...nodes
|
|
84
86
|
];
|
|
85
|
-
if (
|
|
87
|
+
if (guides.length) {
|
|
86
88
|
const first = out.findIndex((n)=>isMark(n) || isDomainClip(n) && n.children.some(isMark));
|
|
87
|
-
if (side === "back" && first >= 0) out.splice(first, 0,
|
|
88
|
-
else out.push(
|
|
89
|
+
if (side === "back" && first >= 0) out.splice(first, 0, ...guides);
|
|
90
|
+
else out.push(...guides);
|
|
89
91
|
}
|
|
90
92
|
out.push(...markers);
|
|
91
93
|
return out;
|
|
92
94
|
}
|
|
93
95
|
/**
|
|
94
|
-
The hover nodes for one chart body's children: with `tooltipShared
|
|
95
|
-
transparent hover surface behind the marks,
|
|
96
|
-
pointer events over empty plot space; and —
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
96
|
+
The hover nodes for one chart body's children: with `tooltipShared` on a
|
|
97
|
+
chart with a discrete axis, a transparent hover surface behind the marks,
|
|
98
|
+
so the SVG backend receives pointer events over empty plot space; and —
|
|
99
|
+
while a hover is active — the crosshair, the hovered Line markers, and the
|
|
100
|
+
axis hover's guides, inside the zoom-clipped plot content when the chart
|
|
101
|
+
is zoomable, with its badges over the axes. `key` maps a node key to its
|
|
102
|
+
key in this body (small-multiples panels prefix theirs).
|
|
103
|
+
*/ function decorateBody(viz, nodes, hover, key) {
|
|
101
104
|
const area = viz._plotArea;
|
|
102
105
|
if (!area) return nodes;
|
|
106
|
+
const { state, axis } = hover;
|
|
107
|
+
const discrete = viz.schema.discrete === "x" || viz.schema.discrete === "y";
|
|
103
108
|
// The surface is only needed for shared hovers over empty space; a single
|
|
104
109
|
// hover (tooltipShared off) needs the pointer on a mark anyway.
|
|
105
|
-
const surface = viz.schema.tooltipShared && hasSharedMarks(viz) ? [
|
|
110
|
+
const surface = discrete && viz.schema.tooltipShared && hasSharedMarks(viz) ? [
|
|
106
111
|
{
|
|
107
112
|
type: "rect",
|
|
108
113
|
key: key("plot-hover-surface"),
|
|
@@ -114,12 +119,17 @@ import { prefixKeys } from "../facet/facetScene.js";
|
|
|
114
119
|
}
|
|
115
120
|
] : [];
|
|
116
121
|
let children = nodes;
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
122
|
+
const crosshair = state && discrete ? crosshairAnnotation(viz, state) : null;
|
|
123
|
+
const axisNodes = axis ? axisHoverNodes(viz, axis) : null;
|
|
124
|
+
const guides = prefixKeys([
|
|
125
|
+
...crosshair ? [
|
|
126
|
+
crosshair
|
|
127
|
+
] : [],
|
|
128
|
+
...axisNodes ? axisNodes.guides : []
|
|
129
|
+
], key);
|
|
130
|
+
const markers = prefixKeys(state && discrete ? hoverMarkers(viz, state) : [], key);
|
|
131
|
+
if (guides.length || markers.length) {
|
|
132
|
+
const side = state ? state.layer : "back";
|
|
123
133
|
const content = children.findIndex((n)=>n.key === key(PLOT_ZOOM_CONTENT_KEY));
|
|
124
134
|
if (content >= 0) {
|
|
125
135
|
const group = children[content];
|
|
@@ -128,13 +138,15 @@ import { prefixKeys } from "../facet/facetScene.js";
|
|
|
128
138
|
];
|
|
129
139
|
children[content] = {
|
|
130
140
|
...group,
|
|
131
|
-
children: layer(group.children || [],
|
|
141
|
+
children: layer(group.children || [], guides, markers, side)
|
|
132
142
|
};
|
|
133
|
-
} else children = layer(children,
|
|
143
|
+
} else children = layer(children, guides, markers, side);
|
|
134
144
|
}
|
|
145
|
+
const badges = axisNodes ? prefixKeys(axisNodes.badges, key) : [];
|
|
135
146
|
return [
|
|
136
147
|
...surface,
|
|
137
|
-
...children
|
|
148
|
+
...children,
|
|
149
|
+
...badges
|
|
138
150
|
];
|
|
139
151
|
}
|
|
140
152
|
/**
|
|
@@ -148,7 +160,11 @@ import { prefixKeys } from "../facet/facetScene.js";
|
|
|
148
160
|
const body = cells && cells.children && cells.children[0];
|
|
149
161
|
if (!cells || !body || !body.children) return group;
|
|
150
162
|
const state = viz._sharedHoverState;
|
|
151
|
-
const
|
|
163
|
+
const axis = viz._axisHoverState;
|
|
164
|
+
const children = withFacetPanel(viz, panel, ()=>decorateBody(viz, body.children, {
|
|
165
|
+
state: state && state.panel === panel.key ? state : null,
|
|
166
|
+
axis: axis && axis.panel === panel.key ? axis : null
|
|
167
|
+
}, (k)=>`${panel.key}/${k}`));
|
|
152
168
|
const next = [
|
|
153
169
|
...kids
|
|
154
170
|
];
|
|
@@ -168,12 +184,12 @@ import { prefixKeys } from "../facet/facetScene.js";
|
|
|
168
184
|
};
|
|
169
185
|
}
|
|
170
186
|
/**
|
|
171
|
-
Adds the
|
|
172
|
-
|
|
173
|
-
|
|
187
|
+
Adds the hover's scene nodes (see `decorateBody`) to the chart body group
|
|
188
|
+
(content space, so they track zoom) — to each panel's body when the chart
|
|
189
|
+
is drawn as small multiples.
|
|
174
190
|
*/ export function appendSharedHoverNodes(viz, scene) {
|
|
175
191
|
const discrete = viz.schema.discrete;
|
|
176
|
-
if (discrete !== "x" && discrete !== "y") return;
|
|
192
|
+
if (discrete !== "x" && discrete !== "y" && !viz._axisHoverState) return;
|
|
177
193
|
const cells = scene.root.children.find((n)=>n.key === "viz-chart-cells");
|
|
178
194
|
const zoom = cells && cells.children && cells.children[0];
|
|
179
195
|
const body = zoom && zoom.children && zoom.children[0];
|
|
@@ -184,5 +200,8 @@ import { prefixKeys } from "../facet/facetScene.js";
|
|
|
184
200
|
const panel = panels.find((p)=>p.key === group.key);
|
|
185
201
|
return panel ? decoratePanel(viz, group, panel) : group;
|
|
186
202
|
});
|
|
187
|
-
} else body.children = decorateBody(viz, body.children,
|
|
203
|
+
} else body.children = decorateBody(viz, body.children, {
|
|
204
|
+
state: viz._sharedHoverState,
|
|
205
|
+
axis: viz._axisHoverState
|
|
206
|
+
}, (k)=>k);
|
|
188
207
|
}
|
|
@@ -7,6 +7,7 @@ import { axisDateLabel, isValidDate, parseTime } from "../../components/Axis/tim
|
|
|
7
7
|
import { axisIsYearLike, formatYear } from "../../components/Axis/yearValues.js";
|
|
8
8
|
import { configPrep } from "../../utils/index.js";
|
|
9
9
|
import { leadTitleWithSwatch, tooltipSwatch, withSwatch } from "../features/tooltipSwatch.js";
|
|
10
|
+
import { thresholdMemberRows } from "../features/thresholdMembers.js";
|
|
10
11
|
import { confidenceRows, confidenceSuffix, rangeSuffix } from "./confidenceTooltip.js";
|
|
11
12
|
const other = (k)=>k === "x" ? "y" : "x";
|
|
12
13
|
/** An axis's display name: its configured title, else its data key. */ export function axisName(viz, k) {
|
|
@@ -134,27 +135,37 @@ const other = (k)=>k === "x" ? "y" : "x";
|
|
|
134
135
|
names: hover.rows.map((r)=>r.projected && !all ? `${r.name}${label}` : r.name)
|
|
135
136
|
};
|
|
136
137
|
}
|
|
138
|
+
/**
|
|
139
|
+
How many of a threshold bucket's series the shared tooltip lists under
|
|
140
|
+
its row: fewer than a single-mark tooltip, since every other series has
|
|
141
|
+
a row of its own beside them.
|
|
142
|
+
*/ export const SHARED_MEMBER_LIMIT = 5;
|
|
137
143
|
/**
|
|
138
144
|
The shared tooltip: title from the continuous axis, a header row naming
|
|
139
145
|
the hovered discrete value, then one `[name, value]` row per series, the
|
|
140
146
|
name led by a swatch in its series stroke and the value followed by its
|
|
141
|
-
`confidence` range
|
|
142
|
-
title/rows win.
|
|
147
|
+
`confidence` range, and a threshold bucket's series listed under its row.
|
|
148
|
+
User `tooltipConfig` styles apply first; the shared title/rows win.
|
|
143
149
|
*/ export function renderSharedTooltip(viz, hover, event) {
|
|
144
150
|
const cont = other(hover.axis);
|
|
145
151
|
const { header, names } = markProjected(viz, hover);
|
|
146
152
|
prepareTooltip(viz).data([
|
|
147
153
|
hover.rows[0].datum
|
|
148
|
-
]).config(configPrep.bind(viz)(viz.schema.tooltipConfig)).title(()=>axisName(viz, cont)).thead(header).tbody(hover.rows.
|
|
149
|
-
|
|
150
|
-
|
|
154
|
+
]).config(configPrep.bind(viz)(viz.schema.tooltipConfig)).title(()=>axisName(viz, cont)).thead(header).tbody(hover.rows.flatMap((r, i)=>[
|
|
155
|
+
[
|
|
156
|
+
withSwatch(tooltipSwatch(r.color, r.shape), names[i]),
|
|
157
|
+
`${axisValue(viz, cont, r.value)}${bounds(viz, cont, r)}`
|
|
158
|
+
],
|
|
159
|
+
// A threshold bucket's series, under its row.
|
|
160
|
+
...thresholdMemberRows(viz, r.datum, SHARED_MEMBER_LIMIT)
|
|
151
161
|
])).footer(false).arrow(false).position(snappedPosition(viz, hover, event)).render();
|
|
152
162
|
}
|
|
153
163
|
/**
|
|
154
164
|
The single-mark tooltip (one series, `tooltipShared(false)`, or a
|
|
155
165
|
side-by-side bar): the default title (the mark's label, unless
|
|
156
166
|
`tooltipConfig` sets one), its x and y values, its `confidence` bounds,
|
|
157
|
-
then any rows the chart's `tooltipConfig` adds
|
|
167
|
+
then any rows the chart's `tooltipConfig` adds, and a threshold bucket's
|
|
168
|
+
series.
|
|
158
169
|
*/ export function renderSingleTooltip(viz, hover, event) {
|
|
159
170
|
const row = hover.rows[0];
|
|
160
171
|
const deeper = viz._drawDepth < viz.schema.groupBy.length - 1;
|
|
@@ -170,6 +181,7 @@ const other = (k)=>k === "x" ? "y" : "x";
|
|
|
170
181
|
axisRow(viz, "y", hover)
|
|
171
182
|
],
|
|
172
183
|
...row.projected ? [] : confidenceRows(viz, row.datum, row.index, (v)=>axisValue(viz, other(hover.axis), v)),
|
|
173
|
-
...Array.isArray(extra) ? extra : []
|
|
184
|
+
...Array.isArray(extra) ? extra : [],
|
|
185
|
+
...thresholdMemberRows(viz, row.datum)
|
|
174
186
|
]).arrow(false).position(snappedPosition(viz, hover, event)).render();
|
|
175
187
|
}
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
pipeline applies: a tagged comparator or an array of series keys.
|
|
9
9
|
*/ import * as d3Shape from "d3-shape";
|
|
10
10
|
import accessor from "../../utils/accessor.js";
|
|
11
|
+
import { markField } from "../../utils/fieldAccessor.js";
|
|
11
12
|
/** Marks a comparator as an already-resolved d3plus stack order. */ function tagOrder(fn) {
|
|
12
13
|
fn.__d3plusStackOrder = true;
|
|
13
14
|
return fn;
|
|
@@ -65,6 +66,16 @@ const asStack = (series)=>series;
|
|
|
65
66
|
return d3Shape.stackOrderNone(asStack(series)).sort((a, b)=>order === "ascending" ? totals[a] - totals[b] : totals[b] - totals[a]);
|
|
66
67
|
});
|
|
67
68
|
}
|
|
69
|
+
/**
|
|
70
|
+
Wraps a stack order so the series in `last` sit at the top of the stack,
|
|
71
|
+
in the order `order` gives them, above every other series.
|
|
72
|
+
*/ export function orderLast(order, last) {
|
|
73
|
+
return (series)=>{
|
|
74
|
+
const ranked = order(series);
|
|
75
|
+
const isLast = (i)=>last.has(series[i].key);
|
|
76
|
+
return ranked.filter((i)=>!isLast(i)).concat(ranked.filter(isLast));
|
|
77
|
+
};
|
|
78
|
+
}
|
|
68
79
|
/** Named stack orders accepted by `Plot.stackOrder`. */ const NAMED_ORDERS = {
|
|
69
80
|
ascending: stackOrderTotalAscending,
|
|
70
81
|
descending: stackOrderTotalDescending,
|
|
@@ -90,7 +101,8 @@ const asStack = (series)=>series;
|
|
|
90
101
|
if (Array.isArray(input)) return input;
|
|
91
102
|
if (input && typeof input === "object") {
|
|
92
103
|
const { value, order } = input;
|
|
93
|
-
|
|
104
|
+
if (typeof value === "function") return stackOrderField(value, order);
|
|
105
|
+
return markField(stackOrderField(accessor(value), order), value);
|
|
94
106
|
}
|
|
95
107
|
if (typeof input === "string") {
|
|
96
108
|
if (input in NAMED_ORDERS) return NAMED_ORDERS[input];
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
BarChart), reading the share that `computePlotInitialDomains` stamps on
|
|
4
4
|
each stacked datum.
|
|
5
5
|
*/ import { formatAbbreviate } from "@d3plus/format";
|
|
6
|
-
import { shareOf } from "../features/shareKey.js";
|
|
6
|
+
import { shareOf, shareOfRows, unwrapRow } from "../features/shareKey.js";
|
|
7
7
|
/**
|
|
8
8
|
A `tooltipConfig` default whose `tbody` resolves per hover, so the Share
|
|
9
9
|
row only appears while the chart is stacked.
|
|
@@ -11,9 +11,14 @@ import { shareOf } from "../features/shareKey.js";
|
|
|
11
11
|
const row = [
|
|
12
12
|
()=>viz.schema.translate("Share"),
|
|
13
13
|
(_d, _i, x)=>{
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
const row = unwrapRow(x);
|
|
15
|
+
let share = shareOf(row);
|
|
16
|
+
// A legend entry merges a series over every discrete position, so its
|
|
17
|
+
// share is of the whole chart: of every legend row's stacked value.
|
|
18
|
+
if (!Number.isFinite(share)) {
|
|
19
|
+
const value = viz[`_${viz.schema.discrete === "y" ? "x" : "y"}`];
|
|
20
|
+
share = row ? shareOfRows(row, viz._legendData || [], value) : NaN;
|
|
21
|
+
}
|
|
17
22
|
if (!Number.isFinite(share)) return "";
|
|
18
23
|
return `${formatAbbreviate(share * 100, viz.schema.locale)}%`;
|
|
19
24
|
}
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
/**
|
|
2
|
+
`threshold` on stacked Plot charts: the series whose summed value, over
|
|
3
|
+
every position on the discrete axis, is under `threshold` of the chart's
|
|
4
|
+
total fold into one bucket series. Membership is decided once for the
|
|
5
|
+
whole chart, so a series is in the bucket at every position or at none.
|
|
6
|
+
*/ import { merge } from "@d3plus/data";
|
|
7
|
+
import { MEMBERS_KEY, thresholdMemberList } from "../features/thresholdMembers.js";
|
|
8
|
+
/** A value's comparison key: arrays by their items, Dates by their time. */ const valueKey = (v)=>Array.isArray(v) ? v.map(valueKey).join("\u0001") : v instanceof Date ? +v : v;
|
|
9
|
+
/**
|
|
10
|
+
The fields that name a series rather than a point on it, merged over the
|
|
11
|
+
bucket's series: every non-numeric field that holds one value along each
|
|
12
|
+
series and is not a row's position. Every bucket row carries them, so the
|
|
13
|
+
bucket keeps one id, label, and color at every position, whichever of
|
|
14
|
+
its series have a row there.
|
|
15
|
+
*/ export function seriesIdentity(series, position, aggs) {
|
|
16
|
+
const keys = new Set();
|
|
17
|
+
series.forEach((rows)=>rows.forEach((d)=>Object.keys(d).forEach((k)=>keys.add(k))));
|
|
18
|
+
const identityKeys = Array.from(keys).filter((k)=>series.every((rows)=>{
|
|
19
|
+
let first;
|
|
20
|
+
return rows.every((d, i)=>{
|
|
21
|
+
const v = d[k];
|
|
22
|
+
if (typeof v === "number") return false;
|
|
23
|
+
const key = valueKey(v);
|
|
24
|
+
if (position.some((p)=>valueKey(p(d, i)) === key)) return false;
|
|
25
|
+
if (i === 0) first = key;
|
|
26
|
+
return key === first;
|
|
27
|
+
});
|
|
28
|
+
}));
|
|
29
|
+
const reps = series.filter((rows)=>rows.length).map((rows)=>{
|
|
30
|
+
const rep = {};
|
|
31
|
+
for (const k of identityKeys)rep[k] = rows[0][k];
|
|
32
|
+
return rep;
|
|
33
|
+
});
|
|
34
|
+
return merge(reps, aggs);
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
The bucket for `rows`: the series whose summed absolute `value` is under
|
|
38
|
+
`threshold` of the summed absolute value of every row. Null when the
|
|
39
|
+
threshold is off (0 or not a number) or fewer than two series fall
|
|
40
|
+
under it: a lone small series stays as itself.
|
|
41
|
+
*/ export function stackThresholdBucket(rows, inputs) {
|
|
42
|
+
const { aggs, id, position, threshold, value } = inputs;
|
|
43
|
+
const percent = Math.min(1, Math.max(0, +threshold(rows)));
|
|
44
|
+
if (!(percent > 0)) return null;
|
|
45
|
+
const totals = new Map();
|
|
46
|
+
const series = new Map();
|
|
47
|
+
let grand = 0;
|
|
48
|
+
rows.forEach((d, i)=>{
|
|
49
|
+
const key = `${id(d, i)}`;
|
|
50
|
+
const v = Math.abs(+value(d, i)) || 0;
|
|
51
|
+
totals.set(key, (totals.get(key) ?? 0) + v);
|
|
52
|
+
const list = series.get(key);
|
|
53
|
+
if (list) list.push(d);
|
|
54
|
+
else series.set(key, [
|
|
55
|
+
d
|
|
56
|
+
]);
|
|
57
|
+
grand += v;
|
|
58
|
+
});
|
|
59
|
+
if (!(grand > 0)) return null;
|
|
60
|
+
const members = new Set();
|
|
61
|
+
totals.forEach((total, key)=>{
|
|
62
|
+
if (total < percent * grand) members.add(key);
|
|
63
|
+
});
|
|
64
|
+
if (members.size < 2) return null;
|
|
65
|
+
const identity = seriesIdentity(Array.from(members, (key)=>series.get(key)), position, aggs);
|
|
66
|
+
return {
|
|
67
|
+
members,
|
|
68
|
+
percent,
|
|
69
|
+
identity
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
Replaces the rows of the bucket's series with one bucket row per
|
|
74
|
+
position: their merged values at that position, the bucket's
|
|
75
|
+
series-level fields, the `_isAggregation` / `_threshold` flags the
|
|
76
|
+
threshold label reads, and its series' values there (largest first,
|
|
77
|
+
under `MEMBERS_KEY`). The bucket rows come after every kept row.
|
|
78
|
+
*/ export function foldStackRows(rows, bucket, inputs) {
|
|
79
|
+
const { aggs, id, position } = inputs;
|
|
80
|
+
const label = inputs.label ?? id;
|
|
81
|
+
const measure = inputs.measure ?? inputs.value;
|
|
82
|
+
const kept = [];
|
|
83
|
+
const folded = new Map();
|
|
84
|
+
rows.forEach((d, i)=>{
|
|
85
|
+
if (!bucket.members.has(`${id(d, i)}`)) {
|
|
86
|
+
kept.push(d);
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
const at = position.map((p)=>`${valueKey(p(d, i))}`).join("\u0002");
|
|
90
|
+
const list = folded.get(at);
|
|
91
|
+
if (list) list.push(d);
|
|
92
|
+
else folded.set(at, [
|
|
93
|
+
d
|
|
94
|
+
]);
|
|
95
|
+
});
|
|
96
|
+
if (!folded.size) return rows;
|
|
97
|
+
const merged = Array.from(folded.values(), (group)=>{
|
|
98
|
+
const row = merge(group, aggs);
|
|
99
|
+
// The fields holding the position keep it, rather than summing it.
|
|
100
|
+
const first = group[0];
|
|
101
|
+
const at = position.map((p)=>valueKey(p(first, 0)));
|
|
102
|
+
for (const k of Object.keys(first)){
|
|
103
|
+
if (at.some((v)=>group.every((d)=>valueKey(d[k]) === v))) row[k] = first[k];
|
|
104
|
+
}
|
|
105
|
+
return {
|
|
106
|
+
...row,
|
|
107
|
+
...bucket.identity,
|
|
108
|
+
_isAggregation: true,
|
|
109
|
+
_threshold: bucket.percent,
|
|
110
|
+
[MEMBERS_KEY]: thresholdMemberList(group, id, label, measure)
|
|
111
|
+
};
|
|
112
|
+
});
|
|
113
|
+
return kept.concat(merged);
|
|
114
|
+
}
|
|
115
|
+
/** The bucket inputs a stacked Plot reads: its series, positions, and stacked value. */ export function plotStackInputs(viz) {
|
|
116
|
+
const discrete = viz.schema.discrete === "y" ? "y" : "x";
|
|
117
|
+
const opp = discrete === "x" ? "y" : "x";
|
|
118
|
+
const position = [
|
|
119
|
+
viz[`_${discrete}`]
|
|
120
|
+
];
|
|
121
|
+
if (viz.schema.time) position.push(viz.schema.time);
|
|
122
|
+
return {
|
|
123
|
+
aggs: viz.schema.aggs,
|
|
124
|
+
id: viz._id,
|
|
125
|
+
label: viz._drawLabel,
|
|
126
|
+
measure: viz[`_${opp}`],
|
|
127
|
+
position,
|
|
128
|
+
threshold: viz.schema.threshold,
|
|
129
|
+
value: viz.schema.thresholdKey ?? viz[`_${opp}`]
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
A stacked Plot's `threshold`: folds `data` (the drawn rows) into a bucket
|
|
134
|
+
series, deciding the bucket's series from `all` (every row, legend-hidden
|
|
135
|
+
ones included, so hiding a series doesn't move others in or out of the
|
|
136
|
+
bucket). Returns `data` unchanged when the chart isn't stacked.
|
|
137
|
+
*/ export function plotStackThreshold(viz, data, all = data) {
|
|
138
|
+
if (!viz.schema.stacked) return data;
|
|
139
|
+
const inputs = plotStackInputs(viz);
|
|
140
|
+
const bucket = stackThresholdBucket(all, inputs);
|
|
141
|
+
return bucket ? foldStackRows(data, bucket, inputs) : data;
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
The legend rows of a stacked Plot with its threshold bucket folded into
|
|
145
|
+
one entry, so the legend shows the bucket instead of its series.
|
|
146
|
+
*/ export function plotStackThresholdLegend(viz, legendData) {
|
|
147
|
+
if (!viz.schema.stacked || !legendData.length) return legendData;
|
|
148
|
+
const inputs = plotStackInputs(viz);
|
|
149
|
+
const bucket = stackThresholdBucket(legendData, inputs);
|
|
150
|
+
return bucket ? foldStackRows(legendData, bucket, {
|
|
151
|
+
...inputs,
|
|
152
|
+
position: []
|
|
153
|
+
}) : legendData;
|
|
154
|
+
}
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
`../polar/wedgeLayout.ts` for the geometry it shares with RadialBar).
|
|
8
8
|
- `emit.ts` — wedge Paths.
|
|
9
9
|
*/ import accessor from "../../utils/accessor.js";
|
|
10
|
+
import { fieldAccessor } from "../../utils/fieldAccessor.js";
|
|
10
11
|
import { centerChartTransform, chartBounds } from "../features/chartGeometry.js";
|
|
11
12
|
import { makeChart } from "../definition/makeChart.js";
|
|
12
13
|
import { sceneInsetRegion } from "../pipeline/insetPlacement.js";
|
|
@@ -86,7 +87,7 @@ export const polarAreaDef = {
|
|
|
86
87
|
@type {string | function}
|
|
87
88
|
*/ {
|
|
88
89
|
key: "metric",
|
|
89
|
-
coerce: (v)=>typeof v === "function" ? v : typeof v === "string" ?
|
|
90
|
+
coerce: (v)=>typeof v === "function" ? v : typeof v === "string" ? fieldAccessor(v) : undefined
|
|
90
91
|
},
|
|
91
92
|
/**
|
|
92
93
|
Room (px) reserved around the circle for the category labels, or
|
|
@@ -117,7 +118,7 @@ export const polarAreaDef = {
|
|
|
117
118
|
/** Accessor for each row's value. */ {
|
|
118
119
|
key: "value",
|
|
119
120
|
default: accessor("value"),
|
|
120
|
-
coerce: (v)=>typeof v === "function" ? v :
|
|
121
|
+
coerce: (v)=>typeof v === "function" ? v : fieldAccessor(v)
|
|
121
122
|
},
|
|
122
123
|
{
|
|
123
124
|
key: "legend",
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
- `emit.ts` — Rect + label scene nodes per band.
|
|
7
7
|
*/ import { min, max } from "d3-array";
|
|
8
8
|
import accessor from "../../utils/accessor.js";
|
|
9
|
+
import { fieldAccessor } from "../../utils/fieldAccessor.js";
|
|
9
10
|
import { Axis } from "../../components/index.js";
|
|
10
11
|
import { makeChart } from "../definition/makeChart.js";
|
|
11
12
|
import { applyPriestleyLayout } from "./applyLayout.js";
|
|
@@ -58,7 +59,7 @@ export const priestleyDef = {
|
|
|
58
59
|
*/ {
|
|
59
60
|
key: "end",
|
|
60
61
|
default: accessor("end"),
|
|
61
|
-
coerce: (v)=>typeof v === "function" ? v :
|
|
62
|
+
coerce: (v)=>typeof v === "function" ? v : fieldAccessor(v),
|
|
62
63
|
onSet: (viz, v)=>{
|
|
63
64
|
// String accessor → also seed a default aggregation (max) for that key.
|
|
64
65
|
const key = typeof v === "function" ? null : v;
|
|
@@ -72,7 +73,7 @@ export const priestleyDef = {
|
|
|
72
73
|
*/ {
|
|
73
74
|
key: "start",
|
|
74
75
|
default: accessor("start"),
|
|
75
|
-
coerce: (v)=>typeof v === "function" ? v :
|
|
76
|
+
coerce: (v)=>typeof v === "function" ? v : fieldAccessor(v),
|
|
76
77
|
onSet: (viz, v)=>{
|
|
77
78
|
const key = typeof v === "function" ? null : v;
|
|
78
79
|
if (key && !viz.schema.aggs[key]) viz.schema.aggs[key] = min;
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
internally and the value axis reads magnitudes on both halves.
|
|
6
6
|
*/ import { formatAbbreviate } from "@d3plus/format";
|
|
7
7
|
import TextBox from "../../components/TextBox.js";
|
|
8
|
-
import
|
|
8
|
+
import { fieldAccessor } from "../../utils/fieldAccessor.js";
|
|
9
9
|
import { makeChart } from "../definition/makeChart.js";
|
|
10
10
|
import BarChart from "../BarChart/index.js";
|
|
11
11
|
import { hasUserDomain } from "../Plot/baselineDomain.js";
|
|
@@ -211,6 +211,8 @@ const pyramidState = (viz)=>viz.ctx.pyramid;
|
|
|
211
211
|
export const pyramidDef = {
|
|
212
212
|
name: "Pyramid",
|
|
213
213
|
paintDriven: true,
|
|
214
|
+
// Its two sides are stacks of their own, so `threshold` folds nothing.
|
|
215
|
+
thresholdFunction: (_viz, data)=>data,
|
|
214
216
|
defaults: {
|
|
215
217
|
groupPadding: 1
|
|
216
218
|
},
|
|
@@ -286,7 +288,7 @@ export const pyramidDef = {
|
|
|
286
288
|
key: "comparison",
|
|
287
289
|
coerce: (v)=>{
|
|
288
290
|
if (typeof v !== "string") return v || undefined;
|
|
289
|
-
const fn =
|
|
291
|
+
const fn = fieldAccessor(v);
|
|
290
292
|
comparisonKeys.set(fn, v);
|
|
291
293
|
return fn;
|
|
292
294
|
}
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
- `rings.ts` — ring styles + ring scene nodes.
|
|
10
10
|
- `emit.ts` — Path scene nodes per polygon.
|
|
11
11
|
*/ import accessor from "../../utils/accessor.js";
|
|
12
|
+
import { fieldAccessor } from "../../utils/fieldAccessor.js";
|
|
12
13
|
import constant from "../../utils/constant.js";
|
|
13
14
|
import { centerChartTransform, chartBounds } from "../features/chartGeometry.js";
|
|
14
15
|
import { makeChart } from "../definition/makeChart.js";
|
|
@@ -74,7 +75,7 @@ export const radarDef = {
|
|
|
74
75
|
*/ {
|
|
75
76
|
key: "metric",
|
|
76
77
|
default: accessor("metric"),
|
|
77
|
-
coerce: (v)=>typeof v === "function" ? v :
|
|
78
|
+
coerce: (v)=>typeof v === "function" ? v : fieldAccessor(v)
|
|
78
79
|
},
|
|
79
80
|
{
|
|
80
81
|
key: "outerPadding",
|
|
@@ -92,7 +93,7 @@ export const radarDef = {
|
|
|
92
93
|
*/ {
|
|
93
94
|
key: "value",
|
|
94
95
|
default: accessor("value"),
|
|
95
|
-
coerce: (v)=>typeof v === "function" ? v :
|
|
96
|
+
coerce: (v)=>typeof v === "function" ? v : fieldAccessor(v)
|
|
96
97
|
},
|
|
97
98
|
{
|
|
98
99
|
key: "axisConfig",
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
*/ import { backgroundColor } from "@d3plus/dom";
|
|
13
13
|
import { formatAbbreviate } from "@d3plus/format";
|
|
14
14
|
import accessor from "../../utils/accessor.js";
|
|
15
|
+
import { fieldAccessor } from "../../utils/fieldAccessor.js";
|
|
15
16
|
import { centerChartTransform, chartBounds } from "../features/chartGeometry.js";
|
|
16
17
|
import { makeChart } from "../definition/makeChart.js";
|
|
17
18
|
import { gridStroke } from "../../components/Axis/gridStroke.js";
|
|
@@ -151,7 +152,7 @@ export const radialBarDef = {
|
|
|
151
152
|
/** Accessor for each row's value. */ {
|
|
152
153
|
key: "value",
|
|
153
154
|
default: accessor("value"),
|
|
154
|
-
coerce: (v)=>typeof v === "function" ? v :
|
|
155
|
+
coerce: (v)=>typeof v === "function" ? v : fieldAccessor(v)
|
|
155
156
|
},
|
|
156
157
|
/**
|
|
157
158
|
RadialBar hides the legend when each row is its own entry and the
|