@d3plus/core 4.0.0 → 4.2.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 +947 -921
- 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/index.js +2 -1
- 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 +22 -12
- package/es/src/charts/Plot/index.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/events/click.legend.js +1 -1
- package/es/src/charts/events/click.legend.js.map +1 -1
- package/es/src/charts/events/mousemove.legend.js +1 -1
- package/es/src/charts/events/mousemove.legend.js.map +1 -1
- package/es/src/charts/features/features.js +3 -3
- package/es/src/charts/features/features.js.map +1 -1
- package/es/src/charts/features/featuresLegend.js +1 -1
- package/es/src/charts/features/featuresLegend.js.map +1 -1
- package/es/src/charts/viz/VizBase.js.map +1 -1
- package/es/src/charts/viz/VizBaseConfig.js.map +1 -1
- package/es/src/components/TextBox.js +21 -5
- package/es/src/components/TextBox.js.map +1 -1
- package/es/src/shapes/Circle.js +12 -4
- package/es/src/shapes/Circle.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 +35 -36
- package/es/src/shapes/Shape.js.map +1 -1
- package/es/src/shapes/buildLabelData.js +59 -4
- package/es/src/shapes/buildLabelData.js.map +1 -1
- 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 +10 -10
- package/types/src/charts/Plot/index.d.ts +22 -6
- package/types/src/charts/Plot/stackHelpers.d.ts +62 -4
- package/types/src/charts/viz/VizBase.d.ts +4 -4
- package/types/src/charts/viz/VizBaseConfig.d.ts +4 -3
- package/types/src/shapes/Image.d.ts +2 -3
- package/types/src/shapes/Shape.d.ts +0 -2
- 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 +59 -14
- package/umd/d3plus-core.full.js +1911 -640
- package/umd/d3plus-core.full.js.map +1 -1
- package/umd/d3plus-core.full.min.js +1192 -942
- package/umd/d3plus-core.js +585 -239
- package/umd/d3plus-core.js.map +1 -1
- package/umd/d3plus-core.min.js +495 -367
package/umd/d3plus-core.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
/*
|
|
2
|
-
@d3plus/core v4.
|
|
2
|
+
@d3plus/core v4.2.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);
|
|
@@ -405,7 +405,7 @@
|
|
|
405
405
|
"top",
|
|
406
406
|
"bottom"
|
|
407
407
|
].includes(position);
|
|
408
|
-
const padding = viz.schema.legendPadding() ? viz._padding : {
|
|
408
|
+
const padding = viz.schema.legendPadding(viz) ? viz._padding : {
|
|
409
409
|
top: 0,
|
|
410
410
|
right: 0,
|
|
411
411
|
bottom: 0,
|
|
@@ -575,7 +575,7 @@
|
|
|
575
575
|
panel: null,
|
|
576
576
|
margin: {}
|
|
577
577
|
};
|
|
578
|
-
const usesPadding = viz.schema[opts.paddingMethod]();
|
|
578
|
+
const usesPadding = viz.schema[opts.paddingMethod](viz);
|
|
579
579
|
const padding = usesPadding ? viz._padding : {
|
|
580
580
|
right: 0,
|
|
581
581
|
left: 0
|
|
@@ -771,7 +771,7 @@
|
|
|
771
771
|
let timelinePossible = viz.schema.time && viz.schema.timeline;
|
|
772
772
|
const ticks = timelinePossible ? data.unique(viz._data.map(viz.schema.time)).map((d)=>dom.date(d)) : [];
|
|
773
773
|
timelinePossible = timelinePossible && ticks.length > 1;
|
|
774
|
-
const padding = viz.schema.timelinePadding() ? viz._padding : {
|
|
774
|
+
const padding = viz.schema.timelinePadding(viz) ? viz._padding : {
|
|
775
775
|
right: 0,
|
|
776
776
|
left: 0
|
|
777
777
|
};
|
|
@@ -854,7 +854,7 @@
|
|
|
854
854
|
"bottom"
|
|
855
855
|
].includes(position);
|
|
856
856
|
const showColorScale = viz.schema.colorScale && position;
|
|
857
|
-
const padding = viz.schema.colorScalePadding() ? viz._padding : {
|
|
857
|
+
const padding = viz.schema.colorScalePadding(viz) ? viz._padding : {
|
|
858
858
|
top: 0,
|
|
859
859
|
right: 0,
|
|
860
860
|
bottom: 0,
|
|
@@ -2763,6 +2763,14 @@
|
|
|
2763
2763
|
id: `${id(d, i)}_${l}`,
|
|
2764
2764
|
r,
|
|
2765
2765
|
rotateAnchor,
|
|
2766
|
+
// Wrapping shape rides on the bounds so it stays paired with them:
|
|
2767
|
+
// a shape whose `labelBounds` returns `shape: "circle"` wraps to the
|
|
2768
|
+
// circle, while a chart that supplies its own rectangular bounds
|
|
2769
|
+
// (no `shape`) wraps normally. Stamped under a namespaced key so it
|
|
2770
|
+
// can't collide with a `shape` field a caller's own data might carry.
|
|
2771
|
+
...b.shape ? {
|
|
2772
|
+
__d3plusWrapShape__: b.shape
|
|
2773
|
+
} : {},
|
|
2766
2774
|
text: labels[l],
|
|
2767
2775
|
width: b.width,
|
|
2768
2776
|
x: xPos + b.x,
|
|
@@ -2810,153 +2818,6 @@
|
|
|
2810
2818
|
};
|
|
2811
2819
|
}
|
|
2812
2820
|
|
|
2813
|
-
/** Image's fluent accessor schema. Config storage lives on `this.schema.<key>`. */ const imageSchema = [
|
|
2814
|
-
{
|
|
2815
|
-
key: "duration",
|
|
2816
|
-
coerce: "identity",
|
|
2817
|
-
default: 600
|
|
2818
|
-
},
|
|
2819
|
-
{
|
|
2820
|
-
key: "height",
|
|
2821
|
-
coerce: "accessor",
|
|
2822
|
-
default: accessor("height")
|
|
2823
|
-
},
|
|
2824
|
-
{
|
|
2825
|
-
key: "id",
|
|
2826
|
-
coerce: "identity",
|
|
2827
|
-
default: accessor("id")
|
|
2828
|
-
},
|
|
2829
|
-
{
|
|
2830
|
-
key: "opacity",
|
|
2831
|
-
coerce: "const",
|
|
2832
|
-
default: constant(1)
|
|
2833
|
-
},
|
|
2834
|
-
{
|
|
2835
|
-
key: "pointerEvents",
|
|
2836
|
-
coerce: "const",
|
|
2837
|
-
default: constant("auto")
|
|
2838
|
-
},
|
|
2839
|
-
{
|
|
2840
|
-
key: "renderMode",
|
|
2841
|
-
coerce: "identity",
|
|
2842
|
-
default: "full"
|
|
2843
|
-
},
|
|
2844
|
-
{
|
|
2845
|
-
key: "url",
|
|
2846
|
-
coerce: "identity",
|
|
2847
|
-
default: accessor("url")
|
|
2848
|
-
},
|
|
2849
|
-
{
|
|
2850
|
-
key: "width",
|
|
2851
|
-
coerce: "accessor",
|
|
2852
|
-
default: accessor("width")
|
|
2853
|
-
},
|
|
2854
|
-
{
|
|
2855
|
-
key: "x",
|
|
2856
|
-
coerce: "const",
|
|
2857
|
-
default: accessor("x", 0)
|
|
2858
|
-
},
|
|
2859
|
-
{
|
|
2860
|
-
key: "y",
|
|
2861
|
-
coerce: "const",
|
|
2862
|
-
default: accessor("y", 0)
|
|
2863
|
-
}
|
|
2864
|
-
];
|
|
2865
|
-
class Image {
|
|
2866
|
-
config(_) {
|
|
2867
|
-
if (!arguments.length) return {
|
|
2868
|
-
...this.schema,
|
|
2869
|
-
data: this._data,
|
|
2870
|
-
select: this._select
|
|
2871
|
-
};
|
|
2872
|
-
const patch = _;
|
|
2873
|
-
for(const k in patch){
|
|
2874
|
-
if (!Object.prototype.hasOwnProperty.call(patch, k)) continue;
|
|
2875
|
-
// `this[k]` resolves the fluent accessor via the index signature.
|
|
2876
|
-
if (typeof this[k] === "function") this[k](patch[k]);
|
|
2877
|
-
else this.schema[k] = patch[k];
|
|
2878
|
-
}
|
|
2879
|
-
return this;
|
|
2880
|
-
}
|
|
2881
|
-
/**
|
|
2882
|
-
Renders the current Image to the page. If a *callback* is specified, it will be called once the images are done drawing.
|
|
2883
|
-
@param callback Optional callback invoked after rendering completes.
|
|
2884
|
-
*/ render(callback) {
|
|
2885
|
-
// Compute mode is a no-op for DOM emission — the caller will read
|
|
2886
|
-
// `toScene()` to get a SceneNode tree, no need to mount.
|
|
2887
|
-
if (this.schema.renderMode === "compute") {
|
|
2888
|
-
if (callback) setTimeout(callback, 0);
|
|
2889
|
-
return this;
|
|
2890
|
-
}
|
|
2891
|
-
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());
|
|
2892
|
-
const images = this._select.selectAll(".d3plus-Image").data(this._data, this.schema.id);
|
|
2893
|
-
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);
|
|
2894
|
-
const t = d3Transition.transition().duration(this.schema.duration), that = this, update = enter.merge(images);
|
|
2895
|
-
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) {
|
|
2896
|
-
const image = d3Selection.select(this), link = that.schema.url(d, i);
|
|
2897
|
-
const fullAddress = link.indexOf("http://") === 0 || link.indexOf("https://") === 0;
|
|
2898
|
-
if (!fullAddress || link.indexOf(window.location.hostname) === 0) {
|
|
2899
|
-
const img = new window.Image();
|
|
2900
|
-
img.src = link;
|
|
2901
|
-
img.crossOrigin = "Anonymous";
|
|
2902
|
-
img.onload = function() {
|
|
2903
|
-
const canvas = document.createElement("canvas");
|
|
2904
|
-
canvas.width = img.width;
|
|
2905
|
-
canvas.height = img.height;
|
|
2906
|
-
const context = canvas.getContext("2d");
|
|
2907
|
-
context.drawImage(img, 0, 0);
|
|
2908
|
-
image.attr("xlink:href", canvas.toDataURL("image/png"));
|
|
2909
|
-
};
|
|
2910
|
-
}
|
|
2911
|
-
});
|
|
2912
|
-
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();
|
|
2913
|
-
if (callback) setTimeout(callback, this.schema.duration + 100);
|
|
2914
|
-
return this;
|
|
2915
|
-
}
|
|
2916
|
-
data(_) {
|
|
2917
|
-
return arguments.length ? (this._data = _, this) : this._data;
|
|
2918
|
-
}
|
|
2919
|
-
/**
|
|
2920
|
-
Compute-mode scene emission. Mirrors Shape.toScene's shape — a
|
|
2921
|
-
keyed GroupNode wrapping per-datum ImageNodes. Used by chart
|
|
2922
|
-
compositors (Shape._backgroundImageClass, plotPaint) that need
|
|
2923
|
-
Image to participate in the scene graph rather than emit
|
|
2924
|
-
d3-selection DOM.
|
|
2925
|
-
*/ toScene() {
|
|
2926
|
-
const children = (this._data || []).map((d, i)=>{
|
|
2927
|
-
const node = {
|
|
2928
|
-
type: "image",
|
|
2929
|
-
key: `${this.schema.id(d, i)}`,
|
|
2930
|
-
x: this.schema.x(d, i),
|
|
2931
|
-
y: this.schema.y(d, i),
|
|
2932
|
-
width: this.schema.width(d, i),
|
|
2933
|
-
height: this.schema.height(d, i),
|
|
2934
|
-
href: this.schema.url(d, i),
|
|
2935
|
-
paint: {
|
|
2936
|
-
opacity: this.schema.opacity(d, i)
|
|
2937
|
-
},
|
|
2938
|
-
datum: d,
|
|
2939
|
-
index: i
|
|
2940
|
-
};
|
|
2941
|
-
return node;
|
|
2942
|
-
});
|
|
2943
|
-
return {
|
|
2944
|
-
type: "group",
|
|
2945
|
-
key: "d3plus-Image",
|
|
2946
|
-
children
|
|
2947
|
-
};
|
|
2948
|
-
}
|
|
2949
|
-
select(_) {
|
|
2950
|
-
return arguments.length ? (this._select = d3Selection.select(_), this) : this._select;
|
|
2951
|
-
}
|
|
2952
|
-
/**
|
|
2953
|
-
Invoked when creating a new class instance, and sets any default parameters.
|
|
2954
|
-
@private
|
|
2955
|
-
*/ constructor(){
|
|
2956
|
-
installFluent(this, imageSchema);
|
|
2957
|
-
}
|
|
2958
|
-
}
|
|
2959
|
-
|
|
2960
2821
|
/** Follows the chart (`__d3plus__`) and shape (`__d3plusShape__`) wrappers back
|
|
2961
2822
|
to the source datum, so a `sort` comparator sees the same object the other
|
|
2962
2823
|
per-datum accessors receive. */ function unwrap(d) {
|
|
@@ -2979,18 +2840,219 @@
|
|
|
2979
2840
|
order.forEach((origIdx, pos)=>rank[origIdx] = pos);
|
|
2980
2841
|
return rank;
|
|
2981
2842
|
}
|
|
2843
|
+
/** Bounding box of a list of polygon points, or null when degenerate. */ function pointsBox(points) {
|
|
2844
|
+
if (!points.length) return null;
|
|
2845
|
+
let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;
|
|
2846
|
+
for (const [px, py] of points){
|
|
2847
|
+
if (px < minX) minX = px;
|
|
2848
|
+
if (py < minY) minY = py;
|
|
2849
|
+
if (px > maxX) maxX = px;
|
|
2850
|
+
if (py > maxY) maxY = py;
|
|
2851
|
+
}
|
|
2852
|
+
if (!Number.isFinite(minX) || maxX <= minX || maxY <= minY) return null;
|
|
2853
|
+
return {
|
|
2854
|
+
x: minX,
|
|
2855
|
+
y: minY,
|
|
2856
|
+
width: maxX - minX,
|
|
2857
|
+
height: maxY - minY
|
|
2858
|
+
};
|
|
2859
|
+
}
|
|
2982
2860
|
/**
|
|
2983
|
-
|
|
2984
|
-
|
|
2985
|
-
|
|
2986
|
-
|
|
2987
|
-
|
|
2988
|
-
*/ function
|
|
2989
|
-
|
|
2990
|
-
|
|
2991
|
-
|
|
2992
|
-
|
|
2993
|
-
|
|
2861
|
+
The local-space bounding box `{x, y, width, height}` a backgroundImage fills,
|
|
2862
|
+
derived from a datum's scene geometry. Rect/Bar geometry is already a box;
|
|
2863
|
+
Circle is centered at (cx, cy) with radius r; a `path` uses the exact
|
|
2864
|
+
(DOM-free) bounds of its `d`; Area/Line fall back to their polygon `points`.
|
|
2865
|
+
Returns null when no finite extent can be determined.
|
|
2866
|
+
*/ function backgroundImageBox(g, points) {
|
|
2867
|
+
if (typeof g.width === "number" && typeof g.height === "number") {
|
|
2868
|
+
const x = typeof g.x === "number" ? g.x : -g.width / 2;
|
|
2869
|
+
const y = typeof g.y === "number" ? g.y : -g.height / 2;
|
|
2870
|
+
return {
|
|
2871
|
+
x,
|
|
2872
|
+
y,
|
|
2873
|
+
width: g.width,
|
|
2874
|
+
height: g.height
|
|
2875
|
+
};
|
|
2876
|
+
}
|
|
2877
|
+
if (typeof g.r === "number") {
|
|
2878
|
+
const cx = typeof g.cx === "number" ? g.cx : 0;
|
|
2879
|
+
const cy = typeof g.cy === "number" ? g.cy : 0;
|
|
2880
|
+
return {
|
|
2881
|
+
x: cx - g.r,
|
|
2882
|
+
y: cy - g.r,
|
|
2883
|
+
width: g.r * 2,
|
|
2884
|
+
height: g.r * 2
|
|
2885
|
+
};
|
|
2886
|
+
}
|
|
2887
|
+
if (typeof g.d === "string") {
|
|
2888
|
+
const b = math.pathBounds(g.d);
|
|
2889
|
+
return b.width > 0 && b.height > 0 ? b : null;
|
|
2890
|
+
}
|
|
2891
|
+
return pointsBox(points);
|
|
2892
|
+
}
|
|
2893
|
+
/** Rounded-rectangle path `d` (falls back to a plain rect when radii are 0). */ function roundedRectPath(x, y, w, h, rx, ry) {
|
|
2894
|
+
rx = Math.min(rx, w / 2);
|
|
2895
|
+
ry = Math.min(ry, h / 2);
|
|
2896
|
+
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`;
|
|
2897
|
+
}
|
|
2898
|
+
/**
|
|
2899
|
+
The shape's own geometry expressed as a clip region in its LOCAL coordinate
|
|
2900
|
+
space, so a background image can be clipped to the shape itself (a Path image
|
|
2901
|
+
is clipped to the path, a Circle image to the circle, etc.). Returns
|
|
2902
|
+
undefined when the geometry has no usable outline.
|
|
2903
|
+
*/ function backgroundImageClip(g, points) {
|
|
2904
|
+
if (typeof g.d === "string") return {
|
|
2905
|
+
type: "path",
|
|
2906
|
+
d: g.d
|
|
2907
|
+
};
|
|
2908
|
+
if (typeof g.width === "number" && typeof g.height === "number") {
|
|
2909
|
+
const x = typeof g.x === "number" ? g.x : -g.width / 2;
|
|
2910
|
+
const y = typeof g.y === "number" ? g.y : -g.height / 2;
|
|
2911
|
+
const rx = typeof g.rx === "number" ? g.rx : 0;
|
|
2912
|
+
const ry = typeof g.ry === "number" ? g.ry : 0;
|
|
2913
|
+
return rx > 0 || ry > 0 ? {
|
|
2914
|
+
type: "path",
|
|
2915
|
+
d: roundedRectPath(x, y, g.width, g.height, rx || ry, ry || rx)
|
|
2916
|
+
} : {
|
|
2917
|
+
type: "rect",
|
|
2918
|
+
x,
|
|
2919
|
+
y,
|
|
2920
|
+
width: g.width,
|
|
2921
|
+
height: g.height
|
|
2922
|
+
};
|
|
2923
|
+
}
|
|
2924
|
+
if (typeof g.r === "number") {
|
|
2925
|
+
const cx = typeof g.cx === "number" ? g.cx : 0;
|
|
2926
|
+
const cy = typeof g.cy === "number" ? g.cy : 0;
|
|
2927
|
+
const r = g.r;
|
|
2928
|
+
return {
|
|
2929
|
+
type: "path",
|
|
2930
|
+
d: `M${cx - r},${cy}a${r},${r} 0 1,0 ${2 * r},0a${r},${r} 0 1,0 ${ -2 * r},0Z`
|
|
2931
|
+
};
|
|
2932
|
+
}
|
|
2933
|
+
if (points.length > 2) {
|
|
2934
|
+
const d = `M${points.map(([x, y])=>`${x},${y}`).join("L")}Z`;
|
|
2935
|
+
return {
|
|
2936
|
+
type: "path",
|
|
2937
|
+
d
|
|
2938
|
+
};
|
|
2939
|
+
}
|
|
2940
|
+
return undefined;
|
|
2941
|
+
}
|
|
2942
|
+
/** A polygon (local coords) approximating the shape outline, for `largestRect`. */ function shapePolygon(g, points) {
|
|
2943
|
+
if (typeof g.d === "string") return math.path2polygon(g.d);
|
|
2944
|
+
return points;
|
|
2945
|
+
}
|
|
2946
|
+
/**
|
|
2947
|
+
Resolves a backgroundImage's box + clip + `preserveAspectRatio` for a datum's
|
|
2948
|
+
geometry, honoring the fit mode:
|
|
2949
|
+
|
|
2950
|
+
- `cover` — the image fills the shape's bounding box and is cropped
|
|
2951
|
+
(`xMidYMid slice`), clipped to the shape's own outline.
|
|
2952
|
+
- `contain` — the whole image is centered and fully visible inside the shape:
|
|
2953
|
+
it is fit (`xMidYMid meet`) into the shape's largest inscribed axis-aligned
|
|
2954
|
+
rectangle (a Rect uses itself; a Circle its inscribed square; a Path/Area
|
|
2955
|
+
uses `largestRect` of its polygon). No clip is needed since the box already
|
|
2956
|
+
sits inside the shape.
|
|
2957
|
+
|
|
2958
|
+
Returns null when no usable box can be derived.
|
|
2959
|
+
*/ function backgroundImageLayout(g, points, fit) {
|
|
2960
|
+
if (fit !== "contain") {
|
|
2961
|
+
const box = backgroundImageBox(g, points);
|
|
2962
|
+
if (!box) return null;
|
|
2963
|
+
return {
|
|
2964
|
+
box,
|
|
2965
|
+
clip: backgroundImageClip(g, points),
|
|
2966
|
+
preserveAspectRatio: "xMidYMid slice"
|
|
2967
|
+
};
|
|
2968
|
+
}
|
|
2969
|
+
// contain: fit inside the largest inscribed rectangle, fully visible.
|
|
2970
|
+
let box = null;
|
|
2971
|
+
if (typeof g.width === "number" && typeof g.height === "number") {
|
|
2972
|
+
box = backgroundImageBox(g, points); // a rect contains itself
|
|
2973
|
+
} else if (typeof g.r === "number") {
|
|
2974
|
+
// Inscribed square of a circle: side = r·√2, centered on (cx, cy).
|
|
2975
|
+
const cx = typeof g.cx === "number" ? g.cx : 0;
|
|
2976
|
+
const cy = typeof g.cy === "number" ? g.cy : 0;
|
|
2977
|
+
const half = g.r / Math.SQRT2;
|
|
2978
|
+
box = {
|
|
2979
|
+
x: cx - half,
|
|
2980
|
+
y: cy - half,
|
|
2981
|
+
width: half * 2,
|
|
2982
|
+
height: half * 2
|
|
2983
|
+
};
|
|
2984
|
+
} else {
|
|
2985
|
+
const poly = shapePolygon(g, points);
|
|
2986
|
+
const r = poly.length > 2 ? math.largestRect(poly, {
|
|
2987
|
+
angle: 0
|
|
2988
|
+
}) : null;
|
|
2989
|
+
box = r ? {
|
|
2990
|
+
x: r.cx - r.width / 2,
|
|
2991
|
+
y: r.cy - r.height / 2,
|
|
2992
|
+
width: r.width,
|
|
2993
|
+
height: r.height
|
|
2994
|
+
} : backgroundImageBox(g, points);
|
|
2995
|
+
}
|
|
2996
|
+
return box ? {
|
|
2997
|
+
box,
|
|
2998
|
+
preserveAspectRatio: "xMidYMid meet"
|
|
2999
|
+
} : null;
|
|
3000
|
+
}
|
|
3001
|
+
/**
|
|
3002
|
+
Emits the per-datum background images collected during `Shape.toScene`. Each
|
|
3003
|
+
image is wrapped in its own group carrying the shape's datum + transform, so
|
|
3004
|
+
it is clipped to the shape's outline, positioned in local space, and dims/
|
|
3005
|
+
raises together with its shape on hover. The image is non-interactive (and
|
|
3006
|
+
keyed apart from the shape) so pointer events pass through to the shape below.
|
|
3007
|
+
When `rank` is set (a `sort` comparator is active) every group needs a `z`
|
|
3008
|
+
so the backend sort keeps images above the geometry in their own order.
|
|
3009
|
+
*/ function emitBackgroundImages(specs, rank, dataLen) {
|
|
3010
|
+
return specs.map((spec, k)=>{
|
|
3011
|
+
const image = {
|
|
3012
|
+
type: "image",
|
|
3013
|
+
// Keyed apart from the shape (which uses `spec.key`): sharing the key would
|
|
3014
|
+
// let this non-interactive image overwrite the shape in the hit-test index.
|
|
3015
|
+
key: `${spec.key}-bgimage-img`,
|
|
3016
|
+
x: spec.box.x,
|
|
3017
|
+
y: spec.box.y,
|
|
3018
|
+
width: spec.box.width,
|
|
3019
|
+
height: spec.box.height,
|
|
3020
|
+
href: spec.url,
|
|
3021
|
+
preserveAspectRatio: spec.preserveAspectRatio,
|
|
3022
|
+
// Decorative: pointer events fall through to the shape underneath.
|
|
3023
|
+
interactive: false
|
|
3024
|
+
};
|
|
3025
|
+
const group = {
|
|
3026
|
+
type: "group",
|
|
3027
|
+
key: `${spec.key}-bgimage`,
|
|
3028
|
+
children: [
|
|
3029
|
+
image
|
|
3030
|
+
],
|
|
3031
|
+
// Carry the shape's datum/index so hover/active dimming treats the image
|
|
3032
|
+
// like its shape — dimming and hover-raising the two together (the group
|
|
3033
|
+
// is emitted after the geometry, so at equal `z` the image stays on top).
|
|
3034
|
+
datum: spec.datum,
|
|
3035
|
+
index: spec.index,
|
|
3036
|
+
interactive: false,
|
|
3037
|
+
// A group-level opacity gives the enter/exit animation a target to fade
|
|
3038
|
+
// to/from (matching the shape): the animate layer collapses it to 0 on
|
|
3039
|
+
// enter and eases up to this. It also cascades to the image, so hover
|
|
3040
|
+
// dimming applied here fades the picture with its shape.
|
|
3041
|
+
paint: {
|
|
3042
|
+
opacity: spec.opacity ?? 1
|
|
3043
|
+
},
|
|
3044
|
+
...spec.transform ? {
|
|
3045
|
+
transform: spec.transform
|
|
3046
|
+
} : {},
|
|
3047
|
+
...spec.clip ? {
|
|
3048
|
+
clip: spec.clip
|
|
3049
|
+
} : {},
|
|
3050
|
+
...rank ? {
|
|
3051
|
+
z: dataLen + k
|
|
3052
|
+
} : {}
|
|
3053
|
+
};
|
|
3054
|
+
return group;
|
|
3055
|
+
});
|
|
2994
3056
|
}
|
|
2995
3057
|
|
|
2996
3058
|
/** Coerces a value to a finite number, or undefined. @private */ function numOrUndef(v) {
|
|
@@ -3024,6 +3086,11 @@
|
|
|
3024
3086
|
coerce: "const",
|
|
3025
3087
|
default: constant(false)
|
|
3026
3088
|
},
|
|
3089
|
+
{
|
|
3090
|
+
key: "backgroundImageFit",
|
|
3091
|
+
coerce: "const",
|
|
3092
|
+
default: constant("cover")
|
|
3093
|
+
},
|
|
3027
3094
|
{
|
|
3028
3095
|
key: "discrete",
|
|
3029
3096
|
coerce: "identity"
|
|
@@ -3336,10 +3403,10 @@
|
|
|
3336
3403
|
let data = this._data;
|
|
3337
3404
|
if (this._dataFilter) data = this._dataFilter(data);
|
|
3338
3405
|
const children = [];
|
|
3339
|
-
//
|
|
3340
|
-
//
|
|
3341
|
-
//
|
|
3342
|
-
const
|
|
3406
|
+
// Collected background images, emitted below (after the geometry) as clipped,
|
|
3407
|
+
// transformed groups. Each datum whose `backgroundImage(d, i)` resolves to a
|
|
3408
|
+
// truthy URL contributes one spec.
|
|
3409
|
+
const bgSpecs = [];
|
|
3343
3410
|
// A `sort` comparator becomes per-datum `z` ranks rather than a reorder of
|
|
3344
3411
|
// `data`: the render backends sort each group's children ascending by `z`
|
|
3345
3412
|
// (stably), so a lower rank paints first (behind) and a higher rank paints
|
|
@@ -3378,41 +3445,37 @@
|
|
|
3378
3445
|
z: rank[i]
|
|
3379
3446
|
} : {}
|
|
3380
3447
|
});
|
|
3381
|
-
// backgroundImage: collect a per-datum image
|
|
3382
|
-
//
|
|
3383
|
-
//
|
|
3448
|
+
// backgroundImage: collect a per-datum image (see backgroundImageLayout for
|
|
3449
|
+
// the cover/contain fit). The wrapping group carries the shape transform,
|
|
3450
|
+
// so the image box + clip stay in local space.
|
|
3384
3451
|
const bg = this._nestWrapper(this.schema.backgroundImage)(d, i);
|
|
3385
3452
|
if (bg) {
|
|
3386
3453
|
const g = geom;
|
|
3387
|
-
//
|
|
3388
|
-
//
|
|
3389
|
-
|
|
3390
|
-
|
|
3391
|
-
const
|
|
3392
|
-
const
|
|
3393
|
-
|
|
3394
|
-
|
|
3395
|
-
|
|
3396
|
-
|
|
3397
|
-
|
|
3398
|
-
|
|
3399
|
-
|
|
3400
|
-
|
|
3401
|
-
|
|
3402
|
-
|
|
3403
|
-
|
|
3404
|
-
|
|
3405
|
-
|
|
3406
|
-
y: (t.y ?? 0) + cy - ih / 2,
|
|
3407
|
-
width: iw,
|
|
3408
|
-
height: ih
|
|
3409
|
-
});
|
|
3454
|
+
// Only Area/Line lack a `d`/box and need polygon points; Path/Rect/Circle
|
|
3455
|
+
// derive their layout from `d`/width/r directly.
|
|
3456
|
+
const needsPoints = typeof g.d !== "string" && typeof g.width !== "number" && typeof g.r !== "number";
|
|
3457
|
+
const points = needsPoints ? this._aes(d, i).points ?? [] : [];
|
|
3458
|
+
const fit = this._nestWrapper(this.schema.backgroundImageFit)(d, i);
|
|
3459
|
+
const layout = backgroundImageLayout(g, points, fit === "contain" ? "contain" : "cover");
|
|
3460
|
+
if (layout) {
|
|
3461
|
+
bgSpecs.push({
|
|
3462
|
+
key,
|
|
3463
|
+
index: i,
|
|
3464
|
+
datum,
|
|
3465
|
+
url: bg,
|
|
3466
|
+
box: layout.box,
|
|
3467
|
+
clip: layout.clip,
|
|
3468
|
+
preserveAspectRatio: layout.preserveAspectRatio,
|
|
3469
|
+
opacity: numOrUndef(this._nestWrapper(this.schema.opacity)(d, i)),
|
|
3470
|
+
transform
|
|
3471
|
+
});
|
|
3472
|
+
}
|
|
3410
3473
|
}
|
|
3411
3474
|
});
|
|
3412
3475
|
// Emit background images AFTER shape children so they paint above the
|
|
3413
3476
|
// shape's fill — matches the DOM order where the <image> was
|
|
3414
3477
|
// appended as a sibling of the shape.
|
|
3415
|
-
if (
|
|
3478
|
+
if (bgSpecs.length) children.push(...emitBackgroundImages(bgSpecs, rank, data.length));
|
|
3416
3479
|
// NOTE: Labels are NOT pushed here. The canonical aggregation point is
|
|
3417
3480
|
// `emitHelpers.collectComputed(shape)`, which appends `shape.toScene()`
|
|
3418
3481
|
// AND `shape._labelClass.toScene()` independently. Pushing labels here
|
|
@@ -3575,7 +3638,6 @@
|
|
|
3575
3638
|
*/ constructor(tagName = "g"){
|
|
3576
3639
|
super();
|
|
3577
3640
|
installFluent(this, shapeSchema);
|
|
3578
|
-
this._backgroundImageClass = new Image();
|
|
3579
3641
|
this._data = [];
|
|
3580
3642
|
this._labelClass = new TextBox();
|
|
3581
3643
|
this._name = "Shape";
|
|
@@ -4003,11 +4065,19 @@
|
|
|
4003
4065
|
super("circle");
|
|
4004
4066
|
installFluent(this, circleSchema);
|
|
4005
4067
|
this._name = "Circle";
|
|
4068
|
+
// Bound the label to the full circle (diameter box) and tag it
|
|
4069
|
+
// `shape: "circle"`, so the label TextBox flows text as circle chords —
|
|
4070
|
+
// lines fill the interior, shorter near the top and bottom and full width
|
|
4071
|
+
// through the middle — rather than being capped to a square inscribed in
|
|
4072
|
+
// the circle. The `shape` hint rides on the bounds (not `labelConfig`) so a
|
|
4073
|
+
// chart that repositions the label with its own `labelBounds` (e.g. Tree's
|
|
4074
|
+
// external node labels) gets ordinary rectangular wrapping.
|
|
4006
4075
|
this.schema.labelBounds = (_d, _i, s)=>({
|
|
4007
|
-
width: s.r *
|
|
4008
|
-
height: s.r *
|
|
4009
|
-
x: -s.r
|
|
4010
|
-
y: -s.r
|
|
4076
|
+
width: s.r * 2,
|
|
4077
|
+
height: s.r * 2,
|
|
4078
|
+
x: -s.r,
|
|
4079
|
+
y: -s.r,
|
|
4080
|
+
shape: "circle"
|
|
4011
4081
|
});
|
|
4012
4082
|
this.schema.labelConfig = dom.assign(this.schema.labelConfig, {
|
|
4013
4083
|
textAnchor: "middle",
|
|
@@ -4695,6 +4765,152 @@
|
|
|
4695
4765
|
}
|
|
4696
4766
|
}
|
|
4697
4767
|
|
|
4768
|
+
/** Image's fluent accessor schema. Config storage lives on `this.schema.<key>`. */ const imageSchema = [
|
|
4769
|
+
{
|
|
4770
|
+
key: "duration",
|
|
4771
|
+
coerce: "identity",
|
|
4772
|
+
default: 600
|
|
4773
|
+
},
|
|
4774
|
+
{
|
|
4775
|
+
key: "height",
|
|
4776
|
+
coerce: "accessor",
|
|
4777
|
+
default: accessor("height")
|
|
4778
|
+
},
|
|
4779
|
+
{
|
|
4780
|
+
key: "id",
|
|
4781
|
+
coerce: "identity",
|
|
4782
|
+
default: accessor("id")
|
|
4783
|
+
},
|
|
4784
|
+
{
|
|
4785
|
+
key: "opacity",
|
|
4786
|
+
coerce: "const",
|
|
4787
|
+
default: constant(1)
|
|
4788
|
+
},
|
|
4789
|
+
{
|
|
4790
|
+
key: "pointerEvents",
|
|
4791
|
+
coerce: "const",
|
|
4792
|
+
default: constant("auto")
|
|
4793
|
+
},
|
|
4794
|
+
{
|
|
4795
|
+
key: "renderMode",
|
|
4796
|
+
coerce: "identity",
|
|
4797
|
+
default: "full"
|
|
4798
|
+
},
|
|
4799
|
+
{
|
|
4800
|
+
key: "url",
|
|
4801
|
+
coerce: "identity",
|
|
4802
|
+
default: accessor("url")
|
|
4803
|
+
},
|
|
4804
|
+
{
|
|
4805
|
+
key: "width",
|
|
4806
|
+
coerce: "accessor",
|
|
4807
|
+
default: accessor("width")
|
|
4808
|
+
},
|
|
4809
|
+
{
|
|
4810
|
+
key: "x",
|
|
4811
|
+
coerce: "const",
|
|
4812
|
+
default: accessor("x", 0)
|
|
4813
|
+
},
|
|
4814
|
+
{
|
|
4815
|
+
key: "y",
|
|
4816
|
+
coerce: "const",
|
|
4817
|
+
default: accessor("y", 0)
|
|
4818
|
+
}
|
|
4819
|
+
];
|
|
4820
|
+
class Image {
|
|
4821
|
+
config(_) {
|
|
4822
|
+
if (!arguments.length) return {
|
|
4823
|
+
...this.schema,
|
|
4824
|
+
data: this._data,
|
|
4825
|
+
select: this._select
|
|
4826
|
+
};
|
|
4827
|
+
const patch = _;
|
|
4828
|
+
for(const k in patch){
|
|
4829
|
+
if (!Object.prototype.hasOwnProperty.call(patch, k)) continue;
|
|
4830
|
+
// `this[k]` resolves the fluent accessor via the index signature.
|
|
4831
|
+
if (typeof this[k] === "function") this[k](patch[k]);
|
|
4832
|
+
else this.schema[k] = patch[k];
|
|
4833
|
+
}
|
|
4834
|
+
return this;
|
|
4835
|
+
}
|
|
4836
|
+
/**
|
|
4837
|
+
Renders the current Image to the page. If a *callback* is specified, it will be called once the images are done drawing.
|
|
4838
|
+
@param callback Optional callback invoked after rendering completes.
|
|
4839
|
+
*/ render(callback) {
|
|
4840
|
+
// Compute mode is a no-op for DOM emission — the caller will read
|
|
4841
|
+
// `toScene()` to get a SceneNode tree, no need to mount.
|
|
4842
|
+
if (this.schema.renderMode === "compute") {
|
|
4843
|
+
if (callback) setTimeout(callback, 0);
|
|
4844
|
+
return this;
|
|
4845
|
+
}
|
|
4846
|
+
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());
|
|
4847
|
+
const images = this._select.selectAll(".d3plus-Image").data(this._data, this.schema.id);
|
|
4848
|
+
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);
|
|
4849
|
+
const t = d3Transition.transition().duration(this.schema.duration), that = this, update = enter.merge(images);
|
|
4850
|
+
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) {
|
|
4851
|
+
const image = d3Selection.select(this), link = that.schema.url(d, i);
|
|
4852
|
+
const fullAddress = link.indexOf("http://") === 0 || link.indexOf("https://") === 0;
|
|
4853
|
+
if (!fullAddress || link.indexOf(window.location.hostname) === 0) {
|
|
4854
|
+
const img = new window.Image();
|
|
4855
|
+
img.src = link;
|
|
4856
|
+
img.crossOrigin = "Anonymous";
|
|
4857
|
+
img.onload = function() {
|
|
4858
|
+
const canvas = document.createElement("canvas");
|
|
4859
|
+
canvas.width = img.width;
|
|
4860
|
+
canvas.height = img.height;
|
|
4861
|
+
const context = canvas.getContext("2d");
|
|
4862
|
+
context.drawImage(img, 0, 0);
|
|
4863
|
+
image.attr("xlink:href", canvas.toDataURL("image/png"));
|
|
4864
|
+
};
|
|
4865
|
+
}
|
|
4866
|
+
});
|
|
4867
|
+
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();
|
|
4868
|
+
if (callback) setTimeout(callback, this.schema.duration + 100);
|
|
4869
|
+
return this;
|
|
4870
|
+
}
|
|
4871
|
+
data(_) {
|
|
4872
|
+
return arguments.length ? (this._data = _, this) : this._data;
|
|
4873
|
+
}
|
|
4874
|
+
/**
|
|
4875
|
+
Compute-mode scene emission. Mirrors Shape.toScene's shape — a
|
|
4876
|
+
keyed GroupNode wrapping per-datum ImageNodes. Used by chart
|
|
4877
|
+
compositors (e.g. plotPaint) that need Image to participate in the
|
|
4878
|
+
scene graph rather than emit d3-selection DOM.
|
|
4879
|
+
*/ toScene() {
|
|
4880
|
+
const children = (this._data || []).map((d, i)=>{
|
|
4881
|
+
const node = {
|
|
4882
|
+
type: "image",
|
|
4883
|
+
key: `${this.schema.id(d, i)}`,
|
|
4884
|
+
x: this.schema.x(d, i),
|
|
4885
|
+
y: this.schema.y(d, i),
|
|
4886
|
+
width: this.schema.width(d, i),
|
|
4887
|
+
height: this.schema.height(d, i),
|
|
4888
|
+
href: this.schema.url(d, i),
|
|
4889
|
+
paint: {
|
|
4890
|
+
opacity: this.schema.opacity(d, i)
|
|
4891
|
+
},
|
|
4892
|
+
datum: d,
|
|
4893
|
+
index: i
|
|
4894
|
+
};
|
|
4895
|
+
return node;
|
|
4896
|
+
});
|
|
4897
|
+
return {
|
|
4898
|
+
type: "group",
|
|
4899
|
+
key: "d3plus-Image",
|
|
4900
|
+
children
|
|
4901
|
+
};
|
|
4902
|
+
}
|
|
4903
|
+
select(_) {
|
|
4904
|
+
return arguments.length ? (this._select = d3Selection.select(_), this) : this._select;
|
|
4905
|
+
}
|
|
4906
|
+
/**
|
|
4907
|
+
Invoked when creating a new class instance, and sets any default parameters.
|
|
4908
|
+
@private
|
|
4909
|
+
*/ constructor(){
|
|
4910
|
+
installFluent(this, imageSchema);
|
|
4911
|
+
}
|
|
4912
|
+
}
|
|
4913
|
+
|
|
4698
4914
|
/** Path's own fluent accessor schema, layered on top of Shape's. */ const pathSchema = [
|
|
4699
4915
|
{
|
|
4700
4916
|
key: "d",
|
|
@@ -7110,9 +7326,11 @@
|
|
|
7110
7326
|
}
|
|
7111
7327
|
return lineRuns;
|
|
7112
7328
|
}
|
|
7113
|
-
/** Pre-scales the font size to fit the box area before wrapping (resize mode). */ function resizeFontSize(fS, w, h, lH, words, style) {
|
|
7329
|
+
/** Pre-scales the font size to fit the box area before wrapping (resize mode). */ function resizeFontSize(fS, w, h, lH, words, style, shape) {
|
|
7114
7330
|
const sizes = dom.textWidth(words, style);
|
|
7115
|
-
const areaMod = 1.165 + w / h * 0.1,
|
|
7331
|
+
const areaMod = 1.165 + w / h * 0.1, // A circle fills only ~π/4 of its bounding box, so scale the usable area
|
|
7332
|
+
// down to keep the initial font-size guess from overshooting.
|
|
7333
|
+
boxArea = w * h * (shape === "circle" ? Math.PI / 4 : 1), maxWidth = d3Array.max(sizes), textArea = d3Array.sum(sizes, (d)=>d * lH) * areaMod;
|
|
7116
7334
|
if (maxWidth > w || textArea > boxArea) {
|
|
7117
7335
|
const areaRatio = Math.sqrt(boxArea / textArea), widthRatio = w / maxWidth;
|
|
7118
7336
|
const sizeRatio = d3Array.min([
|
|
@@ -7182,8 +7400,8 @@
|
|
|
7182
7400
|
"line-height": lH
|
|
7183
7401
|
};
|
|
7184
7402
|
const padding = dom.parseSides(box.schema.padding(d, i));
|
|
7185
|
-
const h = box.schema.height(d, i) - (padding.top + padding.bottom), w = box.schema.width(d, i) - (padding.left + padding.right);
|
|
7186
|
-
const wrapper = text.textWrap().fontFamily(style["font-family"]).fontSize(fS).fontWeight(style["font-weight"]).lineHeight(lH).maxLines(box.schema.maxLines(d, i)).height(h).overflow(box.schema.overflow(d, i)).width(w).split(box.schema.split);
|
|
7403
|
+
const h = box.schema.height(d, i) - (padding.top + padding.bottom), w = box.schema.width(d, i) - (padding.left + padding.right), shape = box.schema.shape(d, i);
|
|
7404
|
+
const wrapper = text.textWrap().fontFamily(style["font-family"]).fontSize(fS).fontWeight(style["font-weight"]).lineHeight(lH).maxLines(box.schema.maxLines(d, i)).height(h).overflow(box.schema.overflow(d, i)).shape(shape).width(w).split(box.schema.split);
|
|
7187
7405
|
const fMax = box.schema.fontMax(d, i), fMin = box.schema.fontMin(d, i), vA = box.schema.verticalAlign(d, i), words = box.schema.split(t, i);
|
|
7188
7406
|
/**
|
|
7189
7407
|
Figures out the lineData to be used for wrapping.
|
|
@@ -7225,7 +7443,7 @@
|
|
|
7225
7443
|
}
|
|
7226
7444
|
}
|
|
7227
7445
|
if (w > fMin && (h > lH || resize && h > fMin * lHRatio)) {
|
|
7228
|
-
if (resize) fS = resizeFontSize(fS, w, h, lH, words, style);
|
|
7446
|
+
if (resize) fS = resizeFontSize(fS, w, h, lH, words, style, shape);
|
|
7229
7447
|
checkSize();
|
|
7230
7448
|
}
|
|
7231
7449
|
if (!lineData.length) return null;
|
|
@@ -7365,6 +7583,17 @@
|
|
|
7365
7583
|
d.h / 2
|
|
7366
7584
|
]
|
|
7367
7585
|
},
|
|
7586
|
+
// Bounding shape for wrapping: "square" (default) fills the full width on
|
|
7587
|
+
// every line; "circle" treats width/height as the diameter and shortens
|
|
7588
|
+
// lines near the top and bottom to keep text inside the circle. Defaults to
|
|
7589
|
+
// the label record's namespaced `__d3plusWrapShape__` (stamped from a shape's
|
|
7590
|
+
// `labelBounds`) so Circle labels wrap to the circle without callers
|
|
7591
|
+
// configuring anything, while a caller's own `shape` data field is ignored.
|
|
7592
|
+
{
|
|
7593
|
+
key: "shape",
|
|
7594
|
+
coerce: "const",
|
|
7595
|
+
default: (d)=>d.__d3plusWrapShape__ ?? "square"
|
|
7596
|
+
},
|
|
7368
7597
|
{
|
|
7369
7598
|
key: "split",
|
|
7370
7599
|
coerce: "identity",
|
|
@@ -8749,7 +8978,7 @@
|
|
|
8749
8978
|
];
|
|
8750
8979
|
return id;
|
|
8751
8980
|
})).length;
|
|
8752
|
-
const inverted = this.schema.legendFilterInvert.bind(this)();
|
|
8981
|
+
const inverted = this.schema.legendFilterInvert.bind(this)(this);
|
|
8753
8982
|
if (inverted) {
|
|
8754
8983
|
if (event.shiftKey) {
|
|
8755
8984
|
if (hiddenIndex < 0 && !this._solo.length) {
|
|
@@ -8907,7 +9136,7 @@
|
|
|
8907
9136
|
const hasDeeperLevel = this._drawDepth < this.schema.groupBy.length - 1;
|
|
8908
9137
|
// only show the hand cursor when the shape has a click event
|
|
8909
9138
|
this._select.style("cursor", hasUserClick || hasDefaultClick && hasDeeperLevel ? "pointer" : "auto");
|
|
8910
|
-
const invertedBehavior = this.schema.legendFilterInvert.bind(this)();
|
|
9139
|
+
const invertedBehavior = this.schema.legendFilterInvert.bind(this)(this);
|
|
8911
9140
|
const solo = this._solo.includes(id);
|
|
8912
9141
|
const hidden = this._hidden.includes(id);
|
|
8913
9142
|
this._tooltipClass.data([
|
|
@@ -11168,8 +11397,10 @@
|
|
|
11168
11397
|
data.sort((a, b)=>a[viz.schema.discrete] - b[viz.schema.discrete]);
|
|
11169
11398
|
}
|
|
11170
11399
|
const order = viz._stackOrder;
|
|
11400
|
+
// An explicit key array orders `stackKeys` directly (then d3-stack keeps
|
|
11401
|
+
// that order via `stackOrderNone`); every other order is a comparator that
|
|
11402
|
+
// reranks the series d3-stack builds, so `stackKeys` is left in input order.
|
|
11171
11403
|
if (Array.isArray(order)) stackKeys.sort((a, b)=>order.indexOf(a) - order.indexOf(b));
|
|
11172
|
-
else if (order === d3Shape__namespace.stackOrderNone) stackKeys.sort((a, b)=>`${a}`.localeCompare(`${b}`));
|
|
11173
11404
|
// d3-stack's generics don't model d3plus's dynamically-keyed rows; the
|
|
11174
11405
|
// order/offset/value accessors are cast (`as never`) at the boundary, and
|
|
11175
11406
|
// the configured stack is invoked as a `Row[][] -> number[][][]` function.
|
|
@@ -12711,6 +12942,13 @@
|
|
|
12711
12942
|
};
|
|
12712
12943
|
}
|
|
12713
12944
|
|
|
12945
|
+
/** Marks a comparator as an already-resolved d3plus stack order. */ function tagOrder(fn) {
|
|
12946
|
+
fn.__d3plusStackOrder = true;
|
|
12947
|
+
return fn;
|
|
12948
|
+
}
|
|
12949
|
+
// @types/d3-shape types the order accessors' param as a single `Series`,
|
|
12950
|
+
// though d3 passes the full stack array; this cast satisfies the signature.
|
|
12951
|
+
const asStack = (series)=>series;
|
|
12714
12952
|
/**
|
|
12715
12953
|
Sums a single stack series, ignoring non-numeric segments.
|
|
12716
12954
|
*/ function stackSum(series) {
|
|
@@ -12720,18 +12958,80 @@
|
|
|
12720
12958
|
return s;
|
|
12721
12959
|
}
|
|
12722
12960
|
/**
|
|
12723
|
-
Stack order:
|
|
12724
|
-
|
|
12961
|
+
Stack order: series with the smallest summed value on the bottom of the
|
|
12962
|
+
stack (matches d3's `stackOrderAscending`).
|
|
12963
|
+
*/ const stackOrderTotalAscending = tagOrder((series)=>d3Shape__namespace.stackOrderAscending(asStack(series)));
|
|
12964
|
+
/**
|
|
12965
|
+
Stack order: series with the largest summed value on the bottom of the
|
|
12966
|
+
stack (matches d3's `stackOrderDescending`). Plot's default.
|
|
12967
|
+
*/ const stackOrderTotalDescending = tagOrder((series)=>d3Shape__namespace.stackOrderDescending(asStack(series)));
|
|
12968
|
+
/**
|
|
12969
|
+
Stack order: ascending by series key (A→Z from the bottom), tie-broken by
|
|
12970
|
+
ascending summed value.
|
|
12971
|
+
*/ const stackOrderKey = tagOrder((series)=>{
|
|
12725
12972
|
const sums = series.map(stackSum);
|
|
12726
12973
|
const keys = series.map((d)=>d.key.split("_")[0]);
|
|
12727
|
-
|
|
12728
|
-
|
|
12729
|
-
|
|
12974
|
+
return d3Shape__namespace.stackOrderNone(asStack(series)).sort((a, b)=>keys[a].localeCompare(keys[b]) || sums[a] - sums[b]);
|
|
12975
|
+
});
|
|
12976
|
+
/**
|
|
12977
|
+
Stack order: the reverse of {@link stackOrderKey} (Z→A from the bottom).
|
|
12978
|
+
*/ const stackOrderKeyReverse = tagOrder((series)=>stackOrderKey(series).reverse());
|
|
12979
|
+
/**
|
|
12980
|
+
Builds a stack order that ranks each series by an aggregate (sum) of a
|
|
12981
|
+
data field, letting users order stacks by any value in their data rather
|
|
12982
|
+
than only the plotted one. `value` receives each series' original datum.
|
|
12983
|
+
*/ function stackOrderField(value, order = "descending") {
|
|
12984
|
+
return tagOrder((series)=>{
|
|
12985
|
+
const totals = series.map((s)=>{
|
|
12986
|
+
let total = 0;
|
|
12987
|
+
for(let i = 0; i < s.length; i++){
|
|
12988
|
+
// Each stacked point carries `.data` = the discrete group's rows;
|
|
12989
|
+
// pick the row for this series and read the field off its datum.
|
|
12990
|
+
const group = s[i].data || [];
|
|
12991
|
+
const row = group.find((g)=>g.id === s.key);
|
|
12992
|
+
if (row && row.data) {
|
|
12993
|
+
const v = +value(row.data);
|
|
12994
|
+
if (!isNaN(v)) total += v;
|
|
12995
|
+
}
|
|
12996
|
+
}
|
|
12997
|
+
return total;
|
|
12998
|
+
});
|
|
12999
|
+
return d3Shape__namespace.stackOrderNone(asStack(series)).sort((a, b)=>order === "ascending" ? totals[a] - totals[b] : totals[b] - totals[a]);
|
|
13000
|
+
});
|
|
12730
13001
|
}
|
|
13002
|
+
/** Named stack orders accepted by `Plot.stackOrder`. */ const NAMED_ORDERS = {
|
|
13003
|
+
ascending: stackOrderTotalAscending,
|
|
13004
|
+
descending: stackOrderTotalDescending,
|
|
13005
|
+
key: stackOrderKey,
|
|
13006
|
+
keyReverse: stackOrderKeyReverse,
|
|
13007
|
+
none: tagOrder((series)=>d3Shape__namespace.stackOrderNone(asStack(series))),
|
|
13008
|
+
data: tagOrder((series)=>d3Shape__namespace.stackOrderNone(asStack(series))),
|
|
13009
|
+
insideOut: tagOrder((series)=>d3Shape__namespace.stackOrderInsideOut(asStack(series))),
|
|
13010
|
+
appearance: tagOrder((series)=>d3Shape__namespace.stackOrderAppearance(asStack(series))),
|
|
13011
|
+
reverse: tagOrder((series)=>d3Shape__namespace.stackOrderReverse(asStack(series)))
|
|
13012
|
+
};
|
|
13013
|
+
/** The named orders accepted by `Plot.stackOrder`, for docs/validation. */ const stackOrderNames = Object.keys(NAMED_ORDERS);
|
|
12731
13014
|
/**
|
|
12732
|
-
|
|
12733
|
-
|
|
12734
|
-
|
|
13015
|
+
Normalizes any `stackOrder` input into a value Plot's pipeline can apply:
|
|
13016
|
+
a tagged comparator, or an explicit array of series keys. Warns and falls
|
|
13017
|
+
back to the default on an unrecognized name.
|
|
13018
|
+
*/ function resolveStackOrder(input) {
|
|
13019
|
+
if (typeof input === "function") {
|
|
13020
|
+
// Already-resolved order (constructor default / config() reset) passes
|
|
13021
|
+
// through; a bare user function is treated as a value accessor.
|
|
13022
|
+
return input.__d3plusStackOrder ? input : stackOrderField(input);
|
|
13023
|
+
}
|
|
13024
|
+
if (Array.isArray(input)) return input;
|
|
13025
|
+
if (input && typeof input === "object") {
|
|
13026
|
+
const { value, order } = input;
|
|
13027
|
+
return stackOrderField(typeof value === "function" ? value : accessor(value), order);
|
|
13028
|
+
}
|
|
13029
|
+
if (typeof input === "string") {
|
|
13030
|
+
if (input in NAMED_ORDERS) return NAMED_ORDERS[input];
|
|
13031
|
+
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".`);
|
|
13032
|
+
return stackOrderTotalDescending;
|
|
13033
|
+
}
|
|
13034
|
+
return stackOrderTotalDescending;
|
|
12735
13035
|
}
|
|
12736
13036
|
/**
|
|
12737
13037
|
Diverging stack offset: positive segments stack upward from zero,
|
|
@@ -12753,6 +13053,23 @@
|
|
|
12753
13053
|
}
|
|
12754
13054
|
}
|
|
12755
13055
|
}
|
|
13056
|
+
/** Named stack offsets accepted by `Plot.stackOffset`. */ const NAMED_OFFSETS = {
|
|
13057
|
+
diverging: stackOffsetDiverging,
|
|
13058
|
+
none: d3Shape__namespace.stackOffsetNone,
|
|
13059
|
+
expand: d3Shape__namespace.stackOffsetExpand,
|
|
13060
|
+
silhouette: d3Shape__namespace.stackOffsetSilhouette,
|
|
13061
|
+
wiggle: d3Shape__namespace.stackOffsetWiggle
|
|
13062
|
+
};
|
|
13063
|
+
/** The named offsets accepted by `Plot.stackOffset`, for docs/validation. */ const stackOffsetNames = Object.keys(NAMED_OFFSETS);
|
|
13064
|
+
/**
|
|
13065
|
+
Normalizes a `stackOffset` input into an offset function. Warns and falls
|
|
13066
|
+
back to the diverging default on an unrecognized name.
|
|
13067
|
+
*/ function resolveStackOffset(input) {
|
|
13068
|
+
if (typeof input === "function") return input;
|
|
13069
|
+
if (typeof input === "string" && input in NAMED_OFFSETS) return NAMED_OFFSETS[input];
|
|
13070
|
+
console.warn(`[d3plus] Unknown stackOffset "${input}". Expected one of: ${stackOffsetNames.join(", ")}; or an offset function. Falling back to "diverging".`);
|
|
13071
|
+
return stackOffsetDiverging;
|
|
13072
|
+
}
|
|
12756
13073
|
|
|
12757
13074
|
/**
|
|
12758
13075
|
Clone the base shape config and, for stacked Area/Bar, inject the
|
|
@@ -13492,6 +13809,7 @@
|
|
|
13492
13809
|
];
|
|
13493
13810
|
}
|
|
13494
13811
|
|
|
13812
|
+
/* eslint no-cond-assign: 0*/ // @ts-ignore
|
|
13495
13813
|
const { theme: openColor } = pkg;
|
|
13496
13814
|
// E4: Plot's identity-coerce accessor schema (18 keys). installFluent's
|
|
13497
13815
|
// per-key idempotence lets this co-exist with vizSchema on the parent
|
|
@@ -13790,18 +14108,29 @@
|
|
|
13790
14108
|
return arguments.length ? (this._size = typeof _ === "function" || !_ ? _ : accessor(_), this) : this._size;
|
|
13791
14109
|
}
|
|
13792
14110
|
/**
|
|
13793
|
-
Sets the
|
|
14111
|
+
Sets the vertical offset applied to stacked series. Accepts a named
|
|
14112
|
+
offset — `"diverging"` (default), `"none"`, `"expand"`, `"silhouette"`,
|
|
14113
|
+
or `"wiggle"` — or a custom offset function. Unknown names warn and fall
|
|
14114
|
+
back to `"diverging"`. If *value* is not specified, returns the current
|
|
14115
|
+
stack offset function.
|
|
13794
14116
|
*/ stackOffset(_) {
|
|
13795
|
-
return arguments.length ? (this._stackOffset =
|
|
14117
|
+
return arguments.length ? (this._stackOffset = resolveStackOffset(_), this) : this._stackOffset;
|
|
13796
14118
|
}
|
|
13797
14119
|
/**
|
|
13798
|
-
Sets the
|
|
14120
|
+
Sets the order of stacked series, from the bottom of the stack upward.
|
|
14121
|
+
Accepts:
|
|
14122
|
+
- a named order: `"descending"` (default) / `"ascending"` by summed
|
|
14123
|
+
value, `"key"` / `"keyReverse"` alphabetically by series key,
|
|
14124
|
+
`"none"` / `"data"` for input order, or d3's `"insideOut"`,
|
|
14125
|
+
`"appearance"`, `"reverse"`;
|
|
14126
|
+
- an Array of series keys for an explicit order;
|
|
14127
|
+
- a value accessor, or a `{value, order}` config, to rank series by an
|
|
14128
|
+
aggregate of any data field.
|
|
14129
|
+
|
|
14130
|
+
Unknown named strings warn and fall back to `"descending"`. If *value*
|
|
14131
|
+
is not specified, returns the current stack order.
|
|
13799
14132
|
*/ stackOrder(_) {
|
|
13800
|
-
|
|
13801
|
-
if (typeof _ === "string") this._stackOrder = _ === "ascending" ? stackOrderAscending : _ === "descending" ? stackOrderDescending : d3Shape__namespace[`stackOrder${_.charAt(0).toUpperCase() + _.slice(1)}`];
|
|
13802
|
-
else this._stackOrder = _;
|
|
13803
|
-
return this;
|
|
13804
|
-
} else return this._stackOrder;
|
|
14133
|
+
return arguments.length ? (this._stackOrder = resolveStackOrder(_), this) : this._stackOrder;
|
|
13805
14134
|
}
|
|
13806
14135
|
/**
|
|
13807
14136
|
Accessor function or string key for the x-axis value of each data point.
|
|
@@ -13946,7 +14275,7 @@
|
|
|
13946
14275
|
this.schema.sizeMin = 5;
|
|
13947
14276
|
this.schema.sizeScale = "sqrt";
|
|
13948
14277
|
this._stackOffset = stackOffsetDiverging;
|
|
13949
|
-
this._stackOrder =
|
|
14278
|
+
this._stackOrder = stackOrderTotalDescending;
|
|
13950
14279
|
this.schema.timelineConfig = dom.assign(this.schema.timelineConfig, {
|
|
13951
14280
|
brushMin: ()=>this._xTime || this._yTime || this._x2Time || this._y2Time ? 2 : 1
|
|
13952
14281
|
});
|
|
@@ -14022,7 +14351,8 @@
|
|
|
14022
14351
|
},
|
|
14023
14352
|
{
|
|
14024
14353
|
key: "shape",
|
|
14025
|
-
default: constant("Area")
|
|
14354
|
+
default: constant("Area"),
|
|
14355
|
+
coerce: "const"
|
|
14026
14356
|
}
|
|
14027
14357
|
]
|
|
14028
14358
|
};
|
|
@@ -14051,10 +14381,12 @@
|
|
|
14051
14381
|
},
|
|
14052
14382
|
{
|
|
14053
14383
|
key: "shape",
|
|
14054
|
-
default: constant("Bar")
|
|
14384
|
+
default: constant("Bar"),
|
|
14385
|
+
coerce: "const"
|
|
14055
14386
|
},
|
|
14056
14387
|
{
|
|
14057
14388
|
key: "legend",
|
|
14389
|
+
coerce: "const",
|
|
14058
14390
|
factory: (viz)=>{
|
|
14059
14391
|
const base = viz.schema.legend;
|
|
14060
14392
|
return (config, arr)=>{
|
|
@@ -14088,7 +14420,8 @@
|
|
|
14088
14420
|
},
|
|
14089
14421
|
{
|
|
14090
14422
|
key: "shape",
|
|
14091
|
-
default: constant("Box")
|
|
14423
|
+
default: constant("Box"),
|
|
14424
|
+
coerce: "const"
|
|
14092
14425
|
},
|
|
14093
14426
|
{
|
|
14094
14427
|
key: "tooltipConfig",
|
|
@@ -14154,7 +14487,8 @@
|
|
|
14154
14487
|
},
|
|
14155
14488
|
{
|
|
14156
14489
|
key: "shape",
|
|
14157
|
-
default: constant("Line")
|
|
14490
|
+
default: constant("Line"),
|
|
14491
|
+
coerce: "const"
|
|
14158
14492
|
}
|
|
14159
14493
|
]
|
|
14160
14494
|
};
|
|
@@ -14389,6 +14723,7 @@
|
|
|
14389
14723
|
},
|
|
14390
14724
|
{
|
|
14391
14725
|
key: "legend",
|
|
14726
|
+
coerce: "const",
|
|
14392
14727
|
factory: (viz)=>{
|
|
14393
14728
|
const base = viz.schema.legend;
|
|
14394
14729
|
return (config, arr)=>{
|
|
@@ -15116,7 +15451,8 @@
|
|
|
15116
15451
|
},
|
|
15117
15452
|
{
|
|
15118
15453
|
key: "shape",
|
|
15119
|
-
default: constant("Circle")
|
|
15454
|
+
default: constant("Circle"),
|
|
15455
|
+
coerce: "const"
|
|
15120
15456
|
},
|
|
15121
15457
|
{
|
|
15122
15458
|
key: "topojson",
|
|
@@ -15214,7 +15550,8 @@
|
|
|
15214
15550
|
},
|
|
15215
15551
|
{
|
|
15216
15552
|
key: "shape",
|
|
15217
|
-
default: constant("Line")
|
|
15553
|
+
default: constant("Line"),
|
|
15554
|
+
coerce: "const"
|
|
15218
15555
|
}
|
|
15219
15556
|
]
|
|
15220
15557
|
};
|
|
@@ -15478,6 +15815,7 @@
|
|
|
15478
15815
|
},
|
|
15479
15816
|
{
|
|
15480
15817
|
key: "label",
|
|
15818
|
+
coerce: "const",
|
|
15481
15819
|
factory: (viz)=>(d, i)=>`${getProp.bind(viz)("row", d, i)} / ${getProp.bind(viz)("column", d, i)}`
|
|
15482
15820
|
}
|
|
15483
15821
|
]
|
|
@@ -16183,7 +16521,8 @@
|
|
|
16183
16521
|
},
|
|
16184
16522
|
{
|
|
16185
16523
|
key: "shape",
|
|
16186
|
-
default: constant("Circle")
|
|
16524
|
+
default: constant("Circle"),
|
|
16525
|
+
coerce: "const"
|
|
16187
16526
|
},
|
|
16188
16527
|
{
|
|
16189
16528
|
key: "shapeConfig",
|
|
@@ -16416,6 +16755,7 @@
|
|
|
16416
16755
|
},
|
|
16417
16756
|
{
|
|
16418
16757
|
key: "legend",
|
|
16758
|
+
coerce: "const",
|
|
16419
16759
|
factory: (viz)=>{
|
|
16420
16760
|
const base = viz.schema.legend;
|
|
16421
16761
|
return (config, arr)=>{
|
|
@@ -16975,7 +17315,8 @@
|
|
|
16975
17315
|
},
|
|
16976
17316
|
{
|
|
16977
17317
|
key: "shape",
|
|
16978
|
-
default: constant("Path")
|
|
17318
|
+
default: constant("Path"),
|
|
17319
|
+
coerce: "const"
|
|
16979
17320
|
},
|
|
16980
17321
|
{
|
|
16981
17322
|
key: "value",
|
|
@@ -17219,6 +17560,7 @@
|
|
|
17219
17560
|
},
|
|
17220
17561
|
{
|
|
17221
17562
|
key: "label",
|
|
17563
|
+
coerce: "const",
|
|
17222
17564
|
factory: (viz)=>(d, i)=>`${getProp.bind(viz)("row", d, i)} / ${getProp.bind(viz)("column", d, i)}`
|
|
17223
17565
|
}
|
|
17224
17566
|
]
|
|
@@ -17937,7 +18279,8 @@
|
|
|
17937
18279
|
},
|
|
17938
18280
|
{
|
|
17939
18281
|
key: "shape",
|
|
17940
|
-
default: constant("Circle")
|
|
18282
|
+
default: constant("Circle"),
|
|
18283
|
+
coerce: "const"
|
|
17941
18284
|
},
|
|
17942
18285
|
{
|
|
17943
18286
|
key: "shapeConfig",
|
|
@@ -18259,7 +18602,8 @@
|
|
|
18259
18602
|
},
|
|
18260
18603
|
{
|
|
18261
18604
|
key: "shape",
|
|
18262
|
-
default: constant("Rect")
|
|
18605
|
+
default: constant("Rect"),
|
|
18606
|
+
coerce: "const"
|
|
18263
18607
|
},
|
|
18264
18608
|
{
|
|
18265
18609
|
key: "shapeConfig",
|
|
@@ -18643,7 +18987,8 @@
|
|
|
18643
18987
|
},
|
|
18644
18988
|
{
|
|
18645
18989
|
key: "shape",
|
|
18646
|
-
default: constant("Circle")
|
|
18990
|
+
default: constant("Circle"),
|
|
18991
|
+
coerce: "const"
|
|
18647
18992
|
},
|
|
18648
18993
|
{
|
|
18649
18994
|
key: "shapeConfig",
|
|
@@ -19017,6 +19362,7 @@
|
|
|
19017
19362
|
},
|
|
19018
19363
|
{
|
|
19019
19364
|
key: "legend",
|
|
19365
|
+
coerce: "const",
|
|
19020
19366
|
factory: (viz)=>{
|
|
19021
19367
|
const base = viz.schema.legend;
|
|
19022
19368
|
return (config, arr)=>{
|