@d3plus/core 4.6.0 → 4.7.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/README.md +728 -1454
- package/es/index.js.map +1 -1
- package/es/internal.js +5 -0
- package/es/internal.js.map +1 -1
- package/es/src/charts/Chord/index.js +2 -0
- package/es/src/charts/Chord/index.js.map +1 -1
- package/es/src/charts/Geomap/applyLayout.js +3 -1
- package/es/src/charts/Geomap/applyLayout.js.map +1 -1
- package/es/src/charts/Geomap/index.js +3 -1
- package/es/src/charts/Geomap/index.js.map +1 -1
- package/es/src/charts/Matrix/emit.js +5 -4
- package/es/src/charts/Matrix/emit.js.map +1 -1
- package/es/src/charts/Network/index.js +4 -0
- package/es/src/charts/Network/index.js.map +1 -1
- package/es/src/charts/Pack/emit.js +6 -6
- package/es/src/charts/Pack/emit.js.map +1 -1
- package/es/src/charts/Pack/index.js +2 -0
- package/es/src/charts/Pack/index.js.map +1 -1
- package/es/src/charts/Pie/emit.js +5 -6
- package/es/src/charts/Pie/emit.js.map +1 -1
- package/es/src/charts/Pie/index.js +2 -0
- package/es/src/charts/Pie/index.js.map +1 -1
- package/es/src/charts/Plot/index.js +15 -1
- package/es/src/charts/Plot/index.js.map +1 -1
- package/es/src/charts/Plot/insetRegion.js +21 -0
- package/es/src/charts/Plot/insetRegion.js.map +1 -0
- package/es/src/charts/Plot/sharedHover.js +117 -16
- package/es/src/charts/Plot/sharedHover.js.map +1 -1
- package/es/src/charts/Plot/sharedTooltip.js +35 -15
- package/es/src/charts/Plot/sharedTooltip.js.map +1 -1
- package/es/src/charts/Plot/trendLines.js +140 -38
- package/es/src/charts/Plot/trendLines.js.map +1 -1
- package/es/src/charts/Plot/trendProjection.js +120 -0
- package/es/src/charts/Plot/trendProjection.js.map +1 -0
- package/es/src/charts/Plot/trendScene.js +33 -19
- package/es/src/charts/Plot/trendScene.js.map +1 -1
- package/es/src/charts/Plot/trendTooltip.js +79 -17
- package/es/src/charts/Plot/trendTooltip.js.map +1 -1
- package/es/src/charts/Priestley/emit.js +3 -4
- package/es/src/charts/Priestley/emit.js.map +1 -1
- package/es/src/charts/RadialMatrix/emit.js +4 -4
- package/es/src/charts/RadialMatrix/emit.js.map +1 -1
- package/es/src/charts/Rings/index.js +5 -1
- package/es/src/charts/Rings/index.js.map +1 -1
- package/es/src/charts/Sankey/index.js +2 -0
- package/es/src/charts/Sankey/index.js.map +1 -1
- package/es/src/charts/Tree/index.js +2 -0
- package/es/src/charts/Tree/index.js.map +1 -1
- package/es/src/charts/Treemap/emit.js +3 -4
- package/es/src/charts/Treemap/emit.js.map +1 -1
- package/es/src/charts/definition/ChartDefinition.js.map +1 -1
- package/es/src/charts/definition/makeChart.js +8 -2
- package/es/src/charts/definition/makeChart.js.map +1 -1
- package/es/src/charts/drawSteps/bottomRightControls.js +3 -0
- package/es/src/charts/drawSteps/bottomRightControls.js.map +1 -1
- package/es/src/charts/drawSteps/bottomRightControlsMarkup.js +135 -4
- package/es/src/charts/drawSteps/bottomRightControlsMarkup.js.map +1 -1
- package/es/src/charts/drawSteps/searchControlsMarkup.js +15 -38
- package/es/src/charts/drawSteps/searchControlsMarkup.js.map +1 -1
- package/es/src/charts/events/click.legend.js +10 -5
- package/es/src/charts/events/click.legend.js.map +1 -1
- package/es/src/charts/events/mousemove.shape.js +8 -1
- package/es/src/charts/events/mousemove.shape.js.map +1 -1
- package/es/src/charts/features/emitHelpers.js +19 -5
- package/es/src/charts/features/emitHelpers.js.map +1 -1
- package/es/src/charts/features/features.js +3 -108
- package/es/src/charts/features/features.js.map +1 -1
- package/es/src/charts/features/featuresColorScale.js +161 -0
- package/es/src/charts/features/featuresColorScale.js.map +1 -0
- package/es/src/charts/features/featuresLegend.js +145 -32
- package/es/src/charts/features/featuresLegend.js.map +1 -1
- package/es/src/charts/features/insetState.js +174 -0
- package/es/src/charts/features/insetState.js.map +1 -0
- package/es/src/charts/features/sceneBounds.js +271 -0
- package/es/src/charts/features/sceneBounds.js.map +1 -0
- package/es/src/charts/features/tooltipSwatch.js +73 -0
- package/es/src/charts/features/tooltipSwatch.js.map +1 -0
- package/es/src/charts/pipeline/insetPlacement.js +406 -0
- package/es/src/charts/pipeline/insetPlacement.js.map +1 -0
- package/es/src/charts/pipeline/runVizPipeline.js +6 -2
- package/es/src/charts/pipeline/runVizPipeline.js.map +1 -1
- package/es/src/charts/viz/Viz.js +18 -3
- package/es/src/charts/viz/Viz.js.map +1 -1
- package/es/src/charts/viz/VizBaseConfig.js +20 -24
- package/es/src/charts/viz/VizBaseConfig.js.map +1 -1
- package/es/src/charts/viz/interactionOpacity.js +21 -13
- package/es/src/charts/viz/interactionOpacity.js.map +1 -1
- package/es/src/charts/viz/linkGroup.js +386 -0
- package/es/src/charts/viz/linkGroup.js.map +1 -0
- package/es/src/charts/viz/sceneRows.js +33 -0
- package/es/src/charts/viz/sceneRows.js.map +1 -0
- package/es/src/charts/viz/vizDefaults.js +13 -8
- package/es/src/charts/viz/vizDefaults.js.map +1 -1
- package/es/src/charts/viz/vizTypes.js.map +1 -1
- package/es/src/components/Axis/AxisBottom.js +1 -1
- package/es/src/components/Axis/AxisBottom.js.map +1 -1
- package/es/src/components/Axis/AxisLeft.js +1 -1
- package/es/src/components/Axis/AxisLeft.js.map +1 -1
- package/es/src/components/Axis/AxisRight.js +1 -1
- package/es/src/components/Axis/AxisRight.js.map +1 -1
- package/es/src/components/Axis/AxisTop.js +1 -1
- package/es/src/components/Axis/AxisTop.js.map +1 -1
- package/es/src/components/Axis/axisLayoutLabels.js +13 -1
- package/es/src/components/Axis/axisLayoutLabels.js.map +1 -1
- package/es/src/components/ColorScale/ColorScale.js.map +1 -1
- package/es/src/components/Legend/legendConfig.js +2 -1
- package/es/src/components/Legend/legendConfig.js.map +1 -1
- package/es/src/components/Legend/legendRender.js +42 -5
- package/es/src/components/Legend/legendRender.js.map +1 -1
- package/es/src/components/TextBox.js +1 -1
- package/es/src/components/TextBox.js.map +1 -1
- package/es/src/shapes/Bar.js +1 -1
- package/es/src/shapes/Bar.js.map +1 -1
- package/es/src/shapes/Box.js +1 -1
- package/es/src/shapes/Box.js.map +1 -1
- package/es/src/shapes/Rect.js +1 -1
- package/es/src/shapes/Rect.js.map +1 -1
- package/es/src/shapes/Shape.js +9 -36
- package/es/src/shapes/Shape.js.map +1 -1
- package/es/src/shapes/Whisker.js +1 -1
- package/es/src/shapes/Whisker.js.map +1 -1
- package/es/src/shapes/textureKey.js +104 -0
- package/es/src/shapes/textureKey.js.map +1 -0
- package/es/src/utils/D3plusConfig.js.map +1 -1
- package/package.json +10 -9
- package/types/index.d.ts +1 -0
- package/types/internal.d.ts +7 -0
- package/types/src/charts/Plot/index.d.ts +8 -0
- package/types/src/charts/Plot/insetRegion.d.ts +4 -0
- package/types/src/charts/Plot/sharedHover.d.ts +5 -0
- package/types/src/charts/Plot/sharedTooltip.d.ts +10 -0
- package/types/src/charts/Plot/trendLines.d.ts +23 -3
- package/types/src/charts/Plot/trendProjection.d.ts +28 -0
- package/types/src/charts/Plot/trendScene.d.ts +2 -1
- package/types/src/charts/Plot/trendTooltip.d.ts +16 -5
- package/types/src/charts/definition/ChartDefinition.d.ts +9 -0
- package/types/src/charts/definition/makeChart.d.ts +2 -2
- package/types/src/charts/drawSteps/bottomRightControlsMarkup.d.ts +2 -0
- package/types/src/charts/drawSteps/searchControlsMarkup.d.ts +7 -5
- package/types/src/charts/features/emitHelpers.d.ts +10 -4
- package/types/src/charts/features/features.d.ts +1 -8
- package/types/src/charts/features/featuresColorScale.d.ts +24 -0
- package/types/src/charts/features/featuresLegend.d.ts +15 -0
- package/types/src/charts/features/insetState.d.ts +95 -0
- package/types/src/charts/features/sceneBounds.d.ts +18 -0
- package/types/src/charts/features/tooltipSwatch.d.ts +31 -0
- package/types/src/charts/pipeline/insetPlacement.d.ts +45 -0
- package/types/src/charts/pipeline/runVizPipeline.d.ts +2 -1
- package/types/src/charts/viz/Viz.d.ts +9 -1
- package/types/src/charts/viz/VizBaseConfig.d.ts +8 -12
- package/types/src/charts/viz/linkGroup.d.ts +96 -0
- package/types/src/charts/viz/sceneRows.d.ts +13 -0
- package/types/src/charts/viz/vizTypes.d.ts +17 -0
- package/types/src/components/Axis/AxisBottom.d.ts +1 -1
- package/types/src/components/Axis/AxisLeft.d.ts +1 -1
- package/types/src/components/Axis/AxisRight.d.ts +1 -1
- package/types/src/components/Axis/AxisTop.d.ts +1 -1
- package/types/src/components/ColorScale/ColorScale.d.ts +4 -4
- package/types/src/components/Legend/legendRender.d.ts +1 -1
- package/types/src/components/TextBox.d.ts +1 -1
- package/types/src/shapes/Bar.d.ts +1 -1
- package/types/src/shapes/Box.d.ts +1 -1
- package/types/src/shapes/Rect.d.ts +1 -1
- package/types/src/shapes/Whisker.d.ts +1 -1
- package/types/src/shapes/textureKey.d.ts +9 -0
- package/types/src/utils/D3plusConfig.d.ts +42 -1
- package/umd/d3plus-core.full.js +2393 -594
- package/umd/d3plus-core.full.js.map +1 -1
- package/umd/d3plus-core.full.min.js +1945 -1601
- package/umd/d3plus-core.js +1744 -404
- package/umd/d3plus-core.js.map +1 -1
- package/umd/d3plus-core.min.js +1401 -1087
package/umd/d3plus-core.full.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
@d3plus/core v4.
|
|
2
|
+
@d3plus/core v4.7.0
|
|
3
3
|
Data visualization made easy. A javascript library that extends the popular D3.js to enable fast and beautiful visualizations.
|
|
4
4
|
Copyright (c) 2026 D3plus - https://d3plus.org
|
|
5
5
|
@license MIT
|
|
@@ -263,7 +263,7 @@
|
|
|
263
263
|
function group(values, ...keys) {
|
|
264
264
|
return nest$1(values, identity$a, identity$a, keys);
|
|
265
265
|
}
|
|
266
|
-
function groups(values, ...keys) {
|
|
266
|
+
function groups$1(values, ...keys) {
|
|
267
267
|
return nest$1(values, Array.from, identity$a, keys);
|
|
268
268
|
}
|
|
269
269
|
function rollup(values, reduce, ...keys) {
|
|
@@ -1799,7 +1799,7 @@
|
|
|
1799
1799
|
var noop$4 = {
|
|
1800
1800
|
value: ()=>{}
|
|
1801
1801
|
};
|
|
1802
|
-
function dispatch() {
|
|
1802
|
+
function dispatch$1() {
|
|
1803
1803
|
for(var i = 0, n = arguments.length, _ = {}, t; i < n; ++i){
|
|
1804
1804
|
if (!(t = arguments[i] + "") || t in _ || /[\s.]/.test(t)) throw new Error("illegal type: " + t);
|
|
1805
1805
|
_[t] = [];
|
|
@@ -1820,7 +1820,7 @@
|
|
|
1820
1820
|
};
|
|
1821
1821
|
});
|
|
1822
1822
|
}
|
|
1823
|
-
Dispatch.prototype = dispatch.prototype = {
|
|
1823
|
+
Dispatch.prototype = dispatch$1.prototype = {
|
|
1824
1824
|
constructor: Dispatch,
|
|
1825
1825
|
on: function(typename, callback) {
|
|
1826
1826
|
var _ = this._, T = parseTypenames(typename + "", _), t, i = -1, n = T.length;
|
|
@@ -1975,7 +1975,7 @@
|
|
|
1975
1975
|
return t;
|
|
1976
1976
|
}
|
|
1977
1977
|
|
|
1978
|
-
var emptyOn = dispatch("start", "end", "cancel", "interrupt");
|
|
1978
|
+
var emptyOn = dispatch$1("start", "end", "cancel", "interrupt");
|
|
1979
1979
|
var emptyTween = [];
|
|
1980
1980
|
var CREATED = 0;
|
|
1981
1981
|
var SCHEDULED = 1;
|
|
@@ -9648,7 +9648,6 @@
|
|
|
9648
9648
|
}
|
|
9649
9649
|
/**
|
|
9650
9650
|
Finds the available width and height for a specified HTMLElement, traversing it's parents until it finds something with constrained dimensions. Falls back to the inner dimensions of the browser window if none is found.
|
|
9651
|
-
@private
|
|
9652
9651
|
*/ function getSize(elem) {
|
|
9653
9652
|
return [
|
|
9654
9653
|
_elementSize(elem, "width"),
|
|
@@ -10017,16 +10016,16 @@
|
|
|
10017
10016
|
return newObject;
|
|
10018
10017
|
}
|
|
10019
10018
|
|
|
10020
|
-
function _array_like_to_array$
|
|
10019
|
+
function _array_like_to_array$m(arr, len) {
|
|
10021
10020
|
if (len == null || len > arr.length) len = arr.length;
|
|
10022
10021
|
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
10023
10022
|
return arr2;
|
|
10024
10023
|
}
|
|
10025
|
-
function _array_with_holes$
|
|
10024
|
+
function _array_with_holes$i(arr) {
|
|
10026
10025
|
if (Array.isArray(arr)) return arr;
|
|
10027
10026
|
}
|
|
10028
|
-
function _array_without_holes$
|
|
10029
|
-
if (Array.isArray(arr)) return _array_like_to_array$
|
|
10027
|
+
function _array_without_holes$b(arr) {
|
|
10028
|
+
if (Array.isArray(arr)) return _array_like_to_array$m(arr);
|
|
10030
10029
|
}
|
|
10031
10030
|
function _instanceof$4(left, right) {
|
|
10032
10031
|
"@swc/helpers - instanceof";
|
|
@@ -10036,10 +10035,10 @@
|
|
|
10036
10035
|
return left instanceof right;
|
|
10037
10036
|
}
|
|
10038
10037
|
}
|
|
10039
|
-
function _iterable_to_array$
|
|
10038
|
+
function _iterable_to_array$b(iter) {
|
|
10040
10039
|
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
10041
10040
|
}
|
|
10042
|
-
function _iterable_to_array_limit$
|
|
10041
|
+
function _iterable_to_array_limit$i(arr, i) {
|
|
10043
10042
|
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
10044
10043
|
if (_i == null) return;
|
|
10045
10044
|
var _arr = [];
|
|
@@ -10063,36 +10062,36 @@
|
|
|
10063
10062
|
}
|
|
10064
10063
|
return _arr;
|
|
10065
10064
|
}
|
|
10066
|
-
function _non_iterable_rest$
|
|
10065
|
+
function _non_iterable_rest$i() {
|
|
10067
10066
|
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
10068
10067
|
}
|
|
10069
|
-
function _non_iterable_spread$
|
|
10068
|
+
function _non_iterable_spread$b() {
|
|
10070
10069
|
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
10071
10070
|
}
|
|
10072
|
-
function _sliced_to_array$
|
|
10073
|
-
return _array_with_holes$
|
|
10071
|
+
function _sliced_to_array$i(arr, i) {
|
|
10072
|
+
return _array_with_holes$i(arr) || _iterable_to_array_limit$i(arr, i) || _unsupported_iterable_to_array$m(arr, i) || _non_iterable_rest$i();
|
|
10074
10073
|
}
|
|
10075
|
-
function _to_consumable_array$
|
|
10076
|
-
return _array_without_holes$
|
|
10074
|
+
function _to_consumable_array$b(arr) {
|
|
10075
|
+
return _array_without_holes$b(arr) || _iterable_to_array$b(arr) || _unsupported_iterable_to_array$m(arr) || _non_iterable_spread$b();
|
|
10077
10076
|
}
|
|
10078
|
-
function _unsupported_iterable_to_array$
|
|
10077
|
+
function _unsupported_iterable_to_array$m(o, minLen) {
|
|
10079
10078
|
if (!o) return;
|
|
10080
|
-
if (typeof o === "string") return _array_like_to_array$
|
|
10079
|
+
if (typeof o === "string") return _array_like_to_array$m(o, minLen);
|
|
10081
10080
|
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
10082
10081
|
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
10083
10082
|
if (n === "Map" || n === "Set") return Array.from(n);
|
|
10084
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$
|
|
10083
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$m(o, minLen);
|
|
10085
10084
|
}
|
|
10086
10085
|
/**
|
|
10087
|
-
|
|
10088
|
-
@param
|
|
10089
|
-
@
|
|
10086
|
+
Groups a flat array of data by one or more key accessors into nested {key, values} entries, one level per accessor. A row whose keys run out before the last level becomes a leaf at the depth where they stopped instead of leaving an empty level.
|
|
10087
|
+
@param data The flat data array to nest.
|
|
10088
|
+
@param keys One key accessor, or an array of them, one per nest level.
|
|
10090
10089
|
*/ function nest(data, keys) {
|
|
10091
10090
|
if (!_instanceof$4(keys, Array)) keys = [
|
|
10092
10091
|
keys
|
|
10093
10092
|
];
|
|
10094
10093
|
var nestedData = nestGroups(data, keys);
|
|
10095
|
-
return bubble(nestedData);
|
|
10094
|
+
return bubble(nestedData, keys.length);
|
|
10096
10095
|
}
|
|
10097
10096
|
/**
|
|
10098
10097
|
Recursively groups data by each key function, producing {key, values} objects compatible with d3-hierarchy.
|
|
@@ -10100,8 +10099,8 @@
|
|
|
10100
10099
|
@param fns An array of key accessor functions, one per nesting level.
|
|
10101
10100
|
*/ function nestGroups(data, fns) {
|
|
10102
10101
|
if (!fns.length) return data;
|
|
10103
|
-
return _to_consumable_array$
|
|
10104
|
-
var _param = _sliced_to_array$
|
|
10102
|
+
return _to_consumable_array$b(group(data, fns[0])).map(function(param) {
|
|
10103
|
+
var _param = _sliced_to_array$i(param, 2), key = _param[0], values = _param[1];
|
|
10105
10104
|
return {
|
|
10106
10105
|
key: key,
|
|
10107
10106
|
values: nestGroups(values, fns.slice(1))
|
|
@@ -10109,62 +10108,25 @@
|
|
|
10109
10108
|
});
|
|
10110
10109
|
}
|
|
10111
10110
|
/**
|
|
10112
|
-
Bubbles up values that do not nest to the furthest key
|
|
10113
|
-
|
|
10111
|
+
Bubbles up values that do not nest to the furthest key: an entry whose next
|
|
10112
|
+
level resolved to no key is replaced by its leaf row, so rows whose keys run
|
|
10113
|
+
out early become leaves at that depth instead of an empty level.
|
|
10114
|
+
@param values The entries of one nest level.
|
|
10115
|
+
@param depth The number of key levels from `values` down, inclusive.
|
|
10114
10116
|
@private
|
|
10115
|
-
*/ function bubble(values) {
|
|
10117
|
+
*/ function bubble(values, depth) {
|
|
10118
|
+
if (depth < 2) return values;
|
|
10116
10119
|
return values.map(function(d) {
|
|
10117
10120
|
if (d.key && d.values) {
|
|
10118
|
-
|
|
10119
|
-
|
|
10121
|
+
var children = d.values;
|
|
10122
|
+
var first = children[0];
|
|
10123
|
+
if (first && (first.key === undefined || first.key === "undefined")) return first.values[0];
|
|
10124
|
+
else d.values = bubble(children, depth - 1);
|
|
10120
10125
|
}
|
|
10121
10126
|
return d;
|
|
10122
10127
|
});
|
|
10123
10128
|
}
|
|
10124
10129
|
|
|
10125
|
-
/**
|
|
10126
|
-
`ResolvedSpec` + `resolveSpec(viz)` — the boundary between
|
|
10127
|
-
"config the user supplied" and "context the pipeline transforms."
|
|
10128
|
-
|
|
10129
|
-
Today the chart's class instance holds both: every `this._foo` slot is
|
|
10130
|
-
either a config the user can set (via accessors) or a derived value the
|
|
10131
|
-
pipeline writes back during `_preDraw` / `_draw` / `_paint`. The clean
|
|
10132
|
-
split is:
|
|
10133
|
-
|
|
10134
|
-
ResolvedSpec <- user config (frozen, immutable, serializable)
|
|
10135
|
-
↓
|
|
10136
|
-
VizContext <- pipeline-derived state (filteredData, drawDepth,
|
|
10137
|
-
legendData, _chartScene, etc.)
|
|
10138
|
-
|
|
10139
|
-
`resolveSpec(viz)` returns a frozen snapshot of every user-settable
|
|
10140
|
-
config key for the given viz instance. The free functions
|
|
10141
|
-
`vizPreDraw(viz)` / `vizDraw(viz)` / `runVizPipeline(viz)` /
|
|
10142
|
-
`plotPaint(viz, ctx)` all take a live viz instance — the
|
|
10143
|
-
contract that's currently shipping. `resolveSpec` is provided as a
|
|
10144
|
-
public seam so callers (custom drivers, tests, future refactors)
|
|
10145
|
-
can pin a config snapshot independently of any draw cycle. The
|
|
10146
|
-
spec type is the contract.
|
|
10147
|
-
|
|
10148
|
-
The spec is a READONLY view: mutating it is a programming error. The
|
|
10149
|
-
type uses `Readonly<>` to discourage in-place writes; runtime
|
|
10150
|
-
freezing happens in `resolveSpec()`.
|
|
10151
|
-
*/ /**
|
|
10152
|
-
Snapshot every config key from a viz instance into a frozen spec.
|
|
10153
|
-
|
|
10154
|
-
Reads the same keys `BaseClass.config()` reflects — strips the `_`
|
|
10155
|
-
prefix from every instance field whose name matches a method on the
|
|
10156
|
-
prototype (the v3/v4 config-method-is-also-the-storage-slot pattern).
|
|
10157
|
-
Returns a frozen object so consumers can't accidentally mutate it
|
|
10158
|
-
upstream of the chart.
|
|
10159
|
-
*/ function resolveSpec(viz) {
|
|
10160
|
-
// BaseClass.config() already does this reflection; reuse it.
|
|
10161
|
-
const cfg = typeof viz.config === "function" ? viz.config() : {};
|
|
10162
|
-
// Object.freeze for shallow protection. Deep freeze isn't worth the cost
|
|
10163
|
-
// (most consumers don't mutate, and accessor functions reading the spec
|
|
10164
|
-
// wouldn't trigger surface mutation anyway).
|
|
10165
|
-
return Object.freeze(cfg);
|
|
10166
|
-
}
|
|
10167
|
-
|
|
10168
10130
|
// These are typically used in conjunction with noevent to ensure that we can
|
|
10169
10131
|
// preventDefault on the event.
|
|
10170
10132
|
const nonpassivecapture = {
|
|
@@ -10417,7 +10379,7 @@
|
|
|
10417
10379
|
return brush$1(XY);
|
|
10418
10380
|
}
|
|
10419
10381
|
function brush$1(dim) {
|
|
10420
|
-
var extent = defaultExtent$1, filter = defaultFilter$1, touchable = defaultTouchable$1, keys = true, listeners = dispatch("start", "brush", "end"), handleSize = 6, touchending;
|
|
10382
|
+
var extent = defaultExtent$1, filter = defaultFilter$1, touchable = defaultTouchable$1, keys = true, listeners = dispatch$1("start", "brush", "end"), handleSize = 6, touchending;
|
|
10421
10383
|
function brush(group) {
|
|
10422
10384
|
var overlay = group.property("__brush", initialize).selectAll(".overlay").data([
|
|
10423
10385
|
type("overlay")
|
|
@@ -13224,7 +13186,7 @@
|
|
|
13224
13186
|
Infinity,
|
|
13225
13187
|
Infinity
|
|
13226
13188
|
]
|
|
13227
|
-
], duration = 250, interpolate = interpolateZoom, listeners = dispatch("start", "zoom", "end"), touchstarting, touchfirst, touchending, touchDelay = 500, wheelDelay = 150, clickDistance2 = 0, tapDistance = 10;
|
|
13189
|
+
], duration = 250, interpolate = interpolateZoom, listeners = dispatch$1("start", "zoom", "end"), touchstarting, touchfirst, touchending, touchDelay = 500, wheelDelay = 150, clickDistance2 = 0, tapDistance = 10;
|
|
13228
13190
|
function zoom(selection) {
|
|
13229
13191
|
selection.property("__zoom", defaultTransform).on("wheel.zoom", wheeled, {
|
|
13230
13192
|
passive: false
|
|
@@ -13810,15 +13772,15 @@
|
|
|
13810
13772
|
}
|
|
13811
13773
|
}
|
|
13812
13774
|
|
|
13813
|
-
function _array_like_to_array$
|
|
13775
|
+
function _array_like_to_array$l(arr, len) {
|
|
13814
13776
|
if (len == null || len > arr.length) len = arr.length;
|
|
13815
13777
|
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
13816
13778
|
return arr2;
|
|
13817
13779
|
}
|
|
13818
|
-
function _array_with_holes$
|
|
13780
|
+
function _array_with_holes$h(arr) {
|
|
13819
13781
|
if (Array.isArray(arr)) return arr;
|
|
13820
13782
|
}
|
|
13821
|
-
function _iterable_to_array_limit$
|
|
13783
|
+
function _iterable_to_array_limit$h(arr, i) {
|
|
13822
13784
|
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
13823
13785
|
if (_i == null) return;
|
|
13824
13786
|
var _arr = [];
|
|
@@ -13842,19 +13804,19 @@
|
|
|
13842
13804
|
}
|
|
13843
13805
|
return _arr;
|
|
13844
13806
|
}
|
|
13845
|
-
function _non_iterable_rest$
|
|
13807
|
+
function _non_iterable_rest$h() {
|
|
13846
13808
|
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
13847
13809
|
}
|
|
13848
|
-
function _sliced_to_array$
|
|
13849
|
-
return _array_with_holes$
|
|
13810
|
+
function _sliced_to_array$h(arr, i) {
|
|
13811
|
+
return _array_with_holes$h(arr) || _iterable_to_array_limit$h(arr, i) || _unsupported_iterable_to_array$l(arr, i) || _non_iterable_rest$h();
|
|
13850
13812
|
}
|
|
13851
|
-
function _unsupported_iterable_to_array$
|
|
13813
|
+
function _unsupported_iterable_to_array$l(o, minLen) {
|
|
13852
13814
|
if (!o) return;
|
|
13853
|
-
if (typeof o === "string") return _array_like_to_array$
|
|
13815
|
+
if (typeof o === "string") return _array_like_to_array$l(o, minLen);
|
|
13854
13816
|
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
13855
13817
|
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
13856
13818
|
if (n === "Map" || n === "Set") return Array.from(n);
|
|
13857
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$
|
|
13819
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$l(o, minLen);
|
|
13858
13820
|
}
|
|
13859
13821
|
var s2lin = function s2lin(c) {
|
|
13860
13822
|
return c <= 0.04045 ? c / 12.92 : Math.pow((c + 0.055) / 1.055, 2.4);
|
|
@@ -13875,7 +13837,7 @@
|
|
|
13875
13837
|
Converts a CSS color string to OKLab.
|
|
13876
13838
|
@param c A valid CSS color string.
|
|
13877
13839
|
*/ function colorToOklab(c) {
|
|
13878
|
-
var _linearRGB = _sliced_to_array$
|
|
13840
|
+
var _linearRGB = _sliced_to_array$h(linearRGB(c), 3), r = _linearRGB[0], g = _linearRGB[1], b = _linearRGB[2];
|
|
13879
13841
|
var l = Math.cbrt(0.4122214708 * r + 0.5363325363 * g + 0.0514459929 * b);
|
|
13880
13842
|
var m = Math.cbrt(0.2119034982 * r + 0.6806995451 * g + 0.1073969566 * b);
|
|
13881
13843
|
var s = Math.cbrt(0.0883024619 * r + 0.2817188376 * g + 0.6299787005 * b);
|
|
@@ -13926,7 +13888,7 @@
|
|
|
13926
13888
|
The WCAG 2.x relative luminance of a color (0 = black, 1 = white).
|
|
13927
13889
|
@param c A valid CSS color string.
|
|
13928
13890
|
*/ function relativeLuminance(c) {
|
|
13929
|
-
var _linearRGB = _sliced_to_array$
|
|
13891
|
+
var _linearRGB = _sliced_to_array$h(linearRGB(c), 3), r = _linearRGB[0], g = _linearRGB[1], b = _linearRGB[2];
|
|
13930
13892
|
return 0.2126 * r + 0.7152 * g + 0.0722 * b;
|
|
13931
13893
|
}
|
|
13932
13894
|
/**
|
|
@@ -13934,7 +13896,7 @@
|
|
|
13934
13896
|
@param a A valid CSS color string.
|
|
13935
13897
|
@param b A valid CSS color string.
|
|
13936
13898
|
*/ function contrastRatio(a, b) {
|
|
13937
|
-
var _sort = _sliced_to_array$
|
|
13899
|
+
var _sort = _sliced_to_array$h([
|
|
13938
13900
|
relativeLuminance(a),
|
|
13939
13901
|
relativeLuminance(b)
|
|
13940
13902
|
].sort(function(x, y) {
|
|
@@ -14027,7 +13989,9 @@
|
|
|
14027
13989
|
return steps;
|
|
14028
13990
|
}
|
|
14029
13991
|
|
|
14030
|
-
|
|
13992
|
+
/**
|
|
13993
|
+
Translations of the strings d3plus renders in its own UI (legend and timeline controls, zoom buttons, the table view, tooltip hints), keyed by locale code such as `en-US` or `es-ES`. Each entry maps the English string to its translation.
|
|
13994
|
+
*/ var translateLocale = {
|
|
14031
13995
|
"ar-SA": {
|
|
14032
13996
|
and: "\u0648",
|
|
14033
13997
|
Back: "\u0644\u0644\u062e\u0644\u0641",
|
|
@@ -14055,6 +14019,7 @@
|
|
|
14055
14019
|
Polynomial: "\u0645\u062a\u0639\u062f\u062f \u0627\u0644\u062d\u062f\u0648\u062f",
|
|
14056
14020
|
Power: "\u0642\u0648\u0629",
|
|
14057
14021
|
"Powered by D3plus": "\u0645\u062f\u0639\u0648\u0645 \u0628\u0648\u0627\u0633\u0637\u0629 D3plus",
|
|
14022
|
+
Projected: "\u0645\u062a\u0648\u0642\u0639",
|
|
14058
14023
|
Range: "\u0627\u0644\u0646\u0637\u0627\u0642",
|
|
14059
14024
|
"Relative Frequency": "\u0627\u0644\u062a\u0643\u0631\u0627\u0631 \u0627\u0644\u0646\u0633\u0628\u064a",
|
|
14060
14025
|
"Reset Zoom": "\u0625\u0639\u0627\u062f\u0629 \u062a\u0639\u064a\u064a\u0646 \u0627\u0644\u062a\u0643\u0628\u064a\u0631",
|
|
@@ -14096,6 +14061,7 @@
|
|
|
14096
14061
|
Polynomial: "Polin\u00f3mica",
|
|
14097
14062
|
Power: "Potencial",
|
|
14098
14063
|
"Powered by D3plus": "Funciona con D3plus",
|
|
14064
|
+
Projected: "Proyectado",
|
|
14099
14065
|
Range: "Rango",
|
|
14100
14066
|
"Relative Frequency": "Frecuencia Relativa",
|
|
14101
14067
|
"Reset Zoom": "Restablecer Zoom",
|
|
@@ -14137,6 +14103,7 @@
|
|
|
14137
14103
|
Polynomial: "Polinomial",
|
|
14138
14104
|
Power: "Pot\u00eancia",
|
|
14139
14105
|
"Powered by D3plus": "Funciona com D3plus",
|
|
14106
|
+
Projected: "Projetado",
|
|
14140
14107
|
Range: "Intervalo",
|
|
14141
14108
|
"Relative Frequency": "Frequ\u00eancia Relativa",
|
|
14142
14109
|
"Reset Zoom": "Redefinir Zoom",
|
|
@@ -14178,6 +14145,7 @@
|
|
|
14178
14145
|
Polynomial: "\u591a\u9879\u5f0f",
|
|
14179
14146
|
Power: "\u5e42",
|
|
14180
14147
|
"Powered by D3plus": "\u7531 D3plus \u63d0\u4f9b\u652f\u6301",
|
|
14148
|
+
Projected: "\u9884\u6d4b",
|
|
14181
14149
|
Range: "\u8303\u56f4",
|
|
14182
14150
|
"Relative Frequency": "\u76f8\u5bf9\u9891\u7387",
|
|
14183
14151
|
"Reset Zoom": "\u91cd\u7f6e\u7f29\u653e",
|
|
@@ -14529,7 +14497,9 @@
|
|
|
14529
14497
|
}
|
|
14530
14498
|
};
|
|
14531
14499
|
|
|
14532
|
-
|
|
14500
|
+
/**
|
|
14501
|
+
d3-time-format locale definitions (date and time patterns, period, day, and month names) keyed by locale code, used when formatting dates on axes, timelines, and tooltips.
|
|
14502
|
+
*/ var locale = {
|
|
14533
14503
|
"ar-SA": {
|
|
14534
14504
|
dateTime: "%x, %X",
|
|
14535
14505
|
date: "%-m/%-d/%Y",
|
|
@@ -24841,7 +24811,7 @@
|
|
|
24841
24811
|
}
|
|
24842
24812
|
};
|
|
24843
24813
|
|
|
24844
|
-
function _define_property$
|
|
24814
|
+
function _define_property$a(obj, key, value) {
|
|
24845
24815
|
if (key in obj) {
|
|
24846
24816
|
Object.defineProperty(obj, key, {
|
|
24847
24817
|
value: value,
|
|
@@ -24863,7 +24833,7 @@
|
|
|
24863
24833
|
});
|
|
24864
24834
|
if (locale.location && isoLanguage) {
|
|
24865
24835
|
var _obj;
|
|
24866
|
-
locales.push((_obj = {}, _define_property$
|
|
24836
|
+
locales.push((_obj = {}, _define_property$a(_obj, "name", locale.language), _define_property$a(_obj, "location", locale.location), _define_property$a(_obj, "tag", locale.tag), _define_property$a(_obj, "lcid", locale.id), _define_property$a(_obj, "iso639-2", isoCodes[isoLanguage]["iso639-2"]), _define_property$a(_obj, "iso639-1", isoCodes[isoLanguage]["iso639-1"]), _obj));
|
|
24867
24837
|
}
|
|
24868
24838
|
});
|
|
24869
24839
|
var defaultLocales = {
|
|
@@ -24969,15 +24939,15 @@
|
|
|
24969
24939
|
.replace(/\.[0]*$/g, ""); // removes any trailing decimal point
|
|
24970
24940
|
}
|
|
24971
24941
|
|
|
24972
|
-
function _array_like_to_array$
|
|
24942
|
+
function _array_like_to_array$k(arr, len) {
|
|
24973
24943
|
if (len == null || len > arr.length) len = arr.length;
|
|
24974
24944
|
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
24975
24945
|
return arr2;
|
|
24976
24946
|
}
|
|
24977
|
-
function _array_with_holes$
|
|
24947
|
+
function _array_with_holes$g(arr) {
|
|
24978
24948
|
if (Array.isArray(arr)) return arr;
|
|
24979
24949
|
}
|
|
24980
|
-
function _iterable_to_array_limit$
|
|
24950
|
+
function _iterable_to_array_limit$g(arr, i) {
|
|
24981
24951
|
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
24982
24952
|
if (_i == null) return;
|
|
24983
24953
|
var _arr = [];
|
|
@@ -25001,19 +24971,19 @@
|
|
|
25001
24971
|
}
|
|
25002
24972
|
return _arr;
|
|
25003
24973
|
}
|
|
25004
|
-
function _non_iterable_rest$
|
|
24974
|
+
function _non_iterable_rest$g() {
|
|
25005
24975
|
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
25006
24976
|
}
|
|
25007
|
-
function _sliced_to_array$
|
|
25008
|
-
return _array_with_holes$
|
|
24977
|
+
function _sliced_to_array$g(arr, i) {
|
|
24978
|
+
return _array_with_holes$g(arr) || _iterable_to_array_limit$g(arr, i) || _unsupported_iterable_to_array$k(arr, i) || _non_iterable_rest$g();
|
|
25009
24979
|
}
|
|
25010
|
-
function _unsupported_iterable_to_array$
|
|
24980
|
+
function _unsupported_iterable_to_array$k(o, minLen) {
|
|
25011
24981
|
if (!o) return;
|
|
25012
|
-
if (typeof o === "string") return _array_like_to_array$
|
|
24982
|
+
if (typeof o === "string") return _array_like_to_array$k(o, minLen);
|
|
25013
24983
|
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
25014
24984
|
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
25015
24985
|
if (n === "Map" || n === "Set") return Array.from(n);
|
|
25016
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$
|
|
24986
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$k(o, minLen);
|
|
25017
24987
|
}
|
|
25018
24988
|
/**
|
|
25019
24989
|
A default set of date formatters, which takes into account both the interval in between in each data point but also the start/end data points.
|
|
@@ -25028,7 +24998,7 @@
|
|
|
25028
24998
|
});
|
|
25029
24999
|
var firstOrLast = labelIndex === 0 || labelIndex === dataArray.length - 1;
|
|
25030
25000
|
var smallArray = dataArray.length <= 5;
|
|
25031
|
-
var _dataArray_reduce = _sliced_to_array$
|
|
25001
|
+
var _dataArray_reduce = _sliced_to_array$g(dataArray.reduce(function(arr, d, i) {
|
|
25032
25002
|
if (i) {
|
|
25033
25003
|
arr[0].push(d.getFullYear() - dataArray[i - 1].getFullYear());
|
|
25034
25004
|
arr[1].push(monthDiff(dataArray[i - 1], d));
|
|
@@ -30411,21 +30381,21 @@
|
|
|
30411
30381
|
|
|
30412
30382
|
var hyphenatedExports = requireHyphenated();
|
|
30413
30383
|
|
|
30414
|
-
function _array_like_to_array$
|
|
30384
|
+
function _array_like_to_array$j(arr, len) {
|
|
30415
30385
|
if (len == null || len > arr.length) len = arr.length;
|
|
30416
30386
|
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
30417
30387
|
return arr2;
|
|
30418
30388
|
}
|
|
30419
|
-
function _array_with_holes$
|
|
30389
|
+
function _array_with_holes$f(arr) {
|
|
30420
30390
|
if (Array.isArray(arr)) return arr;
|
|
30421
30391
|
}
|
|
30422
|
-
function _array_without_holes$
|
|
30423
|
-
if (Array.isArray(arr)) return _array_like_to_array$
|
|
30392
|
+
function _array_without_holes$a(arr) {
|
|
30393
|
+
if (Array.isArray(arr)) return _array_like_to_array$j(arr);
|
|
30424
30394
|
}
|
|
30425
|
-
function _iterable_to_array$
|
|
30395
|
+
function _iterable_to_array$a(iter) {
|
|
30426
30396
|
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
30427
30397
|
}
|
|
30428
|
-
function _iterable_to_array_limit$
|
|
30398
|
+
function _iterable_to_array_limit$f(arr, i) {
|
|
30429
30399
|
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
30430
30400
|
if (_i == null) return;
|
|
30431
30401
|
var _arr = [];
|
|
@@ -30449,25 +30419,25 @@
|
|
|
30449
30419
|
}
|
|
30450
30420
|
return _arr;
|
|
30451
30421
|
}
|
|
30452
|
-
function _non_iterable_rest$
|
|
30422
|
+
function _non_iterable_rest$f() {
|
|
30453
30423
|
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
30454
30424
|
}
|
|
30455
|
-
function _non_iterable_spread$
|
|
30425
|
+
function _non_iterable_spread$a() {
|
|
30456
30426
|
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
30457
30427
|
}
|
|
30458
|
-
function _sliced_to_array$
|
|
30459
|
-
return _array_with_holes$
|
|
30428
|
+
function _sliced_to_array$f(arr, i) {
|
|
30429
|
+
return _array_with_holes$f(arr) || _iterable_to_array_limit$f(arr, i) || _unsupported_iterable_to_array$j(arr, i) || _non_iterable_rest$f();
|
|
30460
30430
|
}
|
|
30461
|
-
function _to_consumable_array$
|
|
30462
|
-
return _array_without_holes$
|
|
30431
|
+
function _to_consumable_array$a(arr) {
|
|
30432
|
+
return _array_without_holes$a(arr) || _iterable_to_array$a(arr) || _unsupported_iterable_to_array$j(arr) || _non_iterable_spread$a();
|
|
30463
30433
|
}
|
|
30464
|
-
function _unsupported_iterable_to_array$
|
|
30434
|
+
function _unsupported_iterable_to_array$j(o, minLen) {
|
|
30465
30435
|
if (!o) return;
|
|
30466
|
-
if (typeof o === "string") return _array_like_to_array$
|
|
30436
|
+
if (typeof o === "string") return _array_like_to_array$j(o, minLen);
|
|
30467
30437
|
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
30468
30438
|
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
30469
30439
|
if (n === "Map" || n === "Set") return Array.from(n);
|
|
30470
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$
|
|
30440
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$j(o, minLen);
|
|
30471
30441
|
}
|
|
30472
30442
|
var cjkRange = /[\u3000-\u9FFF\uF900-\uFAFF]/;
|
|
30473
30443
|
var emojiRange = RegExp("[\\u00A9\\u00AE\\u203C\\u2049\\u2122\\u2139\\u2194-\\u2199\\u21A9-\\u21AA\\u231A-\\u231B\\u2328\\u23CF\\u23E9-\\u23F3\\u23F8-\\u23FA\\u24C2\\u25AA-\\u25AB\\u25B6\\u25C0\\u25FB-\\u25FE\\u2600-\\u2604\\u260E\\u2611\\u2614-\\u2615\\u2618\\u261D\\u2620\\u2622-\\u2623\\u2626\\u262A\\u262E-\\u262F\\u2638-\\u263A\\u2640\\u2642\\u2648-\\u2653\\u265F-\\u2660\\u2663\\u2665-\\u2666\\u2668\\u267B\\u267E-\\u267F\\u2692-\\u2697\\u2699\\u269B-\\u269C\\u26A0-\\u26A1\\u26A7\\u26AA-\\u26AB\\u26B0-\\u26B1\\u26BD-\\u26BE\\u26C4-\\u26C5\\u26C8\\u26CE-\\u26CF\\u26D1\\u26D3-\\u26D4\\u26E9-\\u26EA\\u26F0-\\u26F5\\u26F7-\\u26FA\\u26FD\\u2702\\u2705\\u2708-\\u270D\\u270F\\u2712\\u2714\\u2716\\u271D\\u2721\\u2728\\u2733-\\u2734\\u2744\\u2747\\u274C\\u274E\\u2753-\\u2755\\u2757\\u2763-\\u2764\\u2795-\\u2797\\u27A1\\u27B0\\u27BF\\u2934-\\u2935\\u2B05-\\u2B07\\u2B1B-\\u2B1C\\u2B50\\u2B55\\u3030\\u303D\\u3297\\u3299\\u{1F004}\\u{1F02C}-\\u{1F02F}\\u{1F094}-\\u{1F09F}\\u{1F0AF}-\\u{1F0B0}\\u{1F0C0}\\u{1F0CF}-\\u{1F0D0}\\u{1F0F6}-\\u{1F0FF}\\u{1F170}-\\u{1F171}\\u{1F17E}-\\u{1F17F}\\u{1F18E}\\u{1F191}-\\u{1F19A}\\u{1F1AE}-\\u{1F1E5}\\u{1F201}-\\u{1F20F}\\u{1F21A}\\u{1F22F}\\u{1F232}-\\u{1F23A}\\u{1F23C}-\\u{1F23F}\\u{1F249}-\\u{1F25F}\\u{1F266}-\\u{1F321}\\u{1F324}-\\u{1F393}\\u{1F396}-\\u{1F397}\\u{1F399}-\\u{1F39B}\\u{1F39E}-\\u{1F3F0}\\u{1F3F3}-\\u{1F3F5}\\u{1F3F7}-\\u{1F3FA}\\u{1F400}-\\u{1F4FD}\\u{1F4FF}-\\u{1F53D}\\u{1F549}-\\u{1F54E}\\u{1F550}-\\u{1F567}\\u{1F56F}-\\u{1F570}\\u{1F573}-\\u{1F57A}\\u{1F587}\\u{1F58A}-\\u{1F58D}\\u{1F590}\\u{1F595}-\\u{1F596}\\u{1F5A4}-\\u{1F5A5}\\u{1F5A8}\\u{1F5B1}-\\u{1F5B2}\\u{1F5BC}\\u{1F5C2}-\\u{1F5C4}\\u{1F5D1}-\\u{1F5D3}\\u{1F5DC}-\\u{1F5DE}\\u{1F5E1}\\u{1F5E3}\\u{1F5E8}\\u{1F5EF}\\u{1F5F3}\\u{1F5FA}-\\u{1F64F}\\u{1F680}-\\u{1F6C5}\\u{1F6CB}-\\u{1F6D2}\\u{1F6D5}-\\u{1F6E5}\\u{1F6E9}\\u{1F6EB}-\\u{1F6F0}\\u{1F6F3}-\\u{1F6FF}\\u{1F7DA}-\\u{1F7FF}\\u{1F80C}-\\u{1F80F}\\u{1F848}-\\u{1F84F}\\u{1F85A}-\\u{1F85F}\\u{1F888}-\\u{1F88F}\\u{1F8AE}-\\u{1F8AF}\\u{1F8BC}-\\u{1F8BF}\\u{1F8C2}-\\u{1F8CF}\\u{1F8D9}-\\u{1F8FF}\\u{1F90C}-\\u{1F93A}\\u{1F93C}-\\u{1F945}\\u{1F947}-\\u{1F9FF}\\u{1FA58}-\\u{1FA5F}\\u{1FA6E}-\\u{1FAFF}\\u{1FC00}-\\u{1FFFD}]", "u");
|
|
@@ -30488,7 +30458,7 @@
|
|
|
30488
30458
|
if (!match) return [
|
|
30489
30459
|
word
|
|
30490
30460
|
];
|
|
30491
|
-
var _match = _sliced_to_array$
|
|
30461
|
+
var _match = _sliced_to_array$f(match, 3), text = _match[1], trailing = _match[2];
|
|
30492
30462
|
if (text.length < minHyphenLength) return [
|
|
30493
30463
|
word
|
|
30494
30464
|
];
|
|
@@ -30534,7 +30504,7 @@
|
|
|
30534
30504
|
var word = _step.value;
|
|
30535
30505
|
var _result;
|
|
30536
30506
|
var syllables = hyphenate(word);
|
|
30537
|
-
(_result = result).push.apply(_result, _to_consumable_array$
|
|
30507
|
+
(_result = result).push.apply(_result, _to_consumable_array$a(syllables));
|
|
30538
30508
|
}
|
|
30539
30509
|
} catch (err) {
|
|
30540
30510
|
_didIteratorError = true;
|
|
@@ -30553,15 +30523,15 @@
|
|
|
30553
30523
|
return result;
|
|
30554
30524
|
}
|
|
30555
30525
|
|
|
30556
|
-
function _array_like_to_array$
|
|
30526
|
+
function _array_like_to_array$i(arr, len) {
|
|
30557
30527
|
if (len == null || len > arr.length) len = arr.length;
|
|
30558
30528
|
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
30559
30529
|
return arr2;
|
|
30560
30530
|
}
|
|
30561
|
-
function _array_without_holes$
|
|
30562
|
-
if (Array.isArray(arr)) return _array_like_to_array$
|
|
30531
|
+
function _array_without_holes$9(arr) {
|
|
30532
|
+
if (Array.isArray(arr)) return _array_like_to_array$i(arr);
|
|
30563
30533
|
}
|
|
30564
|
-
function _define_property$
|
|
30534
|
+
function _define_property$9(obj, key, value) {
|
|
30565
30535
|
if (key in obj) {
|
|
30566
30536
|
Object.defineProperty(obj, key, {
|
|
30567
30537
|
value: value,
|
|
@@ -30582,13 +30552,13 @@
|
|
|
30582
30552
|
return left instanceof right;
|
|
30583
30553
|
}
|
|
30584
30554
|
}
|
|
30585
|
-
function _iterable_to_array$
|
|
30555
|
+
function _iterable_to_array$9(iter) {
|
|
30586
30556
|
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
30587
30557
|
}
|
|
30588
|
-
function _non_iterable_spread$
|
|
30558
|
+
function _non_iterable_spread$9() {
|
|
30589
30559
|
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
30590
30560
|
}
|
|
30591
|
-
function _object_spread$
|
|
30561
|
+
function _object_spread$4(target) {
|
|
30592
30562
|
for(var i = 1; i < arguments.length; i++){
|
|
30593
30563
|
var source = arguments[i] != null ? arguments[i] : {};
|
|
30594
30564
|
var ownKeys = Object.keys(source);
|
|
@@ -30598,7 +30568,7 @@
|
|
|
30598
30568
|
}));
|
|
30599
30569
|
}
|
|
30600
30570
|
ownKeys.forEach(function(key) {
|
|
30601
|
-
_define_property$
|
|
30571
|
+
_define_property$9(target, key, source[key]);
|
|
30602
30572
|
});
|
|
30603
30573
|
}
|
|
30604
30574
|
return target;
|
|
@@ -30622,20 +30592,20 @@
|
|
|
30622
30592
|
}
|
|
30623
30593
|
return target;
|
|
30624
30594
|
}
|
|
30625
|
-
function _to_consumable_array$
|
|
30626
|
-
return _array_without_holes$
|
|
30595
|
+
function _to_consumable_array$9(arr) {
|
|
30596
|
+
return _array_without_holes$9(arr) || _iterable_to_array$9(arr) || _unsupported_iterable_to_array$i(arr) || _non_iterable_spread$9();
|
|
30627
30597
|
}
|
|
30628
30598
|
function _type_of(obj) {
|
|
30629
30599
|
"@swc/helpers - typeof";
|
|
30630
30600
|
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
30631
30601
|
}
|
|
30632
|
-
function _unsupported_iterable_to_array$
|
|
30602
|
+
function _unsupported_iterable_to_array$i(o, minLen) {
|
|
30633
30603
|
if (!o) return;
|
|
30634
|
-
if (typeof o === "string") return _array_like_to_array$
|
|
30604
|
+
if (typeof o === "string") return _array_like_to_array$i(o, minLen);
|
|
30635
30605
|
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
30636
30606
|
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
30637
30607
|
if (n === "Map" || n === "Set") return Array.from(n);
|
|
30638
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$
|
|
30608
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$i(o, minLen);
|
|
30639
30609
|
}
|
|
30640
30610
|
var softHyphen = "\u00AD";
|
|
30641
30611
|
/**
|
|
@@ -30647,20 +30617,11 @@
|
|
|
30647
30617
|
if (typeof value === "string" || _instanceof$3(value, String)) return value;
|
|
30648
30618
|
return JSON.stringify(value);
|
|
30649
30619
|
}
|
|
30650
|
-
|
|
30651
|
-
Runs the word-flow loop once. `lineWidth(line)` receives the 1-based line
|
|
30652
|
-
number and returns the width allowed for that line, so callers can vary the
|
|
30653
|
-
available width per line — a constant for a rectangle, or the circle's chord
|
|
30654
|
-
at that line's height for a circle.
|
|
30655
|
-
@private
|
|
30656
|
-
*/ function flowWords(words, sizes, config, lineWidth) {
|
|
30620
|
+
function flowWords(words, sizes, gaps, config, lineWidth) {
|
|
30657
30621
|
var height = config.height, lineHeight = config.lineHeight, maxLines = config.maxLines, overflow = config.overflow;
|
|
30658
30622
|
var line = 1, textProg = "", truncated = false, widthProg = 0;
|
|
30659
|
-
var lineData = [], //
|
|
30660
|
-
//
|
|
30661
|
-
// line as a single string (e.g. a soft hyphen counts toward the break
|
|
30662
|
-
// decision but is stripped from the rendered line, and trailing spaces
|
|
30663
|
-
// measure as 0).
|
|
30623
|
+
var lineData = [], // widths the break logic compared against the line's allowed width, plus
|
|
30624
|
+
// the gaps between them, which tracks the rendered line.
|
|
30664
30625
|
lineWidths = [];
|
|
30665
30626
|
for(var i = 0; i < words.length; i++){
|
|
30666
30627
|
var word = words[i];
|
|
@@ -30669,8 +30630,11 @@
|
|
|
30669
30630
|
// this loop once per candidate line count.
|
|
30670
30631
|
var wordWidth = sizes[i];
|
|
30671
30632
|
var width = lineWidth(line);
|
|
30633
|
+
// A line ending in a soft hyphen gives that hyphen's width back if the
|
|
30634
|
+
// next syllable joins it, so the fit check is made without it.
|
|
30635
|
+
var joinHyphen = i && lineData[line - 1] && lineData[line - 1].endsWith(softHyphen) ? gaps.hyphen : 0;
|
|
30672
30636
|
// newline if breaking character or not enough width
|
|
30673
|
-
if (textProg.slice(-1) === "\n" || widthProg + wordWidth > width) {
|
|
30637
|
+
if (textProg.slice(-1) === "\n" || widthProg - joinHyphen + wordWidth > width) {
|
|
30674
30638
|
if (!i && !overflow) {
|
|
30675
30639
|
truncated = true;
|
|
30676
30640
|
break;
|
|
@@ -30698,15 +30662,21 @@
|
|
|
30698
30662
|
}
|
|
30699
30663
|
} else if (!i) lineData[0] = word;
|
|
30700
30664
|
else {
|
|
30701
|
-
// Strip soft hyphen when syllables stay on the same line
|
|
30702
|
-
|
|
30665
|
+
// Strip the soft hyphen when syllables stay on the same line; its glyph
|
|
30666
|
+
// was counted with the previous syllable and no longer renders.
|
|
30667
|
+
if (joinHyphen) {
|
|
30703
30668
|
lineData[line - 1] = lineData[line - 1].slice(0, -1);
|
|
30669
|
+
widthProg -= joinHyphen;
|
|
30704
30670
|
}
|
|
30705
30671
|
lineData[line - 1] += word;
|
|
30706
30672
|
}
|
|
30707
30673
|
textProg += word;
|
|
30708
30674
|
widthProg += wordWidth;
|
|
30709
30675
|
lineWidths[line - 1] = widthProg;
|
|
30676
|
+
// A word's measured width stops at its last glyph, so the space it
|
|
30677
|
+
// carries only takes up room once another word follows it on the line.
|
|
30678
|
+
// Rendered text collapses a run of spaces to one, so a run counts once.
|
|
30679
|
+
if (endsWithSpace(word)) widthProg += gaps.space;
|
|
30710
30680
|
}
|
|
30711
30681
|
return {
|
|
30712
30682
|
lineData: lineData,
|
|
@@ -30714,6 +30684,9 @@
|
|
|
30714
30684
|
truncated: truncated
|
|
30715
30685
|
};
|
|
30716
30686
|
}
|
|
30687
|
+
/** Whether a word carries one or more ordinary spaces after it. */ function endsWithSpace(word) {
|
|
30688
|
+
return / $/.test(word);
|
|
30689
|
+
}
|
|
30717
30690
|
/**
|
|
30718
30691
|
Builds a per-line width function for `total` vertically-centered lines
|
|
30719
30692
|
inside a circle of the given radius. Each line is measured at whichever of
|
|
@@ -30757,10 +30730,10 @@
|
|
|
30757
30730
|
text is simply too big), it returns the attempt that spills the least and
|
|
30758
30731
|
reports truncation, so a resizing caller shrinks the font and tries again.
|
|
30759
30732
|
@private
|
|
30760
|
-
*/ function flowCircle(words, sizes, config, style) {
|
|
30733
|
+
*/ function flowCircle(words, sizes, gaps, config, style) {
|
|
30761
30734
|
var _loop = function(n) {
|
|
30762
30735
|
var _Math;
|
|
30763
|
-
var pass = flowWords(words, sizes, _object_spread_props$3(_object_spread$
|
|
30736
|
+
var pass = flowWords(words, sizes, gaps, _object_spread_props$3(_object_spread$4({}, config), {
|
|
30764
30737
|
maxLines: n
|
|
30765
30738
|
}), circleLineWidth(radius, n, lineHeight, fontSize));
|
|
30766
30739
|
if (pass.truncated) return "continue";
|
|
@@ -30772,18 +30745,18 @@
|
|
|
30772
30745
|
var chord = circleLineWidth(radius, pass.lineData.length, lineHeight, fontSize);
|
|
30773
30746
|
var over = (_Math = Math).max.apply(_Math, [
|
|
30774
30747
|
0
|
|
30775
|
-
].concat(_to_consumable_array$
|
|
30748
|
+
].concat(_to_consumable_array$9(visibleWidths.map(function(w, i) {
|
|
30776
30749
|
return w - chord(i + 1);
|
|
30777
30750
|
}))));
|
|
30778
30751
|
// `overflow` opts out of containment — let the text spill, as the flag asks.
|
|
30779
30752
|
if (overflow || over <= 0) return {
|
|
30780
|
-
v: _object_spread_props$3(_object_spread$
|
|
30753
|
+
v: _object_spread_props$3(_object_spread$4({}, pass), {
|
|
30781
30754
|
visibleWidths: visibleWidths
|
|
30782
30755
|
})
|
|
30783
30756
|
};
|
|
30784
30757
|
if (over < bestOverflow) {
|
|
30785
30758
|
bestOverflow = over;
|
|
30786
|
-
best = _object_spread_props$3(_object_spread$
|
|
30759
|
+
best = _object_spread_props$3(_object_spread$4({}, pass), {
|
|
30787
30760
|
visibleWidths: visibleWidths
|
|
30788
30761
|
});
|
|
30789
30762
|
}
|
|
@@ -30803,7 +30776,7 @@
|
|
|
30803
30776
|
var _ret = _loop(n);
|
|
30804
30777
|
if (_type_of(_ret) === "object") return _ret.v;
|
|
30805
30778
|
}
|
|
30806
|
-
if (best) return _object_spread_props$3(_object_spread$
|
|
30779
|
+
if (best) return _object_spread_props$3(_object_spread$4({}, best), {
|
|
30807
30780
|
truncated: true
|
|
30808
30781
|
});
|
|
30809
30782
|
// No line count produced even an untruncated layout. Fall back to a plain
|
|
@@ -30811,10 +30784,10 @@
|
|
|
30811
30784
|
// size and re-wraps into something that fits — returning a non-truncated
|
|
30812
30785
|
// result would claim the text fit and leave it overflowing the circle. Empty
|
|
30813
30786
|
// input (no words) is genuinely not truncated, so leave that flag alone.
|
|
30814
|
-
var fallback = flowWords(words, sizes, config, function() {
|
|
30787
|
+
var fallback = flowWords(words, sizes, gaps, config, function() {
|
|
30815
30788
|
return 2 * radius;
|
|
30816
30789
|
});
|
|
30817
|
-
return words.length ? _object_spread_props$3(_object_spread$
|
|
30790
|
+
return words.length ? _object_spread_props$3(_object_spread$4({}, fallback), {
|
|
30818
30791
|
truncated: true
|
|
30819
30792
|
}) : fallback;
|
|
30820
30793
|
}
|
|
@@ -30832,7 +30805,16 @@
|
|
|
30832
30805
|
"line-height": config.lineHeight
|
|
30833
30806
|
};
|
|
30834
30807
|
var sizes = textWidth(words, style);
|
|
30835
|
-
|
|
30808
|
+
// Measurement stops at a word's last glyph, so the spaces between words
|
|
30809
|
+
// are counted separately. A non-breaking space keeps the font's space
|
|
30810
|
+
// advance where a trailing ordinary space collapses to nothing. The soft
|
|
30811
|
+
// hyphen ending a syllable measures as the hyphen it renders at a break,
|
|
30812
|
+
// which the loop removes again when syllables stay together.
|
|
30813
|
+
var gaps = {
|
|
30814
|
+
space: textWidth("\u00a0", style),
|
|
30815
|
+
hyphen: textWidth(softHyphen, style) || textWidth("-", style)
|
|
30816
|
+
};
|
|
30817
|
+
var _ref = shape === "circle" ? flowCircle(words, sizes, gaps, config, style) : flowWords(words, sizes, gaps, config, function() {
|
|
30836
30818
|
return width;
|
|
30837
30819
|
}), lineData = _ref.lineData, lineWidths = _ref.lineWidths, truncated = _ref.truncated, visibleWidths = _ref.visibleWidths;
|
|
30838
30820
|
// Clean remaining soft hyphens from all lines
|
|
@@ -30974,7 +30956,14 @@
|
|
|
30974
30956
|
const wrap = textWrap().fontFamily(fF).fontSize(fS).lineHeight(axis.schema.shapeConfig.lineHeight ? axis.schema.shapeConfig.lineHeight(d, i) : undefined);
|
|
30975
30957
|
wrap[w](horizontal ? space : wSize - hBuff - p - axis._margin.left - axis._margin.right);
|
|
30976
30958
|
wrap[h](horizontal ? hSize - hBuff - p - axis._margin.top - axis._margin.bottom : space);
|
|
30977
|
-
const
|
|
30959
|
+
const text = tickFormat(d);
|
|
30960
|
+
let res = wrap(text);
|
|
30961
|
+
// A label wider than its share of the axis wraps to nothing; measure it
|
|
30962
|
+
// across the whole axis instead, so the overlap pass thins the labels out.
|
|
30963
|
+
if (horizontal && !rotate && `${text}`.trim() && !res.lines.some((l)=>l !== "")) {
|
|
30964
|
+
wrap.width(wSize - p * 2);
|
|
30965
|
+
res = wrap(text);
|
|
30966
|
+
}
|
|
30978
30967
|
res.lines = res.lines.filter((d)=>d !== "");
|
|
30979
30968
|
res.width = res.lines.length ? Math.ceil(max$6(res.widths)) : 0;
|
|
30980
30969
|
res.height = res.lines.length ? Math.ceil(res.lines.length * wrap.lineHeight()) + fP : 0;
|
|
@@ -31042,6 +31031,9 @@
|
|
|
31042
31031
|
textData = textData.map((datum)=>{
|
|
31043
31032
|
datum.space = maxSpace - datum.fP * 2;
|
|
31044
31033
|
const res = calculateLabelSize(axis, datum, labelCtx);
|
|
31034
|
+
// A label measured wider than its share (see `calculateLabelSize`) is
|
|
31035
|
+
// painted at that width; the overlap pass below thins its neighbors.
|
|
31036
|
+
if (horizontal && !datum.rotate) datum.space = Math.max(datum.space, Math.ceil(res.width));
|
|
31045
31037
|
return Object.assign(res, datum);
|
|
31046
31038
|
});
|
|
31047
31039
|
const reverseTextData = textData.slice().reverse();
|
|
@@ -31228,7 +31220,6 @@
|
|
|
31228
31220
|
Clusters one-dimensional numeric data into a specified number of groups using the Ckmeans dynamic programming algorithm, minimizing within-group sum-of-squared-deviations.
|
|
31229
31221
|
@param data input data, as an array of number values
|
|
31230
31222
|
@param nClusters number of desired classes. This cannot be greater than the number of values in the data array.
|
|
31231
|
-
@private
|
|
31232
31223
|
*/ function ckmeans(data, nClusters) {
|
|
31233
31224
|
if (nClusters > data.length) {
|
|
31234
31225
|
throw new Error("Cannot generate more classes than there are data values");
|
|
@@ -31383,15 +31374,15 @@
|
|
|
31383
31374
|
];
|
|
31384
31375
|
}
|
|
31385
31376
|
|
|
31386
|
-
function _array_like_to_array$
|
|
31377
|
+
function _array_like_to_array$h(arr, len) {
|
|
31387
31378
|
if (len == null || len > arr.length) len = arr.length;
|
|
31388
31379
|
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
31389
31380
|
return arr2;
|
|
31390
31381
|
}
|
|
31391
|
-
function _array_with_holes$
|
|
31382
|
+
function _array_with_holes$e(arr) {
|
|
31392
31383
|
if (Array.isArray(arr)) return arr;
|
|
31393
31384
|
}
|
|
31394
|
-
function _iterable_to_array_limit$
|
|
31385
|
+
function _iterable_to_array_limit$e(arr, i) {
|
|
31395
31386
|
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
31396
31387
|
if (_i == null) return;
|
|
31397
31388
|
var _arr = [];
|
|
@@ -31415,19 +31406,19 @@
|
|
|
31415
31406
|
}
|
|
31416
31407
|
return _arr;
|
|
31417
31408
|
}
|
|
31418
|
-
function _non_iterable_rest$
|
|
31409
|
+
function _non_iterable_rest$e() {
|
|
31419
31410
|
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
31420
31411
|
}
|
|
31421
|
-
function _sliced_to_array$
|
|
31422
|
-
return _array_with_holes$
|
|
31412
|
+
function _sliced_to_array$e(arr, i) {
|
|
31413
|
+
return _array_with_holes$e(arr) || _iterable_to_array_limit$e(arr, i) || _unsupported_iterable_to_array$h(arr, i) || _non_iterable_rest$e();
|
|
31423
31414
|
}
|
|
31424
|
-
function _unsupported_iterable_to_array$
|
|
31415
|
+
function _unsupported_iterable_to_array$h(o, minLen) {
|
|
31425
31416
|
if (!o) return;
|
|
31426
|
-
if (typeof o === "string") return _array_like_to_array$
|
|
31417
|
+
if (typeof o === "string") return _array_like_to_array$h(o, minLen);
|
|
31427
31418
|
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
31428
31419
|
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
31429
31420
|
if (n === "Map" || n === "Set") return Array.from(n);
|
|
31430
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$
|
|
31421
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$h(o, minLen);
|
|
31431
31422
|
}
|
|
31432
31423
|
/**
|
|
31433
31424
|
Checks whether a point is inside the bounding box of a line segment.
|
|
@@ -31435,7 +31426,7 @@
|
|
|
31435
31426
|
@param s2 The second point of the line segment to be used for the bounding box, which should always be an `[x, y]` formatted Array.
|
|
31436
31427
|
@param p The point to be checked, which should always be an `[x, y]` formatted Array.
|
|
31437
31428
|
*/ function segmentBoxContains(s1, s2, p) {
|
|
31438
|
-
var eps = 1e-9, _p = _sliced_to_array$
|
|
31429
|
+
var eps = 1e-9, _p = _sliced_to_array$e(p, 2), px = _p[0], py = _p[1];
|
|
31439
31430
|
return !(px < Math.min(s1[0], s2[0]) - eps || px > Math.max(s1[0], s2[0]) + eps || py < Math.min(s1[1], s2[1]) - eps || py > Math.max(s1[1], s2[1]) + eps);
|
|
31440
31431
|
}
|
|
31441
31432
|
|
|
@@ -31483,15 +31474,15 @@
|
|
|
31483
31474
|
return dx * dx + dy * dy;
|
|
31484
31475
|
}
|
|
31485
31476
|
|
|
31486
|
-
function _array_like_to_array$
|
|
31477
|
+
function _array_like_to_array$g(arr, len) {
|
|
31487
31478
|
if (len == null || len > arr.length) len = arr.length;
|
|
31488
31479
|
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
31489
31480
|
return arr2;
|
|
31490
31481
|
}
|
|
31491
|
-
function _array_with_holes$
|
|
31482
|
+
function _array_with_holes$d(arr) {
|
|
31492
31483
|
if (Array.isArray(arr)) return arr;
|
|
31493
31484
|
}
|
|
31494
|
-
function _iterable_to_array_limit$
|
|
31485
|
+
function _iterable_to_array_limit$d(arr, i) {
|
|
31495
31486
|
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
31496
31487
|
if (_i == null) return;
|
|
31497
31488
|
var _arr = [];
|
|
@@ -31515,19 +31506,19 @@
|
|
|
31515
31506
|
}
|
|
31516
31507
|
return _arr;
|
|
31517
31508
|
}
|
|
31518
|
-
function _non_iterable_rest$
|
|
31509
|
+
function _non_iterable_rest$d() {
|
|
31519
31510
|
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
31520
31511
|
}
|
|
31521
|
-
function _sliced_to_array$
|
|
31522
|
-
return _array_with_holes$
|
|
31512
|
+
function _sliced_to_array$d(arr, i) {
|
|
31513
|
+
return _array_with_holes$d(arr) || _iterable_to_array_limit$d(arr, i) || _unsupported_iterable_to_array$g(arr, i) || _non_iterable_rest$d();
|
|
31523
31514
|
}
|
|
31524
|
-
function _unsupported_iterable_to_array$
|
|
31515
|
+
function _unsupported_iterable_to_array$g(o, minLen) {
|
|
31525
31516
|
if (!o) return;
|
|
31526
|
-
if (typeof o === "string") return _array_like_to_array$
|
|
31517
|
+
if (typeof o === "string") return _array_like_to_array$g(o, minLen);
|
|
31527
31518
|
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
31528
31519
|
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
31529
31520
|
if (n === "Map" || n === "Set") return Array.from(n);
|
|
31530
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$
|
|
31521
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$g(o, minLen);
|
|
31531
31522
|
}
|
|
31532
31523
|
/**
|
|
31533
31524
|
Gives the two closest intersection points between a ray cast from a point inside a polygon. The two points should lie on opposite sides of the origin.
|
|
@@ -31542,7 +31533,7 @@
|
|
|
31542
31533
|
origin[0] + eps * Math.cos(alpha),
|
|
31543
31534
|
origin[1] + eps * Math.sin(alpha)
|
|
31544
31535
|
];
|
|
31545
|
-
var _origin = _sliced_to_array$
|
|
31536
|
+
var _origin = _sliced_to_array$d(origin, 2), x0 = _origin[0], y0 = _origin[1];
|
|
31546
31537
|
var shiftedOrigin = [
|
|
31547
31538
|
x0 + Math.cos(alpha),
|
|
31548
31539
|
y0 + Math.sin(alpha)
|
|
@@ -31599,7 +31590,7 @@
|
|
|
31599
31590
|
}
|
|
31600
31591
|
|
|
31601
31592
|
/**
|
|
31602
|
-
Rotates a
|
|
31593
|
+
Rotates a polygon around a given origin.
|
|
31603
31594
|
@param poly The polygon to be rotated, which should be an Array of `[x, y]` values.
|
|
31604
31595
|
@param alpha The angle in radians to rotate.
|
|
31605
31596
|
@param origin The origin point of the rotation, which should be an `[x, y]` formatted Array.
|
|
@@ -31700,12 +31691,12 @@
|
|
|
31700
31691
|
return poly;
|
|
31701
31692
|
}
|
|
31702
31693
|
|
|
31703
|
-
function _array_like_to_array$
|
|
31694
|
+
function _array_like_to_array$f(arr, len) {
|
|
31704
31695
|
if (len == null || len > arr.length) len = arr.length;
|
|
31705
31696
|
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
31706
31697
|
return arr2;
|
|
31707
31698
|
}
|
|
31708
|
-
function _array_with_holes$
|
|
31699
|
+
function _array_with_holes$c(arr) {
|
|
31709
31700
|
if (Array.isArray(arr)) return arr;
|
|
31710
31701
|
}
|
|
31711
31702
|
function _instanceof$1(left, right) {
|
|
@@ -31716,7 +31707,7 @@
|
|
|
31716
31707
|
return left instanceof right;
|
|
31717
31708
|
}
|
|
31718
31709
|
}
|
|
31719
|
-
function _iterable_to_array_limit$
|
|
31710
|
+
function _iterable_to_array_limit$c(arr, i) {
|
|
31720
31711
|
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
31721
31712
|
if (_i == null) return;
|
|
31722
31713
|
var _arr = [];
|
|
@@ -31740,19 +31731,19 @@
|
|
|
31740
31731
|
}
|
|
31741
31732
|
return _arr;
|
|
31742
31733
|
}
|
|
31743
|
-
function _non_iterable_rest$
|
|
31734
|
+
function _non_iterable_rest$c() {
|
|
31744
31735
|
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
31745
31736
|
}
|
|
31746
|
-
function _sliced_to_array$
|
|
31747
|
-
return _array_with_holes$
|
|
31737
|
+
function _sliced_to_array$c(arr, i) {
|
|
31738
|
+
return _array_with_holes$c(arr) || _iterable_to_array_limit$c(arr, i) || _unsupported_iterable_to_array$f(arr, i) || _non_iterable_rest$c();
|
|
31748
31739
|
}
|
|
31749
|
-
function _unsupported_iterable_to_array$
|
|
31740
|
+
function _unsupported_iterable_to_array$f(o, minLen) {
|
|
31750
31741
|
if (!o) return;
|
|
31751
|
-
if (typeof o === "string") return _array_like_to_array$
|
|
31742
|
+
if (typeof o === "string") return _array_like_to_array$f(o, minLen);
|
|
31752
31743
|
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
31753
31744
|
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
31754
31745
|
if (n === "Map" || n === "Set") return Array.from(n);
|
|
31755
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$
|
|
31746
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$f(o, minLen);
|
|
31756
31747
|
}
|
|
31757
31748
|
// Algorithm constants
|
|
31758
31749
|
var aspectRatioStep = 0.5; // step size for the aspect ratio
|
|
@@ -31811,8 +31802,8 @@
|
|
|
31811
31802
|
Improves a candidate origin by averaging the polygon ray-cast intersections
|
|
31812
31803
|
along the width and height axes, returning the refined center points.
|
|
31813
31804
|
*/ function refineOrigins(poly, origOrigin, angleRad, idx, events) {
|
|
31814
|
-
var _polygonRayCast = _sliced_to_array$
|
|
31815
|
-
var _polygonRayCast1 = _sliced_to_array$
|
|
31805
|
+
var _polygonRayCast = _sliced_to_array$c(polygonRayCast(poly, origOrigin, angleRad), 2), p1W = _polygonRayCast[0], p2W = _polygonRayCast[1];
|
|
31806
|
+
var _polygonRayCast1 = _sliced_to_array$c(polygonRayCast(poly, origOrigin, angleRad + Math.PI / 2), 2), p1H = _polygonRayCast1[0], p2H = _polygonRayCast1[1];
|
|
31816
31807
|
var modifOrigins = [];
|
|
31817
31808
|
if (p1W && p2W) modifOrigins.push([
|
|
31818
31809
|
(p1W[0] + p2W[0]) / 2,
|
|
@@ -31844,14 +31835,14 @@
|
|
|
31844
31835
|
cx: origin[0],
|
|
31845
31836
|
cy: origin[1]
|
|
31846
31837
|
});
|
|
31847
|
-
var _polygonRayCast = _sliced_to_array$
|
|
31838
|
+
var _polygonRayCast = _sliced_to_array$c(polygonRayCast(poly, origin, angleRad), 2), p1W = _polygonRayCast[0], p2W = _polygonRayCast[1];
|
|
31848
31839
|
if (p1W === null || p2W === null) return {
|
|
31849
31840
|
maxArea: maxArea,
|
|
31850
31841
|
maxRect: maxRect
|
|
31851
31842
|
};
|
|
31852
31843
|
var minSqDistW = Math.min(pointDistanceSquared(origin, p1W), pointDistanceSquared(origin, p2W));
|
|
31853
31844
|
var maxWidth = 2 * Math.sqrt(minSqDistW);
|
|
31854
|
-
var _polygonRayCast1 = _sliced_to_array$
|
|
31845
|
+
var _polygonRayCast1 = _sliced_to_array$c(polygonRayCast(poly, origin, angleRad + Math.PI / 2), 2), p1H = _polygonRayCast1[0], p2H = _polygonRayCast1[1];
|
|
31855
31846
|
if (p1H === null || p2H === null) return {
|
|
31856
31847
|
maxArea: maxArea,
|
|
31857
31848
|
maxRect: maxRect
|
|
@@ -31881,7 +31872,7 @@
|
|
|
31881
31872
|
while(right - left >= widthStep){
|
|
31882
31873
|
var width = (left + right) / 2;
|
|
31883
31874
|
var height = width / aRatio;
|
|
31884
|
-
var _origin = _sliced_to_array$
|
|
31875
|
+
var _origin = _sliced_to_array$c(origin, 2), cx = _origin[0], cy = _origin[1];
|
|
31885
31876
|
var rectPoly = [
|
|
31886
31877
|
[
|
|
31887
31878
|
cx - width / 2,
|
|
@@ -31996,10 +31987,10 @@
|
|
|
31996
31987
|
return null;
|
|
31997
31988
|
}
|
|
31998
31989
|
// get the width of the bounding box of the original polygon to determine tolerance
|
|
31999
|
-
var _extent = _sliced_to_array$
|
|
31990
|
+
var _extent = _sliced_to_array$c(extent$1(poly, function(d) {
|
|
32000
31991
|
return d[0];
|
|
32001
31992
|
}), 2), minx = _extent[0], maxx = _extent[1];
|
|
32002
|
-
var _extent1 = _sliced_to_array$
|
|
31993
|
+
var _extent1 = _sliced_to_array$c(extent$1(poly, function(d) {
|
|
32003
31994
|
return d[1];
|
|
32004
31995
|
}), 2), miny = _extent1[0], maxy = _extent1[1];
|
|
32005
31996
|
// simplify polygon
|
|
@@ -32011,11 +32002,11 @@
|
|
|
32011
32002
|
});
|
|
32012
32003
|
var ref;
|
|
32013
32004
|
// get the width of the bounding box of the simplified polygon
|
|
32014
|
-
ref = _sliced_to_array$
|
|
32005
|
+
ref = _sliced_to_array$c(extent$1(poly, function(d) {
|
|
32015
32006
|
return d[0];
|
|
32016
32007
|
}), 2), minx = ref[0], maxx = ref[1];
|
|
32017
32008
|
var ref1;
|
|
32018
|
-
ref1 = _sliced_to_array$
|
|
32009
|
+
ref1 = _sliced_to_array$c(extent$1(poly, function(d) {
|
|
32019
32010
|
return d[1];
|
|
32020
32011
|
}), 2), miny = ref1[0], maxy = ref1[1];
|
|
32021
32012
|
var _ref = [
|
|
@@ -32165,15 +32156,15 @@
|
|
|
32165
32156
|
return (lo + hi) / 2;
|
|
32166
32157
|
}
|
|
32167
32158
|
|
|
32168
|
-
function _array_like_to_array$
|
|
32159
|
+
function _array_like_to_array$e(arr, len) {
|
|
32169
32160
|
if (len == null || len > arr.length) len = arr.length;
|
|
32170
32161
|
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
32171
32162
|
return arr2;
|
|
32172
32163
|
}
|
|
32173
|
-
function _array_with_holes$
|
|
32164
|
+
function _array_with_holes$b(arr) {
|
|
32174
32165
|
if (Array.isArray(arr)) return arr;
|
|
32175
32166
|
}
|
|
32176
|
-
function _iterable_to_array_limit$
|
|
32167
|
+
function _iterable_to_array_limit$b(arr, i) {
|
|
32177
32168
|
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
32178
32169
|
if (_i == null) return;
|
|
32179
32170
|
var _arr = [];
|
|
@@ -32197,28 +32188,26 @@
|
|
|
32197
32188
|
}
|
|
32198
32189
|
return _arr;
|
|
32199
32190
|
}
|
|
32200
|
-
function _non_iterable_rest$
|
|
32191
|
+
function _non_iterable_rest$b() {
|
|
32201
32192
|
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
32202
32193
|
}
|
|
32203
|
-
function _sliced_to_array$
|
|
32204
|
-
return _array_with_holes$
|
|
32194
|
+
function _sliced_to_array$b(arr, i) {
|
|
32195
|
+
return _array_with_holes$b(arr) || _iterable_to_array_limit$b(arr, i) || _unsupported_iterable_to_array$e(arr, i) || _non_iterable_rest$b();
|
|
32205
32196
|
}
|
|
32206
|
-
function _unsupported_iterable_to_array$
|
|
32197
|
+
function _unsupported_iterable_to_array$e(o, minLen) {
|
|
32207
32198
|
if (!o) return;
|
|
32208
|
-
if (typeof o === "string") return _array_like_to_array$
|
|
32199
|
+
if (typeof o === "string") return _array_like_to_array$e(o, minLen);
|
|
32209
32200
|
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
32210
32201
|
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
32211
32202
|
if (n === "Map" || n === "Set") return Array.from(n);
|
|
32212
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$
|
|
32203
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$e(o, minLen);
|
|
32213
32204
|
}
|
|
32214
32205
|
/**
|
|
32215
|
-
|
|
32216
|
-
@
|
|
32217
|
-
|
|
32218
|
-
*/ function linearConfidence(points) {
|
|
32219
|
-
var level = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 0.95;
|
|
32206
|
+
Shared setup for the simple linear regression bands: fits `points`, then returns a function mapping an x value to `ŷ ± t·s·√(extra + 1/n + (x − x̄)²/Sxx)`, where `extra` is 0 for the mean response's confidence band and 1 for a new observation's prediction band. Returns `null` when there are fewer than three usable points, the x values do not vary, or `level` is outside (0, 1).
|
|
32207
|
+
@private
|
|
32208
|
+
*/ function linearBand(points, level, extra) {
|
|
32220
32209
|
var usable = (points || []).filter(function(param) {
|
|
32221
|
-
var _param = _sliced_to_array$
|
|
32210
|
+
var _param = _sliced_to_array$b(param, 2), x = _param[0], y = _param[1];
|
|
32222
32211
|
return Number.isFinite(x) && Number.isFinite(y);
|
|
32223
32212
|
});
|
|
32224
32213
|
var n = usable.length;
|
|
@@ -32232,7 +32221,7 @@
|
|
|
32232
32221
|
var sxx = 0;
|
|
32233
32222
|
var sxy = 0;
|
|
32234
32223
|
usable.forEach(function(param) {
|
|
32235
|
-
var _param = _sliced_to_array$
|
|
32224
|
+
var _param = _sliced_to_array$b(param, 2), x = _param[0], y = _param[1];
|
|
32236
32225
|
sxx += Math.pow(x - mx, 2);
|
|
32237
32226
|
sxy += (x - mx) * (y - my);
|
|
32238
32227
|
});
|
|
@@ -32240,14 +32229,14 @@
|
|
|
32240
32229
|
var b = sxy / sxx;
|
|
32241
32230
|
var a = my - b * mx;
|
|
32242
32231
|
var ssRes = usable.reduce(function(s, param) {
|
|
32243
|
-
var _param = _sliced_to_array$
|
|
32232
|
+
var _param = _sliced_to_array$b(param, 2), x = _param[0], y = _param[1];
|
|
32244
32233
|
return s + Math.pow(y - a - b * x, 2);
|
|
32245
32234
|
}, 0);
|
|
32246
32235
|
var s = Math.sqrt(ssRes / (n - 2));
|
|
32247
32236
|
var t = studentTQuantile(1 - (1 - level) / 2, n - 2);
|
|
32248
32237
|
return function(x) {
|
|
32249
32238
|
var yHat = a + b * x;
|
|
32250
|
-
var margin = t * s * Math.sqrt(1 / n + Math.pow(x - mx, 2) / sxx);
|
|
32239
|
+
var margin = t * s * Math.sqrt(extra + 1 / n + Math.pow(x - mx, 2) / sxx);
|
|
32251
32240
|
return [
|
|
32252
32241
|
yHat - margin,
|
|
32253
32242
|
yHat + margin
|
|
@@ -32255,6 +32244,443 @@
|
|
|
32255
32244
|
};
|
|
32256
32245
|
}
|
|
32257
32246
|
|
|
32247
|
+
/**
|
|
32248
|
+
Builds the confidence band for the mean response of a simple linear regression of `points`: `ŷ ± t·s·√(1/n + (x − x̄)²/Sxx)`. Returns a function mapping an x value to its `[lower, upper]` bounds, or `null` when there are fewer than three usable points or the x values do not vary.
|
|
32249
|
+
@param points An array of `[x, y]` pairs.
|
|
32250
|
+
@param level The confidence level, between 0 and 1. Defaults to 0.95.
|
|
32251
|
+
*/ function linearConfidence(points) {
|
|
32252
|
+
var level = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 0.95;
|
|
32253
|
+
return linearBand(points, level, 0);
|
|
32254
|
+
}
|
|
32255
|
+
|
|
32256
|
+
/**
|
|
32257
|
+
Builds the prediction band for a new observation under a simple linear regression of `points`: `ŷ ± t·s·√(1 + 1/n + (x − x̄)²/Sxx)`. Wider than the confidence band of `linearConfidence`, since it covers the scatter of individual values as well as the uncertainty of the fitted line, which makes it the band to draw around a forecast. Returns a function mapping an x value to its `[lower, upper]` bounds, or `null` when there are fewer than three usable points or the x values do not vary.
|
|
32258
|
+
@param points An array of `[x, y]` pairs.
|
|
32259
|
+
@param level The confidence level, between 0 and 1. Defaults to 0.95.
|
|
32260
|
+
*/ function linearPrediction(points) {
|
|
32261
|
+
var level = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 0.95;
|
|
32262
|
+
return linearBand(points, level, 1);
|
|
32263
|
+
}
|
|
32264
|
+
|
|
32265
|
+
function _array_like_to_array$d(arr, len) {
|
|
32266
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
32267
|
+
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
32268
|
+
return arr2;
|
|
32269
|
+
}
|
|
32270
|
+
function _array_with_holes$a(arr) {
|
|
32271
|
+
if (Array.isArray(arr)) return arr;
|
|
32272
|
+
}
|
|
32273
|
+
function _array_without_holes$8(arr) {
|
|
32274
|
+
if (Array.isArray(arr)) return _array_like_to_array$d(arr);
|
|
32275
|
+
}
|
|
32276
|
+
function _define_property$8(obj, key, value) {
|
|
32277
|
+
if (key in obj) {
|
|
32278
|
+
Object.defineProperty(obj, key, {
|
|
32279
|
+
value: value,
|
|
32280
|
+
enumerable: true,
|
|
32281
|
+
configurable: true,
|
|
32282
|
+
writable: true
|
|
32283
|
+
});
|
|
32284
|
+
} else {
|
|
32285
|
+
obj[key] = value;
|
|
32286
|
+
}
|
|
32287
|
+
return obj;
|
|
32288
|
+
}
|
|
32289
|
+
function _iterable_to_array$8(iter) {
|
|
32290
|
+
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
32291
|
+
}
|
|
32292
|
+
function _iterable_to_array_limit$a(arr, i) {
|
|
32293
|
+
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
32294
|
+
if (_i == null) return;
|
|
32295
|
+
var _arr = [];
|
|
32296
|
+
var _n = true;
|
|
32297
|
+
var _d = false;
|
|
32298
|
+
var _s, _e;
|
|
32299
|
+
try {
|
|
32300
|
+
for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
|
|
32301
|
+
_arr.push(_s.value);
|
|
32302
|
+
if (i && _arr.length === i) break;
|
|
32303
|
+
}
|
|
32304
|
+
} catch (err) {
|
|
32305
|
+
_d = true;
|
|
32306
|
+
_e = err;
|
|
32307
|
+
} finally{
|
|
32308
|
+
try {
|
|
32309
|
+
if (!_n && _i["return"] != null) _i["return"]();
|
|
32310
|
+
} finally{
|
|
32311
|
+
if (_d) throw _e;
|
|
32312
|
+
}
|
|
32313
|
+
}
|
|
32314
|
+
return _arr;
|
|
32315
|
+
}
|
|
32316
|
+
function _non_iterable_rest$a() {
|
|
32317
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
32318
|
+
}
|
|
32319
|
+
function _non_iterable_spread$8() {
|
|
32320
|
+
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
32321
|
+
}
|
|
32322
|
+
function _object_spread$3(target) {
|
|
32323
|
+
for(var i = 1; i < arguments.length; i++){
|
|
32324
|
+
var source = arguments[i] != null ? arguments[i] : {};
|
|
32325
|
+
var ownKeys = Object.keys(source);
|
|
32326
|
+
if (typeof Object.getOwnPropertySymbols === "function") {
|
|
32327
|
+
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
32328
|
+
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
32329
|
+
}));
|
|
32330
|
+
}
|
|
32331
|
+
ownKeys.forEach(function(key) {
|
|
32332
|
+
_define_property$8(target, key, source[key]);
|
|
32333
|
+
});
|
|
32334
|
+
}
|
|
32335
|
+
return target;
|
|
32336
|
+
}
|
|
32337
|
+
function _sliced_to_array$a(arr, i) {
|
|
32338
|
+
return _array_with_holes$a(arr) || _iterable_to_array_limit$a(arr, i) || _unsupported_iterable_to_array$d(arr, i) || _non_iterable_rest$a();
|
|
32339
|
+
}
|
|
32340
|
+
function _to_consumable_array$8(arr) {
|
|
32341
|
+
return _array_without_holes$8(arr) || _iterable_to_array$8(arr) || _unsupported_iterable_to_array$d(arr) || _non_iterable_spread$8();
|
|
32342
|
+
}
|
|
32343
|
+
function _unsupported_iterable_to_array$d(o, minLen) {
|
|
32344
|
+
if (!o) return;
|
|
32345
|
+
if (typeof o === "string") return _array_like_to_array$d(o, minLen);
|
|
32346
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
32347
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
32348
|
+
if (n === "Map" || n === "Set") return Array.from(n);
|
|
32349
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$d(o, minLen);
|
|
32350
|
+
}
|
|
32351
|
+
/** Edges of the polygon, as `[from, to]` pairs (the polygon is implicitly closed). */ function polygonEdges(poly) {
|
|
32352
|
+
return poly.map(function(p, i) {
|
|
32353
|
+
return [
|
|
32354
|
+
p,
|
|
32355
|
+
poly[(i + 1) % poly.length]
|
|
32356
|
+
];
|
|
32357
|
+
});
|
|
32358
|
+
}
|
|
32359
|
+
/** Projects every point onto an axis, returning [min, max]. */ function project(points, ax, ay) {
|
|
32360
|
+
var lo = Infinity, hi = -Infinity;
|
|
32361
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
32362
|
+
try {
|
|
32363
|
+
for(var _iterator = points[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
32364
|
+
var _step_value = _sliced_to_array$a(_step.value, 2), x = _step_value[0], y = _step_value[1];
|
|
32365
|
+
var v = x * ax + y * ay;
|
|
32366
|
+
if (v < lo) lo = v;
|
|
32367
|
+
if (v > hi) hi = v;
|
|
32368
|
+
}
|
|
32369
|
+
} catch (err) {
|
|
32370
|
+
_didIteratorError = true;
|
|
32371
|
+
_iteratorError = err;
|
|
32372
|
+
} finally{
|
|
32373
|
+
try {
|
|
32374
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
32375
|
+
_iterator.return();
|
|
32376
|
+
}
|
|
32377
|
+
} finally{
|
|
32378
|
+
if (_didIteratorError) {
|
|
32379
|
+
throw _iteratorError;
|
|
32380
|
+
}
|
|
32381
|
+
}
|
|
32382
|
+
}
|
|
32383
|
+
return [
|
|
32384
|
+
lo,
|
|
32385
|
+
hi
|
|
32386
|
+
];
|
|
32387
|
+
}
|
|
32388
|
+
/**
|
|
32389
|
+
Whether a rectangle's interior overlaps a convex polygon's interior, by the
|
|
32390
|
+
separating axis theorem. Touching edges do not count as overlap.
|
|
32391
|
+
*/ function rectHitsConvex(x0, y0, x1, y1, poly, polyBox, edges) {
|
|
32392
|
+
var eps = 1e-9;
|
|
32393
|
+
if (x1 <= polyBox[0] + eps || x0 >= polyBox[2] - eps) return false;
|
|
32394
|
+
if (y1 <= polyBox[1] + eps || y0 >= polyBox[3] - eps) return false;
|
|
32395
|
+
var corners = [
|
|
32396
|
+
[
|
|
32397
|
+
x0,
|
|
32398
|
+
y0
|
|
32399
|
+
],
|
|
32400
|
+
[
|
|
32401
|
+
x1,
|
|
32402
|
+
y0
|
|
32403
|
+
],
|
|
32404
|
+
[
|
|
32405
|
+
x1,
|
|
32406
|
+
y1
|
|
32407
|
+
],
|
|
32408
|
+
[
|
|
32409
|
+
x0,
|
|
32410
|
+
y1
|
|
32411
|
+
]
|
|
32412
|
+
];
|
|
32413
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
32414
|
+
try {
|
|
32415
|
+
for(var _iterator = edges[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
32416
|
+
var _step_value = _sliced_to_array$a(_step.value, 2), a = _step_value[0], b = _step_value[1];
|
|
32417
|
+
var ax = -(b[1] - a[1]), ay = b[0] - a[0];
|
|
32418
|
+
if (!ax && !ay) continue;
|
|
32419
|
+
var _project = _sliced_to_array$a(project(poly, ax, ay), 2), p0 = _project[0], p1 = _project[1];
|
|
32420
|
+
var _project1 = _sliced_to_array$a(project(corners, ax, ay), 2), r0 = _project1[0], r1 = _project1[1];
|
|
32421
|
+
var tol = eps * Math.hypot(ax, ay);
|
|
32422
|
+
if (r1 <= p0 + tol || r0 >= p1 - tol) return false;
|
|
32423
|
+
}
|
|
32424
|
+
} catch (err) {
|
|
32425
|
+
_didIteratorError = true;
|
|
32426
|
+
_iteratorError = err;
|
|
32427
|
+
} finally{
|
|
32428
|
+
try {
|
|
32429
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
32430
|
+
_iterator.return();
|
|
32431
|
+
}
|
|
32432
|
+
} finally{
|
|
32433
|
+
if (_didIteratorError) {
|
|
32434
|
+
throw _iteratorError;
|
|
32435
|
+
}
|
|
32436
|
+
}
|
|
32437
|
+
}
|
|
32438
|
+
return true;
|
|
32439
|
+
}
|
|
32440
|
+
/** Sorted, de-duplicated values clipped to [lo, hi]. */ function gridLines(values, lo, hi, divisions) {
|
|
32441
|
+
var all = [
|
|
32442
|
+
lo,
|
|
32443
|
+
hi
|
|
32444
|
+
];
|
|
32445
|
+
for(var i = 1; i < divisions; i++)all.push(lo + (hi - lo) * i / divisions);
|
|
32446
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
32447
|
+
try {
|
|
32448
|
+
for(var _iterator = values[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
32449
|
+
var v = _step.value;
|
|
32450
|
+
if (v > lo && v < hi) all.push(v);
|
|
32451
|
+
}
|
|
32452
|
+
} catch (err) {
|
|
32453
|
+
_didIteratorError = true;
|
|
32454
|
+
_iteratorError = err;
|
|
32455
|
+
} finally{
|
|
32456
|
+
try {
|
|
32457
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
32458
|
+
_iterator.return();
|
|
32459
|
+
}
|
|
32460
|
+
} finally{
|
|
32461
|
+
if (_didIteratorError) {
|
|
32462
|
+
throw _iteratorError;
|
|
32463
|
+
}
|
|
32464
|
+
}
|
|
32465
|
+
}
|
|
32466
|
+
all.sort(function(a, b) {
|
|
32467
|
+
return a - b;
|
|
32468
|
+
});
|
|
32469
|
+
return all.filter(function(v, i) {
|
|
32470
|
+
return i === 0 || v - all[i - 1] > 1e-6;
|
|
32471
|
+
});
|
|
32472
|
+
}
|
|
32473
|
+
/**
|
|
32474
|
+
Finds the open, axis-aligned rectangles inside `bounds` that lie entirely
|
|
32475
|
+
outside the marks described by `obstacles`. The marks are treated as a single
|
|
32476
|
+
solid region — the convex hull of every (padded) obstacle box — so a hole in
|
|
32477
|
+
the middle of a ring of points is never returned, only the space around them.
|
|
32478
|
+
Boxes in `options.exclude` are kept clear too, each on its own. Each
|
|
32479
|
+
returned box is maximal (it cannot grow in any direction without leaving
|
|
32480
|
+
`bounds` or touching the hull or an excluded box). Results are sorted largest area first, and the
|
|
32481
|
+
output is deterministic for a given input.
|
|
32482
|
+
@param bounds The region to search, such as a chart's plot area.
|
|
32483
|
+
@param obstacles The bounding boxes of the marks drawn inside `bounds`.
|
|
32484
|
+
@param options Padding and minimum-size options.
|
|
32485
|
+
*/ function negativeSpace(bounds, obstacles) {
|
|
32486
|
+
var options = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
|
|
32487
|
+
var _Math, _Math1, _Math2, _Math3;
|
|
32488
|
+
var _options_padding = options.padding, padding = _options_padding === void 0 ? 0 : _options_padding, _options_minWidth = options.minWidth, minWidth = _options_minWidth === void 0 ? 1 : _options_minWidth, _options_minHeight = options.minHeight, minHeight = _options_minHeight === void 0 ? 1 : _options_minHeight, _options_divisions = options.divisions, divisions = _options_divisions === void 0 ? 48 : _options_divisions, _options_exclude = options.exclude, exclude = _options_exclude === void 0 ? [] : _options_exclude;
|
|
32489
|
+
var bx0 = bounds.x, by0 = bounds.y;
|
|
32490
|
+
var bx1 = bounds.x + bounds.width, by1 = bounds.y + bounds.height;
|
|
32491
|
+
if (!(bounds.width > 0 && bounds.height > 0)) return [];
|
|
32492
|
+
var points = [];
|
|
32493
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
32494
|
+
try {
|
|
32495
|
+
for(var _iterator = obstacles[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
32496
|
+
var o = _step.value;
|
|
32497
|
+
if (![
|
|
32498
|
+
o.x,
|
|
32499
|
+
o.y,
|
|
32500
|
+
o.width,
|
|
32501
|
+
o.height
|
|
32502
|
+
].every(Number.isFinite)) continue;
|
|
32503
|
+
var x0 = o.x - padding, y0 = o.y - padding;
|
|
32504
|
+
var x1 = o.x + o.width + padding, y1 = o.y + o.height + padding;
|
|
32505
|
+
points.push([
|
|
32506
|
+
x0,
|
|
32507
|
+
y0
|
|
32508
|
+
], [
|
|
32509
|
+
x1,
|
|
32510
|
+
y0
|
|
32511
|
+
], [
|
|
32512
|
+
x1,
|
|
32513
|
+
y1
|
|
32514
|
+
], [
|
|
32515
|
+
x0,
|
|
32516
|
+
y1
|
|
32517
|
+
]);
|
|
32518
|
+
}
|
|
32519
|
+
} catch (err) {
|
|
32520
|
+
_didIteratorError = true;
|
|
32521
|
+
_iteratorError = err;
|
|
32522
|
+
} finally{
|
|
32523
|
+
try {
|
|
32524
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
32525
|
+
_iterator.return();
|
|
32526
|
+
}
|
|
32527
|
+
} finally{
|
|
32528
|
+
if (_didIteratorError) {
|
|
32529
|
+
throw _iteratorError;
|
|
32530
|
+
}
|
|
32531
|
+
}
|
|
32532
|
+
}
|
|
32533
|
+
var blocks = exclude.filter(function(b) {
|
|
32534
|
+
return [
|
|
32535
|
+
b.x,
|
|
32536
|
+
b.y,
|
|
32537
|
+
b.width,
|
|
32538
|
+
b.height
|
|
32539
|
+
].every(Number.isFinite);
|
|
32540
|
+
});
|
|
32541
|
+
if (!points.length && !blocks.length) {
|
|
32542
|
+
return bounds.width >= minWidth && bounds.height >= minHeight ? [
|
|
32543
|
+
_object_spread$3({}, bounds)
|
|
32544
|
+
] : [];
|
|
32545
|
+
}
|
|
32546
|
+
var hull = points.length ? polygonHull(points) : [];
|
|
32547
|
+
if (!hull) {
|
|
32548
|
+
var _Math4, _Math5, _Math6, _Math7;
|
|
32549
|
+
var xs = points.map(function(p) {
|
|
32550
|
+
return p[0];
|
|
32551
|
+
}), ys = points.map(function(p) {
|
|
32552
|
+
return p[1];
|
|
32553
|
+
});
|
|
32554
|
+
var x01 = (_Math4 = Math).min.apply(_Math4, _to_consumable_array$8(xs)), x11 = (_Math5 = Math).max.apply(_Math5, _to_consumable_array$8(xs)), y01 = (_Math6 = Math).min.apply(_Math6, _to_consumable_array$8(ys)), y11 = (_Math7 = Math).max.apply(_Math7, _to_consumable_array$8(ys));
|
|
32555
|
+
hull = [
|
|
32556
|
+
[
|
|
32557
|
+
x01,
|
|
32558
|
+
y01
|
|
32559
|
+
],
|
|
32560
|
+
[
|
|
32561
|
+
x11,
|
|
32562
|
+
y01
|
|
32563
|
+
],
|
|
32564
|
+
[
|
|
32565
|
+
x11,
|
|
32566
|
+
y11
|
|
32567
|
+
],
|
|
32568
|
+
[
|
|
32569
|
+
x01,
|
|
32570
|
+
y11
|
|
32571
|
+
]
|
|
32572
|
+
];
|
|
32573
|
+
}
|
|
32574
|
+
var hullBox = hull.length ? [
|
|
32575
|
+
(_Math = Math).min.apply(_Math, _to_consumable_array$8(hull.map(function(p) {
|
|
32576
|
+
return p[0];
|
|
32577
|
+
}))),
|
|
32578
|
+
(_Math1 = Math).min.apply(_Math1, _to_consumable_array$8(hull.map(function(p) {
|
|
32579
|
+
return p[1];
|
|
32580
|
+
}))),
|
|
32581
|
+
(_Math2 = Math).max.apply(_Math2, _to_consumable_array$8(hull.map(function(p) {
|
|
32582
|
+
return p[0];
|
|
32583
|
+
}))),
|
|
32584
|
+
(_Math3 = Math).max.apply(_Math3, _to_consumable_array$8(hull.map(function(p) {
|
|
32585
|
+
return p[1];
|
|
32586
|
+
})))
|
|
32587
|
+
] : [
|
|
32588
|
+
0,
|
|
32589
|
+
0,
|
|
32590
|
+
0,
|
|
32591
|
+
0
|
|
32592
|
+
];
|
|
32593
|
+
var edges = polygonEdges(hull);
|
|
32594
|
+
var xs1 = gridLines(_to_consumable_array$8(hull.map(function(p) {
|
|
32595
|
+
return p[0];
|
|
32596
|
+
})).concat(_to_consumable_array$8(blocks.flatMap(function(b) {
|
|
32597
|
+
return [
|
|
32598
|
+
b.x,
|
|
32599
|
+
b.x + b.width
|
|
32600
|
+
];
|
|
32601
|
+
}))), bx0, bx1, divisions);
|
|
32602
|
+
var ys1 = gridLines(_to_consumable_array$8(hull.map(function(p) {
|
|
32603
|
+
return p[1];
|
|
32604
|
+
})).concat(_to_consumable_array$8(blocks.flatMap(function(b) {
|
|
32605
|
+
return [
|
|
32606
|
+
b.y,
|
|
32607
|
+
b.y + b.height
|
|
32608
|
+
];
|
|
32609
|
+
}))), by0, by1, divisions);
|
|
32610
|
+
var nx = xs1.length - 1, ny = ys1.length - 1;
|
|
32611
|
+
// occupied[j][i]: cell between xs[i..i+1] and ys[j..j+1] overlaps the hull or an excluded box.
|
|
32612
|
+
var hitsBlock = function hitsBlock(x0, y0, x1, y1) {
|
|
32613
|
+
return blocks.some(function(b) {
|
|
32614
|
+
return x0 < b.x + b.width && b.x < x1 && y0 < b.y + b.height && b.y < y1;
|
|
32615
|
+
});
|
|
32616
|
+
};
|
|
32617
|
+
var occupied = [];
|
|
32618
|
+
for(var j = 0; j < ny; j++){
|
|
32619
|
+
var row = new Uint8Array(nx);
|
|
32620
|
+
for(var i = 0; i < nx; i++){
|
|
32621
|
+
var _ref = [
|
|
32622
|
+
xs1[i],
|
|
32623
|
+
ys1[j],
|
|
32624
|
+
xs1[i + 1],
|
|
32625
|
+
ys1[j + 1]
|
|
32626
|
+
], x02 = _ref[0], y02 = _ref[1], x12 = _ref[2], y12 = _ref[3];
|
|
32627
|
+
row[i] = hull.length && rectHitsConvex(x02, y02, x12, y12, hull, hullBox, edges) || hitsBlock(x02, y02, x12, y12) ? 1 : 0;
|
|
32628
|
+
}
|
|
32629
|
+
occupied.push(row);
|
|
32630
|
+
}
|
|
32631
|
+
// Row-wise prefix sums, to test whether a span of the next row is empty.
|
|
32632
|
+
var prefix = occupied.map(function(row) {
|
|
32633
|
+
var p = new Uint32Array(nx + 1);
|
|
32634
|
+
for(var i = 0; i < nx; i++)p[i + 1] = p[i] + row[i];
|
|
32635
|
+
return p;
|
|
32636
|
+
});
|
|
32637
|
+
var spanEmpty = function spanEmpty(j, i0, i1) {
|
|
32638
|
+
return prefix[j][i1 + 1] - prefix[j][i0] === 0;
|
|
32639
|
+
};
|
|
32640
|
+
// Histogram sweep: for each row as the bottom edge, every bar's widest
|
|
32641
|
+
// rectangle at its own height. Every maximal empty rectangle is one of
|
|
32642
|
+
// these; the ones that could still grow downward are dropped.
|
|
32643
|
+
var seen = new Set();
|
|
32644
|
+
var results = [];
|
|
32645
|
+
var heights = new Uint32Array(nx);
|
|
32646
|
+
for(var j1 = 0; j1 < ny; j1++){
|
|
32647
|
+
for(var i1 = 0; i1 < nx; i1++)heights[i1] = occupied[j1][i1] ? 0 : heights[i1] + 1;
|
|
32648
|
+
var left = new Int32Array(nx), right = new Int32Array(nx);
|
|
32649
|
+
var stack = [];
|
|
32650
|
+
for(var i2 = 0; i2 < nx; i2++){
|
|
32651
|
+
while(stack.length && heights[stack[stack.length - 1]] >= heights[i2])stack.pop();
|
|
32652
|
+
left[i2] = stack.length ? stack[stack.length - 1] + 1 : 0;
|
|
32653
|
+
stack.push(i2);
|
|
32654
|
+
}
|
|
32655
|
+
stack.length = 0;
|
|
32656
|
+
for(var i3 = nx - 1; i3 >= 0; i3--){
|
|
32657
|
+
while(stack.length && heights[stack[stack.length - 1]] >= heights[i3])stack.pop();
|
|
32658
|
+
right[i3] = stack.length ? stack[stack.length - 1] - 1 : nx - 1;
|
|
32659
|
+
stack.push(i3);
|
|
32660
|
+
}
|
|
32661
|
+
for(var i4 = 0; i4 < nx; i4++){
|
|
32662
|
+
var h = heights[i4];
|
|
32663
|
+
if (!h) continue;
|
|
32664
|
+
var i0 = left[i4], i11 = right[i4];
|
|
32665
|
+
if (j1 + 1 < ny && spanEmpty(j1 + 1, i0, i11)) continue;
|
|
32666
|
+
var key = "".concat(i0, ",").concat(i11, ",").concat(j1 - h + 1, ",").concat(j1);
|
|
32667
|
+
if (seen.has(key)) continue;
|
|
32668
|
+
seen.add(key);
|
|
32669
|
+
var x = xs1[i0], y = ys1[j1 - h + 1];
|
|
32670
|
+
var width = xs1[i11 + 1] - x, height = ys1[j1 + 1] - y;
|
|
32671
|
+
if (width >= minWidth && height >= minHeight) results.push({
|
|
32672
|
+
x: x,
|
|
32673
|
+
y: y,
|
|
32674
|
+
width: width,
|
|
32675
|
+
height: height
|
|
32676
|
+
});
|
|
32677
|
+
}
|
|
32678
|
+
}
|
|
32679
|
+
return results.sort(function(a, b) {
|
|
32680
|
+
return b.width * b.height - a.width * a.height || a.y - b.y || a.x - b.x;
|
|
32681
|
+
});
|
|
32682
|
+
}
|
|
32683
|
+
|
|
32258
32684
|
function _class_call_check$5(instance, Constructor) {
|
|
32259
32685
|
if (!(instance instanceof Constructor)) {
|
|
32260
32686
|
throw new TypeError("Cannot call a class as a function");
|
|
@@ -33080,7 +33506,7 @@
|
|
|
33080
33506
|
}
|
|
33081
33507
|
return out;
|
|
33082
33508
|
}
|
|
33083
|
-
/** Binomial coefficient C(n, k). */ function choose(n, k) {
|
|
33509
|
+
/** Binomial coefficient C(n, k). */ function choose$1(n, k) {
|
|
33084
33510
|
var r = 1;
|
|
33085
33511
|
for(var i = 1; i <= k; i++)r = r * (n - k + i) / i;
|
|
33086
33512
|
return r;
|
|
@@ -33122,7 +33548,7 @@
|
|
|
33122
33548
|
if (!beta) return null;
|
|
33123
33549
|
var coefficients = new Array(size).fill(0);
|
|
33124
33550
|
beta.forEach(function(bk, k) {
|
|
33125
|
-
for(var j = 0; j <= k; j++)coefficients[j] += bk * choose(k, j) * Math.pow(-mx, k - j) / Math.pow(sd, k);
|
|
33551
|
+
for(var j = 0; j <= k; j++)coefficients[j] += bk * choose$1(k, j) * Math.pow(-mx, k - j) / Math.pow(sd, k);
|
|
33126
33552
|
});
|
|
33127
33553
|
var predict = function predict(x) {
|
|
33128
33554
|
var u = (x - mx) / sd;
|
|
@@ -42800,6 +43226,60 @@
|
|
|
42800
43226
|
} : {};
|
|
42801
43227
|
}
|
|
42802
43228
|
|
|
43229
|
+
/** textures.js path-based texture names, drawn by its `paths()` generator. */ const pathNames = [
|
|
43230
|
+
"squares",
|
|
43231
|
+
"nylon",
|
|
43232
|
+
"waves",
|
|
43233
|
+
"woven",
|
|
43234
|
+
"crosses",
|
|
43235
|
+
"caps",
|
|
43236
|
+
"hexagons"
|
|
43237
|
+
];
|
|
43238
|
+
/** Color-valued texture keys; a d3-color object is reduced to its CSS string. */ const colorKeys = [
|
|
43239
|
+
"background",
|
|
43240
|
+
"fill",
|
|
43241
|
+
"stroke"
|
|
43242
|
+
];
|
|
43243
|
+
/**
|
|
43244
|
+
Builds the JSON key of a textures.js config for one datum, or `false` when
|
|
43245
|
+
the datum has no texture or no fill (`"none"`, e.g. a line or link). The key is what a `pattern:<key>` scene fill
|
|
43246
|
+
carries for the renderer backends to materialize. `fill` and `stroke` are
|
|
43247
|
+
the shape's resolved fill and stroke for the datum, used as the texture's
|
|
43248
|
+
default background and line colors.
|
|
43249
|
+
@private
|
|
43250
|
+
*/ function textureKey(textureVal, fill, stroke, textureDefault = {}) {
|
|
43251
|
+
if (!textureVal) return false;
|
|
43252
|
+
const background = fill();
|
|
43253
|
+
if (background === "none") return false;
|
|
43254
|
+
const texture = isObject(textureVal) ? {
|
|
43255
|
+
...textureVal
|
|
43256
|
+
} : {
|
|
43257
|
+
texture: textureVal
|
|
43258
|
+
};
|
|
43259
|
+
if (!texture.background) texture.background = background;
|
|
43260
|
+
if (!texture.stroke && !textureDefault.stroke) texture.stroke = stroke();
|
|
43261
|
+
if (pathNames.includes(texture.texture) || typeof texture.texture === "function") {
|
|
43262
|
+
texture.d = texture.texture;
|
|
43263
|
+
texture.texture = "paths";
|
|
43264
|
+
} else if (texture.texture === "grid") {
|
|
43265
|
+
if (!texture.orientation && !textureDefault.orientation) texture.orientation = [
|
|
43266
|
+
"vertical",
|
|
43267
|
+
"horizontal"
|
|
43268
|
+
];
|
|
43269
|
+
texture.texture = "lines";
|
|
43270
|
+
}
|
|
43271
|
+
if (!texture.fill && texture.texture !== "paths") texture.fill = texture.stroke;
|
|
43272
|
+
for (const key of colorKeys){
|
|
43273
|
+
const v = texture[key];
|
|
43274
|
+
if (v && typeof v === "object") texture[key] = String(v);
|
|
43275
|
+
}
|
|
43276
|
+
const retObj = assign({}, textureDefault, texture);
|
|
43277
|
+
if (typeof retObj.d === "function") {
|
|
43278
|
+
retObj.d = retObj.d(retObj.size || 20);
|
|
43279
|
+
}
|
|
43280
|
+
return JSON.stringify(retObj);
|
|
43281
|
+
}
|
|
43282
|
+
|
|
42803
43283
|
/** Follows the chart (`__d3plus__`) and shape (`__d3plusShape__`) wrappers back
|
|
42804
43284
|
to the source datum, so a `sort` comparator sees the same object the other
|
|
42805
43285
|
per-datum accessors receive. */ function unwrap(d) {
|
|
@@ -43240,39 +43720,7 @@
|
|
|
43240
43720
|
*/ const styleLogic = (_)=>{
|
|
43241
43721
|
return typeof _ !== "function" ? _ : d.nested && d.key && d.values ? _(d.values[0], this._data.indexOf(d.values[0])) : _(d, i);
|
|
43242
43722
|
};
|
|
43243
|
-
|
|
43244
|
-
let texture;
|
|
43245
|
-
if (!isObject(textureVal)) texture = {
|
|
43246
|
-
texture: textureVal
|
|
43247
|
-
};
|
|
43248
|
-
else texture = textureVal;
|
|
43249
|
-
if (!texture.background) texture.background = styleLogic(this.schema.fill);
|
|
43250
|
-
if (!texture.stroke && !fallback.stroke) texture.stroke = styleLogic(this.schema.stroke);
|
|
43251
|
-
const pathNames = [
|
|
43252
|
-
"squares",
|
|
43253
|
-
"nylon",
|
|
43254
|
-
"waves",
|
|
43255
|
-
"woven",
|
|
43256
|
-
"crosses",
|
|
43257
|
-
"caps",
|
|
43258
|
-
"hexagons"
|
|
43259
|
-
];
|
|
43260
|
-
if (pathNames.includes(texture.texture) || typeof texture.texture === "function") {
|
|
43261
|
-
texture.d = texture.texture;
|
|
43262
|
-
texture.texture = "paths";
|
|
43263
|
-
} else if (texture.texture === "grid") {
|
|
43264
|
-
if (!texture.orientation && !fallback.orientation) texture.orientation = [
|
|
43265
|
-
"vertical",
|
|
43266
|
-
"horizontal"
|
|
43267
|
-
];
|
|
43268
|
-
texture.texture = "lines";
|
|
43269
|
-
}
|
|
43270
|
-
if (!texture.fill && texture.texture !== "paths") texture.fill = texture.stroke;
|
|
43271
|
-
const retObj = assign({}, fallback, texture);
|
|
43272
|
-
if (typeof retObj.d === "function") {
|
|
43273
|
-
retObj.d = retObj.d(retObj.size || 20);
|
|
43274
|
-
}
|
|
43275
|
-
return JSON.stringify(retObj);
|
|
43723
|
+
return textureKey(textureVal, ()=>styleLogic(this.schema.fill), ()=>styleLogic(this.schema.stroke), this.schema.textureDefault);
|
|
43276
43724
|
}
|
|
43277
43725
|
/**
|
|
43278
43726
|
Checks for nested data and uses the appropriate variables for accessor functions.
|
|
@@ -43647,7 +44095,7 @@
|
|
|
43647
44095
|
"none"
|
|
43648
44096
|
].includes(c)) c = this.schema.stroke(d, i);
|
|
43649
44097
|
const col = color(c);
|
|
43650
|
-
return col ? col.darker(1) : c;
|
|
44098
|
+
return col ? col.darker(1).toString() : c;
|
|
43651
44099
|
},
|
|
43652
44100
|
"stroke-width": (d, i)=>{
|
|
43653
44101
|
const s = this.schema.strokeWidth(d, i) || 1;
|
|
@@ -43662,7 +44110,7 @@
|
|
|
43662
44110
|
"none"
|
|
43663
44111
|
].includes(c)) c = this.schema.stroke(d, i);
|
|
43664
44112
|
const col = color(c);
|
|
43665
|
-
return col ? col.darker(0.5) : c;
|
|
44113
|
+
return col ? col.darker(0.5).toString() : c;
|
|
43666
44114
|
},
|
|
43667
44115
|
"stroke-width": (d, i)=>{
|
|
43668
44116
|
const s = this.schema.strokeWidth(d, i) || 1;
|
|
@@ -43757,7 +44205,7 @@
|
|
|
43757
44205
|
Filters/manipulates the data array before binding each point to an SVG group.
|
|
43758
44206
|
@param data @private
|
|
43759
44207
|
*/ _dataFilter(data) {
|
|
43760
|
-
const areas = groups(data, this.schema.id).map(([key, values])=>{
|
|
44208
|
+
const areas = groups$1(data, this.schema.id).map(([key, values])=>{
|
|
43761
44209
|
const d = {
|
|
43762
44210
|
key,
|
|
43763
44211
|
values
|
|
@@ -44188,7 +44636,7 @@
|
|
|
44188
44636
|
Filters/manipulates the data array before binding each point to an SVG group.
|
|
44189
44637
|
@param data @private
|
|
44190
44638
|
*/ _dataFilter(data) {
|
|
44191
|
-
const lines = groups(data, this.schema.id).map(([key, values])=>{
|
|
44639
|
+
const lines = groups$1(data, this.schema.id).map(([key, values])=>{
|
|
44192
44640
|
const d = {
|
|
44193
44641
|
key,
|
|
44194
44642
|
values
|
|
@@ -44376,7 +44824,7 @@
|
|
|
44376
44824
|
});
|
|
44377
44825
|
// Draw whisker endpoint.
|
|
44378
44826
|
this._whiskerEndpoint = [];
|
|
44379
|
-
groups(whiskerData, (d)=>d.endpoint).forEach(([shapeName, values])=>{
|
|
44827
|
+
groups$1(whiskerData, (d)=>d.endpoint).forEach(([shapeName, values])=>{
|
|
44380
44828
|
this._whiskerEndpoint.push(new shapes$2[shapeName]().data(values).renderMode(compute ? "compute" : "full").select(mountInner(`g.d3plus-Whisker-Endpoint-${shapeName}`)).config(markSharedConfig({
|
|
44381
44829
|
height: (d)=>d.orient === "top" || d.orient === "bottom" ? 5 : 20,
|
|
44382
44830
|
width: (d)=>d.orient === "top" || d.orient === "bottom" ? 20 : 5
|
|
@@ -44649,7 +45097,7 @@
|
|
|
44649
45097
|
}).node();
|
|
44650
45098
|
};
|
|
44651
45099
|
const outlierData = [];
|
|
44652
|
-
const filteredData = groups(this._data, (d, i)=>this.schema.orient(d, i) === "vertical" ? this.schema.x(d, i) : this.schema.y(d, i)).map(([key, groupData])=>computeBoxGroup(this, key, groupData, outlierData));
|
|
45100
|
+
const filteredData = groups$1(this._data, (d, i)=>this.schema.orient(d, i) === "vertical" ? this.schema.x(d, i) : this.schema.y(d, i)).map(([key, groupData])=>computeBoxGroup(this, key, groupData, outlierData));
|
|
44653
45101
|
// Draw box.
|
|
44654
45102
|
this._box = new Rect().data(filteredData).x((d)=>d.x).y((d)=>d.y).renderMode(compute ? "compute" : "full").select(mountInner("g.d3plus-Box")).config(configPrep.bind(this)(this.schema.rectConfig, "shape")).render();
|
|
44655
45103
|
// Draw median.
|
|
@@ -44661,7 +45109,7 @@
|
|
|
44661
45109
|
this._whisker = new Whisker().data(whiskerData).renderMode(compute ? "compute" : "full").select(mountInner("g.d3plus-Box-Whisker")).config(configPrep.bind(this)(this.schema.whiskerConfig, "shape")).render();
|
|
44662
45110
|
// Draw outliers.
|
|
44663
45111
|
this._whiskerEndpoint = [];
|
|
44664
|
-
groups(outlierData, (d)=>d.outlier).forEach(([shapeName, values])=>{
|
|
45112
|
+
groups$1(outlierData, (d)=>d.outlier).forEach(([shapeName, values])=>{
|
|
44665
45113
|
this._whiskerEndpoint.push(new shapes$1[shapeName]().data(values).renderMode(compute ? "compute" : "full").select(mountInner(`g.d3plus-Box-Outlier-${shapeName}`)).config(configPrep.bind(this)(this.schema.outlierConfig, "shape", shapeName)).render());
|
|
44666
45114
|
});
|
|
44667
45115
|
return this;
|
|
@@ -46007,8 +46455,7 @@
|
|
|
46007
46455
|
},
|
|
46008
46456
|
labelBounds: (dd, i)=>{
|
|
46009
46457
|
const d = legend._lineData[i];
|
|
46010
|
-
|
|
46011
|
-
if (d.shape === "Circle") x -= d.shapeR / 2;
|
|
46458
|
+
const x = d.shapeWidth / 2;
|
|
46012
46459
|
const height = max$6([
|
|
46013
46460
|
d.shapeHeight,
|
|
46014
46461
|
d.height
|
|
@@ -46034,6 +46481,8 @@
|
|
|
46034
46481
|
// key than its swatch, so hovering across the swatch→label padding would
|
|
46035
46482
|
// otherwise read as leaving one item and entering another.
|
|
46036
46483
|
pointerEvents: constant$d("none"),
|
|
46484
|
+
// Every swatch's label starts right after it (a Circle's own labels center).
|
|
46485
|
+
textAnchor: "start",
|
|
46037
46486
|
verticalAlign: "middle"
|
|
46038
46487
|
},
|
|
46039
46488
|
opacity: 1,
|
|
@@ -46062,14 +46511,16 @@
|
|
|
46062
46511
|
const label = legend.schema.label(d, i);
|
|
46063
46512
|
const shape = legend.schema.shape(d, i);
|
|
46064
46513
|
const r = legend._fetchConfig("r", d, i);
|
|
46514
|
+
const height = legend._fetchConfig("height", d, i);
|
|
46065
46515
|
let res = {
|
|
46066
46516
|
data: d,
|
|
46067
46517
|
i,
|
|
46068
46518
|
id: legend.schema.id(d, i),
|
|
46069
46519
|
shape,
|
|
46070
46520
|
shapeR: r,
|
|
46071
|
-
|
|
46072
|
-
|
|
46521
|
+
// A Line swatch fills a square, like a Rect's, so swatches line up.
|
|
46522
|
+
shapeWidth: shape === "Circle" ? r * 2 : shape === "Line" ? height : legend._fetchConfig("width", d, i),
|
|
46523
|
+
shapeHeight: shape === "Circle" ? r * 2 : height,
|
|
46073
46524
|
y: 0
|
|
46074
46525
|
};
|
|
46075
46526
|
if (!label) {
|
|
@@ -46230,7 +46681,26 @@
|
|
|
46230
46681
|
right: "end"
|
|
46231
46682
|
}[legend.schema.align]).width(legend.schema.width - legend.schema.padding * 2).x(legend.schema.padding).y(legend._outerBounds.y).config(legend.schema.titleConfig).render();
|
|
46232
46683
|
}
|
|
46233
|
-
/**
|
|
46684
|
+
/** A Line swatch's dot radius, as a share of its size: its stroke pokes out either side. */ const LINE_DOT = 0.3;
|
|
46685
|
+
/** A Line swatch's stroke thickness, in pixels. */ const LINE_STROKE = 2;
|
|
46686
|
+
/**
|
|
46687
|
+
Per-shape overrides that draw a "Line" legend entry as a line glyph: a
|
|
46688
|
+
short stroke (in the Rect group, which also carries the item's label and
|
|
46689
|
+
hover target) through a small dot (in the Circle group).
|
|
46690
|
+
*/ function lineSwatchConfig(legend, shapeName) {
|
|
46691
|
+
const isLine = (d)=>d.shape === "Line";
|
|
46692
|
+
const fetch = (key, d)=>legend._fetchConfig(key, d.data, d.i);
|
|
46693
|
+
const line = (d)=>legend._lineData[d.i];
|
|
46694
|
+
return shapeName === "Rect" ? {
|
|
46695
|
+
width: (d)=>isLine(d) ? line(d).shapeWidth : fetch("width", d),
|
|
46696
|
+
height: (d)=>isLine(d) ? LINE_STROKE : fetch("height", d)
|
|
46697
|
+
} : {
|
|
46698
|
+
r: (d)=>isLine(d) ? line(d).shapeHeight * LINE_DOT : fetch("r", d),
|
|
46699
|
+
label: (d)=>isLine(d) ? false : d.label,
|
|
46700
|
+
hitArea: (d)=>isLine(d) ? null : fetch("hitArea", d)
|
|
46701
|
+
};
|
|
46702
|
+
}
|
|
46703
|
+
/** Builds the per-shape data and renders the Circle/Rect swatch groups (Line entries draw in both). */ function renderLegendShapes(legend) {
|
|
46234
46704
|
legend._shapes = [];
|
|
46235
46705
|
const baseConfig = configPrep.bind(legend)(legend.schema.shapeConfig, "legend"), config = {
|
|
46236
46706
|
id: (d)=>d.id,
|
|
@@ -46254,9 +46724,9 @@
|
|
|
46254
46724
|
].forEach((shapeName)=>{
|
|
46255
46725
|
legend._shapes.push(// Child shapes are compute-only — Legend composes the swatches into its
|
|
46256
46726
|
// own toScene, so sub-shapes never auto-render their own <svg>.
|
|
46257
|
-
new shapes[shapeName]().renderMode("compute").parent(legend).data(data.filter((d)=>d.shape === shapeName)).duration(legend.schema.duration).labelConfig({
|
|
46727
|
+
new shapes[shapeName]().renderMode("compute").parent(legend).data(data.filter((d)=>d.shape === shapeName || d.shape === "Line")).duration(legend.schema.duration).labelConfig({
|
|
46258
46728
|
padding: 0
|
|
46259
|
-
}).select(legend._shapeGroup.node()).verticalAlign("top").config(baseConfig).config(config).render());
|
|
46729
|
+
}).select(legend._shapeGroup.node()).verticalAlign("top").config(baseConfig).config(config).config(lineSwatchConfig(legend, shapeName)).render());
|
|
46260
46730
|
});
|
|
46261
46731
|
}
|
|
46262
46732
|
|
|
@@ -50941,6 +51411,234 @@
|
|
|
50941
51411
|
}
|
|
50942
51412
|
}
|
|
50943
51413
|
|
|
51414
|
+
/** Scene mark types that carry a datum hover/active/highlight/search apply to. */ const MARK_TYPES = new Set([
|
|
51415
|
+
"rect",
|
|
51416
|
+
"circle",
|
|
51417
|
+
"line",
|
|
51418
|
+
"area",
|
|
51419
|
+
"path"
|
|
51420
|
+
]);
|
|
51421
|
+
/**
|
|
51422
|
+
Calls `fn` once per painted data mark in `nodes`, with the mark's source
|
|
51423
|
+
row and index. The row is unwrapped one level (`datum.data ?? datum`) and
|
|
51424
|
+
the index resolved `node.index` → `row.i` → 0, the same way
|
|
51425
|
+
`applyInteractionOpacity` evaluates its predicates, so a predicate sees the
|
|
51426
|
+
same arguments here as it does when the scene is dimmed. Rows are de-duped
|
|
51427
|
+
by reference, so a mark's separate label node doesn't visit it twice.
|
|
51428
|
+
*/ function forEachSceneRow(nodes, fn) {
|
|
51429
|
+
const seen = new Set();
|
|
51430
|
+
const walk = (node)=>{
|
|
51431
|
+
if (MARK_TYPES.has(node.type) && node.datum !== undefined) {
|
|
51432
|
+
const raw = node.datum;
|
|
51433
|
+
const row = raw && raw.data ? raw.data : raw;
|
|
51434
|
+
if (row !== undefined && !seen.has(row)) {
|
|
51435
|
+
seen.add(row);
|
|
51436
|
+
const i = typeof node.index === "number" ? node.index : typeof row.i === "number" ? row.i : 0;
|
|
51437
|
+
fn(row, i, node);
|
|
51438
|
+
}
|
|
51439
|
+
}
|
|
51440
|
+
const kids = node.children;
|
|
51441
|
+
if (kids) kids.forEach(walk);
|
|
51442
|
+
};
|
|
51443
|
+
nodes.forEach(walk);
|
|
51444
|
+
}
|
|
51445
|
+
|
|
51446
|
+
const groups = new Map();
|
|
51447
|
+
const groupColorScales = new Map();
|
|
51448
|
+
const dispatching = new Set();
|
|
51449
|
+
const linkAsPredicates = new WeakMap();
|
|
51450
|
+
/** Normalizes a chart's `link` config, or returns null when it isn't linked. */ function resolveLink(viz) {
|
|
51451
|
+
const raw = viz.schema.link;
|
|
51452
|
+
if (!raw) return null;
|
|
51453
|
+
const cfg = typeof raw === "string" ? {
|
|
51454
|
+
group: raw
|
|
51455
|
+
} : raw;
|
|
51456
|
+
if (!cfg.group) return null;
|
|
51457
|
+
const by = typeof cfg.by === "function" ? cfg.by : typeof cfg.by === "string" ? accessor(cfg.by) : (d, i)=>viz._id?.(d, i);
|
|
51458
|
+
return {
|
|
51459
|
+
group: cfg.group,
|
|
51460
|
+
by,
|
|
51461
|
+
hover: cfg.hover !== false,
|
|
51462
|
+
active: cfg.active !== false,
|
|
51463
|
+
highlight: cfg.highlight !== false,
|
|
51464
|
+
legend: cfg.legend !== false,
|
|
51465
|
+
color: cfg.color !== false
|
|
51466
|
+
};
|
|
51467
|
+
}
|
|
51468
|
+
/** Adds the chart to its `link` group, leaving any group it was in before. */ function registerLink(viz) {
|
|
51469
|
+
unregisterLink(viz);
|
|
51470
|
+
const link = resolveLink(viz);
|
|
51471
|
+
if (!link) return;
|
|
51472
|
+
let members = groups.get(link.group);
|
|
51473
|
+
if (!members) groups.set(link.group, members = new Set());
|
|
51474
|
+
members.add(viz);
|
|
51475
|
+
viz._linkGroup = link.group;
|
|
51476
|
+
}
|
|
51477
|
+
/** Removes the chart from its `link` group, if any. */ function unregisterLink(viz) {
|
|
51478
|
+
const group = viz._linkGroup;
|
|
51479
|
+
if (group === undefined) return;
|
|
51480
|
+
const members = groups.get(group);
|
|
51481
|
+
if (members) {
|
|
51482
|
+
members.delete(viz);
|
|
51483
|
+
if (!members.size) {
|
|
51484
|
+
groups.delete(group);
|
|
51485
|
+
groupColorScales.delete(group);
|
|
51486
|
+
}
|
|
51487
|
+
}
|
|
51488
|
+
viz._linkGroup = undefined;
|
|
51489
|
+
}
|
|
51490
|
+
/** The charts currently registered under a group name. */ function linkMembers(group) {
|
|
51491
|
+
return Array.from(groups.get(group) ?? []);
|
|
51492
|
+
}
|
|
51493
|
+
/**
|
|
51494
|
+
The color defaults `viz` assigns categorical colors from. A linked chart
|
|
51495
|
+
still on its own default scale (`viz._autoColorScale`) shares one scale
|
|
51496
|
+
with the rest of its group, so each value takes the same color in every
|
|
51497
|
+
chart however the charts order their data; the first chart to join seeds
|
|
51498
|
+
the group's palette. A chart given its own `colorDefaults.scale`, or linked
|
|
51499
|
+
with `color: false`, keeps its own.
|
|
51500
|
+
*/ function linkedColorDefaults(viz) {
|
|
51501
|
+
const defaults = viz.schema.colorDefaults;
|
|
51502
|
+
const group = viz._linkGroup;
|
|
51503
|
+
if (group === undefined || defaults.scale !== viz._autoColorScale) return defaults;
|
|
51504
|
+
if (!resolveLink(viz)?.color) return defaults;
|
|
51505
|
+
let scale = groupColorScales.get(group);
|
|
51506
|
+
if (!scale) {
|
|
51507
|
+
scale = ordinal().range(defaults.scale.range());
|
|
51508
|
+
groupColorScales.set(group, scale);
|
|
51509
|
+
}
|
|
51510
|
+
return {
|
|
51511
|
+
...defaults,
|
|
51512
|
+
scale
|
|
51513
|
+
};
|
|
51514
|
+
}
|
|
51515
|
+
/**
|
|
51516
|
+
Flattens a `by` value into comparable string keys: arrays (from
|
|
51517
|
+
aggregated rows whose members disagree) contribute every entry, Dates
|
|
51518
|
+
compare by time, and null/undefined contribute nothing.
|
|
51519
|
+
*/ function linkKeys(value) {
|
|
51520
|
+
const values = Array.isArray(value) ? value : [
|
|
51521
|
+
value
|
|
51522
|
+
];
|
|
51523
|
+
const keys = [];
|
|
51524
|
+
for (const v of values){
|
|
51525
|
+
if (v === null || v === undefined) continue;
|
|
51526
|
+
keys.push(v instanceof Date ? `${+v}` : `${v}`);
|
|
51527
|
+
}
|
|
51528
|
+
return keys;
|
|
51529
|
+
}
|
|
51530
|
+
/**
|
|
51531
|
+
The `by` keys of every row in `viz` that `predicate` matches. Evaluates
|
|
51532
|
+
over the painted marks (`_chartScene`), which are the rows the predicate
|
|
51533
|
+
was written against; before a first paint it falls back to the filtered
|
|
51534
|
+
data.
|
|
51535
|
+
*/ function linkValues(viz, by, predicate) {
|
|
51536
|
+
const values = new Set();
|
|
51537
|
+
const visit = (row, i)=>{
|
|
51538
|
+
if (predicate(row, i)) for (const k of linkKeys(by(row, i)))values.add(k);
|
|
51539
|
+
};
|
|
51540
|
+
const scene = viz._chartScene;
|
|
51541
|
+
if (scene && scene.length) forEachSceneRow(scene, visit);
|
|
51542
|
+
else (viz._filteredData ?? []).forEach(visit);
|
|
51543
|
+
return values;
|
|
51544
|
+
}
|
|
51545
|
+
/**
|
|
51546
|
+
A predicate matching the rows whose `by` keys include one of `values`. An
|
|
51547
|
+
empty set matches nothing, so a chart without the linked value dims
|
|
51548
|
+
entirely.
|
|
51549
|
+
*/ function linkPredicate(link, values) {
|
|
51550
|
+
return (d, i)=>linkKeys(link.by(d, i)).some((k)=>values.has(k));
|
|
51551
|
+
}
|
|
51552
|
+
/**
|
|
51553
|
+
Overrides which rows the next broadcast from `viz` treats as matched,
|
|
51554
|
+
for an interaction whose own predicate also matches marks it doesn't
|
|
51555
|
+
mean to emphasize (Plot's stacked column hover keeps non-bar marks
|
|
51556
|
+
bright). Consumed by the next `broadcastLink` call.
|
|
51557
|
+
*/ function linkAs(viz, predicate) {
|
|
51558
|
+
linkAsPredicates.set(viz, predicate);
|
|
51559
|
+
}
|
|
51560
|
+
/** Runs `fn` for each other linked member of `viz`'s group, with echoes suppressed. */ function dispatch(viz, link, fn) {
|
|
51561
|
+
if (dispatching.has(link.group)) return;
|
|
51562
|
+
const members = groups.get(link.group);
|
|
51563
|
+
if (!members || members.size < 2) return;
|
|
51564
|
+
dispatching.add(link.group);
|
|
51565
|
+
try {
|
|
51566
|
+
for (const target of members){
|
|
51567
|
+
if (target === viz) continue;
|
|
51568
|
+
const targetLink = resolveLink(target);
|
|
51569
|
+
if (targetLink) fn(target, targetLink);
|
|
51570
|
+
}
|
|
51571
|
+
} finally{
|
|
51572
|
+
dispatching.delete(link.group);
|
|
51573
|
+
}
|
|
51574
|
+
}
|
|
51575
|
+
/**
|
|
51576
|
+
Mirrors `viz`'s new hover/active/highlight state onto the rest of its link
|
|
51577
|
+
group. A predicate becomes a match on its rows' `by` values; `false`
|
|
51578
|
+
clears the same state everywhere.
|
|
51579
|
+
*/ function broadcastLink(viz, kind, predicate) {
|
|
51580
|
+
const override = linkAsPredicates.get(viz);
|
|
51581
|
+
linkAsPredicates.delete(viz);
|
|
51582
|
+
if (predicate === undefined) return;
|
|
51583
|
+
const link = resolveLink(viz);
|
|
51584
|
+
if (!link || !link[kind]) return;
|
|
51585
|
+
const source = typeof predicate === "function" ? override ?? predicate : null;
|
|
51586
|
+
let values = null;
|
|
51587
|
+
dispatch(viz, link, (target, targetLink)=>{
|
|
51588
|
+
if (!targetLink[kind]) return;
|
|
51589
|
+
const setter = target[kind];
|
|
51590
|
+
if (!setter) return;
|
|
51591
|
+
if (source && !values) values = linkValues(viz, link.by, source);
|
|
51592
|
+
setter.call(target, values ? linkPredicate(targetLink, values) : false);
|
|
51593
|
+
});
|
|
51594
|
+
}
|
|
51595
|
+
/** The raw legend ids of a legend row, as `_hidden`/`_solo` store them. */ function legendIds(viz, d, i) {
|
|
51596
|
+
const id = viz._id(d, i);
|
|
51597
|
+
return Array.isArray(id) ? id : [
|
|
51598
|
+
id
|
|
51599
|
+
];
|
|
51600
|
+
}
|
|
51601
|
+
/** The `by` keys of the legend rows whose ids appear in `ids`. */ function legendKeys(viz, link, ids) {
|
|
51602
|
+
const keys = new Set();
|
|
51603
|
+
if (!ids.length) return keys;
|
|
51604
|
+
(viz._legendData ?? []).forEach((d, i)=>{
|
|
51605
|
+
if (legendIds(viz, d, i).some((id)=>ids.includes(id))) for (const k of linkKeys(link.by(d, i)))keys.add(k);
|
|
51606
|
+
});
|
|
51607
|
+
return keys;
|
|
51608
|
+
}
|
|
51609
|
+
/**
|
|
51610
|
+
Mirrors `viz`'s legend hide/solo state onto the rest of its link group,
|
|
51611
|
+
then re-renders each chart that changed. Matching goes through `by`, so
|
|
51612
|
+
charts with different legend groupings still line up: a target legend item
|
|
51613
|
+
is solo'd when any of its keys is solo'd in the source, and hidden when all
|
|
51614
|
+
of its keys are hidden there. A target that hasn't drawn its legend yet is
|
|
51615
|
+
skipped.
|
|
51616
|
+
*/ function broadcastLegend(viz) {
|
|
51617
|
+
const link = resolveLink(viz);
|
|
51618
|
+
if (!link || !link.legend) return;
|
|
51619
|
+
const hiddenKeys = legendKeys(viz, link, viz._hidden);
|
|
51620
|
+
const soloKeys = legendKeys(viz, link, viz._solo);
|
|
51621
|
+
dispatch(viz, link, (target, targetLink)=>{
|
|
51622
|
+
if (!targetLink.legend || !target._legendData?.length) return;
|
|
51623
|
+
const hidden = [];
|
|
51624
|
+
const solo = [];
|
|
51625
|
+
target._legendData.forEach((d, i)=>{
|
|
51626
|
+
const keys = linkKeys(targetLink.by(d, i));
|
|
51627
|
+
const ids = legendIds(target, d, i);
|
|
51628
|
+
const add = (list)=>{
|
|
51629
|
+
for (const id of ids)if (!list.includes(id)) list.push(id);
|
|
51630
|
+
};
|
|
51631
|
+
if (soloKeys.size && keys.some((k)=>soloKeys.has(k))) add(solo);
|
|
51632
|
+
else if (hiddenKeys.size && keys.length && keys.every((k)=>hiddenKeys.has(k))) add(hidden);
|
|
51633
|
+
});
|
|
51634
|
+
const same = (a, b)=>a.length === b.length && a.every((v)=>b.includes(v));
|
|
51635
|
+
if (same(hidden, target._hidden) && same(solo, target._solo)) return;
|
|
51636
|
+
target._hidden = solo.length ? [] : hidden;
|
|
51637
|
+
target._solo = solo;
|
|
51638
|
+
target.render?.();
|
|
51639
|
+
});
|
|
51640
|
+
}
|
|
51641
|
+
|
|
50944
51642
|
/**
|
|
50945
51643
|
@module clickLegend
|
|
50946
51644
|
On click event for all legend shapes in a Viz.
|
|
@@ -50962,17 +51660,21 @@
|
|
|
50962
51660
|
return id;
|
|
50963
51661
|
})).length;
|
|
50964
51662
|
const inverted = this.schema.legendFilterInvert.bind(this)(this);
|
|
51663
|
+
const rerender = ()=>{
|
|
51664
|
+
broadcastLegend(this);
|
|
51665
|
+
this.render();
|
|
51666
|
+
};
|
|
50965
51667
|
if (inverted) {
|
|
50966
51668
|
if (event.shiftKey) {
|
|
50967
51669
|
if (hiddenIndex < 0 && !this._solo.length) {
|
|
50968
51670
|
this._hidden = this._hidden.concat(id);
|
|
50969
51671
|
if (soloIndex >= 0) this._solo = [];
|
|
50970
51672
|
if (this._hidden.length === dataLength) this._hidden = [];
|
|
50971
|
-
|
|
51673
|
+
rerender();
|
|
50972
51674
|
} else if (soloIndex >= 0) {
|
|
50973
51675
|
this._solo = [];
|
|
50974
51676
|
this._hidden = [];
|
|
50975
|
-
|
|
51677
|
+
rerender();
|
|
50976
51678
|
}
|
|
50977
51679
|
} else {
|
|
50978
51680
|
if (soloIndex < 0 && this._hidden.length < dataLength - 1) {
|
|
@@ -50982,13 +51684,13 @@
|
|
|
50982
51684
|
this._solo = [];
|
|
50983
51685
|
this._hidden = [];
|
|
50984
51686
|
}
|
|
50985
|
-
|
|
51687
|
+
rerender();
|
|
50986
51688
|
}
|
|
50987
51689
|
} else {
|
|
50988
51690
|
if (event.shiftKey && soloIndex < 0) {
|
|
50989
51691
|
this._solo = id;
|
|
50990
51692
|
this._hidden = [];
|
|
50991
|
-
|
|
51693
|
+
rerender();
|
|
50992
51694
|
} else if (!event.shiftKey) {
|
|
50993
51695
|
if (hiddenIndex >= 0) {
|
|
50994
51696
|
this._hidden.splice(hiddenIndex, id.length);
|
|
@@ -51002,7 +51704,7 @@
|
|
|
51002
51704
|
this._hidden = this._hidden.concat(id);
|
|
51003
51705
|
if (this._hidden.length === dataLength) this._hidden = [];
|
|
51004
51706
|
}
|
|
51005
|
-
|
|
51707
|
+
rerender();
|
|
51006
51708
|
}
|
|
51007
51709
|
}
|
|
51008
51710
|
}
|
|
@@ -51222,6 +51924,58 @@
|
|
|
51222
51924
|
}
|
|
51223
51925
|
}
|
|
51224
51926
|
|
|
51927
|
+
/**
|
|
51928
|
+
The small colored glyph that ties a tooltip row or title to the mark it
|
|
51929
|
+
describes, matching the legend's swatches: a dot with a short line through
|
|
51930
|
+
it for a Line, a dot for a Circle, and a square for everything else.
|
|
51931
|
+
*/ /** Every swatch's size in pixels, so swatches line up down a tooltip. */ const SIZE = 10;
|
|
51932
|
+
/** Inline styles shared by every swatch: a fixed box, spaced from its text. */ const BASE = `display: inline-block; flex: none; margin-right: 6px; width: ${SIZE}px; height: ${SIZE}px;`;
|
|
51933
|
+
/**
|
|
51934
|
+
A swatch's HTML for a mark of `shape` in `color`, to lead a tooltip title
|
|
51935
|
+
or row (see `withSwatch`). Empty without a color.
|
|
51936
|
+
@param color The mark's color.
|
|
51937
|
+
@param shape The mark's shape type (e.g. "Line", "Circle", "Bar").
|
|
51938
|
+
*/ function tooltipSwatch(color, shape) {
|
|
51939
|
+
if (!color) return "";
|
|
51940
|
+
if (shape === "Line") {
|
|
51941
|
+
const dot = SIZE * 0.6;
|
|
51942
|
+
return `<span class="d3plus-tooltip-swatch d3plus-tooltip-swatch-line" style="${BASE} position: relative">` + `<span style="position: absolute; left: 0; right: 0; top: ${SIZE / 2 - 1}px; height: 2px; background: ${color}"></span>` + `<span style="position: absolute; left: ${(SIZE - dot) / 2}px; top: ${(SIZE - dot) / 2}px; width: ${dot}px; height: ${dot}px; border-radius: 50%; background: ${color}"></span>` + "</span>";
|
|
51943
|
+
}
|
|
51944
|
+
const radius = shape === "Circle" ? "50%" : "1px";
|
|
51945
|
+
return `<span class="d3plus-tooltip-swatch" style="${BASE} border-radius: ${radius}; background: ${color}"></span>`;
|
|
51946
|
+
}
|
|
51947
|
+
/**
|
|
51948
|
+
Leads `text` with a swatch, centered on the text however large or bold it
|
|
51949
|
+
is (a tooltip title, or a row's name). Just `text` without a swatch.
|
|
51950
|
+
@param swatch The swatch HTML, from `tooltipSwatch`.
|
|
51951
|
+
@param text The title or name it leads.
|
|
51952
|
+
*/ function withSwatch(swatch, text) {
|
|
51953
|
+
if (!swatch) return `${text}`;
|
|
51954
|
+
return `<span style="display: inline-flex; align-items: center">${swatch}<span>${text}</span></span>`;
|
|
51955
|
+
}
|
|
51956
|
+
/** A paint color that actually shows: not unset, "none", or transparent. */ const visibleColor = (s)=>typeof s === "string" && s !== "none" && s !== "transparent" ? s : undefined;
|
|
51957
|
+
/** The scene node with a given key, searching depth-first. */ function findNode(nodes, key) {
|
|
51958
|
+
for (const node of nodes){
|
|
51959
|
+
if (node.key === key) return node;
|
|
51960
|
+
const child = node.children && findNode(node.children, key);
|
|
51961
|
+
if (child) return child;
|
|
51962
|
+
}
|
|
51963
|
+
return undefined;
|
|
51964
|
+
}
|
|
51965
|
+
/**
|
|
51966
|
+
The color a picked scene node draws in: a Line's stroke, otherwise its
|
|
51967
|
+
fill (or stroke, for an unfilled mark). A transparent hover target (a
|
|
51968
|
+
`::hit` node) reads its visible sibling's paint.
|
|
51969
|
+
@param viz The chart, whose scene holds the sibling.
|
|
51970
|
+
@param node The picked scene node.
|
|
51971
|
+
*/ function nodeColor(viz, node) {
|
|
51972
|
+
let n = node;
|
|
51973
|
+
if (n && typeof n.key === "string" && n.key.endsWith("::hit")) n = findNode(viz._chartScene || [], n.key.slice(0, -"::hit".length)) || n;
|
|
51974
|
+
const paint = n && n.paint;
|
|
51975
|
+
if (!paint) return undefined;
|
|
51976
|
+
return n.shapeType === "Line" ? visibleColor(paint.stroke) ?? visibleColor(paint.fill) : visibleColor(paint.fill) ?? visibleColor(paint.stroke);
|
|
51977
|
+
}
|
|
51978
|
+
|
|
51225
51979
|
/**
|
|
51226
51980
|
@module mouseMoveShape
|
|
51227
51981
|
Tooltip logic for a specified data point.
|
|
@@ -51260,9 +52014,12 @@
|
|
|
51260
52014
|
// wrapper whose `.data` chain leads back to the row).
|
|
51261
52015
|
let tooltipDatum = x || d;
|
|
51262
52016
|
while(tooltipDatum && tooltipDatum.__d3plus__ && tooltipDatum.data)tooltipDatum = tooltipDatum.data;
|
|
52017
|
+
// The title leads with a swatch of the hovered mark, as in the legend.
|
|
52018
|
+
const pick = this._lastScenePick;
|
|
52019
|
+
const swatch = pick && !pick.isLegend ? tooltipSwatch(nodeColor(this, pick.node), pick.shapeType ?? undefined) : "";
|
|
51263
52020
|
this._tooltipClass.data([
|
|
51264
52021
|
tooltipDatum
|
|
51265
|
-
]).footer(hasDefaultClick && hasDeeperLevel ? this.schema.translate("Click to Expand") : false).title(this._drawLabel).position(position).config(configPrep.bind(this)(this.schema.tooltipConfig)).render();
|
|
52022
|
+
]).footer(hasDefaultClick && hasDeeperLevel ? this.schema.translate("Click to Expand") : false).title((dd, ii)=>withSwatch(swatch, this._drawLabel(dd, ii))).position(position).config(configPrep.bind(this)(this.schema.tooltipConfig)).render();
|
|
51266
52023
|
}
|
|
51267
52024
|
}
|
|
51268
52025
|
|
|
@@ -51348,6 +52105,11 @@
|
|
|
51348
52105
|
key: "legendSort",
|
|
51349
52106
|
coerce: "identity"
|
|
51350
52107
|
},
|
|
52108
|
+
{
|
|
52109
|
+
key: "link",
|
|
52110
|
+
coerce: "identity",
|
|
52111
|
+
onSet: (viz)=>registerLink(viz)
|
|
52112
|
+
},
|
|
51351
52113
|
{
|
|
51352
52114
|
key: "minimap",
|
|
51353
52115
|
coerce: "identity"
|
|
@@ -51466,10 +52228,12 @@
|
|
|
51466
52228
|
viz.schema.color = (d, i)=>viz.schema.groupBy[0](d, i);
|
|
51467
52229
|
// Each viz gets its own categorical scale so assignments don't leak
|
|
51468
52230
|
// across charts on the same page.
|
|
52231
|
+
const scale = ordinal().range(defaults$1.scale.range());
|
|
51469
52232
|
viz.schema.colorDefaults = {
|
|
51470
52233
|
...defaults$1,
|
|
51471
|
-
scale
|
|
52234
|
+
scale
|
|
51472
52235
|
};
|
|
52236
|
+
viz._autoColorScale = scale;
|
|
51473
52237
|
viz._colorScaleClass = new ColorScale();
|
|
51474
52238
|
viz.schema.colorScaleConfig = {
|
|
51475
52239
|
axisConfig: {
|
|
@@ -51492,11 +52256,6 @@
|
|
|
51492
52256
|
viz.schema.detectVisible = true;
|
|
51493
52257
|
viz.schema.detectVisibleInterval = 1000;
|
|
51494
52258
|
viz.schema.detectVisibleUnload = true;
|
|
51495
|
-
viz.schema.downloadButton = false;
|
|
51496
|
-
viz.schema.downloadConfig = {
|
|
51497
|
-
type: "png"
|
|
51498
|
-
};
|
|
51499
|
-
viz.schema.downloadPosition = "top";
|
|
51500
52259
|
viz.schema.duration = 600;
|
|
51501
52260
|
viz.schema.fontFamily = fontFamily;
|
|
51502
52261
|
viz._hidden = [];
|
|
@@ -51651,7 +52410,7 @@
|
|
|
51651
52410
|
// light→dark ramp (built in vizPreDraw) instead of nominal categorical
|
|
51652
52411
|
// hues, so the color itself carries the ordering.
|
|
51653
52412
|
if (viz.schema.colorOrdinal && viz._ordinalColorScale) return viz._ordinalColorScale(key);
|
|
51654
|
-
return colorAssign(key, viz
|
|
52413
|
+
return colorAssign(key, linkedColorDefaults(viz));
|
|
51655
52414
|
},
|
|
51656
52415
|
labelConfig: {
|
|
51657
52416
|
// Marked so chart emitters layering user label config keep their own
|
|
@@ -51667,7 +52426,7 @@
|
|
|
51667
52426
|
// A fill that doesn't parse as a color (e.g. "none"/"transparent" on a
|
|
51668
52427
|
// confidence band) has no darker shade — fall back to the fill itself.
|
|
51669
52428
|
const col = color(c);
|
|
51670
|
-
return col ? col.darker(0.25) : c;
|
|
52429
|
+
return col ? col.darker(0.25).toString() : c;
|
|
51671
52430
|
},
|
|
51672
52431
|
role: "presentation",
|
|
51673
52432
|
strokeWidth: constant$d(0)
|
|
@@ -53199,51 +53958,27 @@
|
|
|
53199
53958
|
if (!needle) return viz._searchPrevHighlight ?? false;
|
|
53200
53959
|
return (d, i)=>matchesSearchNeedle(viz, d, i, needle);
|
|
53201
53960
|
}
|
|
53202
|
-
/** Scene mark types a match is searched against — mirrors `interactionOpacity.ts`'s own `MARK_TYPES`. */ const MARK_TYPES$1 = new Set([
|
|
53203
|
-
"rect",
|
|
53204
|
-
"circle",
|
|
53205
|
-
"line",
|
|
53206
|
-
"area",
|
|
53207
|
-
"path"
|
|
53208
|
-
]);
|
|
53209
53961
|
/**
|
|
53210
53962
|
Every currently-rendered mark matching the given term, in scene order.
|
|
53211
53963
|
Walks `viz._chartScene` (the actual painted scene, post-layout) rather
|
|
53212
|
-
than the raw data array,
|
|
53213
|
-
`applyInteractionOpacity`
|
|
53214
|
-
rendered mark, not by raw input row
|
|
53215
|
-
|
|
53216
|
-
|
|
53964
|
+
than the raw data array, via `forEachSceneRow` — the same row/index
|
|
53965
|
+
resolution `applyInteractionOpacity` uses — so a grouped/aggregated chart
|
|
53966
|
+
matches by rendered mark, not by raw input row, and the index a custom
|
|
53967
|
+
searchAccessor sees always matches the one the highlight predicate was
|
|
53968
|
+
evaluated with (Enter/Shift+Enter never jumps to a different mark than the
|
|
53969
|
+
one that's actually highlighted). An empty term matches nothing (there's
|
|
53970
|
+
no "everything" state to jump through).
|
|
53217
53971
|
*/ function searchMatches(viz, term) {
|
|
53218
53972
|
const needle = term.trim().toLowerCase();
|
|
53219
53973
|
if (!needle) return [];
|
|
53220
|
-
const nodes = viz._chartScene || [];
|
|
53221
|
-
const seen = new Set();
|
|
53222
53974
|
const results = [];
|
|
53223
|
-
|
|
53224
|
-
if (
|
|
53225
|
-
|
|
53226
|
-
|
|
53227
|
-
|
|
53228
|
-
|
|
53229
|
-
|
|
53230
|
-
// (interactionOpacity.ts) — node.index, then the row's own `.i`,
|
|
53231
|
-
// then 0 — so the index a custom searchAccessor sees here always
|
|
53232
|
-
// matches the index the highlight predicate was evaluated with,
|
|
53233
|
-
// and Enter/Shift+Enter never jumps to a different mark than the
|
|
53234
|
-
// one that's actually highlighted.
|
|
53235
|
-
const i = typeof node.index === "number" ? node.index : typeof row.i === "number" ? row.i : 0;
|
|
53236
|
-
if (matchesSearchNeedle(viz, row, i, needle)) results.push({
|
|
53237
|
-
node,
|
|
53238
|
-
row,
|
|
53239
|
-
index: i
|
|
53240
|
-
});
|
|
53241
|
-
}
|
|
53242
|
-
}
|
|
53243
|
-
const kids = node.children;
|
|
53244
|
-
if (kids) kids.forEach(walk);
|
|
53245
|
-
};
|
|
53246
|
-
nodes.forEach(walk);
|
|
53975
|
+
forEachSceneRow(viz._chartScene || [], (row, i, node)=>{
|
|
53976
|
+
if (matchesSearchNeedle(viz, row, i, needle)) results.push({
|
|
53977
|
+
node,
|
|
53978
|
+
row,
|
|
53979
|
+
index: i
|
|
53980
|
+
});
|
|
53981
|
+
});
|
|
53247
53982
|
return results;
|
|
53248
53983
|
}
|
|
53249
53984
|
/**
|
|
@@ -53701,25 +54436,116 @@
|
|
|
53701
54436
|
}
|
|
53702
54437
|
};
|
|
53703
54438
|
|
|
54439
|
+
const INSET_PRIORITY = [
|
|
54440
|
+
"sizeLegend",
|
|
54441
|
+
"legend",
|
|
54442
|
+
"colorScale"
|
|
54443
|
+
];
|
|
53704
54444
|
/**
|
|
53705
|
-
|
|
53706
|
-
|
|
53707
|
-
|
|
53708
|
-
|
|
53709
|
-
|
|
53710
|
-
|
|
53711
|
-
|
|
53712
|
-
|
|
53713
|
-
|
|
53714
|
-
|
|
53715
|
-
|
|
53716
|
-
|
|
53717
|
-
|
|
53718
|
-
|
|
53719
|
-
|
|
54445
|
+
Seeds `legendInset`/`legendInsetConfig`, and remembers the default
|
|
54446
|
+
legend/colorScale position accessors so a placement can tell a position
|
|
54447
|
+
the user chose (which it leaves alone) from the default. Runs after the
|
|
54448
|
+
legend and color defaults are seeded.
|
|
54449
|
+
*/ function initInsetDefaults(viz) {
|
|
54450
|
+
viz.schema.legendInset = true;
|
|
54451
|
+
viz.schema.legendInsetConfig = {};
|
|
54452
|
+
viz._insetAutoPositions = {
|
|
54453
|
+
legend: viz.schema.legendPosition,
|
|
54454
|
+
colorScale: viz.schema.colorScalePosition
|
|
54455
|
+
};
|
|
54456
|
+
}
|
|
54457
|
+
/** The resolved background-box style, with the chart's defaults filled in. */ function insetStyle(viz) {
|
|
54458
|
+
const config = viz.schema.legendInsetConfig || {};
|
|
54459
|
+
return {
|
|
54460
|
+
padding: 10,
|
|
54461
|
+
margin: 6,
|
|
54462
|
+
fillOpacity: 0.85,
|
|
54463
|
+
strokeWidth: 1,
|
|
54464
|
+
rx: 4,
|
|
54465
|
+
...config
|
|
54466
|
+
};
|
|
54467
|
+
}
|
|
54468
|
+
/** Whether `key` is being laid out for the chart's interior this pass (so it claims no margin). */ function isInsetPending(viz, key) {
|
|
54469
|
+
return Boolean(viz._insetPending && viz._insetPending.has(key));
|
|
54470
|
+
}
|
|
54471
|
+
/** The final placement of `key`, or null when it isn't drawn inside the chart. */ function insetPlacementFor(viz, key) {
|
|
54472
|
+
const p = viz._insetPlacement;
|
|
54473
|
+
return p && p.key === key ? p : null;
|
|
54474
|
+
}
|
|
54475
|
+
/** The orientation `key` is laid out with when inset (column until placement picks one). */ function insetOrient(viz, key) {
|
|
54476
|
+
return insetPlacementFor(viz, key)?.orient ?? "column";
|
|
54477
|
+
}
|
|
54478
|
+
/**
|
|
54479
|
+
The largest frame a legend or colorScale may lay itself out in when inset,
|
|
54480
|
+
for a chart area of `area`: a column takes up to 40% of the width and 60%
|
|
54481
|
+
of the height, a row the reverse.
|
|
54482
|
+
*/ function insetFrame(orient, area) {
|
|
54483
|
+
return orient === "column" ? {
|
|
54484
|
+
width: area.width * 0.4,
|
|
54485
|
+
height: area.height * 0.6
|
|
54486
|
+
} : {
|
|
54487
|
+
width: area.width * 0.6,
|
|
54488
|
+
height: area.height * 0.4
|
|
54489
|
+
};
|
|
54490
|
+
}
|
|
54491
|
+
/** The chart's background color, as the default fill for the inset box. */ function chartBackground(viz) {
|
|
54492
|
+
const node = viz._select && typeof viz._select.node === "function" ? viz._select.node() : null;
|
|
54493
|
+
return node ? backgroundColor(node) : "rgb(255, 255, 255)";
|
|
54494
|
+
}
|
|
54495
|
+
/** The semi-transparent box drawn behind inset chrome, so it stays legible over marks panned beneath it. */ function insetBackground(viz, placement) {
|
|
54496
|
+
const style = insetStyle(viz);
|
|
54497
|
+
const fill = style.fill ?? chartBackground(viz);
|
|
54498
|
+
return {
|
|
54499
|
+
type: "rect",
|
|
54500
|
+
key: "viz-inset-background",
|
|
54501
|
+
x: placement.x,
|
|
54502
|
+
y: placement.y,
|
|
54503
|
+
width: placement.width,
|
|
54504
|
+
height: placement.height,
|
|
54505
|
+
rx: style.rx,
|
|
54506
|
+
ry: style.rx,
|
|
54507
|
+
paint: {
|
|
54508
|
+
fill,
|
|
54509
|
+
fillOpacity: style.fillOpacity,
|
|
54510
|
+
stroke: style.stroke ?? colorContrast(fill, viz.schema.colorDefaults),
|
|
54511
|
+
strokeOpacity: style.stroke ? 1 : 0.15,
|
|
54512
|
+
strokeWidth: style.strokeWidth
|
|
54513
|
+
}
|
|
54514
|
+
};
|
|
54515
|
+
}
|
|
54516
|
+
/**
|
|
54517
|
+
The scene children for a legend or colorScale component: just its own
|
|
54518
|
+
scene normally, or — when it's drawn inside the chart — its background box
|
|
54519
|
+
plus its scene moved into the box. `bounds` is the component's
|
|
54520
|
+
`outerBounds()` (its content box within its own frame).
|
|
54521
|
+
*/ function insetComponentScene(viz, key, scene, bounds) {
|
|
54522
|
+
const transform = insetComponentOffset(viz, key, bounds);
|
|
54523
|
+
if (!transform) return [
|
|
54524
|
+
scene
|
|
54525
|
+
];
|
|
54526
|
+
return [
|
|
54527
|
+
insetBackground(viz, insetPlacementFor(viz, key)),
|
|
54528
|
+
{
|
|
54529
|
+
...scene,
|
|
54530
|
+
transform
|
|
54531
|
+
}
|
|
54532
|
+
];
|
|
54533
|
+
}
|
|
54534
|
+
/**
|
|
54535
|
+
Where a legend or colorScale component's own frame goes so its content
|
|
54536
|
+
(`bounds`, its `outerBounds()`) lands inside its placed box; null when it
|
|
54537
|
+
isn't drawn inside the chart.
|
|
54538
|
+
*/ function insetComponentOffset(viz, key, bounds) {
|
|
54539
|
+
const placed = insetPlacementFor(viz, key);
|
|
54540
|
+
if (!placed) return null;
|
|
54541
|
+
const { margin } = insetStyle(viz);
|
|
54542
|
+
return {
|
|
54543
|
+
x: placed.x + margin - (bounds.x ?? 0),
|
|
54544
|
+
y: placed.y + margin - (bounds.y ?? 0)
|
|
54545
|
+
};
|
|
54546
|
+
}
|
|
53720
54547
|
|
|
53721
|
-
|
|
53722
|
-
*/ /** Horizontal gap between items, and between the panel and content inset around it. */ const BOTTOM_RIGHT_GAP = 6;
|
|
54548
|
+
/** Horizontal gap between items, and between the panel and content inset around it. */ const BOTTOM_RIGHT_GAP = 6;
|
|
53723
54549
|
/** Lays contributions out in a row, right to left: the panel's total width and height. */ function measureBottomRight(items) {
|
|
53724
54550
|
const width = items.reduce((w, item, i)=>w + item.width + (i ? BOTTOM_RIGHT_GAP : 0), 0);
|
|
53725
54551
|
const height = Math.max(0, ...items.map((item)=>item.height));
|
|
@@ -53732,6 +54558,10 @@
|
|
|
53732
54558
|
const box = viz._bottomRightBox;
|
|
53733
54559
|
return box && box.width && box.height ? box : null;
|
|
53734
54560
|
}
|
|
54561
|
+
/** The panel when it occupies the chart's corner, so margins and neighbors make room for it; null when it doesn't. */ function cornerBox(viz) {
|
|
54562
|
+
const box = bottomRightControlsBox(viz);
|
|
54563
|
+
return box && !box.inset ? box : null;
|
|
54564
|
+
}
|
|
53735
54565
|
/**
|
|
53736
54566
|
How far content in the bottom band must pull in its right edge to clear
|
|
53737
54567
|
the panel: content whose bottom edge sits `bottom` px above the chart's
|
|
@@ -53739,7 +54569,7 @@
|
|
|
53739
54569
|
right edge. Zero when nothing is showing or the content starts above the
|
|
53740
54570
|
panel.
|
|
53741
54571
|
*/ function bottomRightControlsInset(viz, bottom, right) {
|
|
53742
|
-
const box =
|
|
54572
|
+
const box = cornerBox(viz);
|
|
53743
54573
|
// A right-side panel already widened the right margin bottom content lays out against.
|
|
53744
54574
|
if (!box || box.side === "right" || bottom >= box.bottom + box.height) return 0;
|
|
53745
54575
|
const inset = box.width - right;
|
|
@@ -53750,7 +54580,7 @@
|
|
|
53750
54580
|
above the chart's bottom edge, must shorten to end above the panel. Zero
|
|
53751
54581
|
when nothing is showing.
|
|
53752
54582
|
*/ function bottomRightControlsDrop(viz, bottom) {
|
|
53753
|
-
const box =
|
|
54583
|
+
const box = cornerBox(viz);
|
|
53754
54584
|
if (!box) return 0;
|
|
53755
54585
|
return Math.max(0, box.bottom + box.height - bottom);
|
|
53756
54586
|
}
|
|
@@ -53769,7 +54599,7 @@
|
|
|
53769
54599
|
`bottom` px above the chart's bottom edge, stays clear of a bottom-side
|
|
53770
54600
|
panel. Zero for a right-side panel.
|
|
53771
54601
|
*/ function bottomRightControlsShortfall(viz, bottom) {
|
|
53772
|
-
const box =
|
|
54602
|
+
const box = cornerBox(viz);
|
|
53773
54603
|
return box && box.side === "bottom" ? Math.max(0, box.bottom + box.height - bottom) : 0;
|
|
53774
54604
|
}
|
|
53775
54605
|
/**
|
|
@@ -53777,14 +54607,63 @@
|
|
|
53777
54607
|
`right` px in from the chart's right edge, stays clear of a right-side
|
|
53778
54608
|
panel. Zero for a bottom-side panel.
|
|
53779
54609
|
*/ function bottomRightControlsRightShortfall(viz, right) {
|
|
53780
|
-
const box =
|
|
54610
|
+
const box = cornerBox(viz);
|
|
53781
54611
|
return box && box.side === "right" ? Math.max(0, box.width + BOTTOM_RIGHT_GAP - right) : 0;
|
|
53782
54612
|
}
|
|
54613
|
+
/**
|
|
54614
|
+
The panel's scene when it's drawn inside the chart: the items painted
|
|
54615
|
+
from their final state, in a row on a background box that hugs them,
|
|
54616
|
+
aligned within the placed box the way the placement anchored it.
|
|
54617
|
+
*/ function buildInsetPanel(viz, box, zoom) {
|
|
54618
|
+
const placed = insetPlacementFor(viz, "sizeLegend");
|
|
54619
|
+
if (!placed) return null;
|
|
54620
|
+
const { margin } = insetStyle(viz);
|
|
54621
|
+
const painted = box.items.map((item)=>({
|
|
54622
|
+
item,
|
|
54623
|
+
paint: item.paint(zoom)
|
|
54624
|
+
})).filter((p)=>Boolean(p.paint));
|
|
54625
|
+
if (!painted.length) return null;
|
|
54626
|
+
const width = painted.reduce((w, p, i)=>w + p.paint.width + (i ? BOTTOM_RIGHT_GAP : 0), 0) + margin * 2;
|
|
54627
|
+
const height = Math.max(...painted.map((p)=>p.paint.height)) + margin * 2;
|
|
54628
|
+
const x = placed.alignX === "left" ? placed.x : placed.alignX === "center" ? placed.x + (placed.width - width) / 2 : placed.x + placed.width - width;
|
|
54629
|
+
const y = placed.alignY === "top" ? placed.y : placed.alignY === "middle" ? placed.y + (placed.height - height) / 2 : placed.y + placed.height - height;
|
|
54630
|
+
const children = [
|
|
54631
|
+
insetBackground(viz, {
|
|
54632
|
+
...placed,
|
|
54633
|
+
x,
|
|
54634
|
+
y,
|
|
54635
|
+
width,
|
|
54636
|
+
height
|
|
54637
|
+
})
|
|
54638
|
+
];
|
|
54639
|
+
let right = x + width - margin;
|
|
54640
|
+
const baseline = y + height - margin;
|
|
54641
|
+
for (const { item, paint } of painted){
|
|
54642
|
+
children.push({
|
|
54643
|
+
type: "group",
|
|
54644
|
+
key: item.key,
|
|
54645
|
+
transform: {
|
|
54646
|
+
x: right - paint.width,
|
|
54647
|
+
y: baseline - paint.height
|
|
54648
|
+
},
|
|
54649
|
+
children: [
|
|
54650
|
+
paint.node
|
|
54651
|
+
]
|
|
54652
|
+
});
|
|
54653
|
+
right -= paint.width + BOTTOM_RIGHT_GAP;
|
|
54654
|
+
}
|
|
54655
|
+
return {
|
|
54656
|
+
type: "group",
|
|
54657
|
+
key: "viz-bottomRight",
|
|
54658
|
+
children
|
|
54659
|
+
};
|
|
54660
|
+
}
|
|
53783
54661
|
/**
|
|
53784
54662
|
The panel's scene: each item painted from its final state, bottom-right
|
|
53785
54663
|
aligned in the slot it reserved. Null when nothing paints.
|
|
53786
54664
|
*/ function buildBottomRightPanel(viz, box) {
|
|
53787
54665
|
const zoom = viz._zoomTransform?.scale ?? 1;
|
|
54666
|
+
if (box.inset) return buildInsetPanel(viz, box, zoom);
|
|
53788
54667
|
const children = [];
|
|
53789
54668
|
let right = viz.schema.width;
|
|
53790
54669
|
const baseline = viz.schema.height - box.bottom;
|
|
@@ -53826,6 +54705,49 @@
|
|
|
53826
54705
|
] : panels;
|
|
53827
54706
|
}
|
|
53828
54707
|
|
|
54708
|
+
/**
|
|
54709
|
+
`ResolvedSpec` + `resolveSpec(viz)` — the boundary between
|
|
54710
|
+
"config the user supplied" and "context the pipeline transforms."
|
|
54711
|
+
|
|
54712
|
+
Today the chart's class instance holds both: every `this._foo` slot is
|
|
54713
|
+
either a config the user can set (via accessors) or a derived value the
|
|
54714
|
+
pipeline writes back during `_preDraw` / `_draw` / `_paint`. The clean
|
|
54715
|
+
split is:
|
|
54716
|
+
|
|
54717
|
+
ResolvedSpec <- user config (frozen, immutable, serializable)
|
|
54718
|
+
↓
|
|
54719
|
+
VizContext <- pipeline-derived state (filteredData, drawDepth,
|
|
54720
|
+
legendData, _chartScene, etc.)
|
|
54721
|
+
|
|
54722
|
+
`resolveSpec(viz)` returns a frozen snapshot of every user-settable
|
|
54723
|
+
config key for the given viz instance. The free functions
|
|
54724
|
+
`vizPreDraw(viz)` / `vizDraw(viz)` / `runVizPipeline(viz)` /
|
|
54725
|
+
`plotPaint(viz, ctx)` all take a live viz instance — the
|
|
54726
|
+
contract that's currently shipping. `resolveSpec` is provided as a
|
|
54727
|
+
public seam so callers (custom drivers, tests, future refactors)
|
|
54728
|
+
can pin a config snapshot independently of any draw cycle. The
|
|
54729
|
+
spec type is the contract.
|
|
54730
|
+
|
|
54731
|
+
The spec is a READONLY view: mutating it is a programming error. The
|
|
54732
|
+
type uses `Readonly<>` to discourage in-place writes; runtime
|
|
54733
|
+
freezing happens in `resolveSpec()`.
|
|
54734
|
+
*/ /**
|
|
54735
|
+
Snapshot every config key from a viz instance into a frozen spec.
|
|
54736
|
+
|
|
54737
|
+
Reads the same keys `BaseClass.config()` reflects — strips the `_`
|
|
54738
|
+
prefix from every instance field whose name matches a method on the
|
|
54739
|
+
prototype (the v3/v4 config-method-is-also-the-storage-slot pattern).
|
|
54740
|
+
Returns a frozen object so consumers can't accidentally mutate it
|
|
54741
|
+
upstream of the chart.
|
|
54742
|
+
*/ function resolveSpec(viz) {
|
|
54743
|
+
// BaseClass.config() already does this reflection; reuse it.
|
|
54744
|
+
const cfg = typeof viz.config === "function" ? viz.config() : {};
|
|
54745
|
+
// Object.freeze for shallow protection. Deep freeze isn't worth the cost
|
|
54746
|
+
// (most consumers don't mutate, and accessor functions reading the spec
|
|
54747
|
+
// wouldn't trigger surface mutation anyway).
|
|
54748
|
+
return Object.freeze(cfg);
|
|
54749
|
+
}
|
|
54750
|
+
|
|
53829
54751
|
/**
|
|
53830
54752
|
Rolls filtered legend data up by paint attributes, sorts it, and computes
|
|
53831
54753
|
`viz._legendDepth` (the lowest groupBy level whose values are unique).
|
|
@@ -53914,59 +54836,118 @@
|
|
|
53914
54836
|
};
|
|
53915
54837
|
}
|
|
53916
54838
|
/**
|
|
53917
|
-
|
|
53918
|
-
|
|
53919
|
-
|
|
53920
|
-
|
|
53921
|
-
*/ function renderLegendFeature(viz, built, layoutMargin) {
|
|
54839
|
+
Configures and renders the chart's `_legendClass` Legend instance in
|
|
54840
|
+
compute mode (Legend contributes to the scene via its `toScene()`,
|
|
54841
|
+
collected on Viz.toScene) into `frame`.
|
|
54842
|
+
*/ function paintLegend(viz, built, frame) {
|
|
53922
54843
|
const { legendData, legendKey, getAttr } = built;
|
|
53923
54844
|
const hidden = (d, i)=>{
|
|
53924
54845
|
let id = viz._id(d, i);
|
|
53925
54846
|
if (Array.isArray(id)) id = id[0];
|
|
53926
54847
|
return viz._hidden.includes(id) || viz._solo.length > 0 && !viz._solo.includes(id);
|
|
53927
54848
|
};
|
|
53928
|
-
// The margin *claim* uses the previous render's outerBounds; on first
|
|
53929
|
-
// render it's zero and the Legend re-flows on the second render with the
|
|
53930
|
-
// real space.
|
|
53931
|
-
const legendBounds = viz._legendClass.outerBounds();
|
|
53932
|
-
const config = resolveSpec(viz);
|
|
53933
|
-
const position = sanitizePosition(viz.schema.legendPosition.bind(viz)(config));
|
|
53934
|
-
const wide = [
|
|
53935
|
-
"top",
|
|
53936
|
-
"bottom"
|
|
53937
|
-
].includes(position);
|
|
53938
|
-
const padding = viz.schema.legendPadding(viz) ? viz._padding : {
|
|
53939
|
-
top: 0,
|
|
53940
|
-
right: 0,
|
|
53941
|
-
bottom: 0,
|
|
53942
|
-
left: 0
|
|
53943
|
-
};
|
|
53944
|
-
const { inset, drop, insetRight, shorten } = legendCornerClearance(viz, position, layoutMargin, padding);
|
|
53945
54849
|
const transform = {
|
|
53946
|
-
transform: `translate(${
|
|
54850
|
+
transform: `translate(${frame.x}, ${frame.y})`
|
|
53947
54851
|
};
|
|
53948
|
-
// `visible` gates the legend group's DOM presence + data binding.
|
|
53949
|
-
// `position === false` forces it off so `.legendPosition(false)` is
|
|
53950
|
-
// an actual hide signal: the legend's render runs against [] data,
|
|
53951
|
-
// which exits any prior DOM and emits no scene.
|
|
53952
|
-
const visible = position === false ? false : viz.schema.legend.bind(viz)(config, legendData);
|
|
53953
54852
|
// The Legend instance renders into a `g.d3plus-viz-legend` group as a
|
|
53954
54853
|
// child of the chart's svg. This group is created via the `elem` helper
|
|
53955
54854
|
// so the Legend has a DOM `_select` (its `toScene()` walks from there).
|
|
53956
54855
|
// Once Legend is fully compute-only the elem wrapper can go.
|
|
53957
54856
|
const legendGroup = elem("g.d3plus-viz-legend", {
|
|
53958
|
-
condition: visible && !viz.schema.legendConfig.select,
|
|
54857
|
+
condition: frame.visible && !viz.schema.legendConfig.select,
|
|
53959
54858
|
enter: transform,
|
|
53960
54859
|
parent: viz._select,
|
|
53961
54860
|
duration: viz.schema.duration,
|
|
53962
54861
|
update: transform
|
|
53963
54862
|
}).node();
|
|
53964
|
-
viz._legendClass.renderMode("compute").id(legendKey).align(
|
|
54863
|
+
viz._legendClass.renderMode("compute").id(legendKey).align(frame.align).direction(frame.direction).duration(viz.schema.duration).data(frame.visible ? legendData : []).height(frame.height).locale(viz.schema.locale).parent(viz).select(legendGroup).shape((d, i)=>{
|
|
54864
|
+
const shape = viz.schema.shape(d, i);
|
|
54865
|
+
return shape === "Circle" || shape === "Line" ? shape : "Rect";
|
|
54866
|
+
}).verticalAlign(frame.verticalAlign).width(frame.width).shapeConfig(configPrep.bind(viz)(viz.schema.shapeConfig, "legend")).shapeConfig({
|
|
53965
54867
|
fill: (d, i)=>hidden(d, i) ? viz.schema.hiddenColor(d, i) : getAttr(d, i, "fill"),
|
|
53966
54868
|
labelConfig: {
|
|
53967
54869
|
fontOpacity: (d, i)=>hidden(d, i) ? viz.schema.hiddenOpacity(d, i) : 1
|
|
53968
54870
|
}
|
|
53969
54871
|
}).config(viz.schema.legendConfig).render();
|
|
54872
|
+
}
|
|
54873
|
+
/**
|
|
54874
|
+
Whether the legend shows at all: `position === false` forces it off so
|
|
54875
|
+
`.legendPosition(false)` is an actual hide signal (the legend's render
|
|
54876
|
+
runs against [] data, which exits any prior DOM and emits no scene).
|
|
54877
|
+
*/ function legendVisible(viz, built) {
|
|
54878
|
+
const config = resolveSpec(viz);
|
|
54879
|
+
const position = sanitizePosition(viz.schema.legendPosition.bind(viz)(config));
|
|
54880
|
+
return position === false ? false : Boolean(viz.schema.legend.bind(viz)(config, built.legendData));
|
|
54881
|
+
}
|
|
54882
|
+
/**
|
|
54883
|
+
Lays the legend out to be drawn inside the chart (see
|
|
54884
|
+
`pipeline/insetPlacement.ts`): at the origin — Viz.toScene moves it into
|
|
54885
|
+
place — as a column or a row sized against the chart area `area`.
|
|
54886
|
+
Returns the legend's measured size, or null when it isn't showing or
|
|
54887
|
+
couldn't fit its labels.
|
|
54888
|
+
*/ function paintLegendInset(viz, orient, area, built = buildLegendData(viz)) {
|
|
54889
|
+
const visible = legendVisible(viz, built) && !viz.schema.legendConfig.select;
|
|
54890
|
+
const frame = insetFrame(orient, area);
|
|
54891
|
+
paintLegend(viz, built, {
|
|
54892
|
+
x: 0,
|
|
54893
|
+
y: 0,
|
|
54894
|
+
...frame,
|
|
54895
|
+
align: "left",
|
|
54896
|
+
direction: orient,
|
|
54897
|
+
verticalAlign: "top",
|
|
54898
|
+
visible
|
|
54899
|
+
});
|
|
54900
|
+
if (!visible) return null;
|
|
54901
|
+
const legend = viz._legendClass;
|
|
54902
|
+
const labelsFit = (legend._lineData || []).every((d)=>d.width > 0);
|
|
54903
|
+
const { width, height } = legend.outerBounds();
|
|
54904
|
+
return labelsFit && width && height ? {
|
|
54905
|
+
width,
|
|
54906
|
+
height
|
|
54907
|
+
} : null;
|
|
54908
|
+
}
|
|
54909
|
+
/**
|
|
54910
|
+
Positions and renders the legend, then returns the margin claim derived
|
|
54911
|
+
from the previous render's outerBounds. Claims nothing while the legend
|
|
54912
|
+
is being laid out for the chart's interior.
|
|
54913
|
+
*/ function renderLegendFeature(viz, built, layoutMargin) {
|
|
54914
|
+
if (isInsetPending(viz, "legend")) {
|
|
54915
|
+
paintLegendInset(viz, insetOrient(viz, "legend"), {
|
|
54916
|
+
width: viz.schema.width - layoutMargin.left - layoutMargin.right,
|
|
54917
|
+
height: viz.schema.height - layoutMargin.top - layoutMargin.bottom
|
|
54918
|
+
}, built);
|
|
54919
|
+
return {
|
|
54920
|
+
panel: null,
|
|
54921
|
+
margin: {}
|
|
54922
|
+
};
|
|
54923
|
+
}
|
|
54924
|
+
// The margin *claim* uses the previous render's outerBounds; on first
|
|
54925
|
+
// render it's zero and the Legend re-flows on the second render with the
|
|
54926
|
+
// real space.
|
|
54927
|
+
const legendBounds = viz._legendClass.outerBounds();
|
|
54928
|
+
const config = resolveSpec(viz);
|
|
54929
|
+
const position = sanitizePosition(viz.schema.legendPosition.bind(viz)(config));
|
|
54930
|
+
const wide = [
|
|
54931
|
+
"top",
|
|
54932
|
+
"bottom"
|
|
54933
|
+
].includes(position);
|
|
54934
|
+
const padding = viz.schema.legendPadding(viz) ? viz._padding : {
|
|
54935
|
+
top: 0,
|
|
54936
|
+
right: 0,
|
|
54937
|
+
bottom: 0,
|
|
54938
|
+
left: 0
|
|
54939
|
+
};
|
|
54940
|
+
const { inset, drop, insetRight, shorten } = legendCornerClearance(viz, position, layoutMargin, padding);
|
|
54941
|
+
paintLegend(viz, built, {
|
|
54942
|
+
x: (wide ? layoutMargin.left + padding.left : layoutMargin.left) + inset,
|
|
54943
|
+
y: (wide ? layoutMargin.top : layoutMargin.top + padding.top) + drop,
|
|
54944
|
+
width: (wide ? viz.schema.width - (layoutMargin.left + layoutMargin.right + padding.left + padding.right) : viz.schema.width - (layoutMargin.left + layoutMargin.right)) - inset * 2 - insetRight,
|
|
54945
|
+
height: (wide ? viz.schema.height - (layoutMargin.bottom + layoutMargin.top) : viz.schema.height - (layoutMargin.bottom + layoutMargin.top + padding.bottom + padding.top)) - drop - shorten,
|
|
54946
|
+
align: wide ? "center" : position,
|
|
54947
|
+
direction: wide ? "row" : "column",
|
|
54948
|
+
verticalAlign: !wide ? "middle" : position,
|
|
54949
|
+
visible: legendVisible(viz, built)
|
|
54950
|
+
});
|
|
53970
54951
|
// Margin claim from the *previous* render's outerBounds:
|
|
53971
54952
|
// `outerBounds()` reads stored state, so on the first render the claim
|
|
53972
54953
|
// is zero and Legend overlaps the chart for one frame; the next render
|
|
@@ -54005,6 +54986,149 @@
|
|
|
54005
54986
|
}
|
|
54006
54987
|
};
|
|
54007
54988
|
|
|
54989
|
+
/** The colorScale's data: the chart's data rolled up per time/id, keeping rows with a colorScale value. */ function colorScaleData(viz) {
|
|
54990
|
+
const data = Array.from(rollup(viz._data, (leaves)=>objectMerge(leaves, viz.schema.aggs), (d, i)=>`${viz.schema.time ? viz.schema.time(d, i) : "all"}-${viz._ids(d, i).join("_")}`).values());
|
|
54991
|
+
return data.filter((d, i)=>{
|
|
54992
|
+
const c = viz.schema.colorScale(d, i);
|
|
54993
|
+
return c !== undefined && c !== null;
|
|
54994
|
+
});
|
|
54995
|
+
}
|
|
54996
|
+
/**
|
|
54997
|
+
Configures and lays out the chart's `_colorScaleClass` into `frame`. It
|
|
54998
|
+
always runs in compute mode: Viz.toScene composes its scene, so the
|
|
54999
|
+
colorScale never paints a DOM copy of its own.
|
|
55000
|
+
*/ function paintColorScale(viz, frame, show) {
|
|
55001
|
+
const transform = {
|
|
55002
|
+
opacity: frame.orient ? 1 : 0,
|
|
55003
|
+
transform: `translate(${frame.x}, ${frame.y})`
|
|
55004
|
+
};
|
|
55005
|
+
const scaleGroup = elem("g.d3plus-viz-colorScale", {
|
|
55006
|
+
condition: show && !viz.schema.colorScaleConfig.select,
|
|
55007
|
+
enter: transform,
|
|
55008
|
+
parent: viz._select,
|
|
55009
|
+
duration: viz.schema.duration,
|
|
55010
|
+
update: transform
|
|
55011
|
+
}).node();
|
|
55012
|
+
if (!viz.schema.colorScale) return;
|
|
55013
|
+
viz._colorScaleClass.renderMode("compute").align(frame.align).duration(viz.schema.duration).data(colorScaleData(viz)).height(frame.height).locale(viz.schema.locale).orient(frame.orient).select(scaleGroup).value(viz.schema.colorScale).width(frame.width).config(viz.schema.colorScaleConfig).render();
|
|
55014
|
+
}
|
|
55015
|
+
/** The colorScale's sanitized position side (false when hidden). */ function colorScalePosition(viz) {
|
|
55016
|
+
return sanitizePosition(viz.schema.colorScalePosition.bind(viz)(resolveSpec(viz)));
|
|
55017
|
+
}
|
|
55018
|
+
/**
|
|
55019
|
+
Lays the colorScale out to be drawn inside the chart: at the origin —
|
|
55020
|
+
Viz.toScene moves it into place — vertically (`"column"`) or
|
|
55021
|
+
horizontally (`"row"`), sized against the chart area `area`. Returns its
|
|
55022
|
+
measured size, or null when it isn't showing.
|
|
55023
|
+
*/ function paintColorScaleInset(viz, orient, area) {
|
|
55024
|
+
const show = Boolean(viz.schema.colorScale) && colorScalePosition(viz) !== false && !viz.schema.colorScaleConfig.select;
|
|
55025
|
+
const frame = insetFrame(orient, area);
|
|
55026
|
+
const maxSize = viz.schema.colorScaleMaxSize;
|
|
55027
|
+
paintColorScale(viz, {
|
|
55028
|
+
x: 0,
|
|
55029
|
+
y: 0,
|
|
55030
|
+
width: orient === "row" ? min$5([
|
|
55031
|
+
maxSize,
|
|
55032
|
+
frame.width
|
|
55033
|
+
]) : frame.width,
|
|
55034
|
+
height: orient === "column" ? min$5([
|
|
55035
|
+
maxSize,
|
|
55036
|
+
frame.height
|
|
55037
|
+
]) : frame.height,
|
|
55038
|
+
orient: orient === "column" ? "right" : "bottom",
|
|
55039
|
+
align: "start"
|
|
55040
|
+
}, show);
|
|
55041
|
+
if (!show) return null;
|
|
55042
|
+
const { width, height } = viz._colorScaleClass.outerBounds();
|
|
55043
|
+
return width && height ? {
|
|
55044
|
+
width,
|
|
55045
|
+
height
|
|
55046
|
+
} : null;
|
|
55047
|
+
}
|
|
55048
|
+
/**
|
|
55049
|
+
Converts `drawColorScale.ts` to a FeatureModule.
|
|
55050
|
+
|
|
55051
|
+
Visible only when `_colorScale` is truthy and `_colorScalePosition` resolves
|
|
55052
|
+
to a side. Renders the chart's `_colorScaleClass` ColorScale instance and
|
|
55053
|
+
claims margin along its position side.
|
|
55054
|
+
*/ const colorScaleFeature = {
|
|
55055
|
+
name: "colorScale",
|
|
55056
|
+
configFields: [
|
|
55057
|
+
"colorScale",
|
|
55058
|
+
"colorScaleConfig",
|
|
55059
|
+
"colorScaleMaxSize",
|
|
55060
|
+
"colorScalePadding",
|
|
55061
|
+
"colorScalePosition"
|
|
55062
|
+
],
|
|
55063
|
+
layout: ({ viz, layoutMargin })=>{
|
|
55064
|
+
if (isInsetPending(viz, "colorScale")) {
|
|
55065
|
+
paintColorScaleInset(viz, insetOrient(viz, "colorScale"), {
|
|
55066
|
+
width: viz.schema.width - layoutMargin.left - layoutMargin.right,
|
|
55067
|
+
height: viz.schema.height - layoutMargin.top - layoutMargin.bottom
|
|
55068
|
+
});
|
|
55069
|
+
return {
|
|
55070
|
+
panel: null,
|
|
55071
|
+
margin: {}
|
|
55072
|
+
};
|
|
55073
|
+
}
|
|
55074
|
+
const position = colorScalePosition(viz);
|
|
55075
|
+
const wide = [
|
|
55076
|
+
"top",
|
|
55077
|
+
"bottom"
|
|
55078
|
+
].includes(position);
|
|
55079
|
+
const showColorScale = viz.schema.colorScale && position;
|
|
55080
|
+
const padding = viz.schema.colorScalePadding(viz) ? viz._padding : {
|
|
55081
|
+
top: 0,
|
|
55082
|
+
right: 0,
|
|
55083
|
+
bottom: 0,
|
|
55084
|
+
left: 0
|
|
55085
|
+
};
|
|
55086
|
+
// Share the bottom band with the bottom-right corner panel (size legend):
|
|
55087
|
+
// a bottom colorScale fits beside it, a side one ends above it.
|
|
55088
|
+
const corner = bottomRightClearance(viz, position, layoutMargin.bottom + padding.bottom, layoutMargin.right + padding.right);
|
|
55089
|
+
const availableWidth = viz.schema.width - (layoutMargin.left + layoutMargin.right + padding.left + padding.right) - corner.inset;
|
|
55090
|
+
const width = wide ? min$5([
|
|
55091
|
+
viz.schema.colorScaleMaxSize,
|
|
55092
|
+
availableWidth
|
|
55093
|
+
]) : viz.schema.width - (layoutMargin.left + layoutMargin.right);
|
|
55094
|
+
const availableHeight = viz.schema.height - (layoutMargin.bottom + layoutMargin.top + padding.bottom + padding.top) - corner.drop;
|
|
55095
|
+
const height = !wide ? min$5([
|
|
55096
|
+
viz.schema.colorScaleMaxSize,
|
|
55097
|
+
availableHeight
|
|
55098
|
+
]) : viz.schema.height - (layoutMargin.bottom + layoutMargin.top);
|
|
55099
|
+
paintColorScale(viz, {
|
|
55100
|
+
x: wide ? layoutMargin.left + padding.left + (availableWidth - width) / 2 : layoutMargin.left,
|
|
55101
|
+
y: wide ? layoutMargin.top : layoutMargin.top + padding.top + (availableHeight - height) / 2,
|
|
55102
|
+
width,
|
|
55103
|
+
height,
|
|
55104
|
+
orient: position,
|
|
55105
|
+
align: {
|
|
55106
|
+
bottom: "end",
|
|
55107
|
+
left: "start",
|
|
55108
|
+
right: "end",
|
|
55109
|
+
top: "start"
|
|
55110
|
+
}[position] || "bottom"
|
|
55111
|
+
}, Boolean(showColorScale));
|
|
55112
|
+
const margin = {};
|
|
55113
|
+
if (showColorScale) {
|
|
55114
|
+
const scaleBounds = viz._colorScaleClass.outerBounds();
|
|
55115
|
+
if (!viz.schema.colorScaleConfig.select && scaleBounds.height) {
|
|
55116
|
+
// Use the colorScale's OWN padding for its margin claim — not the
|
|
55117
|
+
// legend's, so a custom legendPadding doesn't shift the
|
|
55118
|
+
// colorScale's claim when the legend is hidden. The colorScale
|
|
55119
|
+
// class is the source of truth.
|
|
55120
|
+
const csPadding = typeof viz._colorScaleClass.padding === "function" ? viz._colorScaleClass.padding() : viz._legendClass.padding();
|
|
55121
|
+
if (wide) margin[position] = scaleBounds.height + csPadding * 2;
|
|
55122
|
+
else margin[position] = scaleBounds.width + csPadding * 2;
|
|
55123
|
+
}
|
|
55124
|
+
}
|
|
55125
|
+
return {
|
|
55126
|
+
panel: null,
|
|
55127
|
+
margin
|
|
55128
|
+
};
|
|
55129
|
+
}
|
|
55130
|
+
};
|
|
55131
|
+
|
|
54008
55132
|
/**
|
|
54009
55133
|
Shared geometry helpers for chart `_draw` methods and layout stages.
|
|
54010
55134
|
|
|
@@ -54551,105 +55675,6 @@
|
|
|
54551
55675
|
};
|
|
54552
55676
|
}
|
|
54553
55677
|
};
|
|
54554
|
-
/* ------------------------------- ColorScale ------------------------------ */ /**
|
|
54555
|
-
Converts `drawColorScale.ts` to a FeatureModule.
|
|
54556
|
-
|
|
54557
|
-
Visible only when `_colorScale` is truthy and `_colorScalePosition` resolves
|
|
54558
|
-
to a side. Renders the chart's `_colorScaleClass` ColorScale instance and
|
|
54559
|
-
claims margin along its position side.
|
|
54560
|
-
*/ const colorScaleFeature = {
|
|
54561
|
-
name: "colorScale",
|
|
54562
|
-
configFields: [
|
|
54563
|
-
"colorScale",
|
|
54564
|
-
"colorScaleConfig",
|
|
54565
|
-
"colorScaleMaxSize",
|
|
54566
|
-
"colorScalePadding",
|
|
54567
|
-
"colorScalePosition"
|
|
54568
|
-
],
|
|
54569
|
-
layout: ({ viz, layoutMargin })=>{
|
|
54570
|
-
const data = Array.from(rollup(viz._data, (leaves)=>objectMerge(leaves, viz.schema.aggs), (d, i)=>`${viz.schema.time ? viz.schema.time(d, i) : "all"}-${viz._ids(d, i).join("_")}`).values());
|
|
54571
|
-
const position = sanitizePosition(viz.schema.colorScalePosition.bind(viz)(resolveSpec(viz)));
|
|
54572
|
-
const wide = [
|
|
54573
|
-
"top",
|
|
54574
|
-
"bottom"
|
|
54575
|
-
].includes(position);
|
|
54576
|
-
const showColorScale = viz.schema.colorScale && position;
|
|
54577
|
-
const padding = viz.schema.colorScalePadding(viz) ? viz._padding : {
|
|
54578
|
-
top: 0,
|
|
54579
|
-
right: 0,
|
|
54580
|
-
bottom: 0,
|
|
54581
|
-
left: 0
|
|
54582
|
-
};
|
|
54583
|
-
// Share the bottom band with the bottom-right corner panel (size legend):
|
|
54584
|
-
// a bottom colorScale fits beside it, a side one ends above it.
|
|
54585
|
-
const corner = bottomRightClearance(viz, position, layoutMargin.bottom + padding.bottom, layoutMargin.right + padding.right);
|
|
54586
|
-
const availableWidth = viz.schema.width - (layoutMargin.left + layoutMargin.right + padding.left + padding.right) - corner.inset;
|
|
54587
|
-
const width = wide ? min$5([
|
|
54588
|
-
viz.schema.colorScaleMaxSize,
|
|
54589
|
-
availableWidth
|
|
54590
|
-
]) : viz.schema.width - (layoutMargin.left + layoutMargin.right);
|
|
54591
|
-
const availableHeight = viz.schema.height - (layoutMargin.bottom + layoutMargin.top + padding.bottom + padding.top) - corner.drop;
|
|
54592
|
-
const height = !wide ? min$5([
|
|
54593
|
-
viz.schema.colorScaleMaxSize,
|
|
54594
|
-
availableHeight
|
|
54595
|
-
]) : viz.schema.height - (layoutMargin.bottom + layoutMargin.top);
|
|
54596
|
-
const transform = {
|
|
54597
|
-
opacity: position ? 1 : 0,
|
|
54598
|
-
transform: `translate(${wide ? layoutMargin.left + padding.left + (availableWidth - width) / 2 : layoutMargin.left}, ${wide ? layoutMargin.top : layoutMargin.top + padding.top + (availableHeight - height) / 2})`
|
|
54599
|
-
};
|
|
54600
|
-
const scaleGroup = elem("g.d3plus-viz-colorScale", {
|
|
54601
|
-
condition: showColorScale && !viz.schema.colorScaleConfig.select,
|
|
54602
|
-
enter: transform,
|
|
54603
|
-
parent: viz._select,
|
|
54604
|
-
duration: viz.schema.duration,
|
|
54605
|
-
update: transform
|
|
54606
|
-
}).node();
|
|
54607
|
-
if (!viz.schema.colorScale) return {
|
|
54608
|
-
panel: null,
|
|
54609
|
-
margin: {}
|
|
54610
|
-
};
|
|
54611
|
-
const scaleData = data.filter((d, i)=>{
|
|
54612
|
-
const c = viz.schema.colorScale(d, i);
|
|
54613
|
-
return c !== undefined && c !== null;
|
|
54614
|
-
});
|
|
54615
|
-
// Discrete (bucket/jenks/quantile) colorScales render their swatches via an
|
|
54616
|
-
// internal Legend, which composes cleanly through the Viz scene — so run
|
|
54617
|
-
// them in compute mode (like the legend) so the Viz's toScene owns them and
|
|
54618
|
-
// hover/active dimming applies. Without this they render full-mode, where
|
|
54619
|
-
// paintComponentScene paints a full-opacity copy that overlays and defeats
|
|
54620
|
-
// the dimming. The smooth-gradient variant stays full-mode: its gradient
|
|
54621
|
-
// fill is materialized through paintComponentScene, not the Viz scene.
|
|
54622
|
-
const csCfg = viz.schema.colorScaleConfig || {};
|
|
54623
|
-
const csDiscrete = !csCfg.bucketAxis && [
|
|
54624
|
-
"buckets",
|
|
54625
|
-
"jenks",
|
|
54626
|
-
"quantile"
|
|
54627
|
-
].includes(typeof csCfg.scale === "string" ? csCfg.scale : "");
|
|
54628
|
-
viz._colorScaleClass.renderMode(csDiscrete ? "compute" : "full").align({
|
|
54629
|
-
bottom: "end",
|
|
54630
|
-
left: "start",
|
|
54631
|
-
right: "end",
|
|
54632
|
-
top: "start"
|
|
54633
|
-
}[position] || "bottom").duration(viz.schema.duration).data(scaleData).height(height).locale(viz.schema.locale).orient(position).select(scaleGroup).value(viz.schema.colorScale).width(width).config(viz.schema.colorScaleConfig).render();
|
|
54634
|
-
const margin = {};
|
|
54635
|
-
if (showColorScale) {
|
|
54636
|
-
const scaleBounds = viz._colorScaleClass.outerBounds();
|
|
54637
|
-
if (!viz.schema.colorScaleConfig.select && scaleBounds.height) {
|
|
54638
|
-
// Use the colorScale's OWN padding for its margin claim — not the
|
|
54639
|
-
// legend's, so a custom legendPadding doesn't shift the
|
|
54640
|
-
// colorScale's claim when the legend is hidden. The colorScale
|
|
54641
|
-
// class is the source of truth.
|
|
54642
|
-
const csPadding = typeof viz._colorScaleClass.padding === "function" ? viz._colorScaleClass.padding() : viz._legendClass.padding();
|
|
54643
|
-
if (wide) margin[position] = scaleBounds.height + csPadding * 2;
|
|
54644
|
-
else margin[position] = scaleBounds.width + csPadding * 2;
|
|
54645
|
-
}
|
|
54646
|
-
}
|
|
54647
|
-
return {
|
|
54648
|
-
panel: null,
|
|
54649
|
-
margin
|
|
54650
|
-
};
|
|
54651
|
-
}
|
|
54652
|
-
};
|
|
54653
55678
|
/**
|
|
54654
55679
|
Converts `drawTotal.ts` to a FeatureModule. Slightly different from title/
|
|
54655
55680
|
subtitle: the text comes from `sum()` over the filtered data when `_total`
|
|
@@ -54936,6 +55961,7 @@
|
|
|
54936
55961
|
// interaction-opacity pass, so repaint to apply/clear active state.
|
|
54937
55962
|
if (this._sceneRenderer) this._scheduleSceneRepaint();
|
|
54938
55963
|
}
|
|
55964
|
+
broadcastLink(this, "active", _);
|
|
54939
55965
|
return this;
|
|
54940
55966
|
}
|
|
54941
55967
|
/**
|
|
@@ -55057,21 +56083,6 @@
|
|
|
55057
56083
|
*/ detectVisibleUnload(_) {
|
|
55058
56084
|
return arguments.length ? (this.schema.detectVisibleUnload = _, this) : this.schema.detectVisibleUnload;
|
|
55059
56085
|
}
|
|
55060
|
-
/**
|
|
55061
|
-
Shows a button that allows for downloading the current visualization.
|
|
55062
|
-
*/ downloadButton(_) {
|
|
55063
|
-
return arguments.length ? (this.schema.downloadButton = _, this) : this.schema.downloadButton;
|
|
55064
|
-
}
|
|
55065
|
-
/**
|
|
55066
|
-
Sets specific options of the saveElement function used when downloading the visualization.
|
|
55067
|
-
*/ downloadConfig(_) {
|
|
55068
|
-
return arguments.length ? (this.schema.downloadConfig = assign(this.schema.downloadConfig, _), this) : this.schema.downloadConfig;
|
|
55069
|
-
}
|
|
55070
|
-
/**
|
|
55071
|
-
Defines which control group to add the download button into.
|
|
55072
|
-
*/ downloadPosition(_) {
|
|
55073
|
-
return arguments.length ? (this.schema.downloadPosition = _, this) : this.schema.downloadPosition;
|
|
55074
|
-
}
|
|
55075
56086
|
/**
|
|
55076
56087
|
The font family used throughout the visualization.
|
|
55077
56088
|
*/ fontFamily(_) {
|
|
@@ -55189,6 +56200,7 @@
|
|
|
55189
56200
|
// to one paint per frame so a fast pointer sweep doesn't saturate the main
|
|
55190
56201
|
// thread.
|
|
55191
56202
|
if (this._sceneRenderer && _ !== undefined && (this.schema.shapeConfig.hoverOpacity !== 1 || this._hoverBucket)) this._scheduleSceneRepaint();
|
|
56203
|
+
broadcastLink(this, "hover", _);
|
|
55192
56204
|
return this;
|
|
55193
56205
|
}
|
|
55194
56206
|
/**
|
|
@@ -55203,6 +56215,7 @@
|
|
|
55203
56215
|
// Scene-rendered charts express de-emphasis via the scene's
|
|
55204
56216
|
// interaction-opacity pass, so repaint to apply/clear the gray treatment.
|
|
55205
56217
|
if (this._sceneRenderer) this._scheduleSceneRepaint();
|
|
56218
|
+
broadcastLink(this, "highlight", _);
|
|
55206
56219
|
return this;
|
|
55207
56220
|
}
|
|
55208
56221
|
/**
|
|
@@ -55227,6 +56240,16 @@
|
|
|
55227
56240
|
*/ legendFilterInvert(_) {
|
|
55228
56241
|
return arguments.length ? (this.schema.legendFilterInvert = typeof _ === "function" ? _ : constant$d(_), this) : this.schema.legendFilterInvert;
|
|
55229
56242
|
}
|
|
56243
|
+
/**
|
|
56244
|
+
Whether the chart may draw one of its legends inside the empty space around its marks instead of in a margin, for charts that leave room (Plot, Network, Pack, Pie, Rings, Tree, and Geomap). After the chart lays out, the size legend is tried first, then the legend, then the colorScale; the first that fits is drawn over a semi-transparent box (see `legendInsetConfig`), and any others keep their margins. Space enclosed by the marks, like the middle of a ring of points, is never used. A legend or colorScale whose position was set explicitly stays in that margin. Defaults to `true`; also accepts a function that receives the resolved chart config and returns a boolean.
|
|
56245
|
+
*/ legendInset(_) {
|
|
56246
|
+
return arguments.length ? (this.schema.legendInset = _, this) : this.schema.legendInset;
|
|
56247
|
+
}
|
|
56248
|
+
/**
|
|
56249
|
+
Style of the box drawn behind a legend placed inside the chart (see `legendInset`): `fill` (defaults to the chart's background color), `fillOpacity` (0.85), `stroke` (defaults to a faint contrasting line), `strokeWidth` (1), `rx` (corner radius, 4), `margin` (space between the box's edge and the legend, 6), and `padding` (space kept between the box and the chart's marks and edges, 10).
|
|
56250
|
+
*/ legendInsetConfig(_) {
|
|
56251
|
+
return arguments.length ? (this.schema.legendInsetConfig = assign(this.schema.legendInsetConfig, _), this) : this.schema.legendInsetConfig;
|
|
56252
|
+
}
|
|
55230
56253
|
/**
|
|
55231
56254
|
Tells the legend whether or not to use the internal padding defined by the visualization in it's positioning. For example, d3plus-plot will add padding on the left so that the legend appears centered underneath the x-axis. By default, this padding is only applied on screens larger than 600 pixels wide.
|
|
55232
56255
|
*/ legendPadding(_) {
|
|
@@ -55606,13 +56629,6 @@
|
|
|
55606
56629
|
h.s = 0;
|
|
55607
56630
|
return `${h}`;
|
|
55608
56631
|
}
|
|
55609
|
-
/** Scene mark types that carry a fill/stroke a hover/active emphasis applies to. */ const MARK_TYPES = new Set([
|
|
55610
|
-
"rect",
|
|
55611
|
-
"circle",
|
|
55612
|
-
"line",
|
|
55613
|
-
"area",
|
|
55614
|
-
"path"
|
|
55615
|
-
]);
|
|
55616
56632
|
/**
|
|
55617
56633
|
Emphasizes a matched mark's stroke on hover/active — the v3 `hoverStyle` /
|
|
55618
56634
|
`activeStyle` look (a thicker, darker outline). v4 paints from the scene
|
|
@@ -55705,6 +56721,20 @@
|
|
|
55705
56721
|
};
|
|
55706
56722
|
return nodes.map(walk);
|
|
55707
56723
|
}
|
|
56724
|
+
/**
|
|
56725
|
+
Whether `predicate` matches `row` or any row it wraps. A mark's datum
|
|
56726
|
+
unwraps to its source row in one step, but its data label is wrapped once
|
|
56727
|
+
more (label → mark datum → row), so a label is only recognized as its
|
|
56728
|
+
mark's by following the `__d3plus__` chain down to the row.
|
|
56729
|
+
*/ function matchesChain(predicate, row, i) {
|
|
56730
|
+
let d = row;
|
|
56731
|
+
if (predicate(d, i)) return true;
|
|
56732
|
+
while(d && d.__d3plus__ && d.data){
|
|
56733
|
+
d = d.data;
|
|
56734
|
+
if (predicate(d, i)) return true;
|
|
56735
|
+
}
|
|
56736
|
+
return false;
|
|
56737
|
+
}
|
|
55708
56738
|
function applyInteractionOpacity(nodes, viz) {
|
|
55709
56739
|
// Precedence (hover → active → highlight) and the dim-vs-gray treatment are
|
|
55710
56740
|
// resolved once in dimSettings; picking one source avoids ambiguous
|
|
@@ -55726,7 +56756,7 @@
|
|
|
55726
56756
|
// the row; for label nodes it's the layout node whose `.data` is the row.
|
|
55727
56757
|
const row = datum.data ?? datum;
|
|
55728
56758
|
const i = typeof node.index === "number" ? node.index : typeof row.i === "number" ? row.i : 0;
|
|
55729
|
-
if (!predicate
|
|
56759
|
+
if (!matchesChain(predicate, row, i)) {
|
|
55730
56760
|
const paint = node.paint ?? {};
|
|
55731
56761
|
if (gray) {
|
|
55732
56762
|
// highlight: recolor the mark to the de-emphasis gray so the
|
|
@@ -55757,15 +56787,16 @@
|
|
|
55757
56787
|
// adds no outline. An active node keeps the stronger active stroke even
|
|
55758
56788
|
// while hovered, rather than dropping to the thinner hover stroke.
|
|
55759
56789
|
if (kind !== "highlight" && MARK_TYPES.has(node.type)) {
|
|
55760
|
-
const active = kind === "active" || (activePredicate
|
|
56790
|
+
const active = kind === "active" || (activePredicate ? matchesChain(activePredicate, row, i) : false);
|
|
55761
56791
|
next = active ? emphasizeStroke(node, 1, 3) : emphasizeStroke(node, 0.5, 2);
|
|
55762
56792
|
}
|
|
55763
56793
|
if (isHover) {
|
|
55764
56794
|
// Raise the hovered node above its siblings. Both renderers paint by
|
|
55765
56795
|
// ascending `z`; restore is automatic — the next repaint rebuilds the
|
|
55766
|
-
// scene with no `z`.
|
|
55767
|
-
//
|
|
55768
|
-
//
|
|
56796
|
+
// scene with no `z`. A matched mark's data label matches too (see
|
|
56797
|
+
// `matchesChain`), so it's raised with its mark and, emitted after it,
|
|
56798
|
+
// still paints on top. Only for hover: highlight relies on
|
|
56799
|
+
// color-vs-gray, not z-order.
|
|
55769
56800
|
next = {
|
|
55770
56801
|
...next,
|
|
55771
56802
|
z: HOVER_RAISE_Z
|
|
@@ -56802,6 +57833,444 @@
|
|
|
56802
57833
|
}
|
|
56803
57834
|
};
|
|
56804
57835
|
|
|
57836
|
+
/** Maps a point through a node transform: rotate (about its anchor), scale, then translate. */ function applyTransform([px, py], t) {
|
|
57837
|
+
if (!t) return [
|
|
57838
|
+
px,
|
|
57839
|
+
py
|
|
57840
|
+
];
|
|
57841
|
+
let x = px, y = py;
|
|
57842
|
+
if (t.rotate) {
|
|
57843
|
+
const [ax, ay] = t.rotateAnchor ?? [
|
|
57844
|
+
0,
|
|
57845
|
+
0
|
|
57846
|
+
];
|
|
57847
|
+
const a = t.rotate * Math.PI / 180, cos = Math.cos(a), sin = Math.sin(a);
|
|
57848
|
+
const dx = x - ax, dy = y - ay;
|
|
57849
|
+
x = ax + dx * cos - dy * sin;
|
|
57850
|
+
y = ay + dx * sin + dy * cos;
|
|
57851
|
+
}
|
|
57852
|
+
const s = t.scale ?? 1;
|
|
57853
|
+
return [
|
|
57854
|
+
x * s + (t.x ?? 0),
|
|
57855
|
+
y * s + (t.y ?? 0)
|
|
57856
|
+
];
|
|
57857
|
+
}
|
|
57858
|
+
/** How finely a path's curves are traced into outline points, in pixels. */ const PATH_STEP = 10;
|
|
57859
|
+
/** A zero-size box at a series vertex. */ const vertexBox = ([x, y])=>({
|
|
57860
|
+
x,
|
|
57861
|
+
y,
|
|
57862
|
+
width: 0,
|
|
57863
|
+
height: 0
|
|
57864
|
+
});
|
|
57865
|
+
/** One box per laid-out line of a text node, from its anchor, baseline, and font size. */ function textBoxes(node) {
|
|
57866
|
+
const size = node.font?.size ?? 0;
|
|
57867
|
+
const anchor = node.font?.anchor ?? "start";
|
|
57868
|
+
const baseline = node.font?.baseline ?? "alphabetic";
|
|
57869
|
+
const above = baseline === "hanging" ? 0 : baseline === "middle" ? size / 2 : size * 0.8;
|
|
57870
|
+
return (node.lines || []).filter((line)=>line.text && line.width).map((line)=>{
|
|
57871
|
+
const shift = anchor === "middle" ? line.width / 2 : anchor === "end" ? line.width : 0;
|
|
57872
|
+
return {
|
|
57873
|
+
x: node.x + line.x - shift,
|
|
57874
|
+
y: node.y + line.y - above,
|
|
57875
|
+
width: line.width,
|
|
57876
|
+
height: size
|
|
57877
|
+
};
|
|
57878
|
+
});
|
|
57879
|
+
}
|
|
57880
|
+
/** Boxes of a node's own geometry, before its transform. Line/area series and paths contribute one box per outline point. */ function ownBoxes(node) {
|
|
57881
|
+
switch(node.type){
|
|
57882
|
+
case "rect":
|
|
57883
|
+
case "image":
|
|
57884
|
+
return [
|
|
57885
|
+
{
|
|
57886
|
+
x: node.x,
|
|
57887
|
+
y: node.y,
|
|
57888
|
+
width: node.width,
|
|
57889
|
+
height: node.height
|
|
57890
|
+
}
|
|
57891
|
+
];
|
|
57892
|
+
case "circle":
|
|
57893
|
+
return [
|
|
57894
|
+
{
|
|
57895
|
+
x: node.cx - node.r,
|
|
57896
|
+
y: node.cy - node.r,
|
|
57897
|
+
width: node.r * 2,
|
|
57898
|
+
height: node.r * 2
|
|
57899
|
+
}
|
|
57900
|
+
];
|
|
57901
|
+
case "path":
|
|
57902
|
+
{
|
|
57903
|
+
// Its outline, so a curved shape (a pie wedge, a map region) doesn't
|
|
57904
|
+
// claim the empty corners of its bounding box.
|
|
57905
|
+
const outline = path2polygon(node.d, PATH_STEP);
|
|
57906
|
+
return outline.length ? outline.map(vertexBox) : [
|
|
57907
|
+
pathBounds(node.d)
|
|
57908
|
+
];
|
|
57909
|
+
}
|
|
57910
|
+
case "line":
|
|
57911
|
+
return node.points.map(vertexBox);
|
|
57912
|
+
case "area":
|
|
57913
|
+
return [
|
|
57914
|
+
...node.topline,
|
|
57915
|
+
...node.baseline
|
|
57916
|
+
].map(vertexBox);
|
|
57917
|
+
case "text":
|
|
57918
|
+
return textBoxes(node);
|
|
57919
|
+
default:
|
|
57920
|
+
return [];
|
|
57921
|
+
}
|
|
57922
|
+
}
|
|
57923
|
+
/** Composes a chain of transforms (outermost first) into one point mapper. */ function mapper(chain) {
|
|
57924
|
+
return (p)=>chain.reduceRight((q, t)=>applyTransform(q, t), p);
|
|
57925
|
+
}
|
|
57926
|
+
/** The axis-aligned box around a box mapped through `map`. */ function mapBox(b, map) {
|
|
57927
|
+
const corners = [
|
|
57928
|
+
map([
|
|
57929
|
+
b.x,
|
|
57930
|
+
b.y
|
|
57931
|
+
]),
|
|
57932
|
+
map([
|
|
57933
|
+
b.x + b.width,
|
|
57934
|
+
b.y
|
|
57935
|
+
]),
|
|
57936
|
+
map([
|
|
57937
|
+
b.x,
|
|
57938
|
+
b.y + b.height
|
|
57939
|
+
]),
|
|
57940
|
+
map([
|
|
57941
|
+
b.x + b.width,
|
|
57942
|
+
b.y + b.height
|
|
57943
|
+
])
|
|
57944
|
+
];
|
|
57945
|
+
const xs = corners.map((c)=>c[0]), ys = corners.map((c)=>c[1]);
|
|
57946
|
+
const x = Math.min(...xs), y = Math.min(...ys);
|
|
57947
|
+
return {
|
|
57948
|
+
x,
|
|
57949
|
+
y,
|
|
57950
|
+
width: Math.max(...xs) - x,
|
|
57951
|
+
height: Math.max(...ys) - y
|
|
57952
|
+
};
|
|
57953
|
+
}
|
|
57954
|
+
/**
|
|
57955
|
+
Boxes, in the coordinate space of `nodes` after `base` is applied, of
|
|
57956
|
+
every data mark and label in a scene: datum-bearing nodes at any depth,
|
|
57957
|
+
with group transforms composed. `::hit` duplicates and chart decorations
|
|
57958
|
+
(axes, gridlines and other nodes without a datum) are skipped.
|
|
57959
|
+
@param nodes The chart's scene nodes (e.g. `viz._chartScene`).
|
|
57960
|
+
@param base A transform applied to all of them (e.g. `viz._chartTransform`).
|
|
57961
|
+
@param skip Excludes a node and everything inside it, for decorations that carry a datum (like axis ticks).
|
|
57962
|
+
*/ function markBoxes(nodes, base, skip) {
|
|
57963
|
+
const out = [];
|
|
57964
|
+
const walk = (list, chain)=>{
|
|
57965
|
+
for (const node of list){
|
|
57966
|
+
if (String(node.key).endsWith("::hit") || skip && skip(node)) continue;
|
|
57967
|
+
const next = node.transform ? [
|
|
57968
|
+
...chain,
|
|
57969
|
+
node.transform
|
|
57970
|
+
] : chain;
|
|
57971
|
+
if (node.type === "group") {
|
|
57972
|
+
walk(node.children, next);
|
|
57973
|
+
continue;
|
|
57974
|
+
}
|
|
57975
|
+
if (node.datum === undefined) continue;
|
|
57976
|
+
const map = mapper(next);
|
|
57977
|
+
for (const b of ownBoxes(node)){
|
|
57978
|
+
if ([
|
|
57979
|
+
b.x,
|
|
57980
|
+
b.y,
|
|
57981
|
+
b.width,
|
|
57982
|
+
b.height
|
|
57983
|
+
].every(Number.isFinite)) out.push(mapBox(b, map));
|
|
57984
|
+
}
|
|
57985
|
+
}
|
|
57986
|
+
};
|
|
57987
|
+
walk(nodes, base ? [
|
|
57988
|
+
base
|
|
57989
|
+
] : []);
|
|
57990
|
+
return out;
|
|
57991
|
+
}
|
|
57992
|
+
|
|
57993
|
+
/**
|
|
57994
|
+
The default inset region: the chart area (or `bounds`, in surface
|
|
57995
|
+
coordinates), with the boxes of every data mark in the chart's scene as
|
|
57996
|
+
obstacles (less any subtree `skip` excludes). Charts opt in by returning
|
|
57997
|
+
this from their `insetRegion`.
|
|
57998
|
+
*/ function sceneInsetRegion(viz, bounds, skip) {
|
|
57999
|
+
const { width, height } = chartBounds(viz);
|
|
58000
|
+
return {
|
|
58001
|
+
bounds: bounds ?? {
|
|
58002
|
+
x: viz._margin.left,
|
|
58003
|
+
y: viz._margin.top,
|
|
58004
|
+
width,
|
|
58005
|
+
height
|
|
58006
|
+
},
|
|
58007
|
+
obstacles: markBoxes(viz._chartScene || [], viz._chartTransform, skip)
|
|
58008
|
+
};
|
|
58009
|
+
}
|
|
58010
|
+
/** Whether `legendInset` is on for this draw. */ function insetEnabled(viz) {
|
|
58011
|
+
const flag = viz.schema.legendInset;
|
|
58012
|
+
return typeof flag === "function" ? Boolean(flag.bind(viz)(resolveSpec(viz))) : Boolean(flag);
|
|
58013
|
+
}
|
|
58014
|
+
/** The smallest a legend entry can be: a swatch (1.4× the 12px label font) plus its padding. */ const MIN_LEGEND_ENTRY = 12 * 1.4 + 5;
|
|
58015
|
+
/**
|
|
58016
|
+
Whether the legend could possibly lay out inside the chart: its entries,
|
|
58017
|
+
even with their labels dropped, must fit the largest frame an inset
|
|
58018
|
+
legend may take (see `insetFrame`). Rules out laying out a legend of
|
|
58019
|
+
hundreds of entries just to find it doesn't fit.
|
|
58020
|
+
*/ function legendCouldFit(viz) {
|
|
58021
|
+
const frame = insetFrame("column", {
|
|
58022
|
+
width: viz.schema.width || 0,
|
|
58023
|
+
height: viz.schema.height || 0
|
|
58024
|
+
});
|
|
58025
|
+
const entries = buildLegendData(viz).legendData.length;
|
|
58026
|
+
return entries * MIN_LEGEND_ENTRY * MIN_LEGEND_ENTRY <= frame.width * frame.height;
|
|
58027
|
+
}
|
|
58028
|
+
/**
|
|
58029
|
+
The candidates this draw may place inside the chart, in priority order.
|
|
58030
|
+
A legend or colorScale whose position the user set explicitly stays
|
|
58031
|
+
where they put it.
|
|
58032
|
+
*/ function insetCandidates(viz) {
|
|
58033
|
+
const auto = viz._insetAutoPositions;
|
|
58034
|
+
return INSET_PRIORITY.filter((key)=>{
|
|
58035
|
+
if (key === "legend") return (!auto || viz.schema.legendPosition === auto.legend) && legendCouldFit(viz);
|
|
58036
|
+
if (key === "colorScale") return !auto || viz.schema.colorScalePosition === auto.colorScale;
|
|
58037
|
+
return true;
|
|
58038
|
+
});
|
|
58039
|
+
}
|
|
58040
|
+
/** The orientations a candidate may take inside the chart. */ const ORIENTS = {
|
|
58041
|
+
sizeLegend: [
|
|
58042
|
+
"column"
|
|
58043
|
+
],
|
|
58044
|
+
legend: [
|
|
58045
|
+
"column",
|
|
58046
|
+
"row"
|
|
58047
|
+
],
|
|
58048
|
+
colorScale: [
|
|
58049
|
+
"column",
|
|
58050
|
+
"row"
|
|
58051
|
+
]
|
|
58052
|
+
};
|
|
58053
|
+
/** Whether a candidate laid out for the chart's interior this pass is showing at all. */ function isShowing(viz, key) {
|
|
58054
|
+
if (key === "sizeLegend") return Boolean(bottomRightControlsBox(viz)?.inset);
|
|
58055
|
+
if (key === "legend") return Boolean(viz._legendClass?._data?.length);
|
|
58056
|
+
return Boolean(viz.schema.colorScale) && sanitizePosition(viz.schema.colorScalePosition.bind(viz)(resolveSpec(viz))) !== false && !viz.schema.colorScaleConfig.select;
|
|
58057
|
+
}
|
|
58058
|
+
/**
|
|
58059
|
+
Lays a showing candidate out for the chart's interior in `orient` and
|
|
58060
|
+
returns its content size, or null when it can't lay out that way.
|
|
58061
|
+
*/ function measure(viz, key, orient, area) {
|
|
58062
|
+
if (key === "sizeLegend") {
|
|
58063
|
+
const box = bottomRightControlsBox(viz);
|
|
58064
|
+
return box ? {
|
|
58065
|
+
width: box.width,
|
|
58066
|
+
height: box.height
|
|
58067
|
+
} : null;
|
|
58068
|
+
}
|
|
58069
|
+
return key === "legend" ? paintLegendInset(viz, orient, area) : paintColorScaleInset(viz, orient, area);
|
|
58070
|
+
}
|
|
58071
|
+
/** The chart corners an inset box is tried in, most preferred first. */ const CORNERS = [
|
|
58072
|
+
{
|
|
58073
|
+
alignX: "right",
|
|
58074
|
+
alignY: "bottom"
|
|
58075
|
+
},
|
|
58076
|
+
{
|
|
58077
|
+
alignX: "right",
|
|
58078
|
+
alignY: "top"
|
|
58079
|
+
},
|
|
58080
|
+
{
|
|
58081
|
+
alignX: "left",
|
|
58082
|
+
alignY: "bottom"
|
|
58083
|
+
},
|
|
58084
|
+
{
|
|
58085
|
+
alignX: "left",
|
|
58086
|
+
alignY: "top"
|
|
58087
|
+
}
|
|
58088
|
+
];
|
|
58089
|
+
/**
|
|
58090
|
+
Where a box of `width` × `height` sits in the open rects (sorted largest
|
|
58091
|
+
first): in the first chart corner, in `CORNERS` order, that some rect
|
|
58092
|
+
reaching that corner has room for. When it fits in no corner, it goes in
|
|
58093
|
+
the first rect it fits, against whichever of the rect's sides lie on the
|
|
58094
|
+
region's edges (bottom-right when it touches both), centered along an
|
|
58095
|
+
axis otherwise.
|
|
58096
|
+
*/ function fitInset(rects, bounds, width, height) {
|
|
58097
|
+
const eps = 0.5;
|
|
58098
|
+
const fits = rects.filter((r)=>r.width >= width && r.height >= height);
|
|
58099
|
+
if (!fits.length) return null;
|
|
58100
|
+
const edges = (r)=>({
|
|
58101
|
+
right: Math.abs(r.x + r.width - (bounds.x + bounds.width)) < eps,
|
|
58102
|
+
left: Math.abs(r.x - bounds.x) < eps,
|
|
58103
|
+
bottom: Math.abs(r.y + r.height - (bounds.y + bounds.height)) < eps,
|
|
58104
|
+
top: Math.abs(r.y - bounds.y) < eps
|
|
58105
|
+
});
|
|
58106
|
+
const place = (r, alignX, alignY)=>({
|
|
58107
|
+
x: alignX === "right" ? r.x + r.width - width : alignX === "left" ? r.x : r.x + (r.width - width) / 2,
|
|
58108
|
+
y: alignY === "bottom" ? r.y + r.height - height : alignY === "top" ? r.y : r.y + (r.height - height) / 2,
|
|
58109
|
+
width,
|
|
58110
|
+
height,
|
|
58111
|
+
alignX,
|
|
58112
|
+
alignY
|
|
58113
|
+
});
|
|
58114
|
+
for (const { alignX, alignY } of CORNERS){
|
|
58115
|
+
const rect = fits.find((r)=>{
|
|
58116
|
+
const e = edges(r);
|
|
58117
|
+
return e[alignX] && e[alignY];
|
|
58118
|
+
});
|
|
58119
|
+
if (rect) return place(rect, alignX, alignY);
|
|
58120
|
+
}
|
|
58121
|
+
const rect = fits[0], e = edges(rect);
|
|
58122
|
+
return place(rect, e.right ? "right" : e.left ? "left" : "center", e.bottom ? "bottom" : e.top ? "top" : "middle");
|
|
58123
|
+
}
|
|
58124
|
+
/** Rough height of the attribution credit, a single line of small text. */ const ATTRIBUTION_HEIGHT = 22;
|
|
58125
|
+
/**
|
|
58126
|
+
Boxes of the chrome overlaid on the chart that inset chrome must also
|
|
58127
|
+
stay clear of: the zoom buttons (and the minimap that opens beneath
|
|
58128
|
+
them once zoomed), the top-left controls, and the attribution credit in
|
|
58129
|
+
the chart area's bottom-right corner (sized from its rendered node when
|
|
58130
|
+
there is one, otherwise from its text, up to the half of the chart it
|
|
58131
|
+
may span before collapsing to a badge).
|
|
58132
|
+
*/ function chromeBoxes(viz) {
|
|
58133
|
+
const boxes = [];
|
|
58134
|
+
const { width, height } = chartBounds(viz);
|
|
58135
|
+
const zoom = zoomControlsBox(viz);
|
|
58136
|
+
if (zoom) {
|
|
58137
|
+
const minimap = viz.schema.minimap ? (zoom.width - MINIMAP_RIGHT_INSET) * (height / Math.max(1, width)) : 0;
|
|
58138
|
+
boxes.push({
|
|
58139
|
+
x: viz.schema.width - zoom.width,
|
|
58140
|
+
y: 0,
|
|
58141
|
+
width: zoom.width,
|
|
58142
|
+
height: zoom.height + minimap
|
|
58143
|
+
});
|
|
58144
|
+
}
|
|
58145
|
+
const topLeft = topLeftControlsBox(viz, getTopLeftContributions(viz));
|
|
58146
|
+
if (topLeft) boxes.push({
|
|
58147
|
+
x: 0,
|
|
58148
|
+
y: 0,
|
|
58149
|
+
width: topLeft.width,
|
|
58150
|
+
height: topLeft.height
|
|
58151
|
+
});
|
|
58152
|
+
if (viz.schema.attribution) {
|
|
58153
|
+
const parent = viz._select?.node?.()?.parentNode;
|
|
58154
|
+
const node = parent?.querySelector?.("div.d3plus-attribution");
|
|
58155
|
+
const text = String(viz.schema.attribution).replace(/<[^>]*>/g, "");
|
|
58156
|
+
const w = Math.min(node?.offsetWidth || text.length * 6 + 30, width / 2);
|
|
58157
|
+
const h = node?.offsetHeight || ATTRIBUTION_HEIGHT;
|
|
58158
|
+
const right = viz.schema.width - viz._margin.right, bottom = viz.schema.height - viz._margin.bottom;
|
|
58159
|
+
boxes.push({
|
|
58160
|
+
x: right - w,
|
|
58161
|
+
y: bottom - h,
|
|
58162
|
+
width: w,
|
|
58163
|
+
height: h
|
|
58164
|
+
});
|
|
58165
|
+
}
|
|
58166
|
+
return boxes;
|
|
58167
|
+
}
|
|
58168
|
+
/** The open rects in the chart's region, kept `padding` clear of the marks and the region's edges. */ function openSpace(viz) {
|
|
58169
|
+
const region = viz._insetRegion?.();
|
|
58170
|
+
if (!region) return null;
|
|
58171
|
+
const { padding } = insetStyle(viz);
|
|
58172
|
+
const b = region.bounds;
|
|
58173
|
+
const bounds = {
|
|
58174
|
+
x: b.x + padding,
|
|
58175
|
+
y: b.y + padding,
|
|
58176
|
+
width: b.width - padding * 2,
|
|
58177
|
+
height: b.height - padding * 2
|
|
58178
|
+
};
|
|
58179
|
+
if (bounds.width <= 0 || bounds.height <= 0) return null;
|
|
58180
|
+
const exclude = chromeBoxes(viz);
|
|
58181
|
+
return {
|
|
58182
|
+
rects: negativeSpace(bounds, region.obstacles, {
|
|
58183
|
+
padding,
|
|
58184
|
+
exclude
|
|
58185
|
+
}),
|
|
58186
|
+
bounds,
|
|
58187
|
+
area: b
|
|
58188
|
+
};
|
|
58189
|
+
}
|
|
58190
|
+
/**
|
|
58191
|
+
Fits the first of `keys` that has room inside the chart. Returns the
|
|
58192
|
+
placement (or null) and which candidates are showing at all.
|
|
58193
|
+
*/ function choose(viz, keys) {
|
|
58194
|
+
const showing = keys.filter((key)=>isShowing(viz, key));
|
|
58195
|
+
const space = showing.length ? openSpace(viz) : null;
|
|
58196
|
+
if (!space || !space.rects.length) return {
|
|
58197
|
+
placement: null,
|
|
58198
|
+
showing
|
|
58199
|
+
};
|
|
58200
|
+
const { margin } = insetStyle(viz);
|
|
58201
|
+
for (const key of showing){
|
|
58202
|
+
for (const orient of ORIENTS[key]){
|
|
58203
|
+
const size = measure(viz, key, orient, space.area);
|
|
58204
|
+
const spot = size && fitInset(space.rects, space.bounds, size.width + margin * 2, size.height + margin * 2);
|
|
58205
|
+
if (spot) {
|
|
58206
|
+
return {
|
|
58207
|
+
placement: {
|
|
58208
|
+
key,
|
|
58209
|
+
orient,
|
|
58210
|
+
...spot
|
|
58211
|
+
},
|
|
58212
|
+
showing
|
|
58213
|
+
};
|
|
58214
|
+
}
|
|
58215
|
+
}
|
|
58216
|
+
}
|
|
58217
|
+
return {
|
|
58218
|
+
placement: null,
|
|
58219
|
+
showing
|
|
58220
|
+
};
|
|
58221
|
+
}
|
|
58222
|
+
/** Runs `_draw()` again from the margins the render started with. */ function redraw(viz, start) {
|
|
58223
|
+
viz._margin = {
|
|
58224
|
+
...start.margin
|
|
58225
|
+
};
|
|
58226
|
+
viz._padding = {
|
|
58227
|
+
...start.padding
|
|
58228
|
+
};
|
|
58229
|
+
viz._draw();
|
|
58230
|
+
}
|
|
58231
|
+
/**
|
|
58232
|
+
`viz._draw()`, placing chrome inside the chart's negative space when it
|
|
58233
|
+
fits (see the module docs). Leaves `viz._insetPlacement` set to what was
|
|
58234
|
+
placed, or null.
|
|
58235
|
+
*/ function drawWithInset(viz) {
|
|
58236
|
+
viz._insetPlacement = null;
|
|
58237
|
+
const keys = typeof viz._insetRegion === "function" && insetEnabled(viz) ? insetCandidates(viz) : [];
|
|
58238
|
+
if (!keys.length) {
|
|
58239
|
+
viz._insetPending = null;
|
|
58240
|
+
viz._draw();
|
|
58241
|
+
return;
|
|
58242
|
+
}
|
|
58243
|
+
const start = {
|
|
58244
|
+
margin: {
|
|
58245
|
+
...viz._margin
|
|
58246
|
+
},
|
|
58247
|
+
padding: {
|
|
58248
|
+
...viz._padding
|
|
58249
|
+
}
|
|
58250
|
+
};
|
|
58251
|
+
viz._insetPending = new Set(keys);
|
|
58252
|
+
viz._draw();
|
|
58253
|
+
const first = choose(viz, keys);
|
|
58254
|
+
const { showing } = first;
|
|
58255
|
+
let { placement } = first;
|
|
58256
|
+
if (!showing.length) return;
|
|
58257
|
+
if (placement && showing.some((k)=>k !== placement.key)) {
|
|
58258
|
+
viz._insetPending = new Set([
|
|
58259
|
+
placement.key
|
|
58260
|
+
]);
|
|
58261
|
+
redraw(viz, start);
|
|
58262
|
+
placement = choose(viz, [
|
|
58263
|
+
placement.key
|
|
58264
|
+
]).placement;
|
|
58265
|
+
}
|
|
58266
|
+
if (!placement) {
|
|
58267
|
+
viz._insetPending = new Set();
|
|
58268
|
+
redraw(viz, start);
|
|
58269
|
+
return;
|
|
58270
|
+
}
|
|
58271
|
+
viz._insetPlacement = placement;
|
|
58272
|
+
}
|
|
58273
|
+
|
|
56805
58274
|
/** The text/stroke color that reads against the chart's background. */ function inkColor(viz) {
|
|
56806
58275
|
const node = viz._select && typeof viz._select.node === "function" ? viz._select.node() : null;
|
|
56807
58276
|
const bg = node ? backgroundColor(node) : "rgb(255, 255, 255)";
|
|
@@ -56880,10 +58349,12 @@
|
|
|
56880
58349
|
if (c) items.push(c);
|
|
56881
58350
|
}
|
|
56882
58351
|
const side = viz.schema.sizeLegendPosition === "bottom" ? "bottom" : "right";
|
|
58352
|
+
const inset = isInsetPending(viz, "sizeLegend");
|
|
56883
58353
|
viz._bottomRightBox = items.length ? {
|
|
56884
58354
|
...measureBottomRight(items),
|
|
56885
58355
|
bottom,
|
|
56886
58356
|
side,
|
|
58357
|
+
inset,
|
|
56887
58358
|
items
|
|
56888
58359
|
} : null;
|
|
56889
58360
|
}
|
|
@@ -56910,7 +58381,9 @@
|
|
|
56910
58381
|
// hold the BASE Viz behavior; subclasses' `super._preDraw()`/`super._draw()`
|
|
56911
58382
|
// calls hit the shim which delegates to the free functions.
|
|
56912
58383
|
viz._preDraw();
|
|
56913
|
-
|
|
58384
|
+
// `_draw()`, possibly more than once: chrome that fits inside the chart's
|
|
58385
|
+
// negative space is placed there after layout (see insetPlacement.ts).
|
|
58386
|
+
drawWithInset(viz);
|
|
56914
58387
|
// Post-draw features: zoom + brush event wiring, the minimap, the shared
|
|
56915
58388
|
// top-left controls panel (back / table-view button / search), the
|
|
56916
58389
|
// attribution overlay, and the table-view data-table overlay. All run
|
|
@@ -57992,9 +59465,9 @@
|
|
|
57992
59465
|
children.push({
|
|
57993
59466
|
type: "group",
|
|
57994
59467
|
key: `viz-${name}`,
|
|
57995
|
-
children: [
|
|
59468
|
+
children: name === "timeline" ? [
|
|
57996
59469
|
compScene
|
|
57997
|
-
]
|
|
59470
|
+
] : insetComponentScene(this, name, compScene, comp.outerBounds())
|
|
57998
59471
|
});
|
|
57999
59472
|
}
|
|
58000
59473
|
}
|
|
@@ -58030,6 +59503,14 @@
|
|
|
58030
59503
|
*/ _sizeLegendScale(_available) {
|
|
58031
59504
|
return null;
|
|
58032
59505
|
}
|
|
59506
|
+
/**
|
|
59507
|
+
The region chart chrome may be drawn inside, with the chart's mark boxes
|
|
59508
|
+
as obstacles (see `ChartDefinition.insetRegion`). Charts that leave
|
|
59509
|
+
negative space override this; the base chart offers none.
|
|
59510
|
+
@private
|
|
59511
|
+
*/ _insetRegion() {
|
|
59512
|
+
return null;
|
|
59513
|
+
}
|
|
58033
59514
|
/**
|
|
58034
59515
|
* Applies the threshold algorithm according to the type of chart used.
|
|
58035
59516
|
* @param {Array} data The data to process.
|
|
@@ -58404,6 +59885,7 @@
|
|
|
58404
59885
|
/**
|
|
58405
59886
|
Tears down the visualization: disconnects the ResizeObserver, stops listening for web font loads, and removes DOM event listeners. Call this when unmounting to avoid memory leaks.
|
|
58406
59887
|
*/ destroy() {
|
|
59888
|
+
unregisterLink(this);
|
|
58407
59889
|
this._resizeObserver?.disconnect();
|
|
58408
59890
|
this._fontsUnsubscribe?.();
|
|
58409
59891
|
this._fontsUnsubscribe = undefined;
|
|
@@ -58446,6 +59928,7 @@
|
|
|
58446
59928
|
*/ constructor(){
|
|
58447
59929
|
super();
|
|
58448
59930
|
initVizDefaults(this);
|
|
59931
|
+
initInsetDefaults(this);
|
|
58449
59932
|
}
|
|
58450
59933
|
}
|
|
58451
59934
|
|
|
@@ -58466,6 +59949,9 @@
|
|
|
58466
59949
|
_sizeLegendScale(available) {
|
|
58467
59950
|
return def.sizeLegendScale ? def.sizeLegendScale(this, available) : super._sizeLegendScale(available);
|
|
58468
59951
|
}
|
|
59952
|
+
_insetRegion() {
|
|
59953
|
+
return def.insetRegion ? def.insetRegion(this) : super._insetRegion();
|
|
59954
|
+
}
|
|
58469
59955
|
_thresholdFunction(data) {
|
|
58470
59956
|
return def.thresholdFunction ? def.thresholdFunction(this, data) : data;
|
|
58471
59957
|
}
|
|
@@ -58534,13 +60020,22 @@
|
|
|
58534
60020
|
}
|
|
58535
60021
|
return val;
|
|
58536
60022
|
}
|
|
60023
|
+
/**
|
|
60024
|
+
Resolve a datum's scene fill from a shape-config record: a
|
|
60025
|
+
`pattern:<json>` token when `sc.texture` is set for the datum (the
|
|
60026
|
+
renderer backends materialize it), otherwise the resolved `fill` when
|
|
60027
|
+
it is a string. `fill` is the datum's already-resolved `sc.fill`.
|
|
60028
|
+
*/ function textureFill(sc, d, i, fill) {
|
|
60029
|
+
const key = textureKey(resolveAccessor$6(sc.texture, d, i), ()=>fill, ()=>resolveAccessor$6(sc.stroke, d, i), sc.textureDefault);
|
|
60030
|
+
if (key) return `pattern:${key}`;
|
|
60031
|
+
return typeof fill === "string" ? fill : undefined;
|
|
60032
|
+
}
|
|
58537
60033
|
/**
|
|
58538
60034
|
Resolve the standard paint properties (`fill`, `stroke`, `strokeWidth`,
|
|
58539
60035
|
`opacity`) from a shape-config record for a single datum. Returns a
|
|
58540
|
-
`Paint`-shaped object compatible with `SceneNode.paint`. `fill`
|
|
58541
|
-
|
|
58542
|
-
|
|
58543
|
-
do this same coercion).
|
|
60036
|
+
`Paint`-shaped object compatible with `SceneNode.paint`. `fill` resolves
|
|
60037
|
+
through `textureFill`, so a texture becomes a `pattern:<json>` token and
|
|
60038
|
+
a non-string fill becomes `undefined`.
|
|
58544
60039
|
*/ function paintFromShapeConfig(sc, d, i) {
|
|
58545
60040
|
const fill = resolveAccessor$6(sc.fill, d, i);
|
|
58546
60041
|
const stroke = resolveAccessor$6(sc.stroke, d, i);
|
|
@@ -58548,7 +60043,7 @@
|
|
|
58548
60043
|
const opacity = resolveAccessor$6(sc.opacity, d, i);
|
|
58549
60044
|
const ve = resolveAccessor$6(sc.vectorEffect, d, i);
|
|
58550
60045
|
return {
|
|
58551
|
-
fill:
|
|
60046
|
+
fill: textureFill(sc, d, i, fill),
|
|
58552
60047
|
stroke,
|
|
58553
60048
|
strokeWidth,
|
|
58554
60049
|
opacity,
|
|
@@ -58632,6 +60127,79 @@
|
|
|
58632
60127
|
}
|
|
58633
60128
|
}
|
|
58634
60129
|
|
|
60130
|
+
/** The calendar intervals a time axis is checked against, coarsest first. */ const intervals = [
|
|
60131
|
+
timeYear,
|
|
60132
|
+
timeMonth,
|
|
60133
|
+
timeDay,
|
|
60134
|
+
timeHour,
|
|
60135
|
+
timeMinute,
|
|
60136
|
+
second
|
|
60137
|
+
];
|
|
60138
|
+
/** The median of a non-empty list of numbers. */ function median(values) {
|
|
60139
|
+
const sorted = values.slice().sort((a, b)=>a - b);
|
|
60140
|
+
const mid = sorted.length >> 1;
|
|
60141
|
+
return sorted.length % 2 ? sorted[mid] : (sorted[mid - 1] + sorted[mid]) / 2;
|
|
60142
|
+
}
|
|
60143
|
+
/** Drops floating point noise from a stepped number (0.1 + 0.2 → 0.3). */ const clean = (n)=>+n.toPrecision(12);
|
|
60144
|
+
/**
|
|
60145
|
+
How to step along an independent axis: numbers by the median gap between
|
|
60146
|
+
distinct values; dates by the coarsest calendar interval every date lands
|
|
60147
|
+
on (years, months, days, …) times the median number of those intervals
|
|
60148
|
+
between dates, falling back to the median gap in milliseconds. Null for a
|
|
60149
|
+
category axis or fewer than two distinct values.
|
|
60150
|
+
@param order The independent axis's values.
|
|
60151
|
+
*/ function trendStep(order) {
|
|
60152
|
+
const time = order.some((v)=>v instanceof Date);
|
|
60153
|
+
if (order.some((v)=>!(v instanceof Date) && typeof v !== "number")) return null;
|
|
60154
|
+
const values = Array.from(new Set(order.map(Number).filter(Number.isFinite))).sort((a, b)=>a - b);
|
|
60155
|
+
if (values.length < 2) return null;
|
|
60156
|
+
const gaps = values.slice(1).map((v, i)=>v - values[i]);
|
|
60157
|
+
if (!time) {
|
|
60158
|
+
const step = median(gaps);
|
|
60159
|
+
return (v, k)=>clean(v + step * k);
|
|
60160
|
+
}
|
|
60161
|
+
const dates = values.map((v)=>new Date(v));
|
|
60162
|
+
const interval = intervals.find((t)=>dates.every((d)=>+t.floor(d) === +d));
|
|
60163
|
+
if (interval) {
|
|
60164
|
+
const step = Math.round(median(dates.slice(1).map((d, i)=>interval.count(dates[i], d))));
|
|
60165
|
+
if (step > 0) return (v, k)=>interval.offset(v, step * k);
|
|
60166
|
+
}
|
|
60167
|
+
const step = median(gaps);
|
|
60168
|
+
return (v, k)=>new Date(+v + step * k);
|
|
60169
|
+
}
|
|
60170
|
+
/** Most steps a `{to}` projection will add, so a far-off end can't run away. */ const MAX_STEPS = 1000;
|
|
60171
|
+
/**
|
|
60172
|
+
The future independent-axis positions a projection adds after the last
|
|
60173
|
+
value of `order`: `projection` steps, or every step up to and including
|
|
60174
|
+
`projection.to`. Empty when off, on a category axis, or when the end
|
|
60175
|
+
isn't past the last value.
|
|
60176
|
+
@param order The independent axis's values.
|
|
60177
|
+
@param projection The `trendLineConfig.projection` setting.
|
|
60178
|
+
*/ function projectionPositions(order, projection) {
|
|
60179
|
+
if (!projection) return [];
|
|
60180
|
+
const offset = trendStep(order);
|
|
60181
|
+
if (!offset) return [];
|
|
60182
|
+
const time = order.some((v)=>v instanceof Date);
|
|
60183
|
+
const last = order.reduce((a, b)=>+b > +a ? b : a, order[0]);
|
|
60184
|
+
if (typeof projection === "number") {
|
|
60185
|
+
const count = Math.min(Math.floor(projection), MAX_STEPS);
|
|
60186
|
+
return Array.from({
|
|
60187
|
+
length: Math.max(count, 0)
|
|
60188
|
+
}, (_, i)=>offset(last, i + 1));
|
|
60189
|
+
}
|
|
60190
|
+
const to = projection.to;
|
|
60191
|
+
if (to === undefined || to === null) return [];
|
|
60192
|
+
const end = time ? date$2(to) : +to;
|
|
60193
|
+
if (!Number.isFinite(+end)) return [];
|
|
60194
|
+
const out = [];
|
|
60195
|
+
for(let k = 1; k <= MAX_STEPS; k++){
|
|
60196
|
+
const next = offset(last, k);
|
|
60197
|
+
if (+next > +end) break;
|
|
60198
|
+
out.push(next);
|
|
60199
|
+
}
|
|
60200
|
+
return out;
|
|
60201
|
+
}
|
|
60202
|
+
|
|
58635
60203
|
/** The regression types `trendLine` accepts. */ const trendTypes = [
|
|
58636
60204
|
"linear",
|
|
58637
60205
|
"exponential",
|
|
@@ -58649,6 +60217,10 @@
|
|
|
58649
60217
|
confidenceLevel: 0.95,
|
|
58650
60218
|
group: "series",
|
|
58651
60219
|
order: 2,
|
|
60220
|
+
projection: 0,
|
|
60221
|
+
projectionConfig: {
|
|
60222
|
+
strokeDasharray: "2 4"
|
|
60223
|
+
},
|
|
58652
60224
|
strokeDasharray: "6 4",
|
|
58653
60225
|
strokeWidth: 2,
|
|
58654
60226
|
tooltip: true
|
|
@@ -58696,6 +60268,33 @@
|
|
|
58696
60268
|
length: count
|
|
58697
60269
|
}, (_, i)=>lo + (hi - lo) * i / (count - 1));
|
|
58698
60270
|
}
|
|
60271
|
+
/**
|
|
60272
|
+
The independent-axis positions to sample a fit's projection at, past the
|
|
60273
|
+
end of its data: each projected category on a point scale, or on a
|
|
60274
|
+
continuous axis evenly spaced points (as dense as the fitted stretch)
|
|
60275
|
+
together with every projected step. The first position is the fit's last
|
|
60276
|
+
value, where the projection starts.
|
|
60277
|
+
@param extent The fit's `[min, max]` independent values.
|
|
60278
|
+
@param steps The axis positions the projection passes through, as numbers.
|
|
60279
|
+
@param categories The point scale's positions, or null on a continuous axis.
|
|
60280
|
+
*/ function trendProjectionPositions(extent, steps, categories) {
|
|
60281
|
+
const [lo, hi] = extent;
|
|
60282
|
+
const end = Math.max(...steps);
|
|
60283
|
+
if (!(end > hi)) return [];
|
|
60284
|
+
if (categories) return [
|
|
60285
|
+
hi,
|
|
60286
|
+
...categories.filter((n)=>n > hi && n <= end)
|
|
60287
|
+
];
|
|
60288
|
+
const count = hi > lo ? Math.round(SAMPLES * (end - hi) / (hi - lo)) : SAMPLES;
|
|
60289
|
+
const even = trendSamplePositions([
|
|
60290
|
+
hi,
|
|
60291
|
+
end
|
|
60292
|
+
], null, Math.min(Math.max(count, 2), SAMPLES) + 1);
|
|
60293
|
+
return Array.from(new Set([
|
|
60294
|
+
...even,
|
|
60295
|
+
...steps.filter((n)=>n > hi)
|
|
60296
|
+
])).sort((a, b)=>a - b);
|
|
60297
|
+
}
|
|
58699
60298
|
/** Whether an axis plots on a point (category) scale, matching `computePlotScales`. */ function isPointAxis(viz, axis) {
|
|
58700
60299
|
if (viz[`_${axis}Time`]) return false;
|
|
58701
60300
|
return viz.schema.discrete === axis && !isSpanAxis(viz, axis) || !!viz.schema[`${axis}Sort`];
|
|
@@ -58716,7 +60315,7 @@
|
|
|
58716
60315
|
];
|
|
58717
60316
|
// A stacked chart fits the stack totals, so the line follows the stack tops.
|
|
58718
60317
|
if (viz.schema.stacked) {
|
|
58719
|
-
const totals = groups(rows, (r)=>toNumber(r[axis])).map(([n, rs])=>[
|
|
60318
|
+
const totals = groups$1(rows, (r)=>toNumber(r[axis])).map(([n, rs])=>[
|
|
58720
60319
|
n,
|
|
58721
60320
|
rs.reduce((s, r)=>s + (+r[dep] || 0), 0)
|
|
58722
60321
|
]);
|
|
@@ -58738,7 +60337,7 @@
|
|
|
58738
60337
|
]
|
|
58739
60338
|
];
|
|
58740
60339
|
if (viz._trendLineConfig?.group === "all") return all;
|
|
58741
|
-
const bySeries = (depth)=>groups(rows, (r)=>seriesKey(viz, r, depth)).map(([key, rs])=>[
|
|
60340
|
+
const bySeries = (depth)=>groups$1(rows, (r)=>seriesKey(viz, r, depth)).map(([key, rs])=>[
|
|
58742
60341
|
key,
|
|
58743
60342
|
rs.map(point),
|
|
58744
60343
|
rs[0],
|
|
@@ -58749,14 +60348,21 @@
|
|
|
58749
60348
|
if (drawn.some(([, points])=>points.length > 1)) return drawn;
|
|
58750
60349
|
return depth > 0 ? bySeries(depth - 1) : all;
|
|
58751
60350
|
}
|
|
58752
|
-
/**
|
|
60351
|
+
/**
|
|
60352
|
+
Fits the trend lines for the current data; empty when `trendLine` is off.
|
|
60353
|
+
`projected` lists future independent-axis positions (from
|
|
60354
|
+
`projectionPositions`) each line extends to, past the end of its data.
|
|
60355
|
+
*/ function computeTrendFits(viz, rows, order, projected = []) {
|
|
58753
60356
|
const type = resolveTrendType(viz._trendLine);
|
|
58754
60357
|
if (!type || !rows.length) return [];
|
|
58755
60358
|
const config = viz._trendLineConfig || {};
|
|
58756
60359
|
const axis = trendAxis(viz.schema.discrete);
|
|
58757
60360
|
const dep = axis === "x" ? "y" : "x";
|
|
58758
|
-
const { toNumber, fromNumber } = trendNumberScale(order);
|
|
58759
|
-
const categories = isPointAxis(viz, axis) ? order.map(toNumber).filter(Number.isFinite) : null;
|
|
60361
|
+
const { toNumber, fromNumber } = trendNumberScale(order.concat(projected));
|
|
60362
|
+
const categories = isPointAxis(viz, axis) ? order.concat(projected).map(toNumber).filter(Number.isFinite) : null;
|
|
60363
|
+
// With a projection on, a line projects through every axis position past
|
|
60364
|
+
// its data: the projected ones, and those other series still plot.
|
|
60365
|
+
const steps = projected.length ? order.concat(projected).map(toNumber).filter(Number.isFinite) : [];
|
|
58760
60366
|
const logDep = `${viz[`_${dep}Config`]?.scale}`.toLowerCase() === "log";
|
|
58761
60367
|
const fill = viz.schema.shapeConfig.fill;
|
|
58762
60368
|
const fits = [];
|
|
@@ -58765,18 +60371,28 @@
|
|
|
58765
60371
|
order: config.order
|
|
58766
60372
|
});
|
|
58767
60373
|
if (!fit) continue;
|
|
58768
|
-
const
|
|
60374
|
+
const banded = config.confidence && type === "linear";
|
|
60375
|
+
const level = config.confidenceLevel;
|
|
60376
|
+
// The fitted stretch bands the mean response; the projection widens to
|
|
60377
|
+
// where a new observation could fall.
|
|
60378
|
+
const band = banded ? linearConfidence(points, level) : null;
|
|
60379
|
+
const fan = banded ? linearPrediction(points, level) : null;
|
|
58769
60380
|
const samples = [];
|
|
58770
|
-
|
|
60381
|
+
const sampleAt = (n, projectedRun)=>{
|
|
58771
60382
|
const value = fit.predict(n);
|
|
58772
|
-
if (!Number.isFinite(value) || logDep && value <= 0)
|
|
60383
|
+
if (!Number.isFinite(value) || logDep && value <= 0) return;
|
|
58773
60384
|
const sample = {
|
|
58774
60385
|
[axis]: fromNumber(n),
|
|
58775
60386
|
[dep]: value
|
|
58776
60387
|
};
|
|
58777
|
-
|
|
60388
|
+
const bounds = projectedRun ? fan : band;
|
|
60389
|
+
if (bounds) [sample.lci, sample.hci] = bounds(n);
|
|
60390
|
+
if (projectedRun) sample.projected = true;
|
|
60391
|
+
if (projectedRun && n > fit.extent[1] && steps.includes(n)) sample.step = true;
|
|
58778
60392
|
samples.push(sample);
|
|
58779
|
-
}
|
|
60393
|
+
};
|
|
60394
|
+
trendSamplePositions(fit.extent, categories).forEach((n)=>sampleAt(n, false));
|
|
60395
|
+
trendProjectionPositions(fit.extent, steps, categories).forEach((n)=>sampleAt(n, true));
|
|
58780
60396
|
if (samples.length < 2) continue;
|
|
58781
60397
|
const row = source ? source.data : undefined;
|
|
58782
60398
|
const color = config.stroke ? config.stroke : row ? typeof fill === "function" ? fill(row, source.i) : fill : "#444";
|
|
@@ -58808,17 +60424,25 @@
|
|
|
58808
60424
|
`computePlotTrendFits` — runs after `computePlotAxisValues`: fits the
|
|
58809
60425
|
trend lines onto `viz._trendFits` and appends their values to the
|
|
58810
60426
|
dependent axis's values, so the non-stacked domain covers them (the
|
|
58811
|
-
stacked domain reads `viz._trendFits` directly).
|
|
60427
|
+
stacked domain reads `viz._trendFits` directly). A projection's future
|
|
60428
|
+
positions join the independent axis's values, widening it to fit.
|
|
58812
60429
|
*/ const computePlotTrendFits = ({ viz, plotFormattedData, xData, yData })=>{
|
|
58813
60430
|
const axis = trendAxis(viz.schema.discrete);
|
|
58814
|
-
const
|
|
60431
|
+
const order = (axis === "x" ? xData : yData) || [];
|
|
60432
|
+
const projected = resolveTrendType(viz._trendLine) ? projectionPositions(order, viz._trendLineConfig?.projection) : [];
|
|
60433
|
+
const fits = viz._trendFits = computeTrendFits(viz, plotFormattedData || [], order, projected);
|
|
58815
60434
|
if (!fits.length) return {};
|
|
58816
60435
|
const extra = trendDomainValues(fits);
|
|
58817
|
-
|
|
60436
|
+
const out = axis === "x" ? {
|
|
58818
60437
|
yData: (yData || []).concat(extra)
|
|
58819
60438
|
} : {
|
|
58820
60439
|
xData: (xData || []).concat(extra)
|
|
58821
60440
|
};
|
|
60441
|
+
if (!fits.some((f)=>f.samples.some((s)=>s.projected))) return out;
|
|
60442
|
+
return {
|
|
60443
|
+
...out,
|
|
60444
|
+
[`${axis}Data`]: order.concat(projected)
|
|
60445
|
+
};
|
|
58822
60446
|
};
|
|
58823
60447
|
|
|
58824
60448
|
/**
|
|
@@ -58880,7 +60504,7 @@
|
|
|
58880
60504
|
"Area",
|
|
58881
60505
|
"Bar"
|
|
58882
60506
|
].includes(d.shape));
|
|
58883
|
-
const groupValues = groups(stackedData, (d)=>d.group).reduce((obj, [key, values])=>{
|
|
60507
|
+
const groupValues = groups$1(stackedData, (d)=>d.group).reduce((obj, [key, values])=>{
|
|
58884
60508
|
if (!obj[key]) obj[key] = 0;
|
|
58885
60509
|
obj[key] += sum$2(values, (dd)=>dd[opp]);
|
|
58886
60510
|
return obj;
|
|
@@ -58894,7 +60518,7 @@
|
|
|
58894
60518
|
});
|
|
58895
60519
|
const discreteKeys = Array.from(new Set(axisData.map((d)=>d.discrete)));
|
|
58896
60520
|
const stackKeys = Array.from(new Set(axisData.map((d)=>d.id)));
|
|
58897
|
-
const stackGroupsData = groups(axisData, (d)=>d.discrete).map(([, values])=>values);
|
|
60521
|
+
const stackGroupsData = groups$1(axisData, (d)=>d.discrete).map(([, values])=>values);
|
|
58898
60522
|
stampStackShares(data, opp);
|
|
58899
60523
|
fillMissingAreaPoints(viz, {
|
|
58900
60524
|
axisData,
|
|
@@ -59041,7 +60665,7 @@
|
|
|
59041
60665
|
if (d.shape !== "Line") return false;
|
|
59042
60666
|
return typeof viz.schema.lineLabels === "function" ? viz.schema.lineLabels(d.data, d.i) : true;
|
|
59043
60667
|
});
|
|
59044
|
-
const lineData = groups(labelData, (d)=>d.id);
|
|
60668
|
+
const lineData = groups$1(labelData, (d)=>d.id);
|
|
59045
60669
|
if (!lineData.length) {
|
|
59046
60670
|
return {
|
|
59047
60671
|
plotLabelWidths: [],
|
|
@@ -59277,7 +60901,7 @@
|
|
|
59277
60901
|
const xScale = plotScales.xScale, yScale = plotScales.yScale;
|
|
59278
60902
|
const oppScale = viz.schema.discrete === "x" ? yScale : xScale;
|
|
59279
60903
|
if (oppScale !== "Point") {
|
|
59280
|
-
const allShapeData = groups(axisData, (d)=>d.shape);
|
|
60904
|
+
const allShapeData = groups$1(axisData, (d)=>d.shape);
|
|
59281
60905
|
allShapeData.forEach(([key, values])=>{
|
|
59282
60906
|
if ([
|
|
59283
60907
|
"Bar",
|
|
@@ -59563,7 +61187,7 @@
|
|
|
59563
61187
|
*/ function bumpLineLabels(viz, labelWidths, yRange) {
|
|
59564
61188
|
let labelPositions = {};
|
|
59565
61189
|
if (labelWidths) {
|
|
59566
|
-
groups(labelWidths, (d)=>d.xValue).forEach(([, values])=>{
|
|
61190
|
+
groups$1(labelWidths, (d)=>d.xValue).forEach(([, values])=>{
|
|
59567
61191
|
const minFontSize = max$6(values.map((d)=>d.fontSize));
|
|
59568
61192
|
const yBuckets = range$2(yRange[0], yRange[1], minFontSize).reverse();
|
|
59569
61193
|
const bumpLimit = (yRange[1] - yRange[0]) / 8;
|
|
@@ -60171,7 +61795,7 @@
|
|
|
60171
61795
|
let { x, y, x2, y2 } = layoutCtx.plotScales;
|
|
60172
61796
|
const { xScale, yScale } = layoutCtx.plotScales;
|
|
60173
61797
|
const { xConfigScale, yConfigScale, x2ConfigScale, y2ConfigScale } = layoutCtx.plotConfigScales;
|
|
60174
|
-
const shapeData = groups(data, (d)=>d.shape).sort(([a], [b])=>viz.schema.shapeSort(a, b));
|
|
61798
|
+
const shapeData = groups$1(data, (d)=>d.shape).sort(([a], [b])=>viz.schema.shapeSort(a, b));
|
|
60175
61799
|
({ x, y, x2, y2 } = runPlotExtendScales(viz, data, axisData, layoutCtx, {
|
|
60176
61800
|
x,
|
|
60177
61801
|
y,
|
|
@@ -60788,7 +62412,7 @@
|
|
|
60788
62412
|
else space = range[range.length - 1] - range[0];
|
|
60789
62413
|
if (viz._groupPadding < space) space -= viz._groupPadding;
|
|
60790
62414
|
let barSize = space || 1;
|
|
60791
|
-
const barGroups = groups(values, (d)=>d[viz.schema.discrete], (d)=>d.group);
|
|
62415
|
+
const barGroups = groups$1(values, (d)=>d[viz.schema.discrete], (d)=>d.group);
|
|
60792
62416
|
const ids = merge(barGroups.map(([, innerEntries])=>innerEntries.map(([k])=>k)));
|
|
60793
62417
|
const uniqueIds = Array.from(new Set(ids));
|
|
60794
62418
|
const discreteKey = viz.schema.discrete;
|
|
@@ -60892,6 +62516,8 @@
|
|
|
60892
62516
|
"confidence",
|
|
60893
62517
|
"confidenceLevel",
|
|
60894
62518
|
"confidenceConfig",
|
|
62519
|
+
"projection",
|
|
62520
|
+
"projectionConfig",
|
|
60895
62521
|
"tooltip",
|
|
60896
62522
|
"stroke"
|
|
60897
62523
|
];
|
|
@@ -60942,16 +62568,21 @@
|
|
|
60942
62568
|
children.push(...collectComputed(band).map((n)=>stamp(n, fit, false)));
|
|
60943
62569
|
}
|
|
60944
62570
|
const paint = Object.fromEntries(Object.entries(config).filter(([key])=>!FIT_KEYS.includes(key)));
|
|
60945
|
-
const line =
|
|
60946
|
-
|
|
60947
|
-
|
|
60948
|
-
|
|
60949
|
-
|
|
60950
|
-
|
|
60951
|
-
|
|
60952
|
-
|
|
60953
|
-
|
|
60954
|
-
|
|
62571
|
+
const line = (samples, key, style)=>{
|
|
62572
|
+
if (samples.length < 2) return;
|
|
62573
|
+
const shape = makeShape("Line").renderMode("compute").duration(viz.schema.duration).data(samples).config({
|
|
62574
|
+
...paint,
|
|
62575
|
+
id: key,
|
|
62576
|
+
label: false,
|
|
62577
|
+
stroke: fit.color
|
|
62578
|
+
}).config(style).config({
|
|
62579
|
+
x: (d)=>x(d.x),
|
|
62580
|
+
y: (d)=>y(d.y)
|
|
62581
|
+
});
|
|
62582
|
+
children.push(...collectComputed(shape).map((n)=>stamp(n, fit, config.tooltip !== false)));
|
|
62583
|
+
};
|
|
62584
|
+
line(fit.samples.filter((d)=>!d.projected), id, {});
|
|
62585
|
+
line(fit.samples.filter((d)=>d.projected), ()=>`trend-${fit.id}-projection`, config.projectionConfig || {});
|
|
60955
62586
|
if (!children.length) return null;
|
|
60956
62587
|
return {
|
|
60957
62588
|
type: "group",
|
|
@@ -61472,20 +63103,13 @@
|
|
|
61472
63103
|
/** `[axis name, formatted value]` for one axis of a hovered row. */ function axisRow(viz, k, hover) {
|
|
61473
63104
|
const row = hover.rows[0];
|
|
61474
63105
|
const accessor = viz[`_${k}`];
|
|
61475
|
-
|
|
63106
|
+
// A projected row's datum is a source row of its series, not this column.
|
|
63107
|
+
const raw = accessor && !row.projected ? accessor(row.datum, row.index) : hover.value;
|
|
61476
63108
|
return [
|
|
61477
63109
|
axisName(viz, k),
|
|
61478
63110
|
axisValue(viz, k, raw)
|
|
61479
63111
|
];
|
|
61480
63112
|
}
|
|
61481
|
-
/**
|
|
61482
|
-
A small swatch filled with the series stroke, before the series name: a
|
|
61483
|
-
dot for Lines (echoing their markers), a square for Bars and Areas.
|
|
61484
|
-
*/ const swatch = (color, shape)=>{
|
|
61485
|
-
if (!color) return "";
|
|
61486
|
-
const radius = shape === "Line" || shape === "Circle" ? "50%" : "1px";
|
|
61487
|
-
return `<span class="d3plus-tooltip-swatch" style="display: inline-block; width: 8px; height: 8px; margin-right: 6px; vertical-align: middle; border-radius: ${radius}; background: ${color}"></span>`;
|
|
61488
|
-
};
|
|
61489
63113
|
/**
|
|
61490
63114
|
The tooltip's client position: the discrete-axis coordinate locked to the
|
|
61491
63115
|
snapped position (surface space → client space via the pointer's own
|
|
@@ -61531,6 +63155,27 @@
|
|
|
61531
63155
|
if (saved) viz._tooltipClass.arrow(saved.arrow).thead(saved.thead).tbody(saved.tbody);
|
|
61532
63156
|
viz._sharedTooltipSaved = undefined;
|
|
61533
63157
|
}
|
|
63158
|
+
/** A projected row's band bounds, as " (low – high)"; empty otherwise. */ function bounds$1(viz, k, row) {
|
|
63159
|
+
const band = row.projected;
|
|
63160
|
+
if (!band || band.lci === undefined || band.hci === undefined) return "";
|
|
63161
|
+
return ` (${axisValue(viz, k, band.lci)} – ${axisValue(viz, k, band.hci)})`;
|
|
63162
|
+
}
|
|
63163
|
+
/**
|
|
63164
|
+
Marks a shared column's projected values (`trendLineConfig.projection`):
|
|
63165
|
+
on the discrete value in the header when every row is projected, or on
|
|
63166
|
+
each projected row's name when the column mixes in plotted values.
|
|
63167
|
+
*/ function markProjected(viz, hover) {
|
|
63168
|
+
const label = ` (${viz.schema.translate("Projected")})`;
|
|
63169
|
+
const header = axisRow(viz, hover.axis, hover);
|
|
63170
|
+
const all = hover.rows.every((r)=>r.projected);
|
|
63171
|
+
return {
|
|
63172
|
+
header: all ? [
|
|
63173
|
+
header[0],
|
|
63174
|
+
`${header[1]}${label}`
|
|
63175
|
+
] : header,
|
|
63176
|
+
names: hover.rows.map((r)=>r.projected && !all ? `${r.name}${label}` : r.name)
|
|
63177
|
+
};
|
|
63178
|
+
}
|
|
61534
63179
|
/**
|
|
61535
63180
|
The shared tooltip: title from the continuous axis, a header row naming
|
|
61536
63181
|
the hovered discrete value, then one `[name, value]` row per series, the
|
|
@@ -61538,11 +63183,12 @@
|
|
|
61538
63183
|
apply first; the shared title/rows win.
|
|
61539
63184
|
*/ function renderSharedTooltip(viz, hover, event) {
|
|
61540
63185
|
const cont = other(hover.axis);
|
|
63186
|
+
const { header, names } = markProjected(viz, hover);
|
|
61541
63187
|
prepareTooltip(viz).data([
|
|
61542
63188
|
hover.rows[0].datum
|
|
61543
|
-
]).config(configPrep.bind(viz)(viz.schema.tooltipConfig)).title(()=>axisName(viz, cont)).thead(
|
|
61544
|
-
|
|
61545
|
-
axisValue(viz, cont, r.value)
|
|
63189
|
+
]).config(configPrep.bind(viz)(viz.schema.tooltipConfig)).title(()=>axisName(viz, cont)).thead(header).tbody(hover.rows.map((r, i)=>[
|
|
63190
|
+
withSwatch(tooltipSwatch(r.color, r.shape), names[i]),
|
|
63191
|
+
`${axisValue(viz, cont, r.value)}${bounds$1(viz, cont, r)}`
|
|
61546
63192
|
])).footer(false).arrow(false).position(snappedPosition(viz, hover, event)).render();
|
|
61547
63193
|
}
|
|
61548
63194
|
/**
|
|
@@ -61555,7 +63201,7 @@
|
|
|
61555
63201
|
const deeper = viz._drawDepth < viz.schema.groupBy.length - 1;
|
|
61556
63202
|
const tip = prepareTooltip(viz).data([
|
|
61557
63203
|
row.datum
|
|
61558
|
-
]).title(()=>viz._drawLabel(row.datum, row.index)).footer(deeper && viz.schema.on["click.shape"] ? viz.schema.translate("Click to Expand") : false).config(configPrep.bind(viz)(viz.schema.tooltipConfig));
|
|
63204
|
+
]).title(()=>withSwatch(tooltipSwatch(row.color, row.shape), viz._drawLabel(row.datum, row.index))).footer(deeper && viz.schema.on["click.shape"] ? viz.schema.translate("Click to Expand") : false).config(configPrep.bind(viz)(viz.schema.tooltipConfig));
|
|
61559
63205
|
const extra = tip.tbody();
|
|
61560
63206
|
tip.tbody([
|
|
61561
63207
|
axisRow(viz, "x", hover),
|
|
@@ -61620,15 +63266,31 @@
|
|
|
61620
63266
|
/** Abbreviates a coefficient, keeping three significant digits on tiny values. */ function coefficientFormat(locale) {
|
|
61621
63267
|
return (n)=>n !== 0 && Math.abs(n) < 1e-3 ? n.toPrecision(3) : formatAbbreviate(n, locale);
|
|
61622
63268
|
}
|
|
61623
|
-
/**
|
|
63269
|
+
/**
|
|
63270
|
+
The tooltip rows for a fit: type, equation, R², and observations. Given a
|
|
63271
|
+
projected sample, it leads with that projection: its independent-axis
|
|
63272
|
+
value (marked "Projected") and its predicted value, with the band's
|
|
63273
|
+
bounds when drawn.
|
|
63274
|
+
*/ function trendTooltipRows(viz, trend, sample) {
|
|
61624
63275
|
const { fit, axis } = trend;
|
|
61625
63276
|
const t = (s)=>viz.schema.translate(s);
|
|
61626
|
-
const rows = [
|
|
61627
|
-
|
|
61628
|
-
|
|
61629
|
-
|
|
61630
|
-
|
|
61631
|
-
|
|
63277
|
+
const rows = [];
|
|
63278
|
+
if (sample && sample.projected) {
|
|
63279
|
+
const dep = axis === "x" ? "y" : "x";
|
|
63280
|
+
const value = (n)=>axisValue(viz, dep, n);
|
|
63281
|
+
const bounds = sample.lci !== undefined ? ` (${value(sample.lci)} – ${value(sample.hci)})` : "";
|
|
63282
|
+
rows.push([
|
|
63283
|
+
axisName(viz, axis),
|
|
63284
|
+
`${axisValue(viz, axis, sample[axis])} (${t("Projected")})`
|
|
63285
|
+
], [
|
|
63286
|
+
axisName(viz, dep),
|
|
63287
|
+
`${value(sample[dep])}${bounds}`
|
|
63288
|
+
]);
|
|
63289
|
+
}
|
|
63290
|
+
rows.push([
|
|
63291
|
+
t("Trend Line"),
|
|
63292
|
+
t(trendTypeNames[fit.type])
|
|
63293
|
+
]);
|
|
61632
63294
|
// An equation in milliseconds since 1970 says nothing a reader can use.
|
|
61633
63295
|
if (!viz[`_${axis}Time`]) rows.push([
|
|
61634
63296
|
t("Equation"),
|
|
@@ -61643,7 +63305,30 @@
|
|
|
61643
63305
|
]);
|
|
61644
63306
|
return rows;
|
|
61645
63307
|
}
|
|
61646
|
-
/**
|
|
63308
|
+
/**
|
|
63309
|
+
The projected step nearest a content-space pointer along the fit's
|
|
63310
|
+
independent axis, when the pointer is over the projection; undefined over
|
|
63311
|
+
the fitted stretch (or for a fit with no projection).
|
|
63312
|
+
*/ function nearestProjectedSample(viz, trend, cursor) {
|
|
63313
|
+
const position = trend.axis === "x" ? viz._xFunc : viz._yFunc;
|
|
63314
|
+
if (!position) return undefined;
|
|
63315
|
+
const target = trend.axis === "x" ? cursor[0] : cursor[1];
|
|
63316
|
+
const nearest = (samples)=>{
|
|
63317
|
+
let best;
|
|
63318
|
+
let gap = Infinity;
|
|
63319
|
+
for (const sample of samples){
|
|
63320
|
+
const d = Math.abs(position(sample[trend.axis]) - target);
|
|
63321
|
+
if (d < gap) [best, gap] = [
|
|
63322
|
+
sample,
|
|
63323
|
+
d
|
|
63324
|
+
];
|
|
63325
|
+
}
|
|
63326
|
+
return best;
|
|
63327
|
+
};
|
|
63328
|
+
const best = nearest(trend.samples);
|
|
63329
|
+
return best && best.projected ? nearest(trend.samples.filter((s)=>s.step)) : undefined;
|
|
63330
|
+
}
|
|
63331
|
+
/** Renders the trend tooltip at the pointer, leading with the nearest projected value when over the projection. */ function renderTrendTooltip(viz, trend, event, cursor) {
|
|
61647
63332
|
const native = event.nativeEvent;
|
|
61648
63333
|
const position = native && native.touches && native.touches.length ? [
|
|
61649
63334
|
native.touches[0].clientX,
|
|
@@ -61654,7 +63339,7 @@
|
|
|
61654
63339
|
] : event.point;
|
|
61655
63340
|
prepareTooltip(viz).data([
|
|
61656
63341
|
trend.row || {}
|
|
61657
|
-
]).config(configPrep.bind(viz)(viz.schema.tooltipConfig)).title(()=>trend.label).thead([]).tbody(trendTooltipRows(viz, trend)).footer(false).position(position).render();
|
|
63342
|
+
]).config(configPrep.bind(viz)(viz.schema.tooltipConfig)).title(()=>withSwatch(tooltipSwatch(trend.color, "Line"), trend.label)).thead([]).tbody(trendTooltipRows(viz, trend, cursor ? nearestProjectedSample(viz, trend, cursor) : undefined)).footer(false).position(position).render();
|
|
61658
63343
|
}
|
|
61659
63344
|
|
|
61660
63345
|
/**
|
|
@@ -61670,7 +63355,6 @@
|
|
|
61670
63355
|
(point[1] - (t?.y ?? 0)) / scale - (c?.y ?? 0)
|
|
61671
63356
|
];
|
|
61672
63357
|
}
|
|
61673
|
-
const visibleColor = (s)=>typeof s === "string" && s !== "none" && s !== "transparent" ? s : undefined;
|
|
61674
63358
|
const discreteKey = (v)=>v instanceof Date ? String(v.getTime()) : String(v);
|
|
61675
63359
|
/**
|
|
61676
63360
|
Whether a scene node is a data mark the shared tooltip reads: Line/Area
|
|
@@ -61755,9 +63439,67 @@
|
|
|
61755
63439
|
}
|
|
61756
63440
|
};
|
|
61757
63441
|
(viz._chartScene || []).forEach((node)=>walk(node));
|
|
63442
|
+
if (position) addProjectedColumns(viz, axis, columns, position);
|
|
61758
63443
|
return columns;
|
|
61759
63444
|
}
|
|
63445
|
+
/**
|
|
63446
|
+
Adds each trend line's projected steps (see `trendLineConfig.projection`)
|
|
63447
|
+
as column members, so the crosshair snaps onto future positions and lists
|
|
63448
|
+
every series' projected value there.
|
|
63449
|
+
*/ function addProjectedColumns(viz, axis, columns, position) {
|
|
63450
|
+
for (const fit of viz._trendFits || []){
|
|
63451
|
+
if (fit.axis !== axis || viz._trendLineConfig?.tooltip === false) continue;
|
|
63452
|
+
for (const sample of fit.samples){
|
|
63453
|
+
if (!sample.step) continue;
|
|
63454
|
+
const value = sample[axis];
|
|
63455
|
+
const px = position(value);
|
|
63456
|
+
if (!Number.isFinite(px)) continue;
|
|
63457
|
+
const key = discreteKey(value);
|
|
63458
|
+
let column = columns.get(key);
|
|
63459
|
+
if (!column) {
|
|
63460
|
+
column = {
|
|
63461
|
+
px,
|
|
63462
|
+
value,
|
|
63463
|
+
members: new Map(),
|
|
63464
|
+
bars: new Set(),
|
|
63465
|
+
markers: []
|
|
63466
|
+
};
|
|
63467
|
+
columns.set(key, column);
|
|
63468
|
+
}
|
|
63469
|
+
const wrapped = fit.row || {};
|
|
63470
|
+
column.members.set(`${fit.id}::projected`, {
|
|
63471
|
+
wrapped,
|
|
63472
|
+
color: fit.color,
|
|
63473
|
+
shape: "Line",
|
|
63474
|
+
trend: {
|
|
63475
|
+
fit,
|
|
63476
|
+
sample
|
|
63477
|
+
}
|
|
63478
|
+
});
|
|
63479
|
+
}
|
|
63480
|
+
}
|
|
63481
|
+
}
|
|
61760
63482
|
/** A row for one column member; null when its value isn't numeric or its tooltip is off. */ function memberRow(viz, axis, id, member) {
|
|
63483
|
+
if (member.trend) {
|
|
63484
|
+
const { fit, sample } = member.trend;
|
|
63485
|
+
const value = Number(sample[axis === "x" ? "y" : "x"]);
|
|
63486
|
+
if (!Number.isFinite(value)) return null;
|
|
63487
|
+
const name = String(fit.label);
|
|
63488
|
+
const datum = fit.row || {};
|
|
63489
|
+
return {
|
|
63490
|
+
id,
|
|
63491
|
+
name,
|
|
63492
|
+
value,
|
|
63493
|
+
color: member.color,
|
|
63494
|
+
shape: "Line",
|
|
63495
|
+
datum,
|
|
63496
|
+
index: 0,
|
|
63497
|
+
projected: {
|
|
63498
|
+
lci: sample.lci,
|
|
63499
|
+
hci: sample.hci
|
|
63500
|
+
}
|
|
63501
|
+
};
|
|
63502
|
+
}
|
|
61761
63503
|
const valueOf = axis === "x" ? viz._y : viz._x;
|
|
61762
63504
|
const datum = member.wrapped.data || member.wrapped;
|
|
61763
63505
|
const index = typeof member.wrapped.i === "number" ? member.wrapped.i : 0;
|
|
@@ -61841,7 +63583,7 @@
|
|
|
61841
63583
|
const row = memberRow(viz, axis, id, member);
|
|
61842
63584
|
if (row) rows.push(row);
|
|
61843
63585
|
});
|
|
61844
|
-
if (rows.length >= 2) {
|
|
63586
|
+
if (rows.length >= 2 || rows.some((r)=>r.projected)) {
|
|
61845
63587
|
sortRows(viz, axis, rows);
|
|
61846
63588
|
const stack = best.bars.size ? {
|
|
61847
63589
|
rows: best.bars,
|
|
@@ -61945,7 +63687,8 @@
|
|
|
61945
63687
|
const prev = viz._sharedHoverState;
|
|
61946
63688
|
viz._sharedHoverActive = true;
|
|
61947
63689
|
viz._sharedHoverState = null;
|
|
61948
|
-
|
|
63690
|
+
const cursor = Array.isArray(event.point) ? contentPoint(viz, event.point) : undefined;
|
|
63691
|
+
renderTrendTooltip(viz, trend, event, cursor);
|
|
61949
63692
|
if (prev) {
|
|
61950
63693
|
if (prev.mode === "shared" && typeof viz._hover === "function") viz.hover(false);
|
|
61951
63694
|
viz._scheduleSceneRepaint();
|
|
@@ -61963,8 +63706,12 @@
|
|
|
61963
63706
|
};
|
|
61964
63707
|
if (hover.mode === "single") {
|
|
61965
63708
|
if (prevMode === "shared") clear();
|
|
61966
|
-
} else if (stack)
|
|
61967
|
-
|
|
63709
|
+
} else if (stack) {
|
|
63710
|
+
// Non-bar marks stay bright in the column hover, but only the stack's
|
|
63711
|
+
// own rows are what linked charts should match.
|
|
63712
|
+
linkAs(viz, (d)=>stack.rows.has(d));
|
|
63713
|
+
viz.hover((d)=>stack.rows.has(d) || !stack.bars.has(d));
|
|
63714
|
+
} else clear();
|
|
61968
63715
|
}
|
|
61969
63716
|
|
|
61970
63717
|
/** Stamps a subtree inert chrome: no hit-testing, never dimmed by hover. */ function inert(node) {
|
|
@@ -62099,6 +63846,18 @@
|
|
|
62099
63846
|
];
|
|
62100
63847
|
}
|
|
62101
63848
|
|
|
63849
|
+
/** Axis groups carry tick data, but aren't marks to keep clear of. */ const AXIS_KEY = /^plot-(x|x2|y|y2)-axis$/;
|
|
63850
|
+
/** The plot area in surface coordinates, with its marks (not its axes) as obstacles; null before layout. */ function plotInsetRegion(viz) {
|
|
63851
|
+
const area = viz._plotArea, t = viz._chartTransform;
|
|
63852
|
+
if (!area || !t) return null;
|
|
63853
|
+
return sceneInsetRegion(viz, {
|
|
63854
|
+
x: area.x + (t.x ?? 0),
|
|
63855
|
+
y: area.y + (t.y ?? 0),
|
|
63856
|
+
width: area.width,
|
|
63857
|
+
height: area.height
|
|
63858
|
+
}, (node)=>AXIS_KEY.test(String(node.key)));
|
|
63859
|
+
}
|
|
63860
|
+
|
|
62102
63861
|
/**
|
|
62103
63862
|
@module barBuffer
|
|
62104
63863
|
Adds a buffer to either side of the non-discrete axis.
|
|
@@ -62114,7 +63873,7 @@
|
|
|
62114
63873
|
if (isDiscreteX) oppDomain.reverse();
|
|
62115
63874
|
let negVals, posVals;
|
|
62116
63875
|
if (this.schema.stacked) {
|
|
62117
|
-
const groupedData = groups(data, (d)=>`${d[this.schema.discrete]}_${d.group}`).map(([, values])=>values.map((x)=>x[isDiscreteX ? yKey : xKey]));
|
|
63876
|
+
const groupedData = groups$1(data, (d)=>`${d[this.schema.discrete]}_${d.group}`).map(([, values])=>values.map((x)=>x[isDiscreteX ? yKey : xKey]));
|
|
62118
63877
|
posVals = groupedData.map((arr)=>sum$2(arr.filter((d)=>d > 0)));
|
|
62119
63878
|
negVals = groupedData.map((arr)=>sum$2(arr.filter((d)=>d < 0)));
|
|
62120
63879
|
} else {
|
|
@@ -62153,7 +63912,7 @@
|
|
|
62153
63912
|
if (isDiscreteX) oppDomain.reverse();
|
|
62154
63913
|
let negVals, posVals;
|
|
62155
63914
|
if (this.schema.stacked) {
|
|
62156
|
-
const groupedData = groups(data, (d)=>d[this.schema.discrete]).map(([, values])=>values.map((x)=>x[isDiscreteX ? yKey : xKey]));
|
|
63915
|
+
const groupedData = groups$1(data, (d)=>d[this.schema.discrete]).map(([, values])=>values.map((x)=>x[isDiscreteX ? yKey : xKey]));
|
|
62157
63916
|
posVals = groupedData.map((arr)=>sum$2(arr.filter((d)=>d > 0)));
|
|
62158
63917
|
negVals = groupedData.map((arr)=>sum$2(arr.filter((d)=>d < 0)));
|
|
62159
63918
|
} else {
|
|
@@ -62630,6 +64389,13 @@
|
|
|
62630
64389
|
*/ _sizeLegendScale() {
|
|
62631
64390
|
return plotSizeLegendScale(this);
|
|
62632
64391
|
}
|
|
64392
|
+
/**
|
|
64393
|
+
The plot area, with the plotted marks as obstacles, for drawing a
|
|
64394
|
+
legend inside the plot's empty space (see `legendInset`).
|
|
64395
|
+
@private
|
|
64396
|
+
*/ _insetRegion() {
|
|
64397
|
+
return plotInsetRegion(this);
|
|
64398
|
+
}
|
|
62633
64399
|
/**
|
|
62634
64400
|
Paint phase: production axis rendering, shape buffer setup, and shape
|
|
62635
64401
|
emission with event handlers. Receives all cross-phase locals from
|
|
@@ -62758,6 +64524,8 @@
|
|
|
62758
64524
|
- `confidence`: draws a confidence band around a linear fit (default `false`).
|
|
62759
64525
|
- `confidenceLevel`: the band's confidence level (default `0.95`).
|
|
62760
64526
|
- `confidenceConfig`: Area shape config for the band (default `{fillOpacity: 0.15}`; fill defaults to the line color).
|
|
64527
|
+
- `projection`: extends each line past the end of its data, by a number of steps at the data's own spacing (e.g. `5` more years), or to an end value with `{to: 2030}` (default `0`, off). The axis widens to fit, and a linear fit's band becomes a prediction interval that fans out over the projection. Hovering a projected step lists each series' projected value. Ignored on a category axis.
|
|
64528
|
+
- `projectionConfig`: Line shape config for the projected stretch, over the line's own styles (default `{strokeDasharray: "2 4"}`).
|
|
62761
64529
|
- `tooltip`: shows the fitted equation and R² when hovering a line (default `true`).
|
|
62762
64530
|
- Any other key (`stroke`, `strokeWidth`, `strokeDasharray`, …) styles the Line shape.
|
|
62763
64531
|
|
|
@@ -62936,7 +64704,7 @@
|
|
|
62936
64704
|
};
|
|
62937
64705
|
this._labelPosition = constant$d("auto");
|
|
62938
64706
|
this._lineMarkerConfig = {
|
|
62939
|
-
fill: (d, i)=>colorAssign(this._id(d, i), this
|
|
64707
|
+
fill: (d, i)=>colorAssign(this._id(d, i), linkedColorDefaults(this)),
|
|
62940
64708
|
r: constant$d(3)
|
|
62941
64709
|
};
|
|
62942
64710
|
this._lineMarkers = defaults.lineMarkers;
|
|
@@ -63843,6 +65611,7 @@
|
|
|
63843
65611
|
// Scene-emit charts dim via the scene's interaction-opacity pass, not
|
|
63844
65612
|
// `_shapes`; a hover change only takes effect once a repaint is scheduled.
|
|
63845
65613
|
if (this._sceneRenderer) this._scheduleSceneRepaint();
|
|
65614
|
+
broadcastLink(this, "hover", _);
|
|
63846
65615
|
return this;
|
|
63847
65616
|
};
|
|
63848
65617
|
},
|
|
@@ -64040,7 +65809,7 @@
|
|
|
64040
65809
|
endAngle: d.endAngle,
|
|
64041
65810
|
datum: d.data,
|
|
64042
65811
|
paint: {
|
|
64043
|
-
fill:
|
|
65812
|
+
fill: textureFill(sc, d.data, d.i ?? 0, fill),
|
|
64044
65813
|
stroke,
|
|
64045
65814
|
strokeWidth,
|
|
64046
65815
|
// Explicit (not the field's usual `undefined`) for the same reason
|
|
@@ -64099,7 +65868,7 @@
|
|
|
64099
65868
|
const arcMaker = (d)=>arcGen(d) ?? "";
|
|
64100
65869
|
const resolveInnerRadius = arcGen.innerRadius();
|
|
64101
65870
|
const resolveOuterRadius = arcGen.outerRadius();
|
|
64102
|
-
const sc = viz
|
|
65871
|
+
const sc = shapeConfigFor(viz, "Path");
|
|
64103
65872
|
// A drill-down click armed this draw AND the clicked node was itself a Pie
|
|
64104
65873
|
// wedge (parentStartAngle/parentEndAngle only ever come from this chart's
|
|
64105
65874
|
// own click capture, via NodeBase.startAngle/endAngle below) — build each
|
|
@@ -64224,6 +65993,7 @@
|
|
|
64224
65993
|
],
|
|
64225
65994
|
layoutStage: applyPieLayout,
|
|
64226
65995
|
emit: pieEmit,
|
|
65996
|
+
insetRegion: sceneInsetRegion,
|
|
64227
65997
|
chartTransform: (viz)=>centerChartTransform(viz, viz.ctx.pieWidth, viz.ctx.pieHeight),
|
|
64228
65998
|
// Pie's chartTransform centers the origin — wedges are drawn in
|
|
64229
65999
|
// [-pieWidth/2, pieWidth/2] × [-pieHeight/2, pieHeight/2], not the
|
|
@@ -77144,6 +78914,9 @@
|
|
|
77144
78914
|
const r = geomapPointSizeScale(v, pointData);
|
|
77145
78915
|
v._sizeLegendFinal = pointData.length ? r : null;
|
|
77146
78916
|
if (!v._zoomSet || !ctx.extentBounds) {
|
|
78917
|
+
// The point-radius padding belongs with the extent it was computed for,
|
|
78918
|
+
// so a later draw that reuses the cached extent fits the same way.
|
|
78919
|
+
ctx.effectivePadding = undefined;
|
|
77147
78920
|
const fitData = v.schema.fitObject ? topo2feature(v.schema.fitObject, v.schema.fitKey) : coordData;
|
|
77148
78921
|
ctx.extentBounds = {
|
|
77149
78922
|
type: "FeatureCollection",
|
|
@@ -77155,7 +78928,6 @@
|
|
|
77155
78928
|
}
|
|
77156
78929
|
}
|
|
77157
78930
|
const effectivePadding = ctx.effectivePadding || v.schema.projectionPadding;
|
|
77158
|
-
ctx.effectivePadding = undefined;
|
|
77159
78931
|
v.schema.projection = v.schema.projection.fitExtent(ctx.extentBounds.features.length ? [
|
|
77160
78932
|
[
|
|
77161
78933
|
effectivePadding.left,
|
|
@@ -77565,6 +79337,7 @@
|
|
|
77565
79337
|
return pointData.length ? geomapPointSizeScale(viz, pointData) : null;
|
|
77566
79338
|
},
|
|
77567
79339
|
emit: geomapEmit,
|
|
79340
|
+
insetRegion: sceneInsetRegion,
|
|
77568
79341
|
// Clip the geography to the map rectangle — the same box as the ocean rect and
|
|
77569
79342
|
// the imperative inner <svg> viewport — so projected paths and points can't
|
|
77570
79343
|
// spill past it (e.g. under the legend/timeline) when a `fitObject`/zoom pushes
|
|
@@ -77694,7 +79467,7 @@
|
|
|
77694
79467
|
const sc = viz.schema.shapeConfig.Path;
|
|
77695
79468
|
const c = typeof sc.fill === "function" ? sc.fill(d, i) : sc.fill;
|
|
77696
79469
|
const col = color(c);
|
|
77697
|
-
return col ? col.darker() : c;
|
|
79470
|
+
return col ? col.darker().toString() : c;
|
|
77698
79471
|
},
|
|
77699
79472
|
strokeWidth: 1
|
|
77700
79473
|
},
|
|
@@ -77766,7 +79539,7 @@
|
|
|
77766
79539
|
]).thresholds(edges.slice(1, -1));
|
|
77767
79540
|
const total = values.length;
|
|
77768
79541
|
const out = [];
|
|
77769
|
-
for (const [, members] of groups(observations, (o)=>group(o.d, o.i))){
|
|
79542
|
+
for (const [, members] of groups$1(observations, (o)=>group(o.d, o.i))){
|
|
77770
79543
|
const binned = perGroup(members.map((o)=>o.v));
|
|
77771
79544
|
const first = members[0].d;
|
|
77772
79545
|
binned.forEach((b)=>{
|
|
@@ -78121,10 +79894,7 @@
|
|
|
78121
79894
|
};
|
|
78122
79895
|
};
|
|
78123
79896
|
|
|
78124
|
-
|
|
78125
|
-
`matrixEmit` — Rect cells positioned by the row/column scales stashed
|
|
78126
|
-
on `viz.ctx`.
|
|
78127
|
-
*/ function resolveAccessor$4(val, d, i) {
|
|
79897
|
+
function resolveAccessor$4(val, d, i) {
|
|
78128
79898
|
if (typeof val === "function") return val(d, i);
|
|
78129
79899
|
return val;
|
|
78130
79900
|
}
|
|
@@ -78136,7 +79906,7 @@
|
|
|
78136
79906
|
const cellWidth = viz.ctx.cellWidth;
|
|
78137
79907
|
const cellHeight = viz.ctx.cellHeight;
|
|
78138
79908
|
const cellPadding = viz.schema.cellPadding ?? 0;
|
|
78139
|
-
const sc = viz
|
|
79909
|
+
const sc = shapeConfigFor(viz, "Rect");
|
|
78140
79910
|
const colorScale = viz.schema.colorScale;
|
|
78141
79911
|
return cells.map((d, i)=>{
|
|
78142
79912
|
const fill = resolveAccessor$4(sc.fill, d, i);
|
|
@@ -78156,7 +79926,7 @@
|
|
|
78156
79926
|
height: h,
|
|
78157
79927
|
datum: d,
|
|
78158
79928
|
paint: {
|
|
78159
|
-
fill:
|
|
79929
|
+
fill: textureFill(sc, d, i, fill),
|
|
78160
79930
|
stroke,
|
|
78161
79931
|
strokeWidth
|
|
78162
79932
|
},
|
|
@@ -78696,7 +80466,7 @@
|
|
|
78696
80466
|
}
|
|
78697
80467
|
var initialRadius = 10, initialAngle = Math.PI * (3 - Math.sqrt(5));
|
|
78698
80468
|
function forceSimulation(nodes) {
|
|
78699
|
-
var simulation, alpha = 1, alphaMin = 0.001, alphaDecay = 1 - Math.pow(alphaMin, 1 / 300), alphaTarget = 0, velocityDecay = 0.6, forces = new Map(), stepper = timer(step), event = dispatch("tick", "end"), random = lcg$1();
|
|
80469
|
+
var simulation, alpha = 1, alphaMin = 0.001, alphaDecay = 1 - Math.pow(alphaMin, 1 / 300), alphaTarget = 0, velocityDecay = 0.6, forces = new Map(), stepper = timer(step), event = dispatch$1("tick", "end"), random = lcg$1();
|
|
78700
80470
|
if (nodes == null) nodes = [];
|
|
78701
80471
|
function step() {
|
|
78702
80472
|
tick();
|
|
@@ -79141,7 +80911,7 @@
|
|
|
79141
80911
|
label: (d)=>nodes.length <= v.schema.dataCutoff || v._hover && v._hover(d) || v._active && v._active(d) ? v._drawLabel(d.data || d.node, d.i) : false
|
|
79142
80912
|
};
|
|
79143
80913
|
const linkD = (d)=>`M${d.source.x},${d.source.y} ${d.target.x},${d.target.y}`;
|
|
79144
|
-
const nodeGroups = Array.from(groups(nodes, (d)=>d.shape));
|
|
80914
|
+
const nodeGroups = Array.from(groups$1(nodes, (d)=>d.shape));
|
|
79145
80915
|
v.ctx.networkCtx = {
|
|
79146
80916
|
links,
|
|
79147
80917
|
linkConfig,
|
|
@@ -79656,6 +81426,7 @@
|
|
|
79656
81426
|
// Scene-emit charts dim via applyInteractionOpacity during toScene(), so a
|
|
79657
81427
|
// hover change only takes effect if a repaint is scheduled.
|
|
79658
81428
|
if (this._sceneRenderer) this._scheduleSceneRepaint();
|
|
81429
|
+
broadcastLink(this, "hover", _);
|
|
79659
81430
|
return this;
|
|
79660
81431
|
};
|
|
79661
81432
|
}
|
|
@@ -79669,6 +81440,7 @@
|
|
|
79669
81440
|
layoutStage: applyNetworkLayout,
|
|
79670
81441
|
sizeLegendScale: (viz, { width, height })=>networkSizeLegendScale(viz, width, height),
|
|
79671
81442
|
emit: networkEmit,
|
|
81443
|
+
insetRegion: sceneInsetRegion,
|
|
79672
81444
|
// Network mounts its own zoom surface (with a background hitArea whose
|
|
79673
81445
|
// click handler closes over class state); `chartTransform` (default
|
|
79674
81446
|
// margin-origin) is fine for the scene.
|
|
@@ -80730,9 +82502,9 @@
|
|
|
80730
82502
|
const packEmit = ({ viz, shapeData })=>{
|
|
80731
82503
|
const nodes = shapeData ?? [];
|
|
80732
82504
|
if (!nodes.length) return [];
|
|
80733
|
-
const sc = viz
|
|
80734
|
-
// Pack's
|
|
80735
|
-
const circleConfig =
|
|
82505
|
+
const sc = shapeConfigFor(viz, "Circle");
|
|
82506
|
+
// Pack's label accessor is nested under `Circle`.
|
|
82507
|
+
const circleConfig = viz.schema.shapeConfig.Circle ?? {};
|
|
80736
82508
|
const labelFn = circleConfig.label;
|
|
80737
82509
|
const circleNodes = nodes.map((d, i)=>{
|
|
80738
82510
|
const datum = d.data;
|
|
@@ -80753,7 +82525,7 @@
|
|
|
80753
82525
|
shapeType: "Pack",
|
|
80754
82526
|
datum,
|
|
80755
82527
|
paint: {
|
|
80756
|
-
fill:
|
|
82528
|
+
fill: textureFill(sc, datum, i, fill),
|
|
80757
82529
|
stroke,
|
|
80758
82530
|
opacity: datum.__d3plusOpacity__,
|
|
80759
82531
|
strokeWidth
|
|
@@ -80833,6 +82605,7 @@
|
|
|
80833
82605
|
],
|
|
80834
82606
|
layoutStage: applyPackLayout,
|
|
80835
82607
|
emit: packEmit,
|
|
82608
|
+
insetRegion: sceneInsetRegion,
|
|
80836
82609
|
chartTransform: (viz)=>({
|
|
80837
82610
|
x: viz._margin.left + (viz.ctx.packOffsetX ?? 0),
|
|
80838
82611
|
y: viz._margin.top + (viz.ctx.packOffsetY ?? 0)
|
|
@@ -81068,7 +82841,7 @@
|
|
|
81068
82841
|
const xScale = viz.ctx.xScale;
|
|
81069
82842
|
const yScale = viz.ctx.yScale;
|
|
81070
82843
|
const bandWidth = viz.ctx.bandWidth;
|
|
81071
|
-
const sc = viz
|
|
82844
|
+
const sc = shapeConfigFor(viz, "Rect");
|
|
81072
82845
|
const rectNodes = data.map((d, i)=>{
|
|
81073
82846
|
const fill = resolveAccessor$2(sc.fill, d.data, i);
|
|
81074
82847
|
const stroke = resolveAccessor$2(sc.stroke, d.data, i);
|
|
@@ -81096,7 +82869,7 @@
|
|
|
81096
82869
|
height: bandWidth,
|
|
81097
82870
|
datum: d.data,
|
|
81098
82871
|
paint: {
|
|
81099
|
-
fill:
|
|
82872
|
+
fill: textureFill(sc, d.data, i, fill),
|
|
81100
82873
|
stroke,
|
|
81101
82874
|
strokeWidth
|
|
81102
82875
|
},
|
|
@@ -81329,8 +83102,8 @@
|
|
|
81329
83102
|
]) ?? 0) / 2 - outerPadding;
|
|
81330
83103
|
const radius = Math.max(0, rawRadius);
|
|
81331
83104
|
const filtered = viz._filteredData;
|
|
81332
|
-
const nestedAxisData = groups(filtered, metricFn);
|
|
81333
|
-
const nestedGroupData = groups(filtered, viz._id, metricFn);
|
|
83105
|
+
const nestedAxisData = groups$1(filtered, metricFn);
|
|
83106
|
+
const nestedGroupData = groups$1(filtered, viz._id, metricFn);
|
|
81334
83107
|
const maxValue = max$6(nestedGroupData.map(([, innerEntries])=>innerEntries.map(([, vals])=>sum$2(vals, (x, i)=>valueFn(x, i)))).flat());
|
|
81335
83108
|
if (!maxValue) {
|
|
81336
83109
|
viz.ctx.groupData = [];
|
|
@@ -81609,10 +83382,7 @@
|
|
|
81609
83382
|
};
|
|
81610
83383
|
};
|
|
81611
83384
|
|
|
81612
|
-
|
|
81613
|
-
`radialMatrixEmit` — Path SceneNodes for each arc cell, using the
|
|
81614
|
-
`arcData` generator stashed on `viz.ctx`.
|
|
81615
|
-
*/ function resolveAccessor$1(val, d, i) {
|
|
83385
|
+
function resolveAccessor$1(val, d, i) {
|
|
81616
83386
|
if (typeof val === "function") return val(d, i);
|
|
81617
83387
|
return val;
|
|
81618
83388
|
}
|
|
@@ -81620,7 +83390,7 @@
|
|
|
81620
83390
|
const cells = shapeData ?? [];
|
|
81621
83391
|
if (!cells.length) return [];
|
|
81622
83392
|
const arcData = viz.ctx.arcData;
|
|
81623
|
-
const sc = viz
|
|
83393
|
+
const sc = shapeConfigFor(viz, "Path");
|
|
81624
83394
|
const colorScale = viz.schema.colorScale;
|
|
81625
83395
|
return cells.map((d, i)=>{
|
|
81626
83396
|
const fill = resolveAccessor$1(sc.fill, d, i);
|
|
@@ -81633,7 +83403,7 @@
|
|
|
81633
83403
|
d: arcData(d),
|
|
81634
83404
|
datum: d,
|
|
81635
83405
|
paint: {
|
|
81636
|
-
fill:
|
|
83406
|
+
fill: textureFill(sc, d, i, fill),
|
|
81637
83407
|
stroke,
|
|
81638
83408
|
strokeWidth
|
|
81639
83409
|
},
|
|
@@ -82201,7 +83971,7 @@
|
|
|
82201
83971
|
},
|
|
82202
83972
|
rotate: (d)=>nodeLookup[d.id].rotate || 0
|
|
82203
83973
|
};
|
|
82204
|
-
const nodeGroups = Array.from(groups(nodes, (d)=>d.shape));
|
|
83974
|
+
const nodeGroups = Array.from(groups$1(nodes, (d)=>d.shape));
|
|
82205
83975
|
v.ctx.ringsCtx = {
|
|
82206
83976
|
edges,
|
|
82207
83977
|
nodeGroups,
|
|
@@ -82490,6 +84260,7 @@
|
|
|
82490
84260
|
// Scene-emit charts dim via applyInteractionOpacity during toScene(); a
|
|
82491
84261
|
// hover change only takes effect once a repaint is scheduled.
|
|
82492
84262
|
if (this._sceneRenderer) this._scheduleSceneRepaint();
|
|
84263
|
+
broadcastLink(this, "hover", _);
|
|
82493
84264
|
return this;
|
|
82494
84265
|
};
|
|
82495
84266
|
}
|
|
@@ -82503,6 +84274,7 @@
|
|
|
82503
84274
|
layoutStage: applyRingsLayout,
|
|
82504
84275
|
sizeLegendScale: (viz, { width, height })=>ringsSizeLegendScale(viz, width, height),
|
|
82505
84276
|
emit: ringsEmit,
|
|
84277
|
+
insetRegion: sceneInsetRegion,
|
|
82506
84278
|
setup: (viz)=>{
|
|
82507
84279
|
installRingsAccessors(viz);
|
|
82508
84280
|
const v = viz;
|
|
@@ -82565,7 +84337,7 @@
|
|
|
82565
84337
|
right: 0,
|
|
82566
84338
|
top: 0
|
|
82567
84339
|
};
|
|
82568
|
-
viz
|
|
84340
|
+
drawWithInset(viz);
|
|
82569
84341
|
// _draw() resets the feature panels; re-run the post-draw features so
|
|
82570
84342
|
// the corner controls, size legend, and attribution come back.
|
|
82571
84343
|
runPostDrawFeatures(viz);
|
|
@@ -83305,7 +85077,7 @@
|
|
|
83305
85077
|
width,
|
|
83306
85078
|
height
|
|
83307
85079
|
])();
|
|
83308
|
-
const nodeGroups = Array.from(groups(nodes, (d)=>d.shape));
|
|
85080
|
+
const nodeGroups = Array.from(groups$1(nodes, (d)=>d.shape));
|
|
83309
85081
|
v.ctx.sankeyCtx = {
|
|
83310
85082
|
links,
|
|
83311
85083
|
nodeGroups,
|
|
@@ -83513,6 +85285,7 @@
|
|
|
83513
85285
|
// interaction-opacity pass re-reads `_hover` and dims non-matching nodes.
|
|
83514
85286
|
// Coalesced to one paint per frame (see Viz._scheduleSceneRepaint).
|
|
83515
85287
|
if (this._sceneRenderer) this._scheduleSceneRepaint();
|
|
85288
|
+
broadcastLink(this, "hover", _);
|
|
83516
85289
|
return this;
|
|
83517
85290
|
};
|
|
83518
85291
|
},
|
|
@@ -83963,6 +85736,7 @@
|
|
|
83963
85736
|
],
|
|
83964
85737
|
layoutStage: applyTreeLayout,
|
|
83965
85738
|
emit: treeEmit,
|
|
85739
|
+
insetRegion: sceneInsetRegion,
|
|
83966
85740
|
ctx: {
|
|
83967
85741
|
tree: tree(),
|
|
83968
85742
|
previousShapes: []
|
|
@@ -84096,7 +85870,7 @@
|
|
|
84096
85870
|
if (!nodes.length) return [];
|
|
84097
85871
|
const locale = viz.schema.locale;
|
|
84098
85872
|
const drawLabel = viz._drawLabel;
|
|
84099
|
-
const sc = viz
|
|
85873
|
+
const sc = shapeConfigFor(viz, "Rect");
|
|
84100
85874
|
const rectNodes = nodes.map((d)=>{
|
|
84101
85875
|
const fill = resolveAccessor(sc.fill, d.data, d.i);
|
|
84102
85876
|
const stroke = resolveAccessor(sc.stroke, d.data, d.i);
|
|
@@ -84111,7 +85885,7 @@
|
|
|
84111
85885
|
height: d.y1 - d.y0,
|
|
84112
85886
|
datum: d.data,
|
|
84113
85887
|
paint: {
|
|
84114
|
-
fill:
|
|
85888
|
+
fill: textureFill(sc, d.data, d.i, fill),
|
|
84115
85889
|
stroke: typeof stroke === "string" || stroke == null ? stroke : String(stroke),
|
|
84116
85890
|
opacity,
|
|
84117
85891
|
strokeWidth
|
|
@@ -84393,10 +86167,12 @@
|
|
|
84393
86167
|
exports.Donut = index$h;
|
|
84394
86168
|
exports.Geomap = index$e;
|
|
84395
86169
|
exports.Histogram = index$d;
|
|
86170
|
+
exports.INSET_PRIORITY = INSET_PRIORITY;
|
|
84396
86171
|
exports.Image = Image$1;
|
|
84397
86172
|
exports.Legend = Legend;
|
|
84398
86173
|
exports.Line = Line;
|
|
84399
86174
|
exports.LinePlot = index$c;
|
|
86175
|
+
exports.MARK_TYPES = MARK_TYPES;
|
|
84400
86176
|
exports.Matrix = index$b;
|
|
84401
86177
|
exports.Message = Message;
|
|
84402
86178
|
exports.Network = index$9;
|
|
@@ -84444,6 +86220,8 @@
|
|
|
84444
86220
|
exports.bottomRightControlsFeature = bottomRightControlsFeature;
|
|
84445
86221
|
exports.bottomRightControlsInset = bottomRightControlsInset;
|
|
84446
86222
|
exports.bottomRightControlsShortfall = bottomRightControlsShortfall;
|
|
86223
|
+
exports.broadcastLegend = broadcastLegend;
|
|
86224
|
+
exports.broadcastLink = broadcastLink;
|
|
84447
86225
|
exports.chordDef = chordDef;
|
|
84448
86226
|
exports.colorScaleFeature = colorScaleFeature;
|
|
84449
86227
|
exports.computeAxisLayout = computeAxisLayout;
|
|
@@ -84453,11 +86231,28 @@
|
|
|
84453
86231
|
exports.constant = constant$d;
|
|
84454
86232
|
exports.createFluent = createFluent;
|
|
84455
86233
|
exports.defaultSizeLegendValues = defaultSizeLegendValues;
|
|
86234
|
+
exports.drawWithInset = drawWithInset;
|
|
86235
|
+
exports.fitInset = fitInset;
|
|
86236
|
+
exports.forEachSceneRow = forEachSceneRow;
|
|
84456
86237
|
exports.geomapDef = geomapDef;
|
|
84457
86238
|
exports.getTopLeftContributions = getTopLeftContributions;
|
|
84458
86239
|
exports.histogramDef = histogramDef;
|
|
86240
|
+
exports.insetBackground = insetBackground;
|
|
86241
|
+
exports.insetComponentOffset = insetComponentOffset;
|
|
86242
|
+
exports.insetFrame = insetFrame;
|
|
86243
|
+
exports.insetOrient = insetOrient;
|
|
86244
|
+
exports.insetPlacementFor = insetPlacementFor;
|
|
86245
|
+
exports.insetStyle = insetStyle;
|
|
84459
86246
|
exports.installFluent = installFluent;
|
|
86247
|
+
exports.isInsetPending = isInsetPending;
|
|
84460
86248
|
exports.legendFeature = legendFeature;
|
|
86249
|
+
exports.linkAs = linkAs;
|
|
86250
|
+
exports.linkKeys = linkKeys;
|
|
86251
|
+
exports.linkMembers = linkMembers;
|
|
86252
|
+
exports.linkPredicate = linkPredicate;
|
|
86253
|
+
exports.linkValues = linkValues;
|
|
86254
|
+
exports.linkedColorDefaults = linkedColorDefaults;
|
|
86255
|
+
exports.markBoxes = markBoxes;
|
|
84461
86256
|
exports.matrixDef = matrixDef;
|
|
84462
86257
|
exports.measureAxis = measureAxis;
|
|
84463
86258
|
exports.networkDef = networkDef;
|
|
@@ -84468,8 +86263,10 @@
|
|
|
84468
86263
|
exports.priestleyDef = priestleyDef;
|
|
84469
86264
|
exports.radarDef = radarDef;
|
|
84470
86265
|
exports.radialMatrixDef = radialMatrixDef;
|
|
86266
|
+
exports.registerLink = registerLink;
|
|
84471
86267
|
exports.renderAxes = renderAxes;
|
|
84472
86268
|
exports.reserveBottomRight = reserveBottomRight;
|
|
86269
|
+
exports.resolveLink = resolveLink;
|
|
84473
86270
|
exports.resolveSpec = resolveSpec;
|
|
84474
86271
|
exports.ringsDef = ringsDef;
|
|
84475
86272
|
exports.runLayout = runLayout;
|
|
@@ -84477,6 +86274,7 @@
|
|
|
84477
86274
|
exports.runStages = runStages;
|
|
84478
86275
|
exports.runVizPipeline = runVizPipeline;
|
|
84479
86276
|
exports.sankeyDef = sankeyDef;
|
|
86277
|
+
exports.sceneInsetRegion = sceneInsetRegion;
|
|
84480
86278
|
exports.searchContribution = searchContribution;
|
|
84481
86279
|
exports.sizeLegendContribution = sizeLegendContribution;
|
|
84482
86280
|
exports.subtitleFeature = subtitleFeature;
|
|
@@ -84487,6 +86285,7 @@
|
|
|
84487
86285
|
exports.totalFeature = totalFeature;
|
|
84488
86286
|
exports.treeDef = treeDef;
|
|
84489
86287
|
exports.treemapDef = treemapDef;
|
|
86288
|
+
exports.unregisterLink = unregisterLink;
|
|
84490
86289
|
exports.vizDraw = vizDraw;
|
|
84491
86290
|
exports.vizDrawPure = vizDrawPure;
|
|
84492
86291
|
exports.vizPostThresholdCtx = vizPostThresholdCtx;
|