@d3plus/core 4.1.0 → 4.3.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 +781 -688
- package/es/src/charts/AreaPlot/index.js +2 -1
- package/es/src/charts/AreaPlot/index.js.map +1 -1
- package/es/src/charts/BarChart/index.js +3 -1
- package/es/src/charts/BarChart/index.js.map +1 -1
- package/es/src/charts/BoxWhisker/index.js +2 -1
- package/es/src/charts/BoxWhisker/index.js.map +1 -1
- package/es/src/charts/BumpChart/index.js +2 -1
- package/es/src/charts/BumpChart/index.js.map +1 -1
- package/es/src/charts/Geomap/emit.js +44 -4
- package/es/src/charts/Geomap/emit.js.map +1 -1
- package/es/src/charts/Geomap/index.js +32 -2
- package/es/src/charts/Geomap/index.js.map +1 -1
- package/es/src/charts/LinePlot/index.js +2 -1
- package/es/src/charts/LinePlot/index.js.map +1 -1
- package/es/src/charts/Matrix/index.js +1 -0
- package/es/src/charts/Matrix/index.js.map +1 -1
- package/es/src/charts/Network/index.js +2 -1
- package/es/src/charts/Network/index.js.map +1 -1
- package/es/src/charts/Pack/index.js +1 -0
- package/es/src/charts/Pack/index.js.map +1 -1
- package/es/src/charts/Pie/index.js +1 -0
- package/es/src/charts/Pie/index.js.map +1 -1
- package/es/src/charts/Plot/index.js +99 -14
- package/es/src/charts/Plot/index.js.map +1 -1
- package/es/src/charts/Plot/pipeline.js +24 -3
- package/es/src/charts/Plot/pipeline.js.map +1 -1
- package/es/src/charts/Plot/pipelineDomains.js +3 -3
- package/es/src/charts/Plot/pipelineDomains.js.map +1 -1
- package/es/src/charts/Plot/stackHelpers.js +128 -9
- package/es/src/charts/Plot/stackHelpers.js.map +1 -1
- package/es/src/charts/Radar/index.js +2 -1
- package/es/src/charts/Radar/index.js.map +1 -1
- package/es/src/charts/RadialMatrix/index.js +1 -0
- package/es/src/charts/RadialMatrix/index.js.map +1 -1
- package/es/src/charts/Rings/index.js +2 -1
- package/es/src/charts/Rings/index.js.map +1 -1
- package/es/src/charts/Sankey/index.js +2 -1
- package/es/src/charts/Sankey/index.js.map +1 -1
- package/es/src/charts/Tree/index.js +2 -1
- package/es/src/charts/Tree/index.js.map +1 -1
- package/es/src/charts/Treemap/index.js +1 -0
- package/es/src/charts/Treemap/index.js.map +1 -1
- package/es/src/charts/features/shapeEmit.js +3 -1
- package/es/src/charts/features/shapeEmit.js.map +1 -1
- package/es/src/charts/viz/Viz.js +63 -10
- package/es/src/charts/viz/Viz.js.map +1 -1
- package/es/src/charts/viz/interactionOpacity.js +4 -1
- package/es/src/charts/viz/interactionOpacity.js.map +1 -1
- package/es/src/charts/viz/vizDefaults.js +4 -1
- package/es/src/charts/viz/vizDefaults.js.map +1 -1
- package/es/src/charts/viz/vizRender.js +7 -3
- package/es/src/charts/viz/vizRender.js.map +1 -1
- package/es/src/charts/viz/vizTypes.js.map +1 -1
- package/es/src/shapes/Image.js +2 -3
- package/es/src/shapes/Image.js.map +1 -1
- package/es/src/shapes/Shape.js +47 -46
- package/es/src/shapes/Shape.js.map +1 -1
- package/es/src/shapes/hitAreaNode.js +31 -5
- package/es/src/shapes/hitAreaNode.js.map +1 -1
- package/es/src/shapes/interactionPoints.js +30 -0
- package/es/src/shapes/interactionPoints.js.map +1 -0
- package/es/src/shapes/sceneSort.js +304 -24
- package/es/src/shapes/sceneSort.js.map +1 -1
- package/es/src/shapes/shapeConfig.js.map +1 -1
- package/es/src/utils/D3plusConfig.js.map +1 -1
- package/package.json +9 -9
- package/types/src/charts/Plot/index.d.ts +44 -7
- package/types/src/charts/Plot/pipeline.d.ts +2 -1
- package/types/src/charts/Plot/stackHelpers.d.ts +62 -4
- package/types/src/charts/viz/Viz.d.ts +31 -1
- package/types/src/charts/viz/vizTypes.d.ts +18 -0
- package/types/src/shapes/Image.d.ts +2 -3
- package/types/src/shapes/Shape.d.ts +2 -4
- package/types/src/shapes/hitAreaNode.d.ts +5 -4
- package/types/src/shapes/interactionPoints.d.ts +15 -0
- package/types/src/shapes/sceneSort.d.ts +83 -8
- package/types/src/shapes/shapeConfig.d.ts +7 -0
- package/types/src/utils/D3plusConfig.d.ts +19 -2
- package/umd/d3plus-core.full.js +2371 -672
- package/umd/d3plus-core.full.js.map +1 -1
- package/umd/d3plus-core.full.min.js +1506 -1156
- package/umd/d3plus-core.js +804 -259
- package/umd/d3plus-core.js.map +1 -1
- package/umd/d3plus-core.min.js +591 -390
package/umd/d3plus-core.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
/*
|
|
2
|
-
@d3plus/core v4.
|
|
2
|
+
@d3plus/core v4.3.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
|
|
6
6
|
*/
|
|
7
7
|
(function (global, factory) {
|
|
8
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('d3-array'), require('d3-selection'), require('@d3plus/data'), require('@d3plus/dom'), require('@d3plus/locales'), require('@d3plus/render'), require('@d3plus/text'), require('d3-color'), require('d3-brush'), require('d3-scale'), require('d3-zoom'), require('@d3plus/color'), require('@d3plus/format'), require('open-color/open-color.js'), require('d3-transition'), require('
|
|
9
|
-
typeof define === 'function' && define.amd ? define('@d3plus/core', ['exports', 'd3-array', 'd3-selection', '@d3plus/data', '@d3plus/dom', '@d3plus/locales', '@d3plus/render', '@d3plus/text', 'd3-color', 'd3-brush', 'd3-scale', 'd3-zoom', '@d3plus/color', '@d3plus/format', 'open-color/open-color.js', 'd3-transition', '
|
|
10
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.d3plus = {}, global.d3Array, global.d3Selection, global.data, global.dom, global.locales, global.render, global.text, global.d3Color, global.d3Brush, global.scales, global.d3Zoom, global.color, global.format, global.pkg, global.d3Transition, global.
|
|
11
|
-
})(this, (function (exports, d3Array, d3Selection, data, dom, locales, render, text, d3Color, d3Brush, scales, d3Zoom, color, format, pkg, d3Transition,
|
|
8
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('d3-array'), require('d3-selection'), require('@d3plus/data'), require('@d3plus/dom'), require('@d3plus/locales'), require('@d3plus/render'), require('@d3plus/text'), require('d3-color'), require('d3-brush'), require('d3-scale'), require('d3-zoom'), require('@d3plus/color'), require('@d3plus/format'), require('open-color/open-color.js'), require('d3-transition'), require('@d3plus/math'), require('d3-shape'), require('@floating-ui/dom'), require('d3-interpolate'), require('d3-time-format'), require('d3-tile'), require('d3-geo'), require('d3-geo-projection'), require('d3-composite-projections'), require('topojson-client'), require('d3-force'), require('d3-polygon'), require('d3-hierarchy'), require('d3-sankey')) :
|
|
9
|
+
typeof define === 'function' && define.amd ? define('@d3plus/core', ['exports', 'd3-array', 'd3-selection', '@d3plus/data', '@d3plus/dom', '@d3plus/locales', '@d3plus/render', '@d3plus/text', 'd3-color', 'd3-brush', 'd3-scale', 'd3-zoom', '@d3plus/color', '@d3plus/format', 'open-color/open-color.js', 'd3-transition', '@d3plus/math', 'd3-shape', '@floating-ui/dom', 'd3-interpolate', 'd3-time-format', 'd3-tile', 'd3-geo', 'd3-geo-projection', 'd3-composite-projections', 'topojson-client', 'd3-force', 'd3-polygon', 'd3-hierarchy', 'd3-sankey'], factory) :
|
|
10
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.d3plus = {}, global.d3Array, global.d3Selection, global.data, global.dom, global.locales, global.render, global.text, global.d3Color, global.d3Brush, global.scales, global.d3Zoom, global.color, global.format, global.pkg, global.d3Transition, global.math, global.d3Shape, global.dom$1, global.d3Interpolate, global.d3TimeFormat, global.d3Tile, global.d3GeoCore, global.d3GeoProjection, global.d3CompositeProjections, global.topojsonClient, global.d3Force, global.d3Polygon, global.d3Hierarchy, global.d3Sankey));
|
|
11
|
+
})(this, (function (exports, d3Array, d3Selection, data, dom, locales, render, text, d3Color, d3Brush, scales, d3Zoom, color, format, pkg, d3Transition, math, d3Shape, dom$1, d3Interpolate, d3TimeFormat, d3Tile, d3GeoCore, d3GeoProjection, d3CompositeProjections, topojsonClient, d3Force, d3Polygon, d3Hierarchy, d3Sankey) { 'use strict';
|
|
12
12
|
|
|
13
13
|
function _interopNamespaceDefault(e) {
|
|
14
14
|
var n = Object.create(null);
|
|
@@ -2034,7 +2034,10 @@
|
|
|
2034
2034
|
};
|
|
2035
2035
|
let base = typeof paint.fill === "string" ? paint.fill : undefined;
|
|
2036
2036
|
if (!base || base === "transparent" || base === "none") base = typeof paint.stroke === "string" ? paint.stroke : undefined;
|
|
2037
|
-
|
|
2037
|
+
// No visible paint to emphasize (e.g. an invisible hit-area node): leave it
|
|
2038
|
+
// untouched — darkening `transparent`/`none` would format to opaque black.
|
|
2039
|
+
if (!base || base === "transparent" || base === "none") return node;
|
|
2040
|
+
const c = d3Color.color(base);
|
|
2038
2041
|
if (c) paint.stroke = c.darker(darken).formatHex();
|
|
2039
2042
|
const w = typeof paint.strokeWidth === "number" && paint.strokeWidth ? paint.strokeWidth : 1;
|
|
2040
2043
|
paint.strokeWidth = w * widthMult;
|
|
@@ -2792,12 +2795,38 @@
|
|
|
2792
2795
|
the swatch↔hit-area crossing) but a DISTINCT `key`: the hit-area and the
|
|
2793
2796
|
visible geometry are siblings, and the SVG keyed join can't hold two nodes
|
|
2794
2797
|
under one key — sharing it made the geometry re-enter (collapse→grow) on every
|
|
2795
|
-
redraw (a "pulse" on e.g. every timeline step). Returns null when no
|
|
2796
|
-
|
|
2797
|
-
|
|
2798
|
-
|
|
2798
|
+
redraw (a "pulse" on e.g. every timeline step). Returns null when no hitArea
|
|
2799
|
+
is configured. A path-style hitArea (Line: a fat, transparent stroke) reuses
|
|
2800
|
+
the resolved geometry `d`/`transform` so the hover target overlaps the
|
|
2801
|
+
visible line exactly while extending past its ~1px stroke.
|
|
2802
|
+
*/ function hitAreaNode(hitArea, d, i, aes, key, datum, name, transform, geomD) {
|
|
2799
2803
|
const bounds = typeof hitArea === "function" ? hitArea(d, i, aes) : hitArea;
|
|
2800
|
-
if (!bounds
|
|
2804
|
+
if (!bounds) return null;
|
|
2805
|
+
// Path-style hitArea (Line): widen the hover target to a fat transparent
|
|
2806
|
+
// stroke over the line's own geometry. `stroke: transparent` (not "none") is
|
|
2807
|
+
// painted, so it hit-tests across the full width on both backends.
|
|
2808
|
+
if (typeof bounds.width !== "number" && typeof geomD === "string") {
|
|
2809
|
+
const sw = typeof bounds["stroke-width"] === "number" ? bounds["stroke-width"] : 10;
|
|
2810
|
+
return {
|
|
2811
|
+
type: "path",
|
|
2812
|
+
d: geomD,
|
|
2813
|
+
key: `${key}::hit`,
|
|
2814
|
+
datum,
|
|
2815
|
+
index: i,
|
|
2816
|
+
shapeType: name,
|
|
2817
|
+
paint: {
|
|
2818
|
+
fill: "none",
|
|
2819
|
+
stroke: "transparent",
|
|
2820
|
+
strokeWidth: sw,
|
|
2821
|
+
vectorEffect: "non-scaling-stroke"
|
|
2822
|
+
},
|
|
2823
|
+
transform,
|
|
2824
|
+
aria: {
|
|
2825
|
+
hidden: true
|
|
2826
|
+
}
|
|
2827
|
+
};
|
|
2828
|
+
}
|
|
2829
|
+
if (typeof bounds.width !== "number" || typeof bounds.height !== "number") return null;
|
|
2801
2830
|
return {
|
|
2802
2831
|
type: "rect",
|
|
2803
2832
|
x: typeof bounds.x === "number" ? bounds.x : -bounds.width / 2,
|
|
@@ -2818,151 +2847,33 @@
|
|
|
2818
2847
|
};
|
|
2819
2848
|
}
|
|
2820
2849
|
|
|
2821
|
-
/**
|
|
2822
|
-
|
|
2823
|
-
|
|
2824
|
-
|
|
2825
|
-
|
|
2826
|
-
|
|
2827
|
-
|
|
2828
|
-
|
|
2829
|
-
|
|
2830
|
-
|
|
2831
|
-
|
|
2832
|
-
|
|
2833
|
-
|
|
2834
|
-
|
|
2835
|
-
|
|
2836
|
-
|
|
2837
|
-
|
|
2838
|
-
|
|
2839
|
-
|
|
2840
|
-
|
|
2841
|
-
|
|
2842
|
-
|
|
2843
|
-
key: "pointerEvents",
|
|
2844
|
-
coerce: "const",
|
|
2845
|
-
default: constant("auto")
|
|
2846
|
-
},
|
|
2847
|
-
{
|
|
2848
|
-
key: "renderMode",
|
|
2849
|
-
coerce: "identity",
|
|
2850
|
-
default: "full"
|
|
2851
|
-
},
|
|
2852
|
-
{
|
|
2853
|
-
key: "url",
|
|
2854
|
-
coerce: "identity",
|
|
2855
|
-
default: accessor("url")
|
|
2856
|
-
},
|
|
2857
|
-
{
|
|
2858
|
-
key: "width",
|
|
2859
|
-
coerce: "accessor",
|
|
2860
|
-
default: accessor("width")
|
|
2861
|
-
},
|
|
2862
|
-
{
|
|
2863
|
-
key: "x",
|
|
2864
|
-
coerce: "const",
|
|
2865
|
-
default: accessor("x", 0)
|
|
2866
|
-
},
|
|
2867
|
-
{
|
|
2868
|
-
key: "y",
|
|
2869
|
-
coerce: "const",
|
|
2870
|
-
default: accessor("y", 0)
|
|
2871
|
-
}
|
|
2872
|
-
];
|
|
2873
|
-
class Image {
|
|
2874
|
-
config(_) {
|
|
2875
|
-
if (!arguments.length) return {
|
|
2876
|
-
...this.schema,
|
|
2877
|
-
data: this._data,
|
|
2878
|
-
select: this._select
|
|
2879
|
-
};
|
|
2880
|
-
const patch = _;
|
|
2881
|
-
for(const k in patch){
|
|
2882
|
-
if (!Object.prototype.hasOwnProperty.call(patch, k)) continue;
|
|
2883
|
-
// `this[k]` resolves the fluent accessor via the index signature.
|
|
2884
|
-
if (typeof this[k] === "function") this[k](patch[k]);
|
|
2885
|
-
else this.schema[k] = patch[k];
|
|
2886
|
-
}
|
|
2887
|
-
return this;
|
|
2888
|
-
}
|
|
2889
|
-
/**
|
|
2890
|
-
Renders the current Image to the page. If a *callback* is specified, it will be called once the images are done drawing.
|
|
2891
|
-
@param callback Optional callback invoked after rendering completes.
|
|
2892
|
-
*/ render(callback) {
|
|
2893
|
-
// Compute mode is a no-op for DOM emission — the caller will read
|
|
2894
|
-
// `toScene()` to get a SceneNode tree, no need to mount.
|
|
2895
|
-
if (this.schema.renderMode === "compute") {
|
|
2896
|
-
if (callback) setTimeout(callback, 0);
|
|
2897
|
-
return this;
|
|
2898
|
-
}
|
|
2899
|
-
if (this._select === void 0) this.select(d3Selection.select("body").append("svg").style("width", `${window.innerWidth}px`).style("height", `${window.innerHeight}px`).style("display", "block").node());
|
|
2900
|
-
const images = this._select.selectAll(".d3plus-Image").data(this._data, this.schema.id);
|
|
2901
|
-
const enter = images.enter().append("image").attr("class", "d3plus-Image").attr("opacity", 0).attr("width", 0).attr("height", 0).attr("x", (d, i)=>this.schema.x(d, i) + this.schema.width(d, i) / 2).attr("y", (d, i)=>this.schema.y(d, i) + this.schema.height(d, i) / 2);
|
|
2902
|
-
const t = d3Transition.transition().duration(this.schema.duration), that = this, update = enter.merge(images);
|
|
2903
|
-
update.attr("xlink:href", this.schema.url).style("pointer-events", this.schema.pointerEvents).transition(t).attr("opacity", this.schema.opacity).attr("width", (d, i)=>this.schema.width(d, i)).attr("height", (d, i)=>this.schema.height(d, i)).attr("x", (d, i)=>this.schema.x(d, i)).attr("y", (d, i)=>this.schema.y(d, i)).each(function(d, i) {
|
|
2904
|
-
const image = d3Selection.select(this), link = that.schema.url(d, i);
|
|
2905
|
-
const fullAddress = link.indexOf("http://") === 0 || link.indexOf("https://") === 0;
|
|
2906
|
-
if (!fullAddress || link.indexOf(window.location.hostname) === 0) {
|
|
2907
|
-
const img = new window.Image();
|
|
2908
|
-
img.src = link;
|
|
2909
|
-
img.crossOrigin = "Anonymous";
|
|
2910
|
-
img.onload = function() {
|
|
2911
|
-
const canvas = document.createElement("canvas");
|
|
2912
|
-
canvas.width = img.width;
|
|
2913
|
-
canvas.height = img.height;
|
|
2914
|
-
const context = canvas.getContext("2d");
|
|
2915
|
-
context.drawImage(img, 0, 0);
|
|
2916
|
-
image.attr("xlink:href", canvas.toDataURL("image/png"));
|
|
2917
|
-
};
|
|
2918
|
-
}
|
|
2919
|
-
});
|
|
2920
|
-
images.exit().transition(t).attr("width", (d, i)=>this.schema.width(d, i)).attr("height", (d, i)=>this.schema.height(d, i)).attr("x", (d, i)=>this.schema.x(d, i)).attr("y", (d, i)=>this.schema.y(d, i)).attr("opacity", 0).remove();
|
|
2921
|
-
if (callback) setTimeout(callback, this.schema.duration + 100);
|
|
2922
|
-
return this;
|
|
2923
|
-
}
|
|
2924
|
-
data(_) {
|
|
2925
|
-
return arguments.length ? (this._data = _, this) : this._data;
|
|
2926
|
-
}
|
|
2927
|
-
/**
|
|
2928
|
-
Compute-mode scene emission. Mirrors Shape.toScene's shape — a
|
|
2929
|
-
keyed GroupNode wrapping per-datum ImageNodes. Used by chart
|
|
2930
|
-
compositors (Shape._backgroundImageClass, plotPaint) that need
|
|
2931
|
-
Image to participate in the scene graph rather than emit
|
|
2932
|
-
d3-selection DOM.
|
|
2933
|
-
*/ toScene() {
|
|
2934
|
-
const children = (this._data || []).map((d, i)=>{
|
|
2935
|
-
const node = {
|
|
2936
|
-
type: "image",
|
|
2937
|
-
key: `${this.schema.id(d, i)}`,
|
|
2938
|
-
x: this.schema.x(d, i),
|
|
2939
|
-
y: this.schema.y(d, i),
|
|
2940
|
-
width: this.schema.width(d, i),
|
|
2941
|
-
height: this.schema.height(d, i),
|
|
2942
|
-
href: this.schema.url(d, i),
|
|
2943
|
-
paint: {
|
|
2944
|
-
opacity: this.schema.opacity(d, i)
|
|
2945
|
-
},
|
|
2946
|
-
datum: d,
|
|
2947
|
-
index: i
|
|
2948
|
-
};
|
|
2949
|
-
return node;
|
|
2850
|
+
/**
|
|
2851
|
+
For a nested shape datum (Line/Area, whose datum wraps many points) returns a
|
|
2852
|
+
spreadable scene-node fragment carrying each point's content-space position
|
|
2853
|
+
paired with its source datum, so the pointer bridge can report the point
|
|
2854
|
+
nearest the cursor rather than the whole-series aggregate. Points the
|
|
2855
|
+
`defined` accessor rejects, or whose position isn't finite (a missing value),
|
|
2856
|
+
are skipped — so the nearest match is always a real, defined point. Returns
|
|
2857
|
+
an empty object for non-nested data (spreads to nothing).
|
|
2858
|
+
*/ function interactionPoints(d, x, y, defined) {
|
|
2859
|
+
if (!d.__d3plusShape__ || !Array.isArray(d.values)) return {};
|
|
2860
|
+
const values = d.values;
|
|
2861
|
+
const points = [];
|
|
2862
|
+
values.forEach((v, k)=>{
|
|
2863
|
+
if (typeof defined === "function" && defined(v, k) === false) return;
|
|
2864
|
+
const px = Number(x(v, k));
|
|
2865
|
+
const py = Number(y(v, k));
|
|
2866
|
+
if (!Number.isFinite(px) || !Number.isFinite(py)) return;
|
|
2867
|
+
points.push({
|
|
2868
|
+
x: px,
|
|
2869
|
+
y: py,
|
|
2870
|
+
datum: v,
|
|
2871
|
+
index: typeof v.i === "number" ? v.i : k
|
|
2950
2872
|
});
|
|
2951
|
-
|
|
2952
|
-
|
|
2953
|
-
|
|
2954
|
-
|
|
2955
|
-
};
|
|
2956
|
-
}
|
|
2957
|
-
select(_) {
|
|
2958
|
-
return arguments.length ? (this._select = d3Selection.select(_), this) : this._select;
|
|
2959
|
-
}
|
|
2960
|
-
/**
|
|
2961
|
-
Invoked when creating a new class instance, and sets any default parameters.
|
|
2962
|
-
@private
|
|
2963
|
-
*/ constructor(){
|
|
2964
|
-
installFluent(this, imageSchema);
|
|
2965
|
-
}
|
|
2873
|
+
});
|
|
2874
|
+
return points.length ? {
|
|
2875
|
+
interactionPoints: points
|
|
2876
|
+
} : {};
|
|
2966
2877
|
}
|
|
2967
2878
|
|
|
2968
2879
|
/** Follows the chart (`__d3plus__`) and shape (`__d3plusShape__`) wrappers back
|
|
@@ -2987,18 +2898,219 @@
|
|
|
2987
2898
|
order.forEach((origIdx, pos)=>rank[origIdx] = pos);
|
|
2988
2899
|
return rank;
|
|
2989
2900
|
}
|
|
2901
|
+
/** Bounding box of a list of polygon points, or null when degenerate. */ function pointsBox(points) {
|
|
2902
|
+
if (!points.length) return null;
|
|
2903
|
+
let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;
|
|
2904
|
+
for (const [px, py] of points){
|
|
2905
|
+
if (px < minX) minX = px;
|
|
2906
|
+
if (py < minY) minY = py;
|
|
2907
|
+
if (px > maxX) maxX = px;
|
|
2908
|
+
if (py > maxY) maxY = py;
|
|
2909
|
+
}
|
|
2910
|
+
if (!Number.isFinite(minX) || maxX <= minX || maxY <= minY) return null;
|
|
2911
|
+
return {
|
|
2912
|
+
x: minX,
|
|
2913
|
+
y: minY,
|
|
2914
|
+
width: maxX - minX,
|
|
2915
|
+
height: maxY - minY
|
|
2916
|
+
};
|
|
2917
|
+
}
|
|
2918
|
+
/**
|
|
2919
|
+
The local-space bounding box `{x, y, width, height}` a backgroundImage fills,
|
|
2920
|
+
derived from a datum's scene geometry. Rect/Bar geometry is already a box;
|
|
2921
|
+
Circle is centered at (cx, cy) with radius r; a `path` uses the exact
|
|
2922
|
+
(DOM-free) bounds of its `d`; Area/Line fall back to their polygon `points`.
|
|
2923
|
+
Returns null when no finite extent can be determined.
|
|
2924
|
+
*/ function backgroundImageBox(g, points) {
|
|
2925
|
+
if (typeof g.width === "number" && typeof g.height === "number") {
|
|
2926
|
+
const x = typeof g.x === "number" ? g.x : -g.width / 2;
|
|
2927
|
+
const y = typeof g.y === "number" ? g.y : -g.height / 2;
|
|
2928
|
+
return {
|
|
2929
|
+
x,
|
|
2930
|
+
y,
|
|
2931
|
+
width: g.width,
|
|
2932
|
+
height: g.height
|
|
2933
|
+
};
|
|
2934
|
+
}
|
|
2935
|
+
if (typeof g.r === "number") {
|
|
2936
|
+
const cx = typeof g.cx === "number" ? g.cx : 0;
|
|
2937
|
+
const cy = typeof g.cy === "number" ? g.cy : 0;
|
|
2938
|
+
return {
|
|
2939
|
+
x: cx - g.r,
|
|
2940
|
+
y: cy - g.r,
|
|
2941
|
+
width: g.r * 2,
|
|
2942
|
+
height: g.r * 2
|
|
2943
|
+
};
|
|
2944
|
+
}
|
|
2945
|
+
if (typeof g.d === "string") {
|
|
2946
|
+
const b = math.pathBounds(g.d);
|
|
2947
|
+
return b.width > 0 && b.height > 0 ? b : null;
|
|
2948
|
+
}
|
|
2949
|
+
return pointsBox(points);
|
|
2950
|
+
}
|
|
2951
|
+
/** Rounded-rectangle path `d` (falls back to a plain rect when radii are 0). */ function roundedRectPath(x, y, w, h, rx, ry) {
|
|
2952
|
+
rx = Math.min(rx, w / 2);
|
|
2953
|
+
ry = Math.min(ry, h / 2);
|
|
2954
|
+
return `M${x + rx},${y}h${w - 2 * rx}a${rx},${ry} 0 0 1 ${rx},${ry}` + `v${h - 2 * ry}a${rx},${ry} 0 0 1 ${-rx},${ry}h${-(w - 2 * rx)}` + `a${rx},${ry} 0 0 1 ${-rx},${-ry}v${-(h - 2 * ry)}a${rx},${ry} 0 0 1 ${rx},${-ry}Z`;
|
|
2955
|
+
}
|
|
2990
2956
|
/**
|
|
2991
|
-
|
|
2992
|
-
|
|
2993
|
-
|
|
2994
|
-
|
|
2995
|
-
|
|
2996
|
-
|
|
2997
|
-
|
|
2998
|
-
|
|
2999
|
-
|
|
3000
|
-
if (
|
|
3001
|
-
|
|
2957
|
+
The shape's own geometry expressed as a clip region in its LOCAL coordinate
|
|
2958
|
+
space, so a background image can be clipped to the shape itself (a Path image
|
|
2959
|
+
is clipped to the path, a Circle image to the circle, etc.). Returns
|
|
2960
|
+
undefined when the geometry has no usable outline.
|
|
2961
|
+
*/ function backgroundImageClip(g, points) {
|
|
2962
|
+
if (typeof g.d === "string") return {
|
|
2963
|
+
type: "path",
|
|
2964
|
+
d: g.d
|
|
2965
|
+
};
|
|
2966
|
+
if (typeof g.width === "number" && typeof g.height === "number") {
|
|
2967
|
+
const x = typeof g.x === "number" ? g.x : -g.width / 2;
|
|
2968
|
+
const y = typeof g.y === "number" ? g.y : -g.height / 2;
|
|
2969
|
+
const rx = typeof g.rx === "number" ? g.rx : 0;
|
|
2970
|
+
const ry = typeof g.ry === "number" ? g.ry : 0;
|
|
2971
|
+
return rx > 0 || ry > 0 ? {
|
|
2972
|
+
type: "path",
|
|
2973
|
+
d: roundedRectPath(x, y, g.width, g.height, rx || ry, ry || rx)
|
|
2974
|
+
} : {
|
|
2975
|
+
type: "rect",
|
|
2976
|
+
x,
|
|
2977
|
+
y,
|
|
2978
|
+
width: g.width,
|
|
2979
|
+
height: g.height
|
|
2980
|
+
};
|
|
2981
|
+
}
|
|
2982
|
+
if (typeof g.r === "number") {
|
|
2983
|
+
const cx = typeof g.cx === "number" ? g.cx : 0;
|
|
2984
|
+
const cy = typeof g.cy === "number" ? g.cy : 0;
|
|
2985
|
+
const r = g.r;
|
|
2986
|
+
return {
|
|
2987
|
+
type: "path",
|
|
2988
|
+
d: `M${cx - r},${cy}a${r},${r} 0 1,0 ${2 * r},0a${r},${r} 0 1,0 ${ -2 * r},0Z`
|
|
2989
|
+
};
|
|
2990
|
+
}
|
|
2991
|
+
if (points.length > 2) {
|
|
2992
|
+
const d = `M${points.map(([x, y])=>`${x},${y}`).join("L")}Z`;
|
|
2993
|
+
return {
|
|
2994
|
+
type: "path",
|
|
2995
|
+
d
|
|
2996
|
+
};
|
|
2997
|
+
}
|
|
2998
|
+
return undefined;
|
|
2999
|
+
}
|
|
3000
|
+
/** A polygon (local coords) approximating the shape outline, for `largestRect`. */ function shapePolygon(g, points) {
|
|
3001
|
+
if (typeof g.d === "string") return math.path2polygon(g.d);
|
|
3002
|
+
return points;
|
|
3003
|
+
}
|
|
3004
|
+
/**
|
|
3005
|
+
Resolves a backgroundImage's box + clip + `preserveAspectRatio` for a datum's
|
|
3006
|
+
geometry, honoring the fit mode:
|
|
3007
|
+
|
|
3008
|
+
- `cover` — the image fills the shape's bounding box and is cropped
|
|
3009
|
+
(`xMidYMid slice`), clipped to the shape's own outline.
|
|
3010
|
+
- `contain` — the whole image is centered and fully visible inside the shape:
|
|
3011
|
+
it is fit (`xMidYMid meet`) into the shape's largest inscribed axis-aligned
|
|
3012
|
+
rectangle (a Rect uses itself; a Circle its inscribed square; a Path/Area
|
|
3013
|
+
uses `largestRect` of its polygon). No clip is needed since the box already
|
|
3014
|
+
sits inside the shape.
|
|
3015
|
+
|
|
3016
|
+
Returns null when no usable box can be derived.
|
|
3017
|
+
*/ function backgroundImageLayout(g, points, fit) {
|
|
3018
|
+
if (fit !== "contain") {
|
|
3019
|
+
const box = backgroundImageBox(g, points);
|
|
3020
|
+
if (!box) return null;
|
|
3021
|
+
return {
|
|
3022
|
+
box,
|
|
3023
|
+
clip: backgroundImageClip(g, points),
|
|
3024
|
+
preserveAspectRatio: "xMidYMid slice"
|
|
3025
|
+
};
|
|
3026
|
+
}
|
|
3027
|
+
// contain: fit inside the largest inscribed rectangle, fully visible.
|
|
3028
|
+
let box = null;
|
|
3029
|
+
if (typeof g.width === "number" && typeof g.height === "number") {
|
|
3030
|
+
box = backgroundImageBox(g, points); // a rect contains itself
|
|
3031
|
+
} else if (typeof g.r === "number") {
|
|
3032
|
+
// Inscribed square of a circle: side = r·√2, centered on (cx, cy).
|
|
3033
|
+
const cx = typeof g.cx === "number" ? g.cx : 0;
|
|
3034
|
+
const cy = typeof g.cy === "number" ? g.cy : 0;
|
|
3035
|
+
const half = g.r / Math.SQRT2;
|
|
3036
|
+
box = {
|
|
3037
|
+
x: cx - half,
|
|
3038
|
+
y: cy - half,
|
|
3039
|
+
width: half * 2,
|
|
3040
|
+
height: half * 2
|
|
3041
|
+
};
|
|
3042
|
+
} else {
|
|
3043
|
+
const poly = shapePolygon(g, points);
|
|
3044
|
+
const r = poly.length > 2 ? math.largestRect(poly, {
|
|
3045
|
+
angle: 0
|
|
3046
|
+
}) : null;
|
|
3047
|
+
box = r ? {
|
|
3048
|
+
x: r.cx - r.width / 2,
|
|
3049
|
+
y: r.cy - r.height / 2,
|
|
3050
|
+
width: r.width,
|
|
3051
|
+
height: r.height
|
|
3052
|
+
} : backgroundImageBox(g, points);
|
|
3053
|
+
}
|
|
3054
|
+
return box ? {
|
|
3055
|
+
box,
|
|
3056
|
+
preserveAspectRatio: "xMidYMid meet"
|
|
3057
|
+
} : null;
|
|
3058
|
+
}
|
|
3059
|
+
/**
|
|
3060
|
+
Emits the per-datum background images collected during `Shape.toScene`. Each
|
|
3061
|
+
image is wrapped in its own group carrying the shape's datum + transform, so
|
|
3062
|
+
it is clipped to the shape's outline, positioned in local space, and dims/
|
|
3063
|
+
raises together with its shape on hover. The image is non-interactive (and
|
|
3064
|
+
keyed apart from the shape) so pointer events pass through to the shape below.
|
|
3065
|
+
When `rank` is set (a `sort` comparator is active) every group needs a `z`
|
|
3066
|
+
so the backend sort keeps images above the geometry in their own order.
|
|
3067
|
+
*/ function emitBackgroundImages(specs, rank, dataLen) {
|
|
3068
|
+
return specs.map((spec, k)=>{
|
|
3069
|
+
const image = {
|
|
3070
|
+
type: "image",
|
|
3071
|
+
// Keyed apart from the shape (which uses `spec.key`): sharing the key would
|
|
3072
|
+
// let this non-interactive image overwrite the shape in the hit-test index.
|
|
3073
|
+
key: `${spec.key}-bgimage-img`,
|
|
3074
|
+
x: spec.box.x,
|
|
3075
|
+
y: spec.box.y,
|
|
3076
|
+
width: spec.box.width,
|
|
3077
|
+
height: spec.box.height,
|
|
3078
|
+
href: spec.url,
|
|
3079
|
+
preserveAspectRatio: spec.preserveAspectRatio,
|
|
3080
|
+
// Decorative: pointer events fall through to the shape underneath.
|
|
3081
|
+
interactive: false
|
|
3082
|
+
};
|
|
3083
|
+
const group = {
|
|
3084
|
+
type: "group",
|
|
3085
|
+
key: `${spec.key}-bgimage`,
|
|
3086
|
+
children: [
|
|
3087
|
+
image
|
|
3088
|
+
],
|
|
3089
|
+
// Carry the shape's datum/index so hover/active dimming treats the image
|
|
3090
|
+
// like its shape — dimming and hover-raising the two together (the group
|
|
3091
|
+
// is emitted after the geometry, so at equal `z` the image stays on top).
|
|
3092
|
+
datum: spec.datum,
|
|
3093
|
+
index: spec.index,
|
|
3094
|
+
interactive: false,
|
|
3095
|
+
// A group-level opacity gives the enter/exit animation a target to fade
|
|
3096
|
+
// to/from (matching the shape): the animate layer collapses it to 0 on
|
|
3097
|
+
// enter and eases up to this. It also cascades to the image, so hover
|
|
3098
|
+
// dimming applied here fades the picture with its shape.
|
|
3099
|
+
paint: {
|
|
3100
|
+
opacity: spec.opacity ?? 1
|
|
3101
|
+
},
|
|
3102
|
+
...spec.transform ? {
|
|
3103
|
+
transform: spec.transform
|
|
3104
|
+
} : {},
|
|
3105
|
+
...spec.clip ? {
|
|
3106
|
+
clip: spec.clip
|
|
3107
|
+
} : {},
|
|
3108
|
+
...rank ? {
|
|
3109
|
+
z: dataLen + k
|
|
3110
|
+
} : {}
|
|
3111
|
+
};
|
|
3112
|
+
return group;
|
|
3113
|
+
});
|
|
3002
3114
|
}
|
|
3003
3115
|
|
|
3004
3116
|
/** Coerces a value to a finite number, or undefined. @private */ function numOrUndef(v) {
|
|
@@ -3032,6 +3144,11 @@
|
|
|
3032
3144
|
coerce: "const",
|
|
3033
3145
|
default: constant(false)
|
|
3034
3146
|
},
|
|
3147
|
+
{
|
|
3148
|
+
key: "backgroundImageFit",
|
|
3149
|
+
coerce: "const",
|
|
3150
|
+
default: constant("cover")
|
|
3151
|
+
},
|
|
3035
3152
|
{
|
|
3036
3153
|
key: "discrete",
|
|
3037
3154
|
coerce: "identity"
|
|
@@ -3267,15 +3384,12 @@
|
|
|
3267
3384
|
Renders the current Shape to the page. If a *callback* is specified, it will be called once the shapes are done drawing.
|
|
3268
3385
|
@param callback Optional callback invoked after rendering completes.
|
|
3269
3386
|
*/ /**
|
|
3270
|
-
Resolves a style accessor
|
|
3271
|
-
|
|
3387
|
+
Resolves a style accessor. For a nested shape (Line/Area) the accessor gets
|
|
3388
|
+
the merged aggregate `d.data`/`d.i` — matching `_nestWrapper` + scene datum.
|
|
3272
3389
|
@private
|
|
3273
3390
|
*/ _styleVal(fn, d, i) {
|
|
3274
3391
|
if (typeof fn !== "function") return fn;
|
|
3275
|
-
if (d.nested && d.key && d.values)
|
|
3276
|
-
const first = d.values[0];
|
|
3277
|
-
return fn(first, this._data.indexOf(first));
|
|
3278
|
-
}
|
|
3392
|
+
if (d.nested && d.key && d.values) return fn(d.data, d.i);
|
|
3279
3393
|
return fn(d, i);
|
|
3280
3394
|
}
|
|
3281
3395
|
/**
|
|
@@ -3344,10 +3458,10 @@
|
|
|
3344
3458
|
let data = this._data;
|
|
3345
3459
|
if (this._dataFilter) data = this._dataFilter(data);
|
|
3346
3460
|
const children = [];
|
|
3347
|
-
//
|
|
3348
|
-
//
|
|
3349
|
-
//
|
|
3350
|
-
const
|
|
3461
|
+
// Collected background images, emitted below (after the geometry) as clipped,
|
|
3462
|
+
// transformed groups. Each datum whose `backgroundImage(d, i)` resolves to a
|
|
3463
|
+
// truthy URL contributes one spec.
|
|
3464
|
+
const bgSpecs = [];
|
|
3351
3465
|
// A `sort` comparator becomes per-datum `z` ranks rather than a reorder of
|
|
3352
3466
|
// `data`: the render backends sort each group's children ascending by `z`
|
|
3353
3467
|
// (stably), so a lower rank paints first (behind) and a higher rank paints
|
|
@@ -3360,15 +3474,23 @@
|
|
|
3360
3474
|
const key = this._nestWrapper(this.schema.id)(d, i);
|
|
3361
3475
|
const datum = d.__d3plusShape__ ? d.data : d;
|
|
3362
3476
|
const transform = this._sceneTransform(d, i);
|
|
3477
|
+
// Per-point positions (Line/Area) shared by the geometry and its hit area
|
|
3478
|
+
// so a hover anywhere on either resolves to the nearest point.
|
|
3479
|
+
const iPoints = interactionPoints(d, this.schema.x, this.schema.y, this.schema.defined);
|
|
3363
3480
|
// Push the hit area (if any) before the geometry so it sits behind it.
|
|
3481
|
+
// Line's is a fat path built from the geometry `d`; Bar/legend etc. a rect.
|
|
3364
3482
|
if (this.schema.hitArea) {
|
|
3365
|
-
const ha = hitAreaNode(this.schema.hitArea, d, i, this._aes(d, i), key, datum, this._name, transform);
|
|
3483
|
+
const ha = hitAreaNode(this.schema.hitArea, d, i, this._aes(d, i), key, datum, this._name, transform, geom.d);
|
|
3366
3484
|
// Share the datum's rank so the hit area stays paired just behind its
|
|
3367
3485
|
// own geometry (equal `z`, kept in push order by the stable sort).
|
|
3368
3486
|
if (ha) children.push(rank ? {
|
|
3369
3487
|
...ha,
|
|
3488
|
+
...iPoints,
|
|
3370
3489
|
z: rank[i]
|
|
3371
|
-
} :
|
|
3490
|
+
} : {
|
|
3491
|
+
...ha,
|
|
3492
|
+
...iPoints
|
|
3493
|
+
});
|
|
3372
3494
|
}
|
|
3373
3495
|
children.push({
|
|
3374
3496
|
...geom,
|
|
@@ -3382,45 +3504,42 @@
|
|
|
3382
3504
|
role: strOrUndef(this._nestWrapper(this.schema.role)(d, i)),
|
|
3383
3505
|
label: strOrUndef(this._nestWrapper(this.schema.ariaLabel)(d, i))
|
|
3384
3506
|
},
|
|
3507
|
+
...iPoints,
|
|
3385
3508
|
...rank ? {
|
|
3386
3509
|
z: rank[i]
|
|
3387
3510
|
} : {}
|
|
3388
3511
|
});
|
|
3389
|
-
// backgroundImage: collect a per-datum image
|
|
3390
|
-
//
|
|
3391
|
-
//
|
|
3512
|
+
// backgroundImage: collect a per-datum image (see backgroundImageLayout for
|
|
3513
|
+
// the cover/contain fit). The wrapping group carries the shape transform,
|
|
3514
|
+
// so the image box + clip stay in local space.
|
|
3392
3515
|
const bg = this._nestWrapper(this.schema.backgroundImage)(d, i);
|
|
3393
3516
|
if (bg) {
|
|
3394
3517
|
const g = geom;
|
|
3395
|
-
//
|
|
3396
|
-
//
|
|
3397
|
-
|
|
3398
|
-
|
|
3399
|
-
const
|
|
3400
|
-
const
|
|
3401
|
-
|
|
3402
|
-
|
|
3403
|
-
|
|
3404
|
-
|
|
3405
|
-
|
|
3406
|
-
|
|
3407
|
-
|
|
3408
|
-
|
|
3409
|
-
|
|
3410
|
-
|
|
3411
|
-
|
|
3412
|
-
|
|
3413
|
-
|
|
3414
|
-
y: (t.y ?? 0) + cy - ih / 2,
|
|
3415
|
-
width: iw,
|
|
3416
|
-
height: ih
|
|
3417
|
-
});
|
|
3518
|
+
// Only Area/Line lack a `d`/box and need polygon points; Path/Rect/Circle
|
|
3519
|
+
// derive their layout from `d`/width/r directly.
|
|
3520
|
+
const needsPoints = typeof g.d !== "string" && typeof g.width !== "number" && typeof g.r !== "number";
|
|
3521
|
+
const points = needsPoints ? this._aes(d, i).points ?? [] : [];
|
|
3522
|
+
const fit = this._nestWrapper(this.schema.backgroundImageFit)(d, i);
|
|
3523
|
+
const layout = backgroundImageLayout(g, points, fit === "contain" ? "contain" : "cover");
|
|
3524
|
+
if (layout) {
|
|
3525
|
+
bgSpecs.push({
|
|
3526
|
+
key,
|
|
3527
|
+
index: i,
|
|
3528
|
+
datum,
|
|
3529
|
+
url: bg,
|
|
3530
|
+
box: layout.box,
|
|
3531
|
+
clip: layout.clip,
|
|
3532
|
+
preserveAspectRatio: layout.preserveAspectRatio,
|
|
3533
|
+
opacity: numOrUndef(this._nestWrapper(this.schema.opacity)(d, i)),
|
|
3534
|
+
transform
|
|
3535
|
+
});
|
|
3536
|
+
}
|
|
3418
3537
|
}
|
|
3419
3538
|
});
|
|
3420
3539
|
// Emit background images AFTER shape children so they paint above the
|
|
3421
3540
|
// shape's fill — matches the DOM order where the <image> was
|
|
3422
3541
|
// appended as a sibling of the shape.
|
|
3423
|
-
if (
|
|
3542
|
+
if (bgSpecs.length) children.push(...emitBackgroundImages(bgSpecs, rank, data.length));
|
|
3424
3543
|
// NOTE: Labels are NOT pushed here. The canonical aggregation point is
|
|
3425
3544
|
// `emitHelpers.collectComputed(shape)`, which appends `shape.toScene()`
|
|
3426
3545
|
// AND `shape._labelClass.toScene()` independently. Pushing labels here
|
|
@@ -3583,7 +3702,6 @@
|
|
|
3583
3702
|
*/ constructor(tagName = "g"){
|
|
3584
3703
|
super();
|
|
3585
3704
|
installFluent(this, shapeSchema);
|
|
3586
|
-
this._backgroundImageClass = new Image();
|
|
3587
3705
|
this._data = [];
|
|
3588
3706
|
this._labelClass = new TextBox();
|
|
3589
3707
|
this._name = "Shape";
|
|
@@ -4711,6 +4829,152 @@
|
|
|
4711
4829
|
}
|
|
4712
4830
|
}
|
|
4713
4831
|
|
|
4832
|
+
/** Image's fluent accessor schema. Config storage lives on `this.schema.<key>`. */ const imageSchema = [
|
|
4833
|
+
{
|
|
4834
|
+
key: "duration",
|
|
4835
|
+
coerce: "identity",
|
|
4836
|
+
default: 600
|
|
4837
|
+
},
|
|
4838
|
+
{
|
|
4839
|
+
key: "height",
|
|
4840
|
+
coerce: "accessor",
|
|
4841
|
+
default: accessor("height")
|
|
4842
|
+
},
|
|
4843
|
+
{
|
|
4844
|
+
key: "id",
|
|
4845
|
+
coerce: "identity",
|
|
4846
|
+
default: accessor("id")
|
|
4847
|
+
},
|
|
4848
|
+
{
|
|
4849
|
+
key: "opacity",
|
|
4850
|
+
coerce: "const",
|
|
4851
|
+
default: constant(1)
|
|
4852
|
+
},
|
|
4853
|
+
{
|
|
4854
|
+
key: "pointerEvents",
|
|
4855
|
+
coerce: "const",
|
|
4856
|
+
default: constant("auto")
|
|
4857
|
+
},
|
|
4858
|
+
{
|
|
4859
|
+
key: "renderMode",
|
|
4860
|
+
coerce: "identity",
|
|
4861
|
+
default: "full"
|
|
4862
|
+
},
|
|
4863
|
+
{
|
|
4864
|
+
key: "url",
|
|
4865
|
+
coerce: "identity",
|
|
4866
|
+
default: accessor("url")
|
|
4867
|
+
},
|
|
4868
|
+
{
|
|
4869
|
+
key: "width",
|
|
4870
|
+
coerce: "accessor",
|
|
4871
|
+
default: accessor("width")
|
|
4872
|
+
},
|
|
4873
|
+
{
|
|
4874
|
+
key: "x",
|
|
4875
|
+
coerce: "const",
|
|
4876
|
+
default: accessor("x", 0)
|
|
4877
|
+
},
|
|
4878
|
+
{
|
|
4879
|
+
key: "y",
|
|
4880
|
+
coerce: "const",
|
|
4881
|
+
default: accessor("y", 0)
|
|
4882
|
+
}
|
|
4883
|
+
];
|
|
4884
|
+
class Image {
|
|
4885
|
+
config(_) {
|
|
4886
|
+
if (!arguments.length) return {
|
|
4887
|
+
...this.schema,
|
|
4888
|
+
data: this._data,
|
|
4889
|
+
select: this._select
|
|
4890
|
+
};
|
|
4891
|
+
const patch = _;
|
|
4892
|
+
for(const k in patch){
|
|
4893
|
+
if (!Object.prototype.hasOwnProperty.call(patch, k)) continue;
|
|
4894
|
+
// `this[k]` resolves the fluent accessor via the index signature.
|
|
4895
|
+
if (typeof this[k] === "function") this[k](patch[k]);
|
|
4896
|
+
else this.schema[k] = patch[k];
|
|
4897
|
+
}
|
|
4898
|
+
return this;
|
|
4899
|
+
}
|
|
4900
|
+
/**
|
|
4901
|
+
Renders the current Image to the page. If a *callback* is specified, it will be called once the images are done drawing.
|
|
4902
|
+
@param callback Optional callback invoked after rendering completes.
|
|
4903
|
+
*/ render(callback) {
|
|
4904
|
+
// Compute mode is a no-op for DOM emission — the caller will read
|
|
4905
|
+
// `toScene()` to get a SceneNode tree, no need to mount.
|
|
4906
|
+
if (this.schema.renderMode === "compute") {
|
|
4907
|
+
if (callback) setTimeout(callback, 0);
|
|
4908
|
+
return this;
|
|
4909
|
+
}
|
|
4910
|
+
if (this._select === void 0) this.select(d3Selection.select("body").append("svg").style("width", `${window.innerWidth}px`).style("height", `${window.innerHeight}px`).style("display", "block").node());
|
|
4911
|
+
const images = this._select.selectAll(".d3plus-Image").data(this._data, this.schema.id);
|
|
4912
|
+
const enter = images.enter().append("image").attr("class", "d3plus-Image").attr("opacity", 0).attr("width", 0).attr("height", 0).attr("x", (d, i)=>this.schema.x(d, i) + this.schema.width(d, i) / 2).attr("y", (d, i)=>this.schema.y(d, i) + this.schema.height(d, i) / 2);
|
|
4913
|
+
const t = d3Transition.transition().duration(this.schema.duration), that = this, update = enter.merge(images);
|
|
4914
|
+
update.attr("xlink:href", this.schema.url).style("pointer-events", this.schema.pointerEvents).transition(t).attr("opacity", this.schema.opacity).attr("width", (d, i)=>this.schema.width(d, i)).attr("height", (d, i)=>this.schema.height(d, i)).attr("x", (d, i)=>this.schema.x(d, i)).attr("y", (d, i)=>this.schema.y(d, i)).each(function(d, i) {
|
|
4915
|
+
const image = d3Selection.select(this), link = that.schema.url(d, i);
|
|
4916
|
+
const fullAddress = link.indexOf("http://") === 0 || link.indexOf("https://") === 0;
|
|
4917
|
+
if (!fullAddress || link.indexOf(window.location.hostname) === 0) {
|
|
4918
|
+
const img = new window.Image();
|
|
4919
|
+
img.src = link;
|
|
4920
|
+
img.crossOrigin = "Anonymous";
|
|
4921
|
+
img.onload = function() {
|
|
4922
|
+
const canvas = document.createElement("canvas");
|
|
4923
|
+
canvas.width = img.width;
|
|
4924
|
+
canvas.height = img.height;
|
|
4925
|
+
const context = canvas.getContext("2d");
|
|
4926
|
+
context.drawImage(img, 0, 0);
|
|
4927
|
+
image.attr("xlink:href", canvas.toDataURL("image/png"));
|
|
4928
|
+
};
|
|
4929
|
+
}
|
|
4930
|
+
});
|
|
4931
|
+
images.exit().transition(t).attr("width", (d, i)=>this.schema.width(d, i)).attr("height", (d, i)=>this.schema.height(d, i)).attr("x", (d, i)=>this.schema.x(d, i)).attr("y", (d, i)=>this.schema.y(d, i)).attr("opacity", 0).remove();
|
|
4932
|
+
if (callback) setTimeout(callback, this.schema.duration + 100);
|
|
4933
|
+
return this;
|
|
4934
|
+
}
|
|
4935
|
+
data(_) {
|
|
4936
|
+
return arguments.length ? (this._data = _, this) : this._data;
|
|
4937
|
+
}
|
|
4938
|
+
/**
|
|
4939
|
+
Compute-mode scene emission. Mirrors Shape.toScene's shape — a
|
|
4940
|
+
keyed GroupNode wrapping per-datum ImageNodes. Used by chart
|
|
4941
|
+
compositors (e.g. plotPaint) that need Image to participate in the
|
|
4942
|
+
scene graph rather than emit d3-selection DOM.
|
|
4943
|
+
*/ toScene() {
|
|
4944
|
+
const children = (this._data || []).map((d, i)=>{
|
|
4945
|
+
const node = {
|
|
4946
|
+
type: "image",
|
|
4947
|
+
key: `${this.schema.id(d, i)}`,
|
|
4948
|
+
x: this.schema.x(d, i),
|
|
4949
|
+
y: this.schema.y(d, i),
|
|
4950
|
+
width: this.schema.width(d, i),
|
|
4951
|
+
height: this.schema.height(d, i),
|
|
4952
|
+
href: this.schema.url(d, i),
|
|
4953
|
+
paint: {
|
|
4954
|
+
opacity: this.schema.opacity(d, i)
|
|
4955
|
+
},
|
|
4956
|
+
datum: d,
|
|
4957
|
+
index: i
|
|
4958
|
+
};
|
|
4959
|
+
return node;
|
|
4960
|
+
});
|
|
4961
|
+
return {
|
|
4962
|
+
type: "group",
|
|
4963
|
+
key: "d3plus-Image",
|
|
4964
|
+
children
|
|
4965
|
+
};
|
|
4966
|
+
}
|
|
4967
|
+
select(_) {
|
|
4968
|
+
return arguments.length ? (this._select = d3Selection.select(_), this) : this._select;
|
|
4969
|
+
}
|
|
4970
|
+
/**
|
|
4971
|
+
Invoked when creating a new class instance, and sets any default parameters.
|
|
4972
|
+
@private
|
|
4973
|
+
*/ constructor(){
|
|
4974
|
+
installFluent(this, imageSchema);
|
|
4975
|
+
}
|
|
4976
|
+
}
|
|
4977
|
+
|
|
4714
4978
|
/** Path's own fluent accessor schema, layered on top of Shape's. */ const pathSchema = [
|
|
4715
4979
|
{
|
|
4716
4980
|
key: "d",
|
|
@@ -9267,7 +9531,10 @@
|
|
|
9267
9531
|
}
|
|
9268
9532
|
};
|
|
9269
9533
|
const debouncedResize = debounce(applyResize, viz.schema.detectResizeDelay);
|
|
9270
|
-
|
|
9534
|
+
// Guarded so a chart can be constructed in an environment without a DOM (e.g.
|
|
9535
|
+
// before `@d3plus/ssr` installs one). Auto-resize is a browser-only feature;
|
|
9536
|
+
// when absent, `_resizeObserver` stays undefined and its call sites skip it.
|
|
9537
|
+
viz._resizeObserver = typeof ResizeObserver === "undefined" ? undefined : new ResizeObserver((entries)=>{
|
|
9271
9538
|
// The first real-size notification after `observe()` reports the
|
|
9272
9539
|
// container's settled layout size, which on an auto-sized chart often
|
|
9273
9540
|
// differs from the size the chart just measured pre-layout (the
|
|
@@ -9882,7 +10149,9 @@
|
|
|
9882
10149
|
viz._visiblePoll = clearInterval(viz._visiblePoll);
|
|
9883
10150
|
viz._resizePoll = clearTimeout(viz._resizePoll);
|
|
9884
10151
|
viz._scrollPoll = clearTimeout(viz._scrollPoll);
|
|
9885
|
-
|
|
10152
|
+
// scrollContainer is "" when constructed without a window (headless/SSR);
|
|
10153
|
+
// there is nothing to unbind and select("") throws on an invalid selector.
|
|
10154
|
+
if (viz.schema.scrollContainer) d3Selection.select(viz.schema.scrollContainer).on(`scroll.${viz._uuid}`, null);
|
|
9886
10155
|
}
|
|
9887
10156
|
/**
|
|
9888
10157
|
Installs the visibility/scroll detection that defers rendering until the
|
|
@@ -9983,9 +10252,9 @@
|
|
|
9983
10252
|
if (viz._select.attr("opacity") === "0") viz._select.transition().duration(viz.schema.duration).attr("opacity", 1);
|
|
9984
10253
|
}
|
|
9985
10254
|
if (viz.schema.detectResize && (viz._autoWidth || viz._autoHeight)) {
|
|
9986
|
-
viz._resizeObserver
|
|
10255
|
+
viz._resizeObserver?.observe(viz._select.node().parentNode);
|
|
9987
10256
|
} else {
|
|
9988
|
-
viz._resizeObserver
|
|
10257
|
+
viz._resizeObserver?.unobserve(viz._select.node().parentNode);
|
|
9989
10258
|
}
|
|
9990
10259
|
if (callback) setTimeout(()=>{
|
|
9991
10260
|
callback();
|
|
@@ -10684,6 +10953,23 @@
|
|
|
10684
10953
|
*/ render(callback) {
|
|
10685
10954
|
return vizRender(this, callback);
|
|
10686
10955
|
}
|
|
10956
|
+
/**
|
|
10957
|
+
Serializes the most recently rendered output to an SVG string. Returns
|
|
10958
|
+
`""` if the chart has not been rendered yet. Both backends support this:
|
|
10959
|
+
the SVG backend returns its live `<svg>`, the canvas backend re-renders the
|
|
10960
|
+
retained scene through a throwaway SVG backend. Primarily used for
|
|
10961
|
+
server-side rendering (see `@d3plus/ssr`).
|
|
10962
|
+
*/ toSVGString() {
|
|
10963
|
+
return this._sceneRenderer?.toSVGString?.() ?? "";
|
|
10964
|
+
}
|
|
10965
|
+
/**
|
|
10966
|
+
Returns the underlying canvas element of the most recent render when the
|
|
10967
|
+
canvas backend is active (`renderer("canvas")`), or `undefined` otherwise.
|
|
10968
|
+
Server-side callers cast this to their native canvas to encode a raster
|
|
10969
|
+
(see `@d3plus/ssr`).
|
|
10970
|
+
*/ toCanvas() {
|
|
10971
|
+
return this._renderer === "canvas" ? this._sceneRenderer?.toCanvas?.() : undefined;
|
|
10972
|
+
}
|
|
10687
10973
|
renderer(_) {
|
|
10688
10974
|
if (!arguments.length) return this._renderer;
|
|
10689
10975
|
this._renderer = _ === "canvas" ? "canvas" : "svg";
|
|
@@ -10747,10 +11033,14 @@
|
|
|
10747
11033
|
if (this._sceneRenderer && typeof this._sceneRenderer.destroy === "function") this._sceneRenderer.destroy();
|
|
10748
11034
|
const Ctor = kind === "canvas" ? render.CanvasRenderer : render.SvgRenderer;
|
|
10749
11035
|
this._sceneRenderer = new Ctor();
|
|
11036
|
+
// `_scenePixelRatio`, when set (e.g. by @d3plus/ssr for hi-res PNG output),
|
|
11037
|
+
// fixes the canvas backing-store scale; otherwise the renderer falls back
|
|
11038
|
+
// to `devicePixelRatio`.
|
|
10750
11039
|
this._sceneRenderer.mount({
|
|
10751
11040
|
container: mountTarget,
|
|
10752
11041
|
width: w,
|
|
10753
|
-
height: h
|
|
11042
|
+
height: h,
|
|
11043
|
+
pixelRatio: this._scenePixelRatio
|
|
10754
11044
|
});
|
|
10755
11045
|
// Bridge renderer pointer events → viz.schema.on handlers. Without this,
|
|
10756
11046
|
// tooltips never fire on the v4 scene-rendered path because
|
|
@@ -10834,6 +11124,25 @@
|
|
|
10834
11124
|
if (tlGroup) host.appendChild(tlGroup);
|
|
10835
11125
|
}
|
|
10836
11126
|
}
|
|
11127
|
+
/**
|
|
11128
|
+
Resolves the `(d, i, x)` a picked scene node reports to interaction
|
|
11129
|
+
handlers (tooltip, click, user `on` handlers). `pick.datum` is the raw
|
|
11130
|
+
scene datum; for a Plot shape that's the wrapped record `{data, i}`, which
|
|
11131
|
+
handlers expect unwrapped to `(d.data, d.i, wrapped)`. The base does that
|
|
11132
|
+
unwrap; Plot overrides this to report the point nearest the cursor for
|
|
11133
|
+
multi-point shapes (Line/Area) so a series tooltip reflects the hovered
|
|
11134
|
+
x rather than the whole-series aggregate.
|
|
11135
|
+
@private
|
|
11136
|
+
*/ _interactionDatum(pick, _event) {
|
|
11137
|
+
const rawDatum = pick.datum;
|
|
11138
|
+
const sourceDatum = rawDatum && rawDatum.data ? rawDatum.data : rawDatum;
|
|
11139
|
+
const sourceIndex = rawDatum && typeof rawDatum.i === "number" ? rawDatum.i : pick.index ?? 0;
|
|
11140
|
+
return {
|
|
11141
|
+
d: sourceDatum,
|
|
11142
|
+
i: sourceIndex,
|
|
11143
|
+
x: rawDatum
|
|
11144
|
+
};
|
|
11145
|
+
}
|
|
10837
11146
|
/**
|
|
10838
11147
|
Routes a renderer pointer event to the matching `viz.schema.on` handlers.
|
|
10839
11148
|
Bridges the v4 scene-rendered path (SvgRenderer/CanvasRenderer), where
|
|
@@ -10905,12 +11214,12 @@
|
|
|
10905
11214
|
const isLegendNode = nodeAny.interactionGroup === "legend" || (target && typeof target.closest === "function" ? !!target.closest('[data-key="viz-legend"]') : false);
|
|
10906
11215
|
const suffix = isLegendNode ? "legend" : "shape";
|
|
10907
11216
|
const handlerKey = `${event.type}.${suffix}`;
|
|
10908
|
-
// Resolve the
|
|
10909
|
-
//
|
|
10910
|
-
//
|
|
10911
|
-
|
|
10912
|
-
|
|
10913
|
-
const
|
|
11217
|
+
// Resolve the datum + index this pick reports to handlers, ONCE, and reuse
|
|
11218
|
+
// it for every handler fired below so tooltip/click/user handlers agree on
|
|
11219
|
+
// which datum the pointer is over. The base unwraps the node's raw datum to
|
|
11220
|
+
// its source row; Plot overrides `_interactionDatum` to report the point
|
|
11221
|
+
// nearest the cursor for multi-point shapes (Line/Area).
|
|
11222
|
+
const { d: sourceDatum, i: sourceIndex, x: rawDatum } = this._interactionDatum(pick, event);
|
|
10914
11223
|
const shapeType = typeof nodeAny.shapeType === "string" ? nodeAny.shapeType : null;
|
|
10915
11224
|
this._lastScenePick = {
|
|
10916
11225
|
d: sourceDatum,
|
|
@@ -10956,7 +11265,7 @@
|
|
|
10956
11265
|
/**
|
|
10957
11266
|
Tears down the visualization: disconnects the ResizeObserver and removes DOM event listeners. Call this when unmounting to avoid memory leaks.
|
|
10958
11267
|
*/ destroy() {
|
|
10959
|
-
this._resizeObserver
|
|
11268
|
+
this._resizeObserver?.disconnect();
|
|
10960
11269
|
this._tooltipClass.data([]).render();
|
|
10961
11270
|
d3Selection.select("body").on(`touchstart.${this._uuid}`, null);
|
|
10962
11271
|
// Clear the visibility/resize/scroll poll timers + scroll listener
|
|
@@ -10977,7 +11286,7 @@
|
|
|
10977
11286
|
if (typeof cancelAnimationFrame === "function") cancelAnimationFrame(this._sceneRepaintRAF);
|
|
10978
11287
|
this._sceneRepaintRAF = undefined;
|
|
10979
11288
|
}
|
|
10980
|
-
d3Selection.select(this.schema.scrollContainer).on(`scroll.${this._uuid}`, null);
|
|
11289
|
+
if (this.schema.scrollContainer) d3Selection.select(this.schema.scrollContainer).on(`scroll.${this._uuid}`, null);
|
|
10981
11290
|
// Destroy the active scene renderer (clears its own pointer-rect
|
|
10982
11291
|
// listeners, overlay host, canvas/svg DOM, timers).
|
|
10983
11292
|
if (this._sceneRenderer && typeof this._sceneRenderer.destroy === "function") {
|
|
@@ -11197,8 +11506,10 @@
|
|
|
11197
11506
|
data.sort((a, b)=>a[viz.schema.discrete] - b[viz.schema.discrete]);
|
|
11198
11507
|
}
|
|
11199
11508
|
const order = viz._stackOrder;
|
|
11509
|
+
// An explicit key array orders `stackKeys` directly (then d3-stack keeps
|
|
11510
|
+
// that order via `stackOrderNone`); every other order is a comparator that
|
|
11511
|
+
// reranks the series d3-stack builds, so `stackKeys` is left in input order.
|
|
11200
11512
|
if (Array.isArray(order)) stackKeys.sort((a, b)=>order.indexOf(a) - order.indexOf(b));
|
|
11201
|
-
else if (order === d3Shape__namespace.stackOrderNone) stackKeys.sort((a, b)=>`${a}`.localeCompare(`${b}`));
|
|
11202
11513
|
// d3-stack's generics don't model d3plus's dynamically-keyed rows; the
|
|
11203
11514
|
// order/offset/value accessors are cast (`as never`) at the boundary, and
|
|
11204
11515
|
// the configured stack is invoked as a `Row[][] -> number[][][]` function.
|
|
@@ -11387,11 +11698,28 @@
|
|
|
11387
11698
|
};
|
|
11388
11699
|
|
|
11389
11700
|
/** d3-scale's scale constructors, indexed by the dynamic `scale<Type>` name. */ const scaleConstructors = scales__namespace;
|
|
11701
|
+
/**
|
|
11702
|
+
A plotted axis value that can't be turned into a pixel coordinate: a
|
|
11703
|
+
non-finite number (`NaN`/`±Infinity`), `null`, or the empty-array sentinel
|
|
11704
|
+
`merge` yields when a numeric column aggregates to no usable value. Any of
|
|
11705
|
+
these poisons the shape's transform or path `d` downstream — e.g.
|
|
11706
|
+
`translate(NaN,…)` or `…L268.75,NaN` — which the browser rejects. A bare
|
|
11707
|
+
`undefined` is NOT bad: it's how an unused secondary axis (x2/y2) reports
|
|
11708
|
+
"no value on this row".
|
|
11709
|
+
*/ const isBadAxisValue = (v)=>v === null || typeof v === "number" && !Number.isFinite(v) || Array.isArray(v) && v.length === 0;
|
|
11710
|
+
/**
|
|
11711
|
+
A formatted row is plottable when its x/y — and any *defined* x2/y2 — are
|
|
11712
|
+
real coordinates. Rows failing this are dropped in `formatPlotData` before
|
|
11713
|
+
domains, stacking, and paint ever read `_formattedData`, so a NaN measure
|
|
11714
|
+
no longer widens a domain, stacks as 0, or emits a broken coordinate.
|
|
11715
|
+
Resolves d3plus/d3plus#776.
|
|
11716
|
+
*/ const isPlottableRow = (d)=>!isBadAxisValue(d.x) && !isBadAxisValue(d.y) && (d.x2 === undefined || !isBadAxisValue(d.x2)) && (d.y2 === undefined || !isBadAxisValue(d.y2));
|
|
11390
11717
|
/**
|
|
11391
11718
|
`formatPlotData` — first stage of Plot's chart-specific pipeline. Detects
|
|
11392
11719
|
time axes (sets viz._xTime / _x2Time / _yTime / _y2Time), maps the
|
|
11393
11720
|
filtered data through `prepData` to produce the per-row PlotDatum shape
|
|
11394
|
-
(x/y/x2/y2 + id + group + shape + lci/hci + discrete),
|
|
11721
|
+
(x/y/x2/y2 + id + group + shape + lci/hci + discrete), drops rows whose
|
|
11722
|
+
axis values can't be plotted (`isPlottableRow` — see #776), and constructs
|
|
11395
11723
|
the `_sizeScaleD3` if `_size` is set.
|
|
11396
11724
|
|
|
11397
11725
|
Pure compute. Returns `{formattedData, axisData, x2Exists, y2Exists}`
|
|
@@ -11432,8 +11760,8 @@
|
|
|
11432
11760
|
newD.id = newD.shape === "Bar" ? `${newD.id}_${newD[viz.schema.discrete]}` : newD.id;
|
|
11433
11761
|
return newD;
|
|
11434
11762
|
};
|
|
11435
|
-
const formattedData = viz._formattedData = viz._filteredData.map(prepData);
|
|
11436
|
-
const axisData = viz._axisPersist ? viz._data.map(prepData) : formattedData;
|
|
11763
|
+
const formattedData = viz._formattedData = viz._filteredData.map(prepData).filter(isPlottableRow);
|
|
11764
|
+
const axisData = viz._axisPersist ? viz._data.map(prepData).filter(isPlottableRow) : formattedData;
|
|
11437
11765
|
if (viz._size) {
|
|
11438
11766
|
const rExtent = d3Array.extent(axisData, (d)=>viz._size(d.data));
|
|
11439
11767
|
viz._sizeScaleD3 = scaleConstructors[`scale${viz.schema.sizeScale.charAt(0).toUpperCase()}${viz.schema.sizeScale.slice(1)}`]().domain(rExtent).range([
|
|
@@ -12740,6 +13068,13 @@
|
|
|
12740
13068
|
};
|
|
12741
13069
|
}
|
|
12742
13070
|
|
|
13071
|
+
/** Marks a comparator as an already-resolved d3plus stack order. */ function tagOrder(fn) {
|
|
13072
|
+
fn.__d3plusStackOrder = true;
|
|
13073
|
+
return fn;
|
|
13074
|
+
}
|
|
13075
|
+
// @types/d3-shape types the order accessors' param as a single `Series`,
|
|
13076
|
+
// though d3 passes the full stack array; this cast satisfies the signature.
|
|
13077
|
+
const asStack = (series)=>series;
|
|
12743
13078
|
/**
|
|
12744
13079
|
Sums a single stack series, ignoring non-numeric segments.
|
|
12745
13080
|
*/ function stackSum(series) {
|
|
@@ -12749,18 +13084,80 @@
|
|
|
12749
13084
|
return s;
|
|
12750
13085
|
}
|
|
12751
13086
|
/**
|
|
12752
|
-
Stack order:
|
|
12753
|
-
|
|
13087
|
+
Stack order: series with the smallest summed value on the bottom of the
|
|
13088
|
+
stack (matches d3's `stackOrderAscending`).
|
|
13089
|
+
*/ const stackOrderTotalAscending = tagOrder((series)=>d3Shape__namespace.stackOrderAscending(asStack(series)));
|
|
13090
|
+
/**
|
|
13091
|
+
Stack order: series with the largest summed value on the bottom of the
|
|
13092
|
+
stack (matches d3's `stackOrderDescending`). Plot's default.
|
|
13093
|
+
*/ const stackOrderTotalDescending = tagOrder((series)=>d3Shape__namespace.stackOrderDescending(asStack(series)));
|
|
13094
|
+
/**
|
|
13095
|
+
Stack order: ascending by series key (A→Z from the bottom), tie-broken by
|
|
13096
|
+
ascending summed value.
|
|
13097
|
+
*/ const stackOrderKey = tagOrder((series)=>{
|
|
12754
13098
|
const sums = series.map(stackSum);
|
|
12755
13099
|
const keys = series.map((d)=>d.key.split("_")[0]);
|
|
12756
|
-
|
|
12757
|
-
|
|
12758
|
-
|
|
13100
|
+
return d3Shape__namespace.stackOrderNone(asStack(series)).sort((a, b)=>keys[a].localeCompare(keys[b]) || sums[a] - sums[b]);
|
|
13101
|
+
});
|
|
13102
|
+
/**
|
|
13103
|
+
Stack order: the reverse of {@link stackOrderKey} (Z→A from the bottom).
|
|
13104
|
+
*/ const stackOrderKeyReverse = tagOrder((series)=>stackOrderKey(series).reverse());
|
|
13105
|
+
/**
|
|
13106
|
+
Builds a stack order that ranks each series by an aggregate (sum) of a
|
|
13107
|
+
data field, letting users order stacks by any value in their data rather
|
|
13108
|
+
than only the plotted one. `value` receives each series' original datum.
|
|
13109
|
+
*/ function stackOrderField(value, order = "descending") {
|
|
13110
|
+
return tagOrder((series)=>{
|
|
13111
|
+
const totals = series.map((s)=>{
|
|
13112
|
+
let total = 0;
|
|
13113
|
+
for(let i = 0; i < s.length; i++){
|
|
13114
|
+
// Each stacked point carries `.data` = the discrete group's rows;
|
|
13115
|
+
// pick the row for this series and read the field off its datum.
|
|
13116
|
+
const group = s[i].data || [];
|
|
13117
|
+
const row = group.find((g)=>g.id === s.key);
|
|
13118
|
+
if (row && row.data) {
|
|
13119
|
+
const v = +value(row.data);
|
|
13120
|
+
if (!isNaN(v)) total += v;
|
|
13121
|
+
}
|
|
13122
|
+
}
|
|
13123
|
+
return total;
|
|
13124
|
+
});
|
|
13125
|
+
return d3Shape__namespace.stackOrderNone(asStack(series)).sort((a, b)=>order === "ascending" ? totals[a] - totals[b] : totals[b] - totals[a]);
|
|
13126
|
+
});
|
|
12759
13127
|
}
|
|
13128
|
+
/** Named stack orders accepted by `Plot.stackOrder`. */ const NAMED_ORDERS = {
|
|
13129
|
+
ascending: stackOrderTotalAscending,
|
|
13130
|
+
descending: stackOrderTotalDescending,
|
|
13131
|
+
key: stackOrderKey,
|
|
13132
|
+
keyReverse: stackOrderKeyReverse,
|
|
13133
|
+
none: tagOrder((series)=>d3Shape__namespace.stackOrderNone(asStack(series))),
|
|
13134
|
+
data: tagOrder((series)=>d3Shape__namespace.stackOrderNone(asStack(series))),
|
|
13135
|
+
insideOut: tagOrder((series)=>d3Shape__namespace.stackOrderInsideOut(asStack(series))),
|
|
13136
|
+
appearance: tagOrder((series)=>d3Shape__namespace.stackOrderAppearance(asStack(series))),
|
|
13137
|
+
reverse: tagOrder((series)=>d3Shape__namespace.stackOrderReverse(asStack(series)))
|
|
13138
|
+
};
|
|
13139
|
+
/** The named orders accepted by `Plot.stackOrder`, for docs/validation. */ const stackOrderNames = Object.keys(NAMED_ORDERS);
|
|
12760
13140
|
/**
|
|
12761
|
-
|
|
12762
|
-
|
|
12763
|
-
|
|
13141
|
+
Normalizes any `stackOrder` input into a value Plot's pipeline can apply:
|
|
13142
|
+
a tagged comparator, or an explicit array of series keys. Warns and falls
|
|
13143
|
+
back to the default on an unrecognized name.
|
|
13144
|
+
*/ function resolveStackOrder(input) {
|
|
13145
|
+
if (typeof input === "function") {
|
|
13146
|
+
// Already-resolved order (constructor default / config() reset) passes
|
|
13147
|
+
// through; a bare user function is treated as a value accessor.
|
|
13148
|
+
return input.__d3plusStackOrder ? input : stackOrderField(input);
|
|
13149
|
+
}
|
|
13150
|
+
if (Array.isArray(input)) return input;
|
|
13151
|
+
if (input && typeof input === "object") {
|
|
13152
|
+
const { value, order } = input;
|
|
13153
|
+
return stackOrderField(typeof value === "function" ? value : accessor(value), order);
|
|
13154
|
+
}
|
|
13155
|
+
if (typeof input === "string") {
|
|
13156
|
+
if (input in NAMED_ORDERS) return NAMED_ORDERS[input];
|
|
13157
|
+
console.warn(`[d3plus] Unknown stackOrder "${input}". Expected one of: ${stackOrderNames.join(", ")}; an array of series keys; a value accessor; or a {value, order} config. Falling back to "descending".`);
|
|
13158
|
+
return stackOrderTotalDescending;
|
|
13159
|
+
}
|
|
13160
|
+
return stackOrderTotalDescending;
|
|
12764
13161
|
}
|
|
12765
13162
|
/**
|
|
12766
13163
|
Diverging stack offset: positive segments stack upward from zero,
|
|
@@ -12782,6 +13179,23 @@
|
|
|
12782
13179
|
}
|
|
12783
13180
|
}
|
|
12784
13181
|
}
|
|
13182
|
+
/** Named stack offsets accepted by `Plot.stackOffset`. */ const NAMED_OFFSETS = {
|
|
13183
|
+
diverging: stackOffsetDiverging,
|
|
13184
|
+
none: d3Shape__namespace.stackOffsetNone,
|
|
13185
|
+
expand: d3Shape__namespace.stackOffsetExpand,
|
|
13186
|
+
silhouette: d3Shape__namespace.stackOffsetSilhouette,
|
|
13187
|
+
wiggle: d3Shape__namespace.stackOffsetWiggle
|
|
13188
|
+
};
|
|
13189
|
+
/** The named offsets accepted by `Plot.stackOffset`, for docs/validation. */ const stackOffsetNames = Object.keys(NAMED_OFFSETS);
|
|
13190
|
+
/**
|
|
13191
|
+
Normalizes a `stackOffset` input into an offset function. Warns and falls
|
|
13192
|
+
back to the diverging default on an unrecognized name.
|
|
13193
|
+
*/ function resolveStackOffset(input) {
|
|
13194
|
+
if (typeof input === "function") return input;
|
|
13195
|
+
if (typeof input === "string" && input in NAMED_OFFSETS) return NAMED_OFFSETS[input];
|
|
13196
|
+
console.warn(`[d3plus] Unknown stackOffset "${input}". Expected one of: ${stackOffsetNames.join(", ")}; or an offset function. Falling back to "diverging".`);
|
|
13197
|
+
return stackOffsetDiverging;
|
|
13198
|
+
}
|
|
12785
13199
|
|
|
12786
13200
|
/**
|
|
12787
13201
|
Clone the base shape config and, for stacked Area/Bar, inject the
|
|
@@ -12893,7 +13307,9 @@
|
|
|
12893
13307
|
areaConfig[`${key}0`] = (d)=>scaleFunction(confidence[0] ? d.lci : d[key]);
|
|
12894
13308
|
areaConfig[`${key}1`] = (d)=>scaleFunction(confidence[1] ? d.hci : d[key]);
|
|
12895
13309
|
const area = makeShape("Area").renderMode("compute").config(areaConfig).data(values);
|
|
12896
|
-
|
|
13310
|
+
// Fresh object — must NOT mutate the shared `shapeConfig`, or the confidence
|
|
13311
|
+
// fill/fillOpacity leak onto every other shape and every later render.
|
|
13312
|
+
const confidenceConfig = Object.assign({}, viz.schema.shapeConfig, viz._confidenceConfig);
|
|
12897
13313
|
area.config(dom.assign(shapeConfigFor(viz, "Line", confidenceConfig), shapeConfigFor(viz, "Area", confidenceConfig))).render();
|
|
12898
13314
|
out.push(...collectComputed(area));
|
|
12899
13315
|
}
|
|
@@ -13521,6 +13937,7 @@
|
|
|
13521
13937
|
];
|
|
13522
13938
|
}
|
|
13523
13939
|
|
|
13940
|
+
/* eslint no-cond-assign: 0*/ // @ts-ignore
|
|
13524
13941
|
const { theme: openColor } = pkg;
|
|
13525
13942
|
// E4: Plot's identity-coerce accessor schema (18 keys). installFluent's
|
|
13526
13943
|
// per-key idempotence lets this co-exist with vizSchema on the parent
|
|
@@ -13701,6 +14118,53 @@
|
|
|
13701
14118
|
for (const evt of shapeEvents)shape.on(evt, forward(evt));
|
|
13702
14119
|
for (const evt of classEvents)shape.on(evt, forward(evt));
|
|
13703
14120
|
}
|
|
14121
|
+
/**
|
|
14122
|
+
For a multi-point shape (Line/Area) reports the point nearest the cursor
|
|
14123
|
+
along the discrete axis, so every mouse event (tooltip, click, user
|
|
14124
|
+
handlers) reflects the hovered x rather than the whole-series aggregate.
|
|
14125
|
+
Non-nested shapes and legend swatches fall through to the base (aggregate)
|
|
14126
|
+
behavior.
|
|
14127
|
+
@private
|
|
14128
|
+
*/ _interactionDatum(pick, event) {
|
|
14129
|
+
const node = pick.node;
|
|
14130
|
+
const points = node && node.interactionPoints;
|
|
14131
|
+
if (node && node.interactionGroup !== "legend" && Array.isArray(points) && points.length && event && Array.isArray(event.point)) {
|
|
14132
|
+
const nearest = this._nearestInteractionPoint(points, event.point);
|
|
14133
|
+
if (nearest) {
|
|
14134
|
+
const wrapped = nearest.datum;
|
|
14135
|
+
return {
|
|
14136
|
+
d: wrapped && wrapped.data ? wrapped.data : wrapped,
|
|
14137
|
+
i: typeof wrapped.i === "number" ? wrapped.i : nearest.index,
|
|
14138
|
+
x: wrapped
|
|
14139
|
+
};
|
|
14140
|
+
}
|
|
14141
|
+
}
|
|
14142
|
+
return super._interactionDatum(pick, event);
|
|
14143
|
+
}
|
|
14144
|
+
/**
|
|
14145
|
+
Picks the interaction point closest to a surface-local cursor position
|
|
14146
|
+
along the discrete axis. `event.point` is post-zoom surface space while the
|
|
14147
|
+
points are in pre-zoom content space (they live under the `viz-zoom`
|
|
14148
|
+
group), so the cursor is un-zoomed by `_zoomTransform` before comparing.
|
|
14149
|
+
@private
|
|
14150
|
+
*/ _nearestInteractionPoint(points, point) {
|
|
14151
|
+
const t = this._zoomTransform;
|
|
14152
|
+
const scale = t && t.scale ? t.scale : 1;
|
|
14153
|
+
const cx = (point[0] - (t ? t.x : 0)) / scale;
|
|
14154
|
+
const cy = (point[1] - (t ? t.y : 0)) / scale;
|
|
14155
|
+
const axis = this.schema.discrete === "y" ? "y" : "x";
|
|
14156
|
+
const target = axis === "y" ? cy : cx;
|
|
14157
|
+
let best = null;
|
|
14158
|
+
let bestDist = Infinity;
|
|
14159
|
+
for (const p of points){
|
|
14160
|
+
const dist = Math.abs(p[axis] - target);
|
|
14161
|
+
if (dist < bestDist) {
|
|
14162
|
+
bestDist = dist;
|
|
14163
|
+
best = p;
|
|
14164
|
+
}
|
|
14165
|
+
}
|
|
14166
|
+
return best;
|
|
14167
|
+
}
|
|
13704
14168
|
/**
|
|
13705
14169
|
Extends the draw behavior of the abstract Viz class.
|
|
13706
14170
|
@private
|
|
@@ -13819,18 +14283,29 @@
|
|
|
13819
14283
|
return arguments.length ? (this._size = typeof _ === "function" || !_ ? _ : accessor(_), this) : this._size;
|
|
13820
14284
|
}
|
|
13821
14285
|
/**
|
|
13822
|
-
Sets the
|
|
14286
|
+
Sets the vertical offset applied to stacked series. Accepts a named
|
|
14287
|
+
offset — `"diverging"` (default), `"none"`, `"expand"`, `"silhouette"`,
|
|
14288
|
+
or `"wiggle"` — or a custom offset function. Unknown names warn and fall
|
|
14289
|
+
back to `"diverging"`. If *value* is not specified, returns the current
|
|
14290
|
+
stack offset function.
|
|
13823
14291
|
*/ stackOffset(_) {
|
|
13824
|
-
return arguments.length ? (this._stackOffset =
|
|
14292
|
+
return arguments.length ? (this._stackOffset = resolveStackOffset(_), this) : this._stackOffset;
|
|
13825
14293
|
}
|
|
13826
14294
|
/**
|
|
13827
|
-
Sets the
|
|
14295
|
+
Sets the order of stacked series, from the bottom of the stack upward.
|
|
14296
|
+
Accepts:
|
|
14297
|
+
- a named order: `"descending"` (default) / `"ascending"` by summed
|
|
14298
|
+
value, `"key"` / `"keyReverse"` alphabetically by series key,
|
|
14299
|
+
`"none"` / `"data"` for input order, or d3's `"insideOut"`,
|
|
14300
|
+
`"appearance"`, `"reverse"`;
|
|
14301
|
+
- an Array of series keys for an explicit order;
|
|
14302
|
+
- a value accessor, or a `{value, order}` config, to rank series by an
|
|
14303
|
+
aggregate of any data field.
|
|
14304
|
+
|
|
14305
|
+
Unknown named strings warn and fall back to `"descending"`. If *value*
|
|
14306
|
+
is not specified, returns the current stack order.
|
|
13828
14307
|
*/ stackOrder(_) {
|
|
13829
|
-
|
|
13830
|
-
if (typeof _ === "string") this._stackOrder = _ === "ascending" ? stackOrderAscending : _ === "descending" ? stackOrderDescending : d3Shape__namespace[`stackOrder${_.charAt(0).toUpperCase() + _.slice(1)}`];
|
|
13831
|
-
else this._stackOrder = _;
|
|
13832
|
-
return this;
|
|
13833
|
-
} else return this._stackOrder;
|
|
14308
|
+
return arguments.length ? (this._stackOrder = resolveStackOrder(_), this) : this._stackOrder;
|
|
13834
14309
|
}
|
|
13835
14310
|
/**
|
|
13836
14311
|
Accessor function or string key for the x-axis value of each data point.
|
|
@@ -13937,9 +14412,14 @@
|
|
|
13937
14412
|
Line: false
|
|
13938
14413
|
});
|
|
13939
14414
|
this._confidenceConfig = {
|
|
14415
|
+
// A line's colour is its stroke, so the confidence band fills with that
|
|
14416
|
+
// same colour (at the reduced opacity below). Prefer a per-Line stroke
|
|
14417
|
+
// override, else the shared stroke accessor (the Line config itself sets
|
|
14418
|
+
// no `stroke` — the colour comes from the top-level `shapeConfig.stroke`).
|
|
13940
14419
|
fill: (d, i)=>{
|
|
13941
|
-
const
|
|
13942
|
-
|
|
14420
|
+
const { Line, stroke } = this.schema.shapeConfig;
|
|
14421
|
+
const s = Line && Line.stroke !== undefined ? Line.stroke : stroke;
|
|
14422
|
+
return typeof s === "function" ? s(d, i) : s;
|
|
13943
14423
|
},
|
|
13944
14424
|
fillOpacity: constant(0.5)
|
|
13945
14425
|
};
|
|
@@ -13975,7 +14455,7 @@
|
|
|
13975
14455
|
this.schema.sizeMin = 5;
|
|
13976
14456
|
this.schema.sizeScale = "sqrt";
|
|
13977
14457
|
this._stackOffset = stackOffsetDiverging;
|
|
13978
|
-
this._stackOrder =
|
|
14458
|
+
this._stackOrder = stackOrderTotalDescending;
|
|
13979
14459
|
this.schema.timelineConfig = dom.assign(this.schema.timelineConfig, {
|
|
13980
14460
|
brushMin: ()=>this._xTime || this._yTime || this._x2Time || this._y2Time ? 2 : 1
|
|
13981
14461
|
});
|
|
@@ -14051,7 +14531,8 @@
|
|
|
14051
14531
|
},
|
|
14052
14532
|
{
|
|
14053
14533
|
key: "shape",
|
|
14054
|
-
default: constant("Area")
|
|
14534
|
+
default: constant("Area"),
|
|
14535
|
+
coerce: "const"
|
|
14055
14536
|
}
|
|
14056
14537
|
]
|
|
14057
14538
|
};
|
|
@@ -14080,10 +14561,12 @@
|
|
|
14080
14561
|
},
|
|
14081
14562
|
{
|
|
14082
14563
|
key: "shape",
|
|
14083
|
-
default: constant("Bar")
|
|
14564
|
+
default: constant("Bar"),
|
|
14565
|
+
coerce: "const"
|
|
14084
14566
|
},
|
|
14085
14567
|
{
|
|
14086
14568
|
key: "legend",
|
|
14569
|
+
coerce: "const",
|
|
14087
14570
|
factory: (viz)=>{
|
|
14088
14571
|
const base = viz.schema.legend;
|
|
14089
14572
|
return (config, arr)=>{
|
|
@@ -14117,7 +14600,8 @@
|
|
|
14117
14600
|
},
|
|
14118
14601
|
{
|
|
14119
14602
|
key: "shape",
|
|
14120
|
-
default: constant("Box")
|
|
14603
|
+
default: constant("Box"),
|
|
14604
|
+
coerce: "const"
|
|
14121
14605
|
},
|
|
14122
14606
|
{
|
|
14123
14607
|
key: "tooltipConfig",
|
|
@@ -14183,7 +14667,8 @@
|
|
|
14183
14667
|
},
|
|
14184
14668
|
{
|
|
14185
14669
|
key: "shape",
|
|
14186
|
-
default: constant("Line")
|
|
14670
|
+
default: constant("Line"),
|
|
14671
|
+
coerce: "const"
|
|
14187
14672
|
}
|
|
14188
14673
|
]
|
|
14189
14674
|
};
|
|
@@ -14418,6 +14903,7 @@
|
|
|
14418
14903
|
},
|
|
14419
14904
|
{
|
|
14420
14905
|
key: "legend",
|
|
14906
|
+
coerce: "const",
|
|
14421
14907
|
factory: (viz)=>{
|
|
14422
14908
|
const base = viz.schema.legend;
|
|
14423
14909
|
return (config, arr)=>{
|
|
@@ -14738,10 +15224,12 @@
|
|
|
14738
15224
|
const c = viz.ctx.geomapCtx;
|
|
14739
15225
|
if (!c) return [];
|
|
14740
15226
|
const out = [];
|
|
14741
|
-
//
|
|
14742
|
-
// (
|
|
14743
|
-
//
|
|
14744
|
-
|
|
15227
|
+
// The ocean rect and basemap tiles normally live in the imperative geomap
|
|
15228
|
+
// <svg> (`_container`), outside the scene graph. That's fine on-screen, but a
|
|
15229
|
+
// server render serializes only the scene, so under SSR (`viz._ssr`) — and on
|
|
15230
|
+
// the canvas backend, whose compute <svg> keeps its ocean transparent — paint
|
|
15231
|
+
// them into the scene here, beneath the geography, so the output is complete.
|
|
15232
|
+
if (viz._renderer === "canvas" || viz._ssr) {
|
|
14745
15233
|
const ocean = viz.schema.ocean;
|
|
14746
15234
|
if (ocean && ocean !== "transparent") {
|
|
14747
15235
|
const { width, height } = chartBounds(viz);
|
|
@@ -14758,6 +15246,27 @@
|
|
|
14758
15246
|
});
|
|
14759
15247
|
}
|
|
14760
15248
|
}
|
|
15249
|
+
// Basemap tiles, pre-fetched + inlined as data URIs by @d3plus/ssr. Placed
|
|
15250
|
+
// above the ocean and below the geography, at the positions `_computeTileList`
|
|
15251
|
+
// derives from the fitted projection (same math as the live `_renderTiles`).
|
|
15252
|
+
const ssrTiles = viz._ssrTiles;
|
|
15253
|
+
if (ssrTiles && ssrTiles.size && typeof viz._computeTileList === "function") {
|
|
15254
|
+
for (const t of viz._computeTileList()){
|
|
15255
|
+
const href = ssrTiles.get(t.key);
|
|
15256
|
+
if (!href) continue;
|
|
15257
|
+
out.push({
|
|
15258
|
+
type: "image",
|
|
15259
|
+
key: `geomap-tile-${t.key}`,
|
|
15260
|
+
x: t.x,
|
|
15261
|
+
y: t.y,
|
|
15262
|
+
width: t.size,
|
|
15263
|
+
height: t.size,
|
|
15264
|
+
href,
|
|
15265
|
+
preserveAspectRatio: "none",
|
|
15266
|
+
interactive: false
|
|
15267
|
+
});
|
|
15268
|
+
}
|
|
15269
|
+
}
|
|
14761
15270
|
if (c.topoData && c.topoData.length) {
|
|
14762
15271
|
const pathConfig = shapeConfigFor(viz, "Path");
|
|
14763
15272
|
for(let i = 0; i < c.topoData.length; i++){
|
|
@@ -14830,6 +15339,11 @@
|
|
|
14830
15339
|
/** Installs `_renderTiles`, the per-instance method that mutates the tile group. */ function setupGeomapRenderTiles(viz) {
|
|
14831
15340
|
// `_renderTiles` is a per-instance method that mutates the tile group.
|
|
14832
15341
|
viz._renderTiles = function(transform = d3Zoom.zoomTransform((this._zoomEventTarget || this._container).node()), duration = 0) {
|
|
15342
|
+
// Under SSR the basemap is composited into the scene graph (see geomapEmit +
|
|
15343
|
+
// `_computeTileList`), so skip the imperative <image> tile layer entirely.
|
|
15344
|
+
// It wouldn't be serialized anyway, and its transform transition relies on
|
|
15345
|
+
// SVGGElement.transform.baseVal, which headless DOMs don't implement.
|
|
15346
|
+
if (this._ssr) return;
|
|
14833
15347
|
let tileData = [];
|
|
14834
15348
|
if (this.schema.tiles) {
|
|
14835
15349
|
tileData = this._tileGen.extent(this._zoomBehavior.translateExtent()).scale(this.schema.projection.scale() * (2 * Math.PI) * transform.k).translate(transform.apply(this.schema.projection.translate()))();
|
|
@@ -14846,6 +15360,23 @@
|
|
|
14846
15360
|
"c"
|
|
14847
15361
|
][Math.random() * 3 | 0]).replace("{z}", `${z}`).replace("{x}", `${x}`).replace("{y}", `${y}`)).attr("x", ([x])=>x * scale + tileData.translate[0] * scale - transform.x / transform.k).attr("y", ([, y])=>y * scale + tileData.translate[1] * scale - transform.y / transform.k);
|
|
14848
15362
|
};
|
|
15363
|
+
// Static (identity-transform) tile list for server-side rendering: the tile
|
|
15364
|
+
// URLs + their positions in projection pixel space, so @d3plus/ssr can fetch
|
|
15365
|
+
// them and geomapEmit can place them as scene image nodes (both SVG string and
|
|
15366
|
+
// canvas output then include the basemap, with no network at view time).
|
|
15367
|
+
// Deterministic `{s}` = "a" so tiles are cacheable across renders.
|
|
15368
|
+
viz._computeTileList = function() {
|
|
15369
|
+
if (!this.schema.tiles) return [];
|
|
15370
|
+
const tileData = this._tileGen.extent(this._zoomBehavior.translateExtent()).scale(this.schema.projection.scale() * (2 * Math.PI)).translate(this.schema.projection.translate())();
|
|
15371
|
+
const size = tileData.scale;
|
|
15372
|
+
return tileData.map(([x, y, z])=>({
|
|
15373
|
+
key: `${x}-${y}-${z}`,
|
|
15374
|
+
url: this.schema.tileUrl.replace("{s}", "a").replace("{z}", `${z}`).replace("{x}", `${x}`).replace("{y}", `${y}`),
|
|
15375
|
+
x: x * size + tileData.translate[0] * size,
|
|
15376
|
+
y: y * size + tileData.translate[1] * size,
|
|
15377
|
+
size
|
|
15378
|
+
}));
|
|
15379
|
+
};
|
|
14849
15380
|
}
|
|
14850
15381
|
/** Wraps `_draw` to ensure the DOM zoom group + zoom wiring exist before drawing. */ function setupGeomapDraw(viz) {
|
|
14851
15382
|
// Wrap _draw to ensure DOM zoom group + zoom wiring.
|
|
@@ -14917,7 +15448,10 @@
|
|
|
14917
15448
|
const supDrawScene = viz._drawSceneToTarget.bind(viz);
|
|
14918
15449
|
viz._drawSceneToTarget = function(durationOverride) {
|
|
14919
15450
|
supDrawScene(durationOverride);
|
|
14920
|
-
if (viz._renderer === "canvas" &&
|
|
15451
|
+
if (viz._renderer === "canvas" && // Under SSR the canvas is a headless native surface with no
|
|
15452
|
+
// addEventListener; there is no interaction to wire, so skip the
|
|
15453
|
+
// pointer/zoom rebind entirely.
|
|
15454
|
+
!viz._ssr && viz._sceneRenderer && typeof viz._sceneRenderer.toCanvas === "function") {
|
|
14921
15455
|
const canvasNode = viz._sceneRenderer.toCanvas();
|
|
14922
15456
|
if (canvasNode) {
|
|
14923
15457
|
// The compute svg is absolutely positioned over the canvas; an svg root
|
|
@@ -15145,7 +15679,8 @@
|
|
|
15145
15679
|
},
|
|
15146
15680
|
{
|
|
15147
15681
|
key: "shape",
|
|
15148
|
-
default: constant("Circle")
|
|
15682
|
+
default: constant("Circle"),
|
|
15683
|
+
coerce: "const"
|
|
15149
15684
|
},
|
|
15150
15685
|
{
|
|
15151
15686
|
key: "topojson",
|
|
@@ -15243,7 +15778,8 @@
|
|
|
15243
15778
|
},
|
|
15244
15779
|
{
|
|
15245
15780
|
key: "shape",
|
|
15246
|
-
default: constant("Line")
|
|
15781
|
+
default: constant("Line"),
|
|
15782
|
+
coerce: "const"
|
|
15247
15783
|
}
|
|
15248
15784
|
]
|
|
15249
15785
|
};
|
|
@@ -15507,6 +16043,7 @@
|
|
|
15507
16043
|
},
|
|
15508
16044
|
{
|
|
15509
16045
|
key: "label",
|
|
16046
|
+
coerce: "const",
|
|
15510
16047
|
factory: (viz)=>(d, i)=>`${getProp.bind(viz)("row", d, i)} / ${getProp.bind(viz)("column", d, i)}`
|
|
15511
16048
|
}
|
|
15512
16049
|
]
|
|
@@ -16212,7 +16749,8 @@
|
|
|
16212
16749
|
},
|
|
16213
16750
|
{
|
|
16214
16751
|
key: "shape",
|
|
16215
|
-
default: constant("Circle")
|
|
16752
|
+
default: constant("Circle"),
|
|
16753
|
+
coerce: "const"
|
|
16216
16754
|
},
|
|
16217
16755
|
{
|
|
16218
16756
|
key: "shapeConfig",
|
|
@@ -16445,6 +16983,7 @@
|
|
|
16445
16983
|
},
|
|
16446
16984
|
{
|
|
16447
16985
|
key: "legend",
|
|
16986
|
+
coerce: "const",
|
|
16448
16987
|
factory: (viz)=>{
|
|
16449
16988
|
const base = viz.schema.legend;
|
|
16450
16989
|
return (config, arr)=>{
|
|
@@ -17004,7 +17543,8 @@
|
|
|
17004
17543
|
},
|
|
17005
17544
|
{
|
|
17006
17545
|
key: "shape",
|
|
17007
|
-
default: constant("Path")
|
|
17546
|
+
default: constant("Path"),
|
|
17547
|
+
coerce: "const"
|
|
17008
17548
|
},
|
|
17009
17549
|
{
|
|
17010
17550
|
key: "value",
|
|
@@ -17248,6 +17788,7 @@
|
|
|
17248
17788
|
},
|
|
17249
17789
|
{
|
|
17250
17790
|
key: "label",
|
|
17791
|
+
coerce: "const",
|
|
17251
17792
|
factory: (viz)=>(d, i)=>`${getProp.bind(viz)("row", d, i)} / ${getProp.bind(viz)("column", d, i)}`
|
|
17252
17793
|
}
|
|
17253
17794
|
]
|
|
@@ -17966,7 +18507,8 @@
|
|
|
17966
18507
|
},
|
|
17967
18508
|
{
|
|
17968
18509
|
key: "shape",
|
|
17969
|
-
default: constant("Circle")
|
|
18510
|
+
default: constant("Circle"),
|
|
18511
|
+
coerce: "const"
|
|
17970
18512
|
},
|
|
17971
18513
|
{
|
|
17972
18514
|
key: "shapeConfig",
|
|
@@ -18288,7 +18830,8 @@
|
|
|
18288
18830
|
},
|
|
18289
18831
|
{
|
|
18290
18832
|
key: "shape",
|
|
18291
|
-
default: constant("Rect")
|
|
18833
|
+
default: constant("Rect"),
|
|
18834
|
+
coerce: "const"
|
|
18292
18835
|
},
|
|
18293
18836
|
{
|
|
18294
18837
|
key: "shapeConfig",
|
|
@@ -18672,7 +19215,8 @@
|
|
|
18672
19215
|
},
|
|
18673
19216
|
{
|
|
18674
19217
|
key: "shape",
|
|
18675
|
-
default: constant("Circle")
|
|
19218
|
+
default: constant("Circle"),
|
|
19219
|
+
coerce: "const"
|
|
18676
19220
|
},
|
|
18677
19221
|
{
|
|
18678
19222
|
key: "shapeConfig",
|
|
@@ -19046,6 +19590,7 @@
|
|
|
19046
19590
|
},
|
|
19047
19591
|
{
|
|
19048
19592
|
key: "legend",
|
|
19593
|
+
coerce: "const",
|
|
19049
19594
|
factory: (viz)=>{
|
|
19050
19595
|
const base = viz.schema.legend;
|
|
19051
19596
|
return (config, arr)=>{
|