@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
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
*/ import { colorContrast } from "@d3plus/color";
|
|
8
8
|
import { backgroundColor } from "@d3plus/dom";
|
|
9
9
|
import accessor from "../../utils/accessor.js";
|
|
10
|
+
import { fieldAccessor } from "../../utils/fieldAccessor.js";
|
|
10
11
|
import constant from "../../utils/constant.js";
|
|
11
12
|
import { TextBox } from "../../components/index.js";
|
|
12
13
|
import { centerChartTransform } from "../features/chartGeometry.js";
|
|
@@ -69,7 +70,7 @@ export const radialMatrixDef = {
|
|
|
69
70
|
*/ {
|
|
70
71
|
key: "column",
|
|
71
72
|
default: accessor("column"),
|
|
72
|
-
coerce: (v)=>typeof v === "function" ? v :
|
|
73
|
+
coerce: (v)=>typeof v === "function" ? v : fieldAccessor(v)
|
|
73
74
|
},
|
|
74
75
|
/**
|
|
75
76
|
The row each data point falls in (one ring): a key present in every
|
|
@@ -79,7 +80,7 @@ export const radialMatrixDef = {
|
|
|
79
80
|
*/ {
|
|
80
81
|
key: "row",
|
|
81
82
|
default: accessor("row"),
|
|
82
|
-
coerce: (v)=>typeof v === "function" ? v :
|
|
83
|
+
coerce: (v)=>typeof v === "function" ? v : fieldAccessor(v)
|
|
83
84
|
},
|
|
84
85
|
/**
|
|
85
86
|
A manual list of column values to draw, in place of the unique
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
- `ringsGraph.ts` — node set + link resolution.
|
|
9
9
|
- `ringsSizing.ts` — ring geometry + node sizing.
|
|
10
10
|
*/ import { addToQueue } from "@d3plus/data";
|
|
11
|
-
import
|
|
11
|
+
import { fieldAccessor } from "../../utils/fieldAccessor.js";
|
|
12
12
|
import constant from "../../utils/constant.js";
|
|
13
13
|
import { makeChart } from "../definition/makeChart.js";
|
|
14
14
|
import { runPostDrawFeatures } from "../pipeline/runVizPipeline.js";
|
|
@@ -70,7 +70,7 @@ import { simpleHover } from "../viz/simpleHover.js";
|
|
|
70
70
|
const vv = Array.from(new Set(a.map(c)));
|
|
71
71
|
return vv.length === 1 ? vv[0] : vv;
|
|
72
72
|
};
|
|
73
|
-
return
|
|
73
|
+
return fieldAccessor(k);
|
|
74
74
|
});
|
|
75
75
|
return this;
|
|
76
76
|
};
|
|
@@ -81,7 +81,7 @@ import { simpleHover } from "../viz/simpleHover.js";
|
|
|
81
81
|
@type {string | function}
|
|
82
82
|
*/ v.size = function(_) {
|
|
83
83
|
if (!arguments.length) return this._size;
|
|
84
|
-
this._size = typeof _ === "function" || !_ ? _ :
|
|
84
|
+
this._size = typeof _ === "function" || !_ ? _ : fieldAccessor(_);
|
|
85
85
|
this._sizeKey = typeof _ === "string" ? _ : undefined;
|
|
86
86
|
return this;
|
|
87
87
|
};
|
|
@@ -112,6 +112,8 @@ export const ringsDef = {
|
|
|
112
112
|
const id = viz.schema.nodeGroupBy && viz.schema.nodeGroupBy[viz._drawDepth](d, i) ? viz.schema.nodeGroupBy[viz._drawDepth](d, i) : viz._id(d, i);
|
|
113
113
|
const links = viz.ctx.linkLookup[id] ?? [];
|
|
114
114
|
const node = viz.ctx.nodeLookup[id];
|
|
115
|
+
// An edge has no node to focus.
|
|
116
|
+
if (!node) return;
|
|
115
117
|
const filterIds = [
|
|
116
118
|
node.id
|
|
117
119
|
];
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
*/ import { sankey, sankeyCenter, sankeyJustify, sankeyLeft, sankeyLinkHorizontal, sankeyRight } from "./sankeyLayout.js";
|
|
9
9
|
import { addToQueue } from "@d3plus/data";
|
|
10
10
|
import accessor from "../../utils/accessor.js";
|
|
11
|
+
import { fieldAccessor } from "../../utils/fieldAccessor.js";
|
|
11
12
|
import constant from "../../utils/constant.js";
|
|
12
13
|
import { makeChart } from "../definition/makeChart.js";
|
|
13
14
|
import { applySankeyLayout } from "./applyLayout.js";
|
|
@@ -116,7 +117,7 @@ export const sankeyDef = {
|
|
|
116
117
|
sources and targets are matched against these ids.
|
|
117
118
|
@type {string | function}
|
|
118
119
|
*/ v.nodeId = function(_) {
|
|
119
|
-
return arguments.length ? (this.schema.nodeId = typeof _ === "function" ? _ :
|
|
120
|
+
return arguments.length ? (this.schema.nodeId = typeof _ === "function" ? _ : fieldAccessor(_), this) : this.schema.nodeId;
|
|
120
121
|
};
|
|
121
122
|
/**
|
|
122
123
|
The value of each link, which sets its width: a key or an accessor
|
|
@@ -125,7 +126,7 @@ export const sankeyDef = {
|
|
|
125
126
|
@type {string | function}
|
|
126
127
|
*/ v.value = function(_) {
|
|
127
128
|
if (!arguments.length) return this.schema.value;
|
|
128
|
-
this.schema.value = typeof _ === "function" ? _ :
|
|
129
|
+
this.schema.value = typeof _ === "function" ? _ : fieldAccessor(_);
|
|
129
130
|
return this;
|
|
130
131
|
};
|
|
131
132
|
v.hover = simpleHover;
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
import { merge, nestGroups } from "@d3plus/data";
|
|
5
5
|
import { chartBounds } from "../features/chartGeometry.js";
|
|
6
6
|
import { stampShare } from "../features/shareKey.js";
|
|
7
|
+
import { attachGroupHeaders, groupLabelStyle, groupPaddingTop } from "./groupHeaders.js";
|
|
7
8
|
export const applyTreemapLayout = ({ viz })=>{
|
|
8
9
|
const data = viz._filteredData;
|
|
9
10
|
if (!data || !data.length) return {
|
|
@@ -14,7 +15,14 @@ export const applyTreemapLayout = ({ viz })=>{
|
|
|
14
15
|
const root = hierarchy({
|
|
15
16
|
values: nestedData
|
|
16
17
|
}, (d)=>d.values).sum(viz.schema.sum).sort(viz.schema.sort);
|
|
17
|
-
const
|
|
18
|
+
const padding = viz.schema.layoutPadding;
|
|
19
|
+
const strips = new Map();
|
|
20
|
+
const style = groupLabelStyle(viz);
|
|
21
|
+
const built = viz.ctx.treemap.padding(padding).paddingTop(groupPaddingTop({
|
|
22
|
+
drawDepth: viz._drawDepth,
|
|
23
|
+
padding,
|
|
24
|
+
style
|
|
25
|
+
}, strips)).size([
|
|
18
26
|
width,
|
|
19
27
|
height
|
|
20
28
|
]).tile(viz.schema.tile);
|
|
@@ -50,6 +58,11 @@ export const applyTreemapLayout = ({ viz })=>{
|
|
|
50
58
|
d.data.rank = i;
|
|
51
59
|
});
|
|
52
60
|
const total = tmapData.value;
|
|
61
|
+
attachGroupHeaders(strips, {
|
|
62
|
+
aggs: viz.schema.aggs,
|
|
63
|
+
label: style?.label,
|
|
64
|
+
total
|
|
65
|
+
});
|
|
53
66
|
const sumFn = viz.schema.sum;
|
|
54
67
|
shapeData.forEach((d)=>{
|
|
55
68
|
const share = sumFn(d.data) / total;
|
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
2
|
`treemapEmit` — scene nodes for a laid-out Treemap: one rect per cell
|
|
3
|
-
plus the title + share-% text labels for each cell, both as flat data
|
|
3
|
+
plus the title + share-% text labels for each cell, both as flat data,
|
|
4
|
+
then the group header strips above them.
|
|
4
5
|
*/ import { colorContrast } from "@d3plus/color";
|
|
5
6
|
import { formatAbbreviate } from "@d3plus/format";
|
|
6
7
|
import constant from "../../utils/constant.js";
|
|
7
8
|
import { emitLabels } from "../../shapes/emitLabels.js";
|
|
8
9
|
import { userLabelConfig, textureFill, shapeConfigFor, resolveAccessor } from "../features/emitHelpers.js";
|
|
9
10
|
import { backgroundImageNodes } from "../features/backgroundImageEmit.js";
|
|
11
|
+
import { groupHeaderNodes } from "./emitGroupHeaders.js";
|
|
12
|
+
import { collectGroupHeaders, groupLabelStyle } from "./groupHeaders.js";
|
|
10
13
|
export const treemapEmit = ({ viz, shapeData })=>{
|
|
11
14
|
const nodes = shapeData ?? [];
|
|
12
15
|
if (!nodes.length) return [];
|
|
@@ -106,9 +109,12 @@ export const treemapEmit = ({ viz, shapeData })=>{
|
|
|
106
109
|
nodes[k].data,
|
|
107
110
|
nodes[k].i
|
|
108
111
|
]);
|
|
112
|
+
const style = groupLabelStyle(viz);
|
|
113
|
+
const headerNodes = style ? groupHeaderNodes(viz, collectGroupHeaders(nodes), style) : [];
|
|
109
114
|
return [
|
|
110
115
|
...rectNodes,
|
|
111
116
|
...imageNodes,
|
|
112
|
-
...labelNodes
|
|
117
|
+
...labelNodes,
|
|
118
|
+
...headerNodes
|
|
113
119
|
];
|
|
114
120
|
};
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
/**
|
|
2
|
+
Scene nodes for the Treemap's group headers: a strip rect per header and
|
|
3
|
+
its left-aligned, single-line name.
|
|
4
|
+
*/ import { color } from "d3-color";
|
|
5
|
+
import { interpolateRgb } from "d3-interpolate";
|
|
6
|
+
import { colorContrast } from "@d3plus/color";
|
|
7
|
+
import { formatAbbreviate } from "@d3plus/format";
|
|
8
|
+
import constant from "../../utils/constant.js";
|
|
9
|
+
import { emitLabels } from "../../shapes/emitLabels.js";
|
|
10
|
+
import { resolveAccessor, shapeConfigFor } from "../features/emitHelpers.js";
|
|
11
|
+
import { summedShare } from "../features/shareKey.js";
|
|
12
|
+
import { backgroundInk, chartBackground } from "../viz/backgroundInk.js";
|
|
13
|
+
/**
|
|
14
|
+
A header strip's default fill: a darker shade of its group's color, or,
|
|
15
|
+
when a colorScale colors the tiles by value, a neutral tone between the
|
|
16
|
+
chart's background and its ink.
|
|
17
|
+
*/ export function defaultGroupFill(viz, row, i) {
|
|
18
|
+
const neutral = ()=>interpolateRgb(chartBackground(viz), backgroundInk(viz))(0.7);
|
|
19
|
+
if (viz.schema.colorScale) return neutral();
|
|
20
|
+
const sc = shapeConfigFor(viz, "Rect");
|
|
21
|
+
const base = color(`${resolveAccessor(sc.fill, row, i)}`);
|
|
22
|
+
return base ? base.darker(0.8).formatHex() : neutral();
|
|
23
|
+
}
|
|
24
|
+
/** The strip rects and name labels for `headers`. */ export function groupHeaderNodes(viz, headers, style) {
|
|
25
|
+
if (!headers.length) return [];
|
|
26
|
+
const fills = new Map();
|
|
27
|
+
const fillOf = (h)=>{
|
|
28
|
+
let fill = fills.get(h);
|
|
29
|
+
if (fill === undefined) {
|
|
30
|
+
fill = resolveAccessor(style.fill, h.data, 0) ?? defaultGroupFill(viz, h.data, 0);
|
|
31
|
+
fills.set(h, fill);
|
|
32
|
+
}
|
|
33
|
+
return fill;
|
|
34
|
+
};
|
|
35
|
+
const sum = viz.schema.sum;
|
|
36
|
+
const name = (h)=>viz._drawLabel(h.data, 0, h.depth);
|
|
37
|
+
const rects = headers.map((h)=>({
|
|
38
|
+
type: "rect",
|
|
39
|
+
key: `treemap-group-${h.id}`,
|
|
40
|
+
x: h.x0,
|
|
41
|
+
y: h.y0,
|
|
42
|
+
width: h.x1 - h.x0,
|
|
43
|
+
height: h.y1 - h.y0,
|
|
44
|
+
datum: h.data,
|
|
45
|
+
paint: {
|
|
46
|
+
fill: fillOf(h)
|
|
47
|
+
},
|
|
48
|
+
aria: {
|
|
49
|
+
label: `${name(h)}, ${sum(h.data)}, ${formatAbbreviate(summedShare(h.data) * 100, viz.schema.locale)}%`
|
|
50
|
+
}
|
|
51
|
+
}));
|
|
52
|
+
const asHeader = (d)=>d;
|
|
53
|
+
const byRow = new Map(headers.map((h)=>[
|
|
54
|
+
h.data,
|
|
55
|
+
h
|
|
56
|
+
]));
|
|
57
|
+
const labels = emitLabels({
|
|
58
|
+
data: headers,
|
|
59
|
+
label: (d)=>name(asHeader(d)),
|
|
60
|
+
x: (d)=>asHeader(d).x0,
|
|
61
|
+
y: (d)=>asHeader(d).y0,
|
|
62
|
+
aes: (d)=>{
|
|
63
|
+
const h = asHeader(d);
|
|
64
|
+
return {
|
|
65
|
+
width: h.x1 - h.x0,
|
|
66
|
+
height: h.y1 - h.y0
|
|
67
|
+
};
|
|
68
|
+
},
|
|
69
|
+
rotate: constant(0),
|
|
70
|
+
id: (d)=>`group-${asHeader(d).id}`,
|
|
71
|
+
datum: (d)=>asHeader(d).data,
|
|
72
|
+
labelBounds: (_d, _i, aes)=>{
|
|
73
|
+
const { width, height } = aes;
|
|
74
|
+
return {
|
|
75
|
+
x: 0,
|
|
76
|
+
y: 0,
|
|
77
|
+
width,
|
|
78
|
+
height
|
|
79
|
+
};
|
|
80
|
+
},
|
|
81
|
+
labelConfig: {
|
|
82
|
+
fontColor: (d)=>{
|
|
83
|
+
const h = byRow.get(d.data) ?? headers[0];
|
|
84
|
+
return resolveAccessor(style.fontColor, h.data, 0) ?? colorContrast(fillOf(h), viz.schema.colorDefaults);
|
|
85
|
+
},
|
|
86
|
+
...style.fontFamily ? {
|
|
87
|
+
fontFamily: style.fontFamily
|
|
88
|
+
} : {},
|
|
89
|
+
fontResize: false,
|
|
90
|
+
fontSize: style.fontSize,
|
|
91
|
+
fontWeight: style.fontWeight,
|
|
92
|
+
maxLines: 1,
|
|
93
|
+
padding: style.padding,
|
|
94
|
+
textAnchor: "start",
|
|
95
|
+
verticalAlign: "middle"
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
// Moves with its strip in the drill-down morph, like the tile labels.
|
|
99
|
+
for (const n of labels)n.shapeType = "Label";
|
|
100
|
+
return [
|
|
101
|
+
...rects,
|
|
102
|
+
...labels
|
|
103
|
+
];
|
|
104
|
+
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
Treemap group headers: with a nested `groupBy`, each group above the drawn
|
|
3
|
+
tiles gets a strip across its top naming it, and its tiles sit below the
|
|
4
|
+
strip. Every level above the tiles gets its own strip, nested inside its
|
|
5
|
+
parent's. A group too small for a readable strip gets none, and its tiles
|
|
6
|
+
fill it.
|
|
7
|
+
|
|
8
|
+
The layout reserves a strip through d3-hierarchy's `paddingTop`, which
|
|
9
|
+
sees each group's box before its children are tiled into it.
|
|
10
|
+
*/ import { merge } from "@d3plus/data";
|
|
11
|
+
import { stampShare } from "../features/shareKey.js";
|
|
12
|
+
import { GROUP_DEPTH_KEY, GROUP_LABEL_KEY } from "../viz/groupRow.js";
|
|
13
|
+
import { MEMBERS_KEY } from "../features/thresholdMembers.js";
|
|
14
|
+
/** `groupLabelConfig` defaults, under the user's config. */ export const groupLabelDefaults = {
|
|
15
|
+
fontSize: 11,
|
|
16
|
+
fontWeight: 600,
|
|
17
|
+
padding: 3
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
The chart's group-header style, or null when headers are off
|
|
21
|
+
(`groupLabels: false`).
|
|
22
|
+
*/ export function groupLabelStyle(viz) {
|
|
23
|
+
if (viz.schema.groupLabels === false) return null;
|
|
24
|
+
const config = viz.schema.groupLabelConfig ?? {};
|
|
25
|
+
return {
|
|
26
|
+
...groupLabelDefaults,
|
|
27
|
+
fontFamily: viz.schema.fontFamily,
|
|
28
|
+
...config
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
/** A strip's height: one line of text plus its padding above and below. */ export function groupStripHeight(style) {
|
|
32
|
+
return Math.ceil(style.fontSize * 1.2 + style.padding * 2);
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
Whether a group `width` × `height` pixels gets a strip: it keeps at least
|
|
36
|
+
a strip's height for its tiles below the strip, and is wide enough for a
|
|
37
|
+
few characters of its name.
|
|
38
|
+
*/ export function groupStripFits(width, height, style) {
|
|
39
|
+
return height >= groupStripHeight(style) * 2 && width >= style.fontSize * 3 + style.padding * 2;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
The treemap's `paddingTop`: a group above the drawn tiles (hierarchy depth
|
|
43
|
+
1 through `drawDepth`) that fits a strip reserves it, and is recorded in
|
|
44
|
+
`strips` with the strip's height; every other node keeps `padding`.
|
|
45
|
+
*/ export function groupPaddingTop(opts, strips) {
|
|
46
|
+
const { drawDepth, padding, style } = opts;
|
|
47
|
+
return (node)=>{
|
|
48
|
+
const group = node;
|
|
49
|
+
if (!style || group.depth < 1 || group.depth > drawDepth || group.data.key == null || !groupStripFits(group.x1 - group.x0, group.y1 - group.y0, style)) return padding;
|
|
50
|
+
const height = groupStripHeight(style);
|
|
51
|
+
strips.set(group, height);
|
|
52
|
+
return height + padding;
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
/** The `id` of a group at a hierarchy node: its key at each level. */ function groupId(node) {
|
|
56
|
+
return node.ancestors().reverse().slice(1).map((n)=>`${n.data.key}`).join("/");
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
Stamps each group that reserved a strip with its header: the strip's box
|
|
60
|
+
(in the group's final, rounded position) and the group's merged row,
|
|
61
|
+
carrying its share of `total` and, when `label` gives one, its own label.
|
|
62
|
+
*/ export function attachGroupHeaders(strips, opts) {
|
|
63
|
+
for (const [node, height] of strips){
|
|
64
|
+
const rows = node.leaves().map((leaf)=>leaf.data);
|
|
65
|
+
const data = merge(rows, opts.aggs);
|
|
66
|
+
// A group holding the threshold bucket is still a real group.
|
|
67
|
+
delete data._isAggregation;
|
|
68
|
+
delete data._threshold;
|
|
69
|
+
delete data[MEMBERS_KEY];
|
|
70
|
+
data[GROUP_DEPTH_KEY] = node.depth - 1;
|
|
71
|
+
const text = opts.label ? opts.label(data, 0) : undefined;
|
|
72
|
+
if (text !== undefined && text !== null && text !== false && text !== "") data[GROUP_LABEL_KEY] = `${text}`;
|
|
73
|
+
stampShare(data, (node.value ?? 0) / opts.total);
|
|
74
|
+
node.groupHeader = {
|
|
75
|
+
__d3plus__: true,
|
|
76
|
+
data,
|
|
77
|
+
depth: node.depth - 1,
|
|
78
|
+
id: groupId(node),
|
|
79
|
+
x0: node.x0,
|
|
80
|
+
y0: node.y0,
|
|
81
|
+
x1: node.x1,
|
|
82
|
+
y1: Math.min(node.y1, node.y0 + height)
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
/** The headers above the laid-out tiles, shallowest level first. */ export function collectGroupHeaders(leaves) {
|
|
87
|
+
const seen = new Set();
|
|
88
|
+
for (const leaf of leaves){
|
|
89
|
+
let n = leaf.parent;
|
|
90
|
+
for(; n; n = n.parent)if (n.groupHeader) seen.add(n.groupHeader);
|
|
91
|
+
}
|
|
92
|
+
return [
|
|
93
|
+
...seen
|
|
94
|
+
].sort((a, b)=>a.depth - b.depth);
|
|
95
|
+
}
|
|
@@ -5,11 +5,14 @@
|
|
|
5
5
|
- `applyLayout.ts` — chart-specific `TransformStage`.
|
|
6
6
|
- `emit.ts` — rect + label scene nodes from the laid-out data.
|
|
7
7
|
- `thresholdFunction.ts` — pure threshold-merge algorithm.
|
|
8
|
+
- `groupHeaders.ts` / `emitGroupHeaders.ts` — the header strip above
|
|
9
|
+
each group of a nested `groupBy`.
|
|
8
10
|
|
|
9
11
|
The default export is the chart class via `makeChart(def)`; the named
|
|
10
12
|
export is the def itself.
|
|
11
13
|
*/ import { treemap, treemapBinary, treemapDice, treemapResquarify, treemapSlice, treemapSliceDice, treemapSquarify } from "d3-hierarchy";
|
|
12
14
|
import accessor from "../../utils/accessor.js";
|
|
15
|
+
import { fieldAccessor } from "../../utils/fieldAccessor.js";
|
|
13
16
|
import { rowLegend, shareRow } from "../features/sharedFields.js";
|
|
14
17
|
import { makeChart } from "../definition/makeChart.js";
|
|
15
18
|
import { applyTreemapLayout } from "./applyLayout.js";
|
|
@@ -33,7 +36,8 @@ export const treemapDef = {
|
|
|
33
36
|
drawDepth: viz._drawDepth,
|
|
34
37
|
groupBy: viz.schema.groupBy,
|
|
35
38
|
threshold: viz.schema.threshold,
|
|
36
|
-
thresholdKey: viz.schema.thresholdKey
|
|
39
|
+
thresholdKey: viz.schema.thresholdKey,
|
|
40
|
+
label: (d, i)=>viz._drawLabel(d, i)
|
|
37
41
|
}),
|
|
38
42
|
ctx: {
|
|
39
43
|
treemap: treemap().round(true)
|
|
@@ -46,6 +50,15 @@ export const treemapDef = {
|
|
|
46
50
|
key: "layoutPadding",
|
|
47
51
|
default: 1
|
|
48
52
|
},
|
|
53
|
+
{
|
|
54
|
+
key: "groupLabels",
|
|
55
|
+
default: true
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
key: "groupLabelConfig",
|
|
59
|
+
default: {},
|
|
60
|
+
merge: true
|
|
61
|
+
},
|
|
49
62
|
/**
|
|
50
63
|
Comparator for sibling rectangles, given two d3-hierarchy nodes. Defaults to
|
|
51
64
|
descending by summed value, with any threshold bucket last.
|
|
@@ -68,7 +81,7 @@ export const treemapDef = {
|
|
|
68
81
|
*/ {
|
|
69
82
|
key: "sum",
|
|
70
83
|
default: accessor("value"),
|
|
71
|
-
coerce: (v)=>typeof v === "function" ? v :
|
|
84
|
+
coerce: (v)=>typeof v === "function" ? v : fieldAccessor(v),
|
|
72
85
|
onSet: (viz, v)=>{
|
|
73
86
|
viz.schema.thresholdKey = v;
|
|
74
87
|
}
|
|
@@ -4,13 +4,15 @@
|
|
|
4
4
|
from the viz.
|
|
5
5
|
*/ import { group, sum } from "d3-array";
|
|
6
6
|
import { merge } from "@d3plus/data";
|
|
7
|
+
import { MEMBERS_KEY, thresholdMemberList } from "../features/thresholdMembers.js";
|
|
7
8
|
/**
|
|
8
9
|
Walks `data` to `drawDepth` and merges entries whose `thresholdKey`
|
|
9
10
|
value falls below `threshold(branchData) * totalSum` into a single
|
|
10
|
-
aggregated row at that depth
|
|
11
|
-
|
|
11
|
+
aggregated row at that depth, listing them (largest first) under
|
|
12
|
+
`MEMBERS_KEY`. A lone entry under the threshold stays as itself: a
|
|
13
|
+
bucket needs two. Returns the kept set; original `data` is not mutated.
|
|
12
14
|
*/ export function thresholdFunction(data, inputs) {
|
|
13
|
-
const { aggs, drawDepth, groupBy, threshold, thresholdKey } = inputs;
|
|
15
|
+
const { aggs, drawDepth, groupBy, label, threshold, thresholdKey } = inputs;
|
|
14
16
|
const totalSum = sum(data, thresholdKey);
|
|
15
17
|
if (!threshold || !thresholdKey) return data;
|
|
16
18
|
/**
|
|
@@ -37,12 +39,12 @@ import { merge } from "@d3plus/data";
|
|
|
37
39
|
if (thresholdKey(datum) < thresholdValue) removedItems.push(datum);
|
|
38
40
|
else kept.push(datum);
|
|
39
41
|
}
|
|
40
|
-
if (removedItems.length
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
42
|
+
if (removedItems.length < 2) return branchData;
|
|
43
|
+
const mergedItem = merge(removedItems, aggs);
|
|
44
|
+
mergedItem._isAggregation = true;
|
|
45
|
+
mergedItem._threshold = thresholdPercent;
|
|
46
|
+
mergedItem[MEMBERS_KEY] = thresholdMemberList(removedItems, (_d, i)=>i, label ?? ((d)=>groupBy[depth](d)), thresholdKey);
|
|
47
|
+
kept.push(mergedItem);
|
|
46
48
|
return kept;
|
|
47
49
|
}
|
|
48
50
|
throw new Error("Depth is higher than the amount of grouping levels.");
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
- `waffleLayout.ts` — pure allocation (largest remainder) and grid math.
|
|
10
10
|
- `tooltip.ts` — the "Value" and "Share" tooltip rows.
|
|
11
11
|
*/ import accessor from "../../utils/accessor.js";
|
|
12
|
+
import { fieldAccessor } from "../../utils/fieldAccessor.js";
|
|
12
13
|
import { makeChart } from "../definition/makeChart.js";
|
|
13
14
|
import { sceneInsetRegion } from "../pipeline/insetPlacement.js";
|
|
14
15
|
import { thresholdFunction } from "../Treemap/thresholdFunction.js";
|
|
@@ -34,7 +35,8 @@ export const waffleDef = {
|
|
|
34
35
|
drawDepth: viz._drawDepth,
|
|
35
36
|
groupBy: viz.schema.groupBy,
|
|
36
37
|
threshold: viz.schema.threshold,
|
|
37
|
-
thresholdKey: viz.schema.thresholdKey
|
|
38
|
+
thresholdKey: viz.schema.thresholdKey,
|
|
39
|
+
label: (d, i)=>viz._drawLabel(d, i)
|
|
38
40
|
}),
|
|
39
41
|
// The default 10 × 10 grid is square.
|
|
40
42
|
facet: {
|
|
@@ -124,7 +126,7 @@ export const waffleDef = {
|
|
|
124
126
|
*/ {
|
|
125
127
|
key: "sum",
|
|
126
128
|
default: accessor("value"),
|
|
127
|
-
coerce: (v)=>typeof v === "function" ? v :
|
|
129
|
+
coerce: (v)=>typeof v === "function" ? v : fieldAccessor(v),
|
|
128
130
|
onSet: (viz, v)=>{
|
|
129
131
|
viz.schema.thresholdKey = v;
|
|
130
132
|
}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
@module
|
|
5
5
|
*/ import { formatAbbreviate } from "@d3plus/format";
|
|
6
6
|
import { colorScaleBucketShare } from "../features/colorScaleBucket.js";
|
|
7
|
-
import { summedShare } from "../features/shareKey.js";
|
|
7
|
+
import { shareOfRows, summedShare, unwrapRow } from "../features/shareKey.js";
|
|
8
8
|
/** Formats a 0–1 share as an abbreviated percentage, or "" when not finite. */ export function formatShare(share, locale) {
|
|
9
9
|
return share == null || !Number.isFinite(share) ? "" : `${formatAbbreviate(share * 100, locale)}%`;
|
|
10
10
|
}
|
|
@@ -15,7 +15,11 @@ import { summedShare } from "../features/shareKey.js";
|
|
|
15
15
|
*/ export function waffleShare(viz, x) {
|
|
16
16
|
const sum = viz.schema.sum;
|
|
17
17
|
if (x._isColorScaleBucket) return colorScaleBucketShare(viz, x.color, sum);
|
|
18
|
-
|
|
18
|
+
const row = unwrapRow(x);
|
|
19
|
+
const share = summedShare(row);
|
|
20
|
+
// A legend entry the layout hasn't stamped (a threshold bucket) reads its
|
|
21
|
+
// share of every legend row's value.
|
|
22
|
+
return Number.isFinite(share) ? share : shareOfRows(row, viz._legendData || [], (d)=>sum(d, 0));
|
|
19
23
|
}
|
|
20
24
|
/** The `[label, value]` tooltip rows: the summed value, then its share. */ export function waffleTooltipRows(viz) {
|
|
21
25
|
const locale = ()=>viz.schema.locale;
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
the running total before it ended, and subtotal rows draw from zero to the
|
|
4
4
|
running total. Bars are colored by whether they increase, decrease, or
|
|
5
5
|
total, with thin connectors carrying each bar's end level to the next.
|
|
6
|
-
*/ import
|
|
6
|
+
*/ import { fieldAccessor } from "../../utils/fieldAccessor.js";
|
|
7
7
|
import { makeChart } from "../definition/makeChart.js";
|
|
8
8
|
import BarChart from "../BarChart/index.js";
|
|
9
9
|
import { backgroundInk } from "../viz/backgroundInk.js";
|
|
@@ -87,6 +87,8 @@ import { WATERFALL_KINDS, waterfallKinds, waterfallStackOffset } from "./steps.j
|
|
|
87
87
|
export const waterfallDef = {
|
|
88
88
|
name: "Waterfall",
|
|
89
89
|
paintDriven: true,
|
|
90
|
+
// Each bar is a step of its own, so `threshold` folds nothing.
|
|
91
|
+
thresholdFunction: (_viz, data)=>data,
|
|
90
92
|
setup: (viz)=>{
|
|
91
93
|
viz.ctx.waterfall = {
|
|
92
94
|
accessors: {
|
|
@@ -163,7 +165,7 @@ export const waterfallDef = {
|
|
|
163
165
|
has its own value, the running total resets to that value.
|
|
164
166
|
*/ {
|
|
165
167
|
key: "subtotal",
|
|
166
|
-
coerce: (v)=>typeof v === "string" ?
|
|
168
|
+
coerce: (v)=>typeof v === "string" ? fieldAccessor(v) : typeof v === "function" ? v : undefined
|
|
167
169
|
},
|
|
168
170
|
/**
|
|
169
171
|
Fill for subtotal bars. Defaults to `colorDefaults.sequential`.
|
|
@@ -5,9 +5,10 @@
|
|
|
5
5
|
The class is identical for every chart: its constructor runs
|
|
6
6
|
`applyDefinition(this, def)`, its `_draw` runs the shared Viz pipeline
|
|
7
7
|
then the chart's own layout stage via `runChartDraw`, and its
|
|
8
|
-
`_thresholdFunction` / `_sizeLegendScale` / `_insetRegion`
|
|
9
|
-
`
|
|
10
|
-
|
|
8
|
+
`_thresholdFunction` / `_thresholdLegend` / `_sizeLegendScale` / `_insetRegion` /
|
|
9
|
+
`_colorScaleShape` delegate to `def.thresholdFunction` /
|
|
10
|
+
`def.sizeLegendScale` / `def.insetRegion` / `def.colorScaleShape` if
|
|
11
|
+
present (else to the base chart's), `_facetHooks` layers `def.facet` over the base chart's, and
|
|
11
12
|
`toScene` passes the base chart's scene through `def.decorateScene`.
|
|
12
13
|
|
|
13
14
|
A chart's `index.ts` becomes literally `export default makeChart(def)`.
|
|
@@ -43,14 +44,20 @@ import Viz from "../viz/Viz.js";
|
|
|
43
44
|
_insetRegion() {
|
|
44
45
|
return def.insetRegion ? def.insetRegion(this) : super._insetRegion();
|
|
45
46
|
}
|
|
47
|
+
_colorScaleShape(d, i) {
|
|
48
|
+
return def.colorScaleShape ? def.colorScaleShape(this, d, i) : super._colorScaleShape(d, i);
|
|
49
|
+
}
|
|
46
50
|
_facetHooks() {
|
|
47
51
|
return def.facet ? {
|
|
48
52
|
...super._facetHooks(),
|
|
49
53
|
...def.facet
|
|
50
54
|
} : super._facetHooks();
|
|
51
55
|
}
|
|
52
|
-
|
|
53
|
-
return def.thresholdFunction ? def.thresholdFunction(this,
|
|
56
|
+
_thresholdLegend(legendData) {
|
|
57
|
+
return def.thresholdFunction ? def.thresholdFunction(this, legendData, legendData) : super._thresholdLegend(legendData);
|
|
58
|
+
}
|
|
59
|
+
_thresholdFunction(data, tree, all) {
|
|
60
|
+
return def.thresholdFunction ? def.thresholdFunction(this, data, all) : super._thresholdFunction(data, tree, all);
|
|
54
61
|
}
|
|
55
62
|
}
|
|
56
63
|
Object.defineProperty(Chart, "name", {
|