@d3plus/core 4.3.0 → 4.5.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 +1820 -714
- package/es/index.js +1 -1
- package/es/index.js.map +1 -1
- package/es/internal.js +7 -1
- package/es/internal.js.map +1 -1
- package/es/src/charts/AreaPlot/index.js +1 -2
- package/es/src/charts/AreaPlot/index.js.map +1 -1
- package/es/src/charts/BarChart/index.js +1 -2
- package/es/src/charts/BarChart/index.js.map +1 -1
- package/es/src/charts/BoxWhisker/index.js +1 -2
- package/es/src/charts/BoxWhisker/index.js.map +1 -1
- package/es/src/charts/BumpChart/index.js +1 -2
- package/es/src/charts/BumpChart/index.js.map +1 -1
- package/es/src/charts/Chord/applyLayout.js +205 -0
- package/es/src/charts/Chord/applyLayout.js.map +1 -0
- package/es/src/charts/Chord/emit.js +168 -0
- package/es/src/charts/Chord/emit.js.map +1 -0
- package/es/src/charts/Chord/index.js +234 -0
- package/es/src/charts/Chord/index.js.map +1 -0
- package/es/src/charts/Geomap/basemapTheme.js +78 -0
- package/es/src/charts/Geomap/basemapTheme.js.map +1 -0
- package/es/src/charts/Geomap/emit.js +18 -9
- package/es/src/charts/Geomap/emit.js.map +1 -1
- package/es/src/charts/Geomap/index.js +69 -104
- package/es/src/charts/Geomap/index.js.map +1 -1
- package/es/src/charts/LinePlot/index.js +1 -2
- package/es/src/charts/LinePlot/index.js.map +1 -1
- package/es/src/charts/Matrix/emit.js +6 -0
- package/es/src/charts/Matrix/emit.js.map +1 -1
- package/es/src/charts/Matrix/index.js +1 -2
- package/es/src/charts/Matrix/index.js.map +1 -1
- package/es/src/charts/Network/emit.js +58 -24
- package/es/src/charts/Network/emit.js.map +1 -1
- package/es/src/charts/Network/index.js +34 -54
- package/es/src/charts/Network/index.js.map +1 -1
- package/es/src/charts/Pack/emit.js +3 -0
- package/es/src/charts/Pack/emit.js.map +1 -1
- package/es/src/charts/Pack/index.js +1 -2
- package/es/src/charts/Pack/index.js.map +1 -1
- package/es/src/charts/Pie/emit.js +6 -2
- package/es/src/charts/Pie/emit.js.map +1 -1
- package/es/src/charts/Pie/index.js +1 -2
- package/es/src/charts/Pie/index.js.map +1 -1
- package/es/src/charts/Plot/index.js +26 -6
- package/es/src/charts/Plot/index.js.map +1 -1
- package/es/src/charts/Plot/pipeline.js +1 -2
- package/es/src/charts/Plot/pipeline.js.map +1 -1
- package/es/src/charts/Plot/plotZoom.js +278 -0
- package/es/src/charts/Plot/plotZoom.js.map +1 -0
- package/es/src/charts/Priestley/emit.js +4 -0
- package/es/src/charts/Priestley/emit.js.map +1 -1
- package/es/src/charts/Priestley/index.js +1 -2
- package/es/src/charts/Priestley/index.js.map +1 -1
- package/es/src/charts/Radar/emit.js +4 -1
- package/es/src/charts/Radar/emit.js.map +1 -1
- package/es/src/charts/Radar/index.js +1 -2
- package/es/src/charts/Radar/index.js.map +1 -1
- package/es/src/charts/RadialMatrix/emit.js +6 -0
- package/es/src/charts/RadialMatrix/emit.js.map +1 -1
- package/es/src/charts/RadialMatrix/index.js +1 -2
- package/es/src/charts/RadialMatrix/index.js.map +1 -1
- package/es/src/charts/Rings/emit.js +74 -8
- package/es/src/charts/Rings/emit.js.map +1 -1
- package/es/src/charts/Rings/index.js +11 -3
- package/es/src/charts/Rings/index.js.map +1 -1
- package/es/src/charts/Sankey/emit.js +55 -11
- package/es/src/charts/Sankey/emit.js.map +1 -1
- package/es/src/charts/Sankey/index.js +8 -2
- package/es/src/charts/Sankey/index.js.map +1 -1
- package/es/src/charts/StackedArea/index.js +1 -2
- package/es/src/charts/StackedArea/index.js.map +1 -1
- package/es/src/charts/Tree/emit.js +8 -2
- package/es/src/charts/Tree/emit.js.map +1 -1
- package/es/src/charts/Tree/index.js +1 -2
- package/es/src/charts/Tree/index.js.map +1 -1
- package/es/src/charts/Treemap/index.js +1 -2
- package/es/src/charts/Treemap/index.js.map +1 -1
- package/es/src/charts/definition/ChartDefinition.js.map +1 -1
- package/es/src/charts/drawSteps/backControl.js +70 -0
- package/es/src/charts/drawSteps/backControl.js.map +1 -0
- package/es/src/charts/drawSteps/controlButtonStyle.js +108 -0
- package/es/src/charts/drawSteps/controlButtonStyle.js.map +1 -0
- package/es/src/charts/drawSteps/minimap.js +370 -0
- package/es/src/charts/drawSteps/minimap.js.map +1 -0
- package/es/src/charts/drawSteps/minimapMarkup.js +147 -0
- package/es/src/charts/drawSteps/minimapMarkup.js.map +1 -0
- package/es/src/charts/drawSteps/searchControls.js +358 -0
- package/es/src/charts/drawSteps/searchControls.js.map +1 -0
- package/es/src/charts/drawSteps/searchControlsMarkup.js +430 -0
- package/es/src/charts/drawSteps/searchControlsMarkup.js.map +1 -0
- package/es/src/charts/drawSteps/tableView.js +173 -0
- package/es/src/charts/drawSteps/tableView.js.map +1 -0
- package/es/src/charts/drawSteps/tableViewControl.js +39 -0
- package/es/src/charts/drawSteps/tableViewControl.js.map +1 -0
- package/es/src/charts/drawSteps/tableViewMarkup.js +647 -0
- package/es/src/charts/drawSteps/tableViewMarkup.js.map +1 -0
- package/es/src/charts/drawSteps/topLeftControls.js +73 -0
- package/es/src/charts/drawSteps/topLeftControls.js.map +1 -0
- package/es/src/charts/drawSteps/topLeftControlsMarkup.js +227 -0
- package/es/src/charts/drawSteps/topLeftControlsMarkup.js.map +1 -0
- package/es/src/charts/drawSteps/zoomControls.js +314 -175
- package/es/src/charts/drawSteps/zoomControls.js.map +1 -1
- package/es/src/charts/drawSteps/zoomControlsMarkup.js +280 -0
- package/es/src/charts/drawSteps/zoomControlsMarkup.js.map +1 -0
- package/es/src/charts/features/attributionFeature.js +137 -0
- package/es/src/charts/features/attributionFeature.js.map +1 -0
- package/es/src/charts/features/axes.js +20 -8
- package/es/src/charts/features/axes.js.map +1 -1
- package/es/src/charts/features/chartGeometry.js +16 -2
- package/es/src/charts/features/chartGeometry.js.map +1 -1
- package/es/src/charts/features/edgeArrows.js +155 -0
- package/es/src/charts/features/edgeArrows.js.map +1 -0
- package/es/src/charts/features/emitHelpers.js +8 -0
- package/es/src/charts/features/emitHelpers.js.map +1 -1
- package/es/src/charts/features/ensureZoomDom.js +63 -12
- package/es/src/charts/features/ensureZoomDom.js.map +1 -1
- package/es/src/charts/features/features.js +83 -110
- package/es/src/charts/features/features.js.map +1 -1
- package/es/src/charts/features/featuresLegend.js +45 -17
- package/es/src/charts/features/featuresLegend.js.map +1 -1
- package/es/src/charts/features/plotPaint.js +32 -7
- package/es/src/charts/features/plotPaint.js.map +1 -1
- package/es/src/charts/features/zoomExtent.js +185 -0
- package/es/src/charts/features/zoomExtent.js.map +1 -0
- package/es/src/charts/helpers/tileAttributions.js +26 -0
- package/es/src/charts/helpers/tileAttributions.js.map +1 -1
- package/es/src/charts/index.js +1 -0
- package/es/src/charts/index.js.map +1 -1
- package/es/src/charts/pipeline/runVizPipeline.js +33 -14
- package/es/src/charts/pipeline/runVizPipeline.js.map +1 -1
- package/es/src/charts/pipeline/vizDrawPure.js +32 -6
- package/es/src/charts/pipeline/vizDrawPure.js.map +1 -1
- package/es/src/charts/viz/Viz.js +39 -51
- package/es/src/charts/viz/Viz.js.map +1 -1
- package/es/src/charts/viz/VizBase.js +157 -4
- package/es/src/charts/viz/VizBase.js.map +1 -1
- package/es/src/charts/viz/VizBaseConfig.js +32 -2
- package/es/src/charts/viz/VizBaseConfig.js.map +1 -1
- package/es/src/charts/viz/vizDefaults.js +243 -50
- package/es/src/charts/viz/vizDefaults.js.map +1 -1
- package/es/src/charts/viz/vizTypes.js.map +1 -1
- package/es/src/components/Axis/Axis.js +10 -1
- package/es/src/components/Axis/Axis.js.map +1 -1
- package/es/src/components/Axis/axisLayoutLabels.js +2 -1
- package/es/src/components/Axis/axisLayoutLabels.js.map +1 -1
- package/es/src/components/Axis/axisRender.js +5 -1
- package/es/src/components/Axis/axisRender.js.map +1 -1
- package/es/src/components/Legend/legendConfig.js +86 -20
- package/es/src/components/Legend/legendConfig.js.map +1 -1
- package/es/src/utils/D3plusConfig.js.map +1 -1
- package/package.json +11 -10
- package/types/index.d.ts +1 -1
- package/types/internal.d.ts +8 -1
- package/types/src/charts/Chord/applyLayout.d.ts +43 -0
- package/types/src/charts/Chord/emit.d.ts +10 -0
- package/types/src/charts/Chord/index.d.ts +19 -0
- package/types/src/charts/Geomap/basemapTheme.d.ts +35 -0
- package/types/src/charts/Plot/index.d.ts +12 -3
- package/types/src/charts/Plot/plotZoom.d.ts +65 -0
- package/types/src/charts/definition/ChartDefinition.d.ts +3 -1
- package/types/src/charts/drawSteps/backControl.d.ts +29 -0
- package/types/src/charts/drawSteps/controlButtonStyle.d.ts +45 -0
- package/types/src/charts/drawSteps/minimap.d.ts +19 -0
- package/types/src/charts/drawSteps/minimapMarkup.d.ts +45 -0
- package/types/src/charts/drawSteps/searchControls.d.ts +3 -0
- package/types/src/charts/drawSteps/searchControlsMarkup.d.ts +111 -0
- package/types/src/charts/drawSteps/tableView.d.ts +23 -0
- package/types/src/charts/drawSteps/tableViewControl.d.ts +21 -0
- package/types/src/charts/drawSteps/tableViewMarkup.d.ts +119 -0
- package/types/src/charts/drawSteps/topLeftControls.d.ts +32 -0
- package/types/src/charts/drawSteps/topLeftControlsMarkup.d.ts +72 -0
- package/types/src/charts/drawSteps/zoomControls.d.ts +48 -8
- package/types/src/charts/drawSteps/zoomControlsMarkup.d.ts +138 -0
- package/types/src/charts/features/attributionFeature.d.ts +21 -0
- package/types/src/charts/features/axes.d.ts +1 -1
- package/types/src/charts/features/chartGeometry.d.ts +9 -3
- package/types/src/charts/features/edgeArrows.d.ts +92 -0
- package/types/src/charts/features/emitHelpers.d.ts +11 -0
- package/types/src/charts/features/ensureZoomDom.d.ts +6 -2
- package/types/src/charts/features/features.d.ts +32 -17
- package/types/src/charts/features/featuresLegend.d.ts +15 -0
- package/types/src/charts/features/plotPaint.d.ts +15 -2
- package/types/src/charts/features/zoomExtent.d.ts +25 -0
- package/types/src/charts/index.d.ts +1 -0
- package/types/src/charts/pipeline/runVizPipeline.d.ts +6 -3
- package/types/src/charts/viz/VizBase.d.ts +86 -4
- package/types/src/charts/viz/VizBaseConfig.d.ts +20 -2
- package/types/src/charts/viz/vizDefaults.d.ts +155 -0
- package/types/src/charts/viz/vizTypes.d.ts +57 -1
- package/types/src/components/Axis/Axis.d.ts +2 -0
- package/types/src/utils/D3plusConfig.d.ts +102 -8
- package/umd/d3plus-core.full.js +39613 -35374
- package/umd/d3plus-core.full.js.map +1 -1
- package/umd/d3plus-core.full.min.js +5747 -4361
- package/umd/d3plus-core.js +13132 -9289
- package/umd/d3plus-core.js.map +1 -1
- package/umd/d3plus-core.min.js +3658 -2302
|
@@ -3,6 +3,90 @@ import { colorContrast } from "@d3plus/color";
|
|
|
3
3
|
import { backgroundColor } from "@d3plus/dom";
|
|
4
4
|
import { accessor, constant } from "../../utils/index.js";
|
|
5
5
|
var padding = 5;
|
|
6
|
+
var positionCache = new WeakMap();
|
|
7
|
+
/**
|
|
8
|
+
Every swatch's x/y position, computed in one pass and cached until the
|
|
9
|
+
legend's layout changes. Scene repaints (hover, zoom) re-walk the swatch
|
|
10
|
+
accessors, and resolving each item against its whole row made that
|
|
11
|
+
quadratic in the number of legend items.
|
|
12
|
+
*/ function legendPositions(legend) {
|
|
13
|
+
var lineData = legend._lineData;
|
|
14
|
+
var _legend_schema = legend.schema, align = _legend_schema.align, direction = _legend_schema.direction, pad = _legend_schema.padding;
|
|
15
|
+
var bounds = legend._outerBounds;
|
|
16
|
+
var deps = [
|
|
17
|
+
lineData,
|
|
18
|
+
legend._data,
|
|
19
|
+
bounds.x,
|
|
20
|
+
bounds.y,
|
|
21
|
+
bounds.width,
|
|
22
|
+
legend._titleHeight,
|
|
23
|
+
legend._rtl,
|
|
24
|
+
align,
|
|
25
|
+
direction,
|
|
26
|
+
pad
|
|
27
|
+
];
|
|
28
|
+
var cached = positionCache.get(legend);
|
|
29
|
+
if (cached && cached.deps.every(function(v, i) {
|
|
30
|
+
return v === deps[i];
|
|
31
|
+
})) return cached;
|
|
32
|
+
// Each row's items (in legend order), total width, and tallest label.
|
|
33
|
+
var rows = new Map();
|
|
34
|
+
lineData.forEach(function(l) {
|
|
35
|
+
var row = rows.get(l.y);
|
|
36
|
+
if (row) row.push(l);
|
|
37
|
+
else rows.set(l.y, [
|
|
38
|
+
l
|
|
39
|
+
]);
|
|
40
|
+
});
|
|
41
|
+
var rowWidths = new Map();
|
|
42
|
+
var rowHeights = new Map();
|
|
43
|
+
rows.forEach(function(row, y) {
|
|
44
|
+
rowWidths.set(y, legend._rowWidth(row));
|
|
45
|
+
rowHeights.set(y, max(row.map(function(l) {
|
|
46
|
+
return l.height;
|
|
47
|
+
})));
|
|
48
|
+
});
|
|
49
|
+
var dataHeight = max(legend._data.map(function(l, x) {
|
|
50
|
+
return legend._fetchConfig("height", l, x);
|
|
51
|
+
}));
|
|
52
|
+
// Running `_rowWidth` of the items before each one in its row: the sum of
|
|
53
|
+
// their shape + label widths, plus the padding after every one but the last.
|
|
54
|
+
var running = new Map();
|
|
55
|
+
var x = [];
|
|
56
|
+
var y = [];
|
|
57
|
+
lineData.forEach(function(datum) {
|
|
58
|
+
var rowY = datum.y;
|
|
59
|
+
var rowWidth = rowWidths.get(rowY);
|
|
60
|
+
var offset = align === "left" || align === "right" && direction === "column" ? 0 : align === "center" ? (bounds.width - rowWidth) / 2 : bounds.width - rowWidth;
|
|
61
|
+
var r = running.get(rowY) || {
|
|
62
|
+
widths: 0,
|
|
63
|
+
pads: 0,
|
|
64
|
+
last: 0,
|
|
65
|
+
count: 0
|
|
66
|
+
};
|
|
67
|
+
var prevWidth = r.count ? r.widths + pad * (r.pads - r.last) : 0;
|
|
68
|
+
var rtlMod = legend._rtl ? datum.width + pad : 0;
|
|
69
|
+
x.push(prevWidth + pad * (r.count ? datum.sentence ? 2 : 1 : 0) + bounds.x + datum.shapeWidth / 2 + offset + rtlMod);
|
|
70
|
+
y.push(rowY + legend._titleHeight + bounds.y + max([
|
|
71
|
+
rowHeights.get(rowY),
|
|
72
|
+
dataHeight
|
|
73
|
+
]) / 2);
|
|
74
|
+
var factor = datum.width ? 2 : 1;
|
|
75
|
+
running.set(rowY, {
|
|
76
|
+
widths: r.widths + datum.shapeWidth + datum.width,
|
|
77
|
+
pads: r.pads + factor,
|
|
78
|
+
last: factor,
|
|
79
|
+
count: r.count + 1
|
|
80
|
+
});
|
|
81
|
+
});
|
|
82
|
+
var positions = {
|
|
83
|
+
deps: deps,
|
|
84
|
+
x: x,
|
|
85
|
+
y: y
|
|
86
|
+
};
|
|
87
|
+
positionCache.set(legend, positions);
|
|
88
|
+
return positions;
|
|
89
|
+
}
|
|
6
90
|
/**
|
|
7
91
|
Builds the Legend's default `shapeConfig` object. The accessors close over
|
|
8
92
|
the `legend` instance so they read live `_lineData` / `_outerBounds` /
|
|
@@ -58,28 +142,10 @@ var padding = 5;
|
|
|
58
142
|
r: constant(6),
|
|
59
143
|
width: constant(12),
|
|
60
144
|
x: function x(d, i) {
|
|
61
|
-
|
|
62
|
-
var y = datum.y;
|
|
63
|
-
var pad = legend.schema.align === "left" || legend.schema.align === "right" && legend.schema.direction === "column" ? 0 : legend.schema.align === "center" ? (legend._outerBounds.width - legend._rowWidth(legend._lineData.filter(function(l) {
|
|
64
|
-
return y === l.y;
|
|
65
|
-
}))) / 2 : legend._outerBounds.width - legend._rowWidth(legend._lineData.filter(function(l) {
|
|
66
|
-
return y === l.y;
|
|
67
|
-
}));
|
|
68
|
-
var prevWords = legend._lineData.slice(0, i).filter(function(l) {
|
|
69
|
-
return y === l.y;
|
|
70
|
-
});
|
|
71
|
-
var rtlMod = legend._rtl ? datum.width + legend.schema.padding : 0;
|
|
72
|
-
return legend._rowWidth(prevWords) + legend.schema.padding * (prevWords.length ? datum.sentence ? 2 : 1 : 0) + legend._outerBounds.x + datum.shapeWidth / 2 + pad + rtlMod;
|
|
145
|
+
return legendPositions(legend).x[i];
|
|
73
146
|
},
|
|
74
147
|
y: function y(d, i) {
|
|
75
|
-
|
|
76
|
-
return ld.y + legend._titleHeight + legend._outerBounds.y + max(legend._lineData.filter(function(l) {
|
|
77
|
-
return ld.y === l.y;
|
|
78
|
-
}).map(function(l) {
|
|
79
|
-
return l.height;
|
|
80
|
-
}).concat(legend._data.map(function(l, x) {
|
|
81
|
-
return legend._fetchConfig("height", l, x);
|
|
82
|
-
}))) / 2;
|
|
148
|
+
return legendPositions(legend).y[i];
|
|
83
149
|
}
|
|
84
150
|
};
|
|
85
151
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/components/Legend/legendConfig.ts"],"sourcesContent":["import {max} from \"d3-array\";\n\nimport {colorContrast} from \"@d3plus/color\";\nimport type {DataPoint} from \"@d3plus/data\";\nimport {backgroundColor} from \"@d3plus/dom\";\n\nimport {accessor, constant} from \"../../utils/index.js\";\n\nimport type Legend from \"./Legend.js\";\n\nconst padding = 5;\n\n/**\n Builds the Legend's default `shapeConfig` object. The accessors close over\n the `legend` instance so they read live `_lineData` / `_outerBounds` /\n `_rtl` / `_titleHeight` state during render.\n*/\nexport function buildLegendShapeConfig(legend: Legend): Record<string, unknown> {\n return {\n fill: accessor(\"color\"),\n height: constant(12),\n hitArea: (dd: DataPoint, i: number) => {\n const d = legend._lineData[i],\n h = max([d.height as number, d.shapeHeight as number]);\n return {\n width: (d.width as number) + (d.shapeWidth as number),\n height: h,\n x: -(d.shapeWidth as number) / 2,\n y: -h! / 2,\n };\n },\n labelBounds: (dd: DataPoint, i: number) => {\n const d = legend._lineData[i];\n let x = (d.shapeWidth as number) / 2;\n if (d.shape === \"Circle\") x -= (d.shapeR as number) / 2;\n const height = max([d.shapeHeight as number, d.height as number]);\n const rtlMod = legend._rtl\n ? (d.shapeWidth as number) + (d.width as number) + legend.schema.padding * 2\n : 0;\n return {\n width: d.width as number,\n height,\n x: x + padding - rtlMod,\n y: -height! / 2,\n };\n },\n labelConfig: {\n fontColor: () => {\n const bg = legend._select ? backgroundColor(legend._select.node()) : \"rgb(255, 255, 255)\";\n return colorContrast(bg);\n },\n fontFamily: legend._titleClass.fontFamily(),\n fontResize: false,\n fontSize: constant(10),\n // The swatch's `hitArea` already spans the label, so let it own pointer\n // events for the whole item. A bare label would carry a different scene\n // key than its swatch, so hovering across the swatch→label padding would\n // otherwise read as leaving one item and entering another.\n pointerEvents: constant(\"none\"),\n verticalAlign: \"middle\",\n },\n opacity: 1,\n r: constant(6),\n width: constant(12),\n x: (d: DataPoint, i: number) => {\n const datum = legend._lineData[i];\n const y = datum.y;\n const pad =\n legend.schema.align === \"left\" ||\n (legend.schema.align === \"right\" && legend.schema.direction === \"column\")\n ? 0\n : legend.schema.align === \"center\"\n ? (legend._outerBounds.width -\n legend._rowWidth(\n legend._lineData.filter(\n (l: Record<string, unknown>) => y === l.y,\n ),\n )) /\n 2\n : legend._outerBounds.width -\n legend._rowWidth(\n legend._lineData.filter((l: Record<string, unknown>) => y === l.y),\n );\n const prevWords = legend._lineData\n .slice(0, i)\n .filter((l: Record<string, unknown>) => y === l.y);\n const rtlMod = legend._rtl ? (datum.width as number) + legend.schema.padding : 0;\n return (\n legend._rowWidth(prevWords) +\n legend.schema.padding * (prevWords.length ? (datum.sentence ? 2 : 1) : 0) +\n legend._outerBounds.x +\n (datum.shapeWidth as number) / 2 +\n pad +\n rtlMod\n );\n },\n y: (d: DataPoint, i: number) => {\n const ld = legend._lineData[i];\n return (\n (ld.y as number) +\n legend._titleHeight +\n legend._outerBounds.y +\n max(\n legend._lineData\n .filter((l: Record<string, unknown>) => ld.y === l.y)\n .map((l: Record<string, unknown>) => l.height as number)\n .concat(\n legend._data.map((l: DataPoint, x: number) =>\n legend._fetchConfig(\"height\", l, x) as number,\n ),\n ),\n )! /\n 2\n );\n },\n };\n}\n"],"names":["max","colorContrast","backgroundColor","accessor","constant","padding","buildLegendShapeConfig","legend","fill","height","hitArea","dd","i","d","_lineData","h","shapeHeight","width","shapeWidth","x","y","labelBounds","shape","shapeR","rtlMod","_rtl","schema","labelConfig","fontColor","bg","_select","node","fontFamily","_titleClass","fontResize","fontSize","pointerEvents","verticalAlign","opacity","r","datum","pad","align","direction","_outerBounds","_rowWidth","filter","l","prevWords","slice","length","sentence","ld","_titleHeight","map","concat","_data","_fetchConfig"],"mappings":"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"}
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/Legend/legendConfig.ts"],"sourcesContent":["import {max} from \"d3-array\";\n\nimport {colorContrast} from \"@d3plus/color\";\nimport type {DataPoint} from \"@d3plus/data\";\nimport {backgroundColor} from \"@d3plus/dom\";\n\nimport {accessor, constant} from \"../../utils/index.js\";\n\nimport type Legend from \"./Legend.js\";\n\nconst padding = 5;\n\ntype Row = Record<string, unknown>;\n\ninterface LegendPositions {\n deps: unknown[];\n x: number[];\n y: number[];\n}\n\nconst positionCache = new WeakMap<Legend, LegendPositions>();\n\n/**\n Every swatch's x/y position, computed in one pass and cached until the\n legend's layout changes. Scene repaints (hover, zoom) re-walk the swatch\n accessors, and resolving each item against its whole row made that\n quadratic in the number of legend items.\n*/\nfunction legendPositions(legend: Legend): LegendPositions {\n const lineData = legend._lineData as Row[];\n const {align, direction, padding: pad} = legend.schema;\n const bounds = legend._outerBounds;\n const deps = [\n lineData, legend._data, bounds.x, bounds.y, bounds.width,\n legend._titleHeight, legend._rtl, align, direction, pad,\n ];\n const cached = positionCache.get(legend);\n if (cached && cached.deps.every((v, i) => v === deps[i])) return cached;\n\n // Each row's items (in legend order), total width, and tallest label.\n const rows = new Map<unknown, Row[]>();\n lineData.forEach(l => {\n const row = rows.get(l.y);\n if (row) row.push(l);\n else rows.set(l.y, [l]);\n });\n const rowWidths = new Map<unknown, number>();\n const rowHeights = new Map<unknown, number>();\n rows.forEach((row, y) => {\n rowWidths.set(y, legend._rowWidth(row));\n rowHeights.set(y, max(row.map(l => l.height as number))!);\n });\n const dataHeight = max(\n legend._data.map((l: DataPoint, x: number) => legend._fetchConfig(\"height\", l, x) as number),\n );\n\n // Running `_rowWidth` of the items before each one in its row: the sum of\n // their shape + label widths, plus the padding after every one but the last.\n const running = new Map<unknown, {widths: number; pads: number; last: number; count: number}>();\n const x: number[] = [];\n const y: number[] = [];\n lineData.forEach(datum => {\n const rowY = datum.y;\n const rowWidth = rowWidths.get(rowY)!;\n const offset =\n align === \"left\" || (align === \"right\" && direction === \"column\")\n ? 0\n : align === \"center\"\n ? (bounds.width - rowWidth) / 2\n : bounds.width - rowWidth;\n const r = running.get(rowY) || {widths: 0, pads: 0, last: 0, count: 0};\n const prevWidth = r.count ? r.widths + pad * (r.pads - r.last) : 0;\n const rtlMod = legend._rtl ? (datum.width as number) + pad : 0;\n x.push(\n prevWidth +\n pad * (r.count ? (datum.sentence ? 2 : 1) : 0) +\n bounds.x +\n (datum.shapeWidth as number) / 2 +\n offset +\n rtlMod,\n );\n y.push(\n (rowY as number) +\n legend._titleHeight +\n bounds.y +\n max([rowHeights.get(rowY)!, dataHeight!])! / 2,\n );\n const factor = datum.width ? 2 : 1;\n running.set(rowY, {\n widths: r.widths + (datum.shapeWidth as number) + (datum.width as number),\n pads: r.pads + factor,\n last: factor,\n count: r.count + 1,\n });\n });\n\n const positions = {deps, x, y};\n positionCache.set(legend, positions);\n return positions;\n}\n\n/**\n Builds the Legend's default `shapeConfig` object. The accessors close over\n the `legend` instance so they read live `_lineData` / `_outerBounds` /\n `_rtl` / `_titleHeight` state during render.\n*/\nexport function buildLegendShapeConfig(legend: Legend): Record<string, unknown> {\n return {\n fill: accessor(\"color\"),\n height: constant(12),\n hitArea: (dd: DataPoint, i: number) => {\n const d = legend._lineData[i],\n h = max([d.height as number, d.shapeHeight as number]);\n return {\n width: (d.width as number) + (d.shapeWidth as number),\n height: h,\n x: -(d.shapeWidth as number) / 2,\n y: -h! / 2,\n };\n },\n labelBounds: (dd: DataPoint, i: number) => {\n const d = legend._lineData[i];\n let x = (d.shapeWidth as number) / 2;\n if (d.shape === \"Circle\") x -= (d.shapeR as number) / 2;\n const height = max([d.shapeHeight as number, d.height as number]);\n const rtlMod = legend._rtl\n ? (d.shapeWidth as number) + (d.width as number) + legend.schema.padding * 2\n : 0;\n return {\n width: d.width as number,\n height,\n x: x + padding - rtlMod,\n y: -height! / 2,\n };\n },\n labelConfig: {\n fontColor: () => {\n const bg = legend._select ? backgroundColor(legend._select.node()) : \"rgb(255, 255, 255)\";\n return colorContrast(bg);\n },\n fontFamily: legend._titleClass.fontFamily(),\n fontResize: false,\n fontSize: constant(10),\n // The swatch's `hitArea` already spans the label, so let it own pointer\n // events for the whole item. A bare label would carry a different scene\n // key than its swatch, so hovering across the swatch→label padding would\n // otherwise read as leaving one item and entering another.\n pointerEvents: constant(\"none\"),\n verticalAlign: \"middle\",\n },\n opacity: 1,\n r: constant(6),\n width: constant(12),\n x: (d: DataPoint, i: number) => legendPositions(legend).x[i],\n y: (d: DataPoint, i: number) => legendPositions(legend).y[i],\n };\n}\n"],"names":["max","colorContrast","backgroundColor","accessor","constant","padding","positionCache","WeakMap","legendPositions","legend","lineData","_lineData","schema","align","direction","pad","bounds","_outerBounds","deps","_data","x","y","width","_titleHeight","_rtl","cached","get","every","v","i","rows","Map","forEach","l","row","push","set","rowWidths","rowHeights","_rowWidth","map","height","dataHeight","_fetchConfig","running","datum","rowY","rowWidth","offset","r","widths","pads","last","count","prevWidth","rtlMod","sentence","shapeWidth","factor","positions","buildLegendShapeConfig","fill","hitArea","dd","d","h","shapeHeight","labelBounds","shape","shapeR","labelConfig","fontColor","bg","_select","node","fontFamily","_titleClass","fontResize","fontSize","pointerEvents","verticalAlign","opacity"],"mappings":"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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/utils/D3plusConfig.ts"],"sourcesContent":["import type {DataPoint} from \"@d3plus/data\";\n\nimport type VizBase from \"../charts/viz/VizBase.js\";\nimport type {AccessorFn} from \"./AccessorFn.js\";\n\ntype Position = \"top\" | \"right\" | \"bottom\" | \"left\";\n\ntype DataPointAccessor<T> = string | ((d: DataPoint) => T);\n\n/** A config value that is either a constant or a `(datum, index)` accessor. */\ntype Accessor<T> = T | ((d: DataPoint, i?: number) => T);\n\ntype AxisScale =\n | \"auto\"\n | \"band\"\n | \"diverging\"\n | \"divergingLog\"\n | \"divergingPow\"\n | \"divergingSqrt\"\n | \"divergingSymlog\"\n | \"identity\"\n | \"implicit\"\n | \"jenks\"\n | \"linear\"\n | \"log\"\n | \"ordinal\"\n | \"point\"\n | \"pow\"\n | \"quantile\"\n | \"quantize\"\n | \"radial\"\n | \"sequential\"\n | \"sequentialLog\"\n | \"sequentialPow\"\n | \"sequentialQuantile\"\n | \"sequentialSqrt\"\n | \"sequentialSymlog\"\n | \"sqrt\"\n | \"symlog\"\n | \"threshold\"\n | \"time\"\n | \"utc\";\n\nexport interface AxisConfig {\n barConfig?: Record<string, string | number>;\n /** Grid values of the axis. */\n grid?: unknown[];\n gridConfig?: Record<string, string | number>;\n /** Grid size of the axis. */\n gridSize?: number;\n label?: string;\n /** Visible tick labels of the axis. */\n labels?: unknown[];\n labelOffset?: false | number;\n /** Maximum size allowed for the space that contains the axis tick labels and title. */\n maxSize?: number;\n /** Minimum size alloted for the space that contains the axis tick labels and title. */\n minSize?: number;\n /**\n Scale range (in pixels) of the axis. The given array must have 2 values,\n but one may be `undefined` to allow the default behavior for that value.\n */\n range?: (number | undefined)[];\n /** Scale of the axis. */\n scale?: AxisScale;\n /** Tick formatter. */\n tickFormat?: (d: number | string) => string | number;\n /** Tick values of the axis. */\n ticks?: unknown[];\n tickSize?: number;\n /**\n Defines a custom locale object to be used in time scales. Must include\n `dateTime`, `date`, `time`, `periods`, `days`, `shortDays`, `months`, and\n `shortMonths` (see\n [d3-time-format](https://github.com/d3/d3-time-format/blob/master/README.md#timeFormatLocale)).\n */\n timeLocale?: Record<string, unknown>;\n /** Title of the axis. */\n title?: string;\n}\n\nexport interface TooltipConfig {\n /** The inner HTML content of the arrow element, empty by default. */\n arrow?: ((d: DataPoint) => string) | string;\n /** The background color accessor for each tooltip. */\n background?: ((d: DataPoint) => string) | string;\n /** The border accessor for each tooltip. */\n border?: ((d: DataPoint) => string) | string;\n /** The border-radius accessor for each tooltip. */\n borderRadius?: ((d: DataPoint) => string) | string;\n /** The footer content accessor for each tooltip. */\n footer?: ((d: DataPoint) => string) | string;\n /** The max-width accessor for each tooltip. */\n maxWidth?: ((d: DataPoint) => string | number) | string | number;\n /** The min-width accessor for each tooltip. */\n minWidth?: ((d: DataPoint) => string | number) | string | number;\n /** The pixel offset between the tooltip and its anchor point. */\n offset?: ((d: DataPoint) => number) | number;\n /** The inner padding of each tooltip. */\n padding?: ((d: DataPoint) => string | number) | string | number;\n title?: ((d: DataPoint) => string) | string;\n body?: ((d: DataPoint) => string) | string;\n thead?:\n | ((d: DataPoint) => [string, string][])\n | Array<\n Array<\n | ((d: DataPoint, i?: number, x?: {share: number}) => string)\n | string\n >\n >;\n tbody?:\n | ((d: DataPoint) => [string, string][])\n | Array<\n Array<\n | ((d: DataPoint, i?: number, x?: {share: number}) => string)\n | string\n >\n >;\n}\n\nexport interface TextBoxConfig {\n /** The text content for each box. */\n text?: Accessor<string>;\n /** The font color as an accessor function or static string. Inferred from the DOM selection by default. */\n fontColor?: Accessor<string>;\n /** The font size in pixels. Inferred from the DOM selection by default. */\n fontSize?: Accessor<number>;\n /**\n The font-family to use: a font name, a comma-separated list of fallbacks,\n an array of fallbacks, or an accessor returning a string or array. The\n first available font on the client is used.\n */\n fontFamily?: Accessor<string | string[]>;\n /** The font weight. Inferred from the DOM selection by default. */\n fontWeight?: Accessor<string | number>;\n /** The minimum font size in pixels, used when dynamically resizing fonts. */\n fontMin?: number;\n /** The maximum font size in pixels, used when dynamically resizing fonts. */\n fontMax?: number;\n /** Toggles font resizing — a static boolean, or an accessor returning a boolean. */\n fontResize?: Accessor<boolean>;\n /** The font opacity as an accessor function or static number between 0 and 1. */\n fontOpacity?: Accessor<number>;\n /** The font stroke color for the rendered text. */\n fontStroke?: Accessor<string>;\n /** The font stroke width for the rendered text. */\n fontStrokeWidth?: Accessor<number>;\n /** The line height, which is 1.2 times the font size by default. */\n lineHeight?: Accessor<number>;\n /** Restricts the maximum number of lines to wrap onto; null (unlimited) by default. */\n maxLines?: Accessor<number | null>;\n /** Whether text is allowed to overflow its bounding box. */\n overflow?: Accessor<boolean>;\n /**\n Handles truncated lines, returning the new line value. Passed the line's\n text and number; by default appends an ellipsis to every line except a\n first word that cannot fit (which returns \"\").\n */\n ellipsis?: (text: string, line: number) => string;\n /** The padding as a CSS shorthand string or number. Defaults to 0. */\n padding?: Accessor<string | number>;\n /** The anchor point around which to rotate the text box. */\n rotateAnchor?: Accessor<[number, number]>;\n /** The word split function: given a string, returns it split into an array of words. */\n split?: (text: string) => string[];\n /** The width for each text box. */\n width?: Accessor<number>;\n /** The height for each text box. */\n height?: Accessor<number>;\n /** The x position (left edge) for each text box. */\n x?: Accessor<number>;\n /** The y position (top edge) for each text box. */\n y?: Accessor<number>;\n}\n\nexport interface TimelineConfig {\n /** Brush event filter. */\n brushFilter?: () => boolean;\n /**\n The minimum number of ticks that can be highlighted when using \"ticks\"\n `buttonBehavior`. Helpful for x/y plots where selecting fewer than 2 time\n periods is undesirable.\n */\n brushMin?: number;\n /** Toggles the horizontal alignment of the button timeline. */\n buttonAlign?: \"start\" | \"middle\" | \"end\";\n /** Toggles the style of the timeline. */\n buttonBehavior?: \"auto\" | \"buttons\" | \"ticks\";\n /** Button height. */\n buttonHeight?: number;\n /** Button padding. */\n buttonPadding?: number;\n /** Handle style. */\n handleConfig?: Record<string, unknown>;\n /** Handle size. */\n handleSize?: number;\n /**\n Determines the visibility of the play button to the left of the timeline,\n which cycles through the available periods at a rate set by `playButtonInterval`.\n */\n playButton?: boolean;\n /**\n The interval, in milliseconds, between periods when cycling via the play\n button. Used only when the chart's `duration` is 0 (no transition);\n otherwise playback steps once per `duration` so each step animates in full.\n */\n playButtonInterval?: number;\n /** The current selection. Defaults to the most recent period in the timeline. */\n selection?: (Date | number)[] | Date | number | false;\n /** Toggles the snapping value. */\n snapping?: boolean;\n}\n\nexport interface LegendConfig {\n /** The active method for all shapes. */\n active?: ((d: DataPoint, i?: number) => boolean) | false;\n /** The hover method for all shapes. */\n hover?: ((d: DataPoint, i?: number) => boolean) | false;\n /** The shape type used for each legend entry. */\n shape?: Accessor<string>;\n}\n\nexport interface ColorScaleConfig {\n /**\n For a linear scale, the `[min, max]` values used by the color scale; values\n outside this range map to the nearest color.\n */\n domain?: number[];\n /**\n Formats the label for each bucket in a bucket-type scale (\"jenks\",\n \"quantile\", …). Passed the bucket's start value, its index, the full\n bucket array, and every data value used to build the buckets.\n */\n bucketFormat?: (\n start: number,\n i: number,\n buckets: number[],\n values: number[],\n ) => string;\n /** Given a bucket's minimum and maximum values, returns the full label. */\n bucketJoiner?: (min: string, max: string) => string;\n}\n\nexport interface D3plusConfig {\n /** Data array or URL string to load data from. */\n data?: DataPoint[] | string;\n /** Locale code used for text and number formatting. */\n locale?: string;\n\n /** The active callback function for highlighting shapes. */\n active?: ((d: DataPoint, i: number) => boolean) | false | null;\n /** Custom aggregation functions keyed by data property. */\n aggs?: {[k: string]: (d: DataPoint[]) => unknown};\n /** Hides the SVG from assistive technology when true (`aria-hidden`). */\n ariaHidden?: boolean;\n /** Padding between bars in pixels. */\n barPadding?: number;\n /** The baseline for the x/y plot. */\n baseline?: number;\n /** Whether to cache the processed data between renders. */\n cache?: boolean;\n /** Treat a discrete color field as ordered: color it with a single-hue light→dark ramp instead of nominal categorical hues. */\n colorOrdinal?: boolean;\n /** Color scale key or custom color function. */\n colorScale?: string | ((d: number) => string);\n /** Configuration for the color scale component. */\n colorScaleConfig?: {\n axisConfig?: AxisConfig;\n centered?: boolean;\n colors?: string[];\n colorMin?: string;\n colorMid?: string;\n colorMax?: string;\n scale?: AxisScale;\n };\n /** Whether the color scale uses the visualization's internal padding when positioning, or an accessor receiving the viz. */\n colorScalePadding?: boolean | ((viz: VizBase) => boolean);\n /** Position of the color scale, `false` to hide it, or an accessor returning either. */\n colorScalePosition?: false | Position | (() => false | Position);\n /** Column key for matrix-style layouts. */\n column?: string;\n /**\n The confidence interval as `[lower, upper]` bounds — each given as an\n accessor function or a static data key (e.g. `[\"lci\", \"hci\"]`), or `false`\n to disable.\n */\n confidence?:\n | [\n string | ((d: DataPoint, i: number) => number),\n string | ((d: DataPoint, i: number) => number),\n ]\n | false;\n /** Maximum number of data points to render before downsampling. */\n dataCutoff?: number;\n /** Active depth level for nested groupings. */\n depth?: number;\n /** Sets orientation of main category axis. */\n discrete?: \"x\" | \"y\";\n /** Default duration of transitions, in milliseconds. */\n duration?: number;\n /** Predicate filtering which data points are included, or false to disable. */\n filter?: ((d: DataPoint, i: number) => boolean) | false;\n /** Allows removing specific geographies from topojson file to improve zoom. */\n fitFilter?:\n | number\n | string\n | ((d: Record<string, unknown>) => boolean);\n /** Grouping key(s) or accessor function(s). */\n groupBy?:\n | string\n | string[]\n | ((d: DataPoint) => string | number)\n | ((d: DataPoint) => string | number)[];\n /** Padding between groups of bars in pixels. */\n groupPadding?: number;\n /** Overall height of the visualization in pixels. */\n height?: number;\n /** Color for legend shapes whose grouping is hidden (via legend click), or a `(datum, index)` accessor. */\n hiddenColor?: string | ((d: DataPoint, i: number) => string);\n /** Opacity for legend labels whose grouping is hidden (via legend click), or a `(datum, index)` accessor. */\n hiddenOpacity?: number | ((d: DataPoint, i: number) => number);\n /** The hover callback function for highlighting shapes on mouseover. */\n hover?: ((d: DataPoint, i: number) => boolean) | false | null;\n /** Persistently emphasizes matching marks (keep color) and grays the rest. */\n highlight?: ((d: DataPoint, i: number) => boolean) | false | null;\n /** Label accessor for shapes. */\n label?: string | string[] | false | AccessorFn;\n /**\n Controls legend visibility. Pass `false` to hide it, `true` to always\n show it, or a `(config, data) => boolean` accessor to decide dynamically\n — the chart defaults use an accessor to auto-hide the legend when it\n would be redundant.\n */\n legend?: boolean | ((config: D3plusConfig, arr: DataPoint[]) => boolean);\n /** Configuration for the legend component. */\n legendConfig?: {\n label?: DataPointAccessor<string>;\n shapeConfig?: Record<string, string | number>;\n };\n /** Inverts legend click behavior (click hides / shift-click solos, or the reverse), or an accessor receiving the viz. */\n legendFilterInvert?: boolean | ((viz: VizBase) => boolean);\n /** Whether the legend uses the visualization's internal padding when positioning, or an accessor receiving the viz. */\n legendPadding?: boolean | ((viz: VizBase) => boolean);\n /** Position of the legend, or an accessor returning it. */\n legendPosition?: Position | (() => Position);\n /** Custom sort comparator for legend items. */\n legendSort?: (a: DataPoint, b: DataPoint) => number;\n /** Tooltip configuration for legend items. */\n legendTooltip?: TooltipConfig;\n /** Whether to show labels on line charts. */\n lineLabels?: boolean;\n /** Whether to show the loading message. */\n loadingMessage?: boolean;\n /** Custom HTML content for the loading indicator, or a function receiving the viz instance. */\n loadingHTML?: string | ((viz: VizBase) => string);\n /** Metric key for the visualization. */\n metric?: string;\n /** Custom HTML content shown when no data is supplied, or a function receiving the viz instance. */\n noDataHTML?: string | ((viz: VizBase) => string);\n /** Ocean color for geomaps (any CSS value including 'transparent'). */\n ocean?: string;\n /** Event listeners keyed by event name. */\n on?: Record<string, (event: Event) => void>;\n /** Coordinate accessor for point-based geomaps. */\n point?: (d: DataPoint) => number[];\n /** Point size accessor for geomaps. */\n pointSize?: string | ((d: DataPoint) => number);\n /** Minimum point size for geomaps. */\n pointSizeMin?: number;\n /** Maximum point size for geomaps. */\n pointSizeMax?: number;\n /** Map projection name or function. */\n projection?: string | ((x: number, y: number) => [number, number]);\n /** Outer padding between the visualization edge and map shapes. */\n projectionPadding?: number | string;\n /** Rotation offset for the map projection center. */\n projectionRotate?: [number, number];\n /** Row key for matrix-style layouts. */\n row?: string;\n /** Scrollable container selector for tooltip positioning. */\n scrollContainer?: string | Window;\n /** Configuration for shape rendering. */\n shapeConfig?: {\n duration?: number;\n [key: string]: unknown;\n };\n /**\n A [sort comparator](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort)\n that receives each shape class (e.g. \"Circle\", \"Line\") as its arguments.\n Shapes are drawn in groups by type, so this defines the layering order for\n all shapes of a given type.\n */\n shapeSort?: (a: string, b: string) => number;\n /** Size accessor key. */\n size?: string;\n /** Whether to stack series. */\n stacked?: boolean;\n /**\n Vertical offset applied to stacked series. One of `\"diverging\"`\n (default — positive and negative values split around zero), `\"none\"`,\n `\"expand\"` (normalize each stack to 100%), `\"silhouette\"` (streamgraph),\n or `\"wiggle\"` (minimize slope changes); or a custom offset function.\n */\n stackOffset?: string | ((series: number[][][], order: number[]) => void);\n /**\n Order of stacked series, from the bottom of the stack upward. Accepts a\n named order (`\"descending\"` [default] / `\"ascending\"` by summed value,\n `\"key\"` / `\"keyReverse\"` alphabetically, `\"none\"` / `\"data\"` for input\n order, or d3's `\"insideOut\"` / `\"appearance\"` / `\"reverse\"`), an Array of\n series keys for an explicit order, a value accessor, or a `{value, order}`\n config to rank series by an aggregate of any data field.\n */\n stackOrder?:\n | string\n | string[]\n | {value: string | ((d: DataPoint) => unknown); order?: \"ascending\" | \"descending\"}\n | ((d: DataPoint) => unknown);\n /** Subtitle text, or an accessor returning it. */\n subtitle?: string | ((data: DataPoint[]) => string);\n /** Whether the subtitle uses the visualization's internal padding when positioning, or an accessor receiving the viz. */\n subtitlePadding?: boolean | ((viz: VizBase) => boolean);\n /** Value accessor for treemaps and aggregation. */\n sum?: DataPointAccessor<number>;\n /** Accessible description applied to the root SVG (`<desc>`). */\n svgDesc?: string;\n /** Accessible title applied to the root SVG (`<title>`). */\n svgTitle?: string;\n /** Threshold value for grouping small slices. */\n threshold?: number;\n /** Label for the threshold group, or a `(datum, index)` accessor. */\n thresholdName?: string | ((d: DataPoint, i: number) => string);\n /** URL to XYZ map tiles. */\n tileUrl?: string;\n /** Whether to show map tiles. */\n tiles?: boolean;\n /** Time key for temporal data. */\n time?: string;\n /** Predicate filtering which time slices are shown, or false to disable. */\n timeFilter?: ((d: DataPoint, i: number) => boolean) | false;\n /** Whether to show the timeline component. */\n timeline?: boolean;\n /** Whether the timeline uses the visualization's internal padding when positioning, or an accessor receiving the viz. */\n timelinePadding?: boolean | ((viz: VizBase) => boolean);\n /** Chart title or title accessor function. */\n title?: string | ((data: DataPoint[]) => string);\n /** CSS style configuration for the title. */\n titleConfig?: Record<string, string | number>;\n /** Whether the title uses the visualization's internal padding when positioning, or an accessor receiving the viz. */\n titlePadding?: boolean | ((viz: VizBase) => boolean);\n /** Whether to show tooltips, or a `(datum, index)` accessor deciding per mark. */\n tooltip?: boolean | ((d: DataPoint, i: number) => boolean);\n /** Configuration for the tooltip component. */\n tooltipConfig?: TooltipConfig;\n /** Path or object for the topojson data. */\n topojson?: string | object;\n /** CSS color to fill the map shapes. */\n topojsonFill?: string;\n /** Accessor function for topojson feature IDs. */\n topojsonId?: (obj: Record<string, unknown>) => string;\n /** Whether the total uses the visualization's internal padding when positioning, or an accessor receiving the viz. */\n totalPadding?: boolean | ((viz: VizBase) => boolean);\n /** Value accessor for the visualization. */\n value?: DataPointAccessor<number>;\n /** Overall width of the visualization in pixels. */\n width?: number;\n /** Key, index, or accessor function for x-axis values. */\n x?: string | number | ((d: DataPoint, i: number) => unknown);\n /** Configuration for the x-axis. */\n xConfig?: AxisConfig;\n /** The x domain as an array. If either value is undefined, it is calculated from the data. */\n xDomain?: (number | Date)[];\n /** The x2 domain as an array. If either value is undefined, it is calculated from the data. */\n x2Domain?: (number | Date)[];\n /** Custom sort function for x-axis values. */\n xSort?: (a: DataPoint, b: DataPoint) => number;\n /** Defines a custom sorting comparator function for discrete x2 axes. */\n x2Sort?: (a: DataPoint, b: DataPoint) => number;\n /** Key, index, or accessor function for y-axis values. */\n y?: string | number | ((d: DataPoint, i: number) => unknown);\n /** Configuration for the y-axis. */\n yConfig?: AxisConfig;\n /** The y domain as an array. If either value is undefined, it is calculated from the data. */\n yDomain?: (number | Date)[];\n /** The y2 domain as an array. If either value is undefined, it is calculated from the data. */\n y2Domain?: (number | Date)[];\n /** Custom sort function for y-axis values. */\n ySort?: (a: DataPoint, b: DataPoint) => number;\n /** Defines a custom sorting comparator function for discrete y2 axes. */\n y2Sort?: (a: DataPoint, b: DataPoint) => number;\n /** Set to false to disable zooming on Geomap and Network. */\n zoom?: boolean;\n /** Multiplier applied to programmatic zoom steps. */\n zoomFactor?: number;\n /** Maximum zoom scale factor. */\n zoomMax?: number;\n /** Whether panning (drag) is enabled while zoomed. */\n zoomPan?: boolean;\n /** Whether scroll-wheel zooming is enabled. */\n zoomScroll?: boolean;\n\n /** Allows additional custom properties. */\n [key: string]: unknown;\n}\n"],"names":[],"mappings":"AAmPA,WAmQC"}
|
|
1
|
+
{"version":3,"sources":["../../../src/utils/D3plusConfig.ts"],"sourcesContent":["import type {DataPoint} from \"@d3plus/data\";\n\nimport type VizBase from \"../charts/viz/VizBase.js\";\nimport type {AccessorFn} from \"./AccessorFn.js\";\n\ntype Position = \"top\" | \"right\" | \"bottom\" | \"left\";\n\ntype DataPointAccessor<T> = string | ((d: DataPoint) => T);\n\n/** A config value that is either a constant or a `(datum, index)` accessor. */\ntype Accessor<T> = T | ((d: DataPoint, i?: number) => T);\n\ntype AxisScale =\n | \"auto\"\n | \"band\"\n | \"diverging\"\n | \"divergingLog\"\n | \"divergingPow\"\n | \"divergingSqrt\"\n | \"divergingSymlog\"\n | \"identity\"\n | \"implicit\"\n | \"jenks\"\n | \"linear\"\n | \"log\"\n | \"ordinal\"\n | \"point\"\n | \"pow\"\n | \"quantile\"\n | \"quantize\"\n | \"radial\"\n | \"sequential\"\n | \"sequentialLog\"\n | \"sequentialPow\"\n | \"sequentialQuantile\"\n | \"sequentialSqrt\"\n | \"sequentialSymlog\"\n | \"sqrt\"\n | \"symlog\"\n | \"threshold\"\n | \"time\"\n | \"utc\";\n\nexport interface AxisConfig {\n barConfig?: Record<string, string | number>;\n /** Grid values of the axis. */\n grid?: unknown[];\n gridConfig?: Record<string, string | number>;\n /** Grid size of the axis. */\n gridSize?: number;\n label?: string;\n /** Visible tick labels of the axis. */\n labels?: unknown[];\n labelOffset?: false | number;\n /**\n Exact size of the space that contains the axis tick labels and title.\n Labels that need more room overflow outward instead of moving the axis\n line; zooming pins a rescaled axis this way so it doesn't shift.\n */\n fixedSize?: number;\n /** Maximum size allowed for the space that contains the axis tick labels and title. */\n maxSize?: number;\n /** Minimum size alloted for the space that contains the axis tick labels and title. */\n minSize?: number;\n /**\n Scale range (in pixels) of the axis. The given array must have 2 values,\n but one may be `undefined` to allow the default behavior for that value.\n */\n range?: (number | undefined)[];\n /** Scale of the axis. */\n scale?: AxisScale;\n /** Tick formatter. */\n tickFormat?: (d: number | string) => string | number;\n /** Tick values of the axis. */\n ticks?: unknown[];\n /**\n Whether the domain's min and max are always shown as ticks, even when\n they aren't among the scale's own \"nice\" tick values (the nearest nice\n tick is dropped when it would crowd them). Defaults to `true`; zooming\n turns it off so a rescaled axis shows only nice values.\n */\n domainTicks?: boolean;\n tickSize?: number;\n /**\n Defines a custom locale object to be used in time scales. Must include\n `dateTime`, `date`, `time`, `periods`, `days`, `shortDays`, `months`, and\n `shortMonths` (see\n [d3-time-format](https://github.com/d3/d3-time-format/blob/master/README.md#timeFormatLocale)).\n */\n timeLocale?: Record<string, unknown>;\n /** Title of the axis. */\n title?: string;\n}\n\nexport interface TooltipConfig {\n /** The inner HTML content of the arrow element, empty by default. */\n arrow?: ((d: DataPoint) => string) | string;\n /** The background color accessor for each tooltip. */\n background?: ((d: DataPoint) => string) | string;\n /** The border accessor for each tooltip. */\n border?: ((d: DataPoint) => string) | string;\n /** The border-radius accessor for each tooltip. */\n borderRadius?: ((d: DataPoint) => string) | string;\n /** The footer content accessor for each tooltip. */\n footer?: ((d: DataPoint) => string) | string;\n /** The max-width accessor for each tooltip. */\n maxWidth?: ((d: DataPoint) => string | number) | string | number;\n /** The min-width accessor for each tooltip. */\n minWidth?: ((d: DataPoint) => string | number) | string | number;\n /** The pixel offset between the tooltip and its anchor point. */\n offset?: ((d: DataPoint) => number) | number;\n /** The inner padding of each tooltip. */\n padding?: ((d: DataPoint) => string | number) | string | number;\n title?: ((d: DataPoint) => string) | string;\n body?: ((d: DataPoint) => string) | string;\n thead?:\n | ((d: DataPoint) => [string, string][])\n | Array<\n Array<\n | ((d: DataPoint, i?: number, x?: {share: number}) => string)\n | string\n >\n >;\n tbody?:\n | ((d: DataPoint) => [string, string][])\n | Array<\n Array<\n | ((d: DataPoint, i?: number, x?: {share: number}) => string)\n | string\n >\n >;\n}\n\nexport interface TextBoxConfig {\n /** The text content for each box. */\n text?: Accessor<string>;\n /** The font color as an accessor function or static string. Inferred from the DOM selection by default. */\n fontColor?: Accessor<string>;\n /** The font size in pixels. Inferred from the DOM selection by default. */\n fontSize?: Accessor<number>;\n /**\n The font-family to use: a font name, a comma-separated list of fallbacks,\n an array of fallbacks, or an accessor returning a string or array. The\n first available font on the client is used.\n */\n fontFamily?: Accessor<string | string[]>;\n /** The font weight. Inferred from the DOM selection by default. */\n fontWeight?: Accessor<string | number>;\n /** The minimum font size in pixels, used when dynamically resizing fonts. */\n fontMin?: number;\n /** The maximum font size in pixels, used when dynamically resizing fonts. */\n fontMax?: number;\n /** Toggles font resizing — a static boolean, or an accessor returning a boolean. */\n fontResize?: Accessor<boolean>;\n /** The font opacity as an accessor function or static number between 0 and 1. */\n fontOpacity?: Accessor<number>;\n /** The font stroke color for the rendered text. */\n fontStroke?: Accessor<string>;\n /** The font stroke width for the rendered text. */\n fontStrokeWidth?: Accessor<number>;\n /** The line height, which is 1.2 times the font size by default. */\n lineHeight?: Accessor<number>;\n /** Restricts the maximum number of lines to wrap onto; null (unlimited) by default. */\n maxLines?: Accessor<number | null>;\n /** Whether text is allowed to overflow its bounding box. */\n overflow?: Accessor<boolean>;\n /**\n Handles truncated lines, returning the new line value. Passed the line's\n text and number; by default appends an ellipsis to every line except a\n first word that cannot fit (which returns \"\").\n */\n ellipsis?: (text: string, line: number) => string;\n /** The padding as a CSS shorthand string or number. Defaults to 0. */\n padding?: Accessor<string | number>;\n /** The anchor point around which to rotate the text box. */\n rotateAnchor?: Accessor<[number, number]>;\n /** The word split function: given a string, returns it split into an array of words. */\n split?: (text: string) => string[];\n /** The width for each text box. */\n width?: Accessor<number>;\n /** The height for each text box. */\n height?: Accessor<number>;\n /** The x position (left edge) for each text box. */\n x?: Accessor<number>;\n /** The y position (top edge) for each text box. */\n y?: Accessor<number>;\n}\n\nexport interface TimelineConfig {\n /** Brush event filter. */\n brushFilter?: () => boolean;\n /**\n The minimum number of ticks that can be highlighted when using \"ticks\"\n `buttonBehavior`. Helpful for x/y plots where selecting fewer than 2 time\n periods is undesirable.\n */\n brushMin?: number;\n /** Toggles the horizontal alignment of the button timeline. */\n buttonAlign?: \"start\" | \"middle\" | \"end\";\n /** Toggles the style of the timeline. */\n buttonBehavior?: \"auto\" | \"buttons\" | \"ticks\";\n /** Button height. */\n buttonHeight?: number;\n /** Button padding. */\n buttonPadding?: number;\n /** Handle style. */\n handleConfig?: Record<string, unknown>;\n /** Handle size. */\n handleSize?: number;\n /**\n Determines the visibility of the play button to the left of the timeline,\n which cycles through the available periods at a rate set by `playButtonInterval`.\n */\n playButton?: boolean;\n /**\n The interval, in milliseconds, between periods when cycling via the play\n button. Used only when the chart's `duration` is 0 (no transition);\n otherwise playback steps once per `duration` so each step animates in full.\n */\n playButtonInterval?: number;\n /** The current selection. Defaults to the most recent period in the timeline. */\n selection?: (Date | number)[] | Date | number | false;\n /** Toggles the snapping value. */\n snapping?: boolean;\n}\n\nexport interface LegendConfig {\n /** The active method for all shapes. */\n active?: ((d: DataPoint, i?: number) => boolean) | false;\n /** The hover method for all shapes. */\n hover?: ((d: DataPoint, i?: number) => boolean) | false;\n /** The shape type used for each legend entry. */\n shape?: Accessor<string>;\n}\n\nexport interface ColorScaleConfig {\n /**\n For a linear scale, the `[min, max]` values used by the color scale; values\n outside this range map to the nearest color.\n */\n domain?: number[];\n /**\n Formats the label for each bucket in a bucket-type scale (\"jenks\",\n \"quantile\", …). Passed the bucket's start value, its index, the full\n bucket array, and every data value used to build the buckets.\n */\n bucketFormat?: (\n start: number,\n i: number,\n buckets: number[],\n values: number[],\n ) => string;\n /** Given a bucket's minimum and maximum values, returns the full label. */\n bucketJoiner?: (min: string, max: string) => string;\n}\n\nexport interface D3plusConfig {\n /** Data array or URL string to load data from. */\n data?: DataPoint[] | string;\n /** Locale code used for text and number formatting. */\n locale?: string;\n\n /** The active callback function for highlighting shapes. */\n active?: ((d: DataPoint, i: number) => boolean) | false | null;\n /** Custom aggregation functions keyed by data property. */\n aggs?: {[k: string]: (d: DataPoint[]) => unknown};\n /** Hides the SVG from assistive technology when true (`aria-hidden`). */\n ariaHidden?: boolean;\n /**\n Text (rendered as HTML — any valid HTML string works, including anchor\n links) shown in the chart's bottom-right corner, most often a map tile\n credit. `false` (the default) shows nothing. A credit wider than half\n the chart area collapses to a small \"ⓘ\" badge that expands on hover,\n focus, or click.\n */\n attribution?: string | boolean;\n /**\n Overrides the \"ⓘ\" badge a long attribution collapses to, which\n otherwise renders as an inline SVG. A string is used as the badge's\n raw HTML content; a mount function, `(el: HTMLElement) => void | (() =>\n void)`, is called once with the badge's reserved element so a live\n component (a React tree via `createRoot(el).render(...)`, or anything\n else imperative) can be mounted into it — return a cleanup function if\n there's teardown to do.\n */\n attributionIcon?: string | ((el: HTMLElement) => void | (() => void));\n /** CSS key/value pairs used to style the attribution text. */\n attributionStyle?: Record<string, unknown>;\n /** Additional CSS class name(s) applied to the back button, alongside the fixed `back-control` class. */\n backControlClassName?: string;\n /** Padding between bars in pixels. */\n barPadding?: number;\n /** The baseline for the x/y plot. */\n baseline?: number;\n /** Whether to cache the processed data between renders. */\n cache?: boolean;\n /** Treat a discrete color field as ordered: color it with a single-hue light→dark ramp instead of nominal categorical hues. */\n colorOrdinal?: boolean;\n /** Color scale key or custom color function. */\n colorScale?: string | ((d: number) => string);\n /** Configuration for the color scale component. */\n colorScaleConfig?: {\n axisConfig?: AxisConfig;\n centered?: boolean;\n colors?: string[];\n colorMin?: string;\n colorMid?: string;\n colorMax?: string;\n scale?: AxisScale;\n };\n /** Whether the color scale uses the visualization's internal padding when positioning, or an accessor receiving the viz. */\n colorScalePadding?: boolean | ((viz: VizBase) => boolean);\n /** Position of the color scale, `false` to hide it, or an accessor returning either. */\n colorScalePosition?: false | Position | (() => false | Position);\n /** Column key for matrix-style layouts. */\n column?: string;\n /**\n The confidence interval as `[lower, upper]` bounds — each given as an\n accessor function or a static data key (e.g. `[\"lci\", \"hci\"]`), or `false`\n to disable.\n */\n confidence?:\n | [\n string | ((d: DataPoint, i: number) => number),\n string | ((d: DataPoint, i: number) => number),\n ]\n | false;\n /** Maximum number of data points to render before downsampling. */\n dataCutoff?: number;\n /** Active depth level for nested groupings. */\n depth?: number;\n /** Sets orientation of main category axis. */\n discrete?: \"x\" | \"y\";\n /** Default duration of transitions, in milliseconds. */\n duration?: number;\n /** Predicate filtering which data points are included, or false to disable. */\n filter?: ((d: DataPoint, i: number) => boolean) | false;\n /** Allows removing specific geographies from topojson file to improve zoom. */\n fitFilter?:\n | number\n | string\n | ((d: Record<string, unknown>) => boolean);\n /** Grouping key(s) or accessor function(s). */\n groupBy?:\n | string\n | string[]\n | ((d: DataPoint) => string | number)\n | ((d: DataPoint) => string | number)[];\n /** Padding between groups of bars in pixels. */\n groupPadding?: number;\n /** Overall height of the visualization in pixels. */\n height?: number;\n /** Color for legend shapes whose grouping is hidden (via legend click), or a `(datum, index)` accessor. */\n hiddenColor?: string | ((d: DataPoint, i: number) => string);\n /** Opacity for legend labels whose grouping is hidden (via legend click), or a `(datum, index)` accessor. */\n hiddenOpacity?: number | ((d: DataPoint, i: number) => number);\n /** The hover callback function for highlighting shapes on mouseover. */\n hover?: ((d: DataPoint, i: number) => boolean) | false | null;\n /** Persistently emphasizes matching marks (keep color) and grays the rest. */\n highlight?: ((d: DataPoint, i: number) => boolean) | false | null;\n /** Label accessor for shapes. */\n label?: string | string[] | false | AccessorFn;\n /**\n Controls legend visibility. Pass `false` to hide it, `true` to always\n show it, or a `(config, data) => boolean` accessor to decide dynamically\n — the chart defaults use an accessor to auto-hide the legend when it\n would be redundant.\n */\n legend?: boolean | ((config: D3plusConfig, arr: DataPoint[]) => boolean);\n /** Configuration for the legend component. */\n legendConfig?: {\n label?: DataPointAccessor<string>;\n shapeConfig?: Record<string, string | number>;\n };\n /** Inverts legend click behavior (click hides / shift-click solos, or the reverse), or an accessor receiving the viz. */\n legendFilterInvert?: boolean | ((viz: VizBase) => boolean);\n /** Whether the legend uses the visualization's internal padding when positioning, or an accessor receiving the viz. */\n legendPadding?: boolean | ((viz: VizBase) => boolean);\n /** Position of the legend, or an accessor returning it. */\n legendPosition?: Position | (() => Position);\n /** Custom sort comparator for legend items. */\n legendSort?: (a: DataPoint, b: DataPoint) => number;\n /** Tooltip configuration for legend items. */\n legendTooltip?: TooltipConfig;\n /** Whether to show labels on line charts. */\n lineLabels?: boolean;\n /** Whether to show the loading message. */\n loadingMessage?: boolean;\n /** Custom HTML content for the loading indicator, or a function receiving the viz instance. */\n loadingHTML?: string | ((viz: VizBase) => string);\n /** Metric key for the visualization. */\n metric?: string;\n /** Shows a small overview + draggable-viewport minimap underneath the zoom controls once the chart is zoomed in. On by default whenever `zoom` is enabled. */\n minimap?: boolean;\n /** Additional CSS class name(s) applied to the minimap, alongside its fixed `d3plus-minimap`/etc. classes. */\n minimapClassName?: string;\n /** Custom HTML content shown when no data is supplied, or a function receiving the viz instance. */\n noDataHTML?: string | ((viz: VizBase) => string);\n /**\n Ocean color for geomaps (any CSS value including 'transparent'), or a\n `{light, dark}` pair chosen by the chart's backdrop. Defaults to the\n default basemap's own water colors.\n */\n ocean?: string | {light: string; dark: string};\n /** Event listeners keyed by event name. */\n on?: Record<string, (event: Event) => void>;\n /** Coordinate accessor for point-based geomaps. */\n point?: (d: DataPoint) => number[];\n /** Point size accessor for geomaps. */\n pointSize?: string | ((d: DataPoint) => number);\n /** Minimum point size for geomaps. */\n pointSizeMin?: number;\n /** Maximum point size for geomaps. */\n pointSizeMax?: number;\n /** Map projection name or function. */\n projection?: string | ((x: number, y: number) => [number, number]);\n /** Outer padding between the visualization edge and map shapes. */\n projectionPadding?: number | string;\n /** Rotation offset for the map projection center. */\n projectionRotate?: [number, number];\n /** Row key for matrix-style layouts. */\n row?: string;\n /** Scrollable container selector for tooltip positioning. */\n scrollContainer?: string | Window;\n /** Shows a top-left search button that expands into an input; typing highlights shapes whose label matches. On by default for every chart. */\n search?: boolean;\n /** Resolves the string the search box matches its typed term against, for a given datum. Defaults to the mark's resolved on-screen label. */\n searchAccessor?: (d: DataPoint, i: number) => string;\n /** Additional CSS class name(s) applied to the search toggle button and input, alongside the fixed `search-control` classes. */\n searchControlClassName?: string;\n /** Configuration for shape rendering. */\n shapeConfig?: {\n duration?: number;\n [key: string]: unknown;\n };\n /**\n A [sort comparator](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort)\n that receives each shape class (e.g. \"Circle\", \"Line\") as its arguments.\n Shapes are drawn in groups by type, so this defines the layering order for\n all shapes of a given type.\n */\n shapeSort?: (a: string, b: string) => number;\n /** Size accessor key. */\n size?: string;\n /** Whether to stack series. */\n stacked?: boolean;\n /**\n Vertical offset applied to stacked series. One of `\"diverging\"`\n (default — positive and negative values split around zero), `\"none\"`,\n `\"expand\"` (normalize each stack to 100%), `\"silhouette\"` (streamgraph),\n or `\"wiggle\"` (minimize slope changes); or a custom offset function.\n */\n stackOffset?: string | ((series: number[][][], order: number[]) => void);\n /**\n Order of stacked series, from the bottom of the stack upward. Accepts a\n named order (`\"descending\"` [default] / `\"ascending\"` by summed value,\n `\"key\"` / `\"keyReverse\"` alphabetically, `\"none\"` / `\"data\"` for input\n order, or d3's `\"insideOut\"` / `\"appearance\"` / `\"reverse\"`), an Array of\n series keys for an explicit order, a value accessor, or a `{value, order}`\n config to rank series by an aggregate of any data field.\n */\n stackOrder?:\n | string\n | string[]\n | {value: string | ((d: DataPoint) => unknown); order?: \"ascending\" | \"descending\"}\n | ((d: DataPoint) => unknown);\n /** Subtitle text, or an accessor returning it. */\n subtitle?: string | ((data: DataPoint[]) => string);\n /** Whether the subtitle uses the visualization's internal padding when positioning, or an accessor receiving the viz. */\n subtitlePadding?: boolean | ((viz: VizBase) => boolean);\n /** Value accessor for treemaps and aggregation. */\n sum?: DataPointAccessor<number>;\n /** Accessible description applied to the root SVG (`<desc>`). */\n svgDesc?: string;\n /** Accessible title applied to the root SVG (`<title>`). */\n svgTitle?: string;\n /** Enables the top-left table-view toggle button, which swaps the chart for a static, scrollable `<table>` of its data. On by default for every chart. */\n tableView?: boolean;\n /** Additional CSS class name(s) applied to the `<table>` element rendered while in table view, alongside the fixed `d3plus-table-view-table` class. */\n tableViewClassName?: string;\n /** Additional CSS class name(s) applied to the table-view toggle button, alongside the fixed `table-view-control`/`table-view-toggle` classes. */\n tableViewControlClassName?: string;\n /** CSS key/value pairs styling the table-view toggle button. `false` removes all default styling. */\n tableViewControlStyle?: Record<string, unknown> | false;\n /** CSS key/value pairs styling the table-view toggle button while active (showing the data table). `false` removes all default styling. */\n tableViewControlStyleActive?: Record<string, unknown> | false;\n /** CSS key/value pairs styling the table-view toggle button on hover. `false` removes all default styling. */\n tableViewControlStyleHover?: Record<string, unknown> | false;\n /** Whether the data table shows a \"download CSV\" button, exporting its full (sorted, unpaginated) rows. On by default. */\n tableViewDownload?: boolean;\n /** Rows per page while in table view. `false` (or any non-positive number) disables pagination and shows every row on one page. */\n tableViewPageSize?: number | false;\n /** Whether the data table's column headers are clickable to sort (toggling asc/desc). On by default. */\n tableViewSort?: boolean;\n /** Threshold value for grouping small slices. */\n threshold?: number;\n /** Label for the threshold group, or a `(datum, index)` accessor. */\n thresholdName?: string | ((d: DataPoint, i: number) => string);\n /**\n URL template for XYZ map tiles, with `{z}`, `{x}`, `{y}` (and optional\n `{s}` subdomain) placeholders — or a `{light, dark}` pair, chosen by the\n chart's backdrop. Defaults to Esri's Light Gray and Dark Gray Canvas.\n */\n tileUrl?: string | {light: string; dark: string};\n /** Whether to show map tiles. */\n tiles?: boolean;\n /** Time key for temporal data. */\n time?: string;\n /** Predicate filtering which time slices are shown, or false to disable. */\n timeFilter?: ((d: DataPoint, i: number) => boolean) | false;\n /** Whether to show the timeline component. */\n timeline?: boolean;\n /** Whether the timeline uses the visualization's internal padding when positioning, or an accessor receiving the viz. */\n timelinePadding?: boolean | ((viz: VizBase) => boolean);\n /** Chart title or title accessor function. */\n title?: string | ((data: DataPoint[]) => string);\n /** CSS style configuration for the title. */\n titleConfig?: Record<string, string | number>;\n /** Whether the title uses the visualization's internal padding when positioning, or an accessor receiving the viz. */\n titlePadding?: boolean | ((viz: VizBase) => boolean);\n /** Whether to show tooltips, or a `(datum, index)` accessor deciding per mark. */\n tooltip?: boolean | ((d: DataPoint, i: number) => boolean);\n /** Configuration for the tooltip component. */\n tooltipConfig?: TooltipConfig;\n /** Path or object for the topojson data. */\n topojson?: string | object;\n /** CSS color to fill the map shapes. */\n topojsonFill?: string;\n /** Accessor function for topojson feature IDs. */\n topojsonId?: (obj: Record<string, unknown>) => string;\n /** Whether the total uses the visualization's internal padding when positioning, or an accessor receiving the viz. */\n totalPadding?: boolean | ((viz: VizBase) => boolean);\n /** Value accessor for the visualization. */\n value?: DataPointAccessor<number>;\n /** Overall width of the visualization in pixels. */\n width?: number;\n /** Key, index, or accessor function for x-axis values. */\n x?: string | number | ((d: DataPoint, i: number) => unknown);\n /** Configuration for the x-axis. */\n xConfig?: AxisConfig;\n /** The x domain as an array. If either value is undefined, it is calculated from the data. */\n xDomain?: (number | Date)[];\n /** The x2 domain as an array. If either value is undefined, it is calculated from the data. */\n x2Domain?: (number | Date)[];\n /** Custom sort function for x-axis values. */\n xSort?: (a: DataPoint, b: DataPoint) => number;\n /** Defines a custom sorting comparator function for discrete x2 axes. */\n x2Sort?: (a: DataPoint, b: DataPoint) => number;\n /** Key, index, or accessor function for y-axis values. */\n y?: string | number | ((d: DataPoint, i: number) => unknown);\n /** Configuration for the y-axis. */\n yConfig?: AxisConfig;\n /** The y domain as an array. If either value is undefined, it is calculated from the data. */\n yDomain?: (number | Date)[];\n /** The y2 domain as an array. If either value is undefined, it is calculated from the data. */\n y2Domain?: (number | Date)[];\n /** Custom sort function for y-axis values. */\n ySort?: (a: DataPoint, b: DataPoint) => number;\n /** Defines a custom sorting comparator function for discrete y2 axes. */\n y2Sort?: (a: DataPoint, b: DataPoint) => number;\n /** Enables pan/zoom with zoom-control buttons. On by default for every chart. */\n zoom?: boolean;\n /** Additional CSS class name(s) applied to each zoom control button, alongside the fixed `zoom-control`/`zoom-in`/etc. classes. */\n zoomControlClassName?: string;\n /**\n Overrides one or more of the four built-in zoom-control icons (`zoomIn`,\n `zoomOut`, `zoomReset`, `zoomBrush`), which otherwise render as inline\n SVGs. Each value is either raw HTML — used as that button's content — or\n a mount function, `(el: HTMLElement) => void | (() => void)`, called\n once with the button's reserved icon slot so a live component (a React\n tree via `createRoot(el).render(...)`, or anything else imperative) can\n be mounted into it — return a cleanup function if there's teardown to do.\n */\n zoomControlIcons?: Partial<\n Record<\n \"zoomIn\" | \"zoomOut\" | \"zoomReset\" | \"zoomBrush\",\n string | ((el: HTMLElement) => void | (() => void))\n >\n >;\n /** Multiplier applied to programmatic zoom steps. */\n zoomFactor?: number;\n /** Maximum zoom scale factor. Defaults to the scale at which the smallest shape fills the chart area. */\n zoomMax?: number;\n /** Whether panning (drag) is enabled while zoomed. */\n zoomPan?: boolean;\n /**\n Whether the mouse wheel (and one-finger touch) zooms. `\"modifier\"` (the\n default) leaves page scrolling alone: only\n Ctrl/⌘ + wheel or a trackpad/two-finger pinch zooms, and one finger pans\n only once zoomed in. `true` zooms on any wheel; `false` never does.\n */\n zoomScroll?: boolean | \"modifier\";\n\n /** Allows additional custom properties. */\n [key: string]: unknown;\n}\n"],"names":[],"mappings":"AAgQA,WAmVC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@d3plus/core",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.5.0",
|
|
4
4
|
"description": "Data visualization made easy. A javascript library that extends the popular D3.js to enable fast and beautiful visualizations.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -42,6 +42,7 @@
|
|
|
42
42
|
"@floating-ui/dom": "^1.6.0",
|
|
43
43
|
"d3-array": "^3.2.4",
|
|
44
44
|
"d3-brush": "^3.0.0",
|
|
45
|
+
"d3-chord": "^3.0.1",
|
|
45
46
|
"d3-color": "^3.1.0",
|
|
46
47
|
"d3-composite-projections": "^1.4.0",
|
|
47
48
|
"d3-force": "^3.0.0",
|
|
@@ -62,14 +63,14 @@
|
|
|
62
63
|
"open-color": "^1.9.1",
|
|
63
64
|
"textures": "^1.2.3",
|
|
64
65
|
"topojson-client": "^3.1.0",
|
|
65
|
-
"@d3plus/
|
|
66
|
-
"@d3plus/
|
|
67
|
-
"@d3plus/format": "4.
|
|
68
|
-
"@d3plus/
|
|
69
|
-
"@d3plus/
|
|
70
|
-
"@d3plus/
|
|
71
|
-
"@d3plus/render": "4.
|
|
72
|
-
"@d3plus/
|
|
66
|
+
"@d3plus/data": "4.5.0",
|
|
67
|
+
"@d3plus/dom": "4.5.0",
|
|
68
|
+
"@d3plus/format": "4.5.0",
|
|
69
|
+
"@d3plus/locales": "4.5.0",
|
|
70
|
+
"@d3plus/math": "4.5.0",
|
|
71
|
+
"@d3plus/text": "4.5.0",
|
|
72
|
+
"@d3plus/render": "4.5.0",
|
|
73
|
+
"@d3plus/color": "4.5.0"
|
|
73
74
|
},
|
|
74
75
|
"devDependencies": {
|
|
75
76
|
"playwright": "1.59.1"
|
|
@@ -79,7 +80,7 @@
|
|
|
79
80
|
"build:types": "tsc",
|
|
80
81
|
"build:umd": "node ../../scripts/build-umd.js",
|
|
81
82
|
"dev": "node ../../scripts/dev.js",
|
|
82
|
-
"test": "eslint index.ts internal.ts umd-entry.ts src
|
|
83
|
+
"test": "eslint index.ts internal.ts umd-entry.ts src && eslint --global=it test && mocha 'test/**/*-test.js'",
|
|
83
84
|
"test:coverage": "c8 -r text -r lcov --src src mocha 'test/**/*-test.js'"
|
|
84
85
|
}
|
|
85
86
|
}
|
package/types/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { AreaPlot, BarChart, BoxWhisker, BumpChart, Donut, Geomap, LinePlot, Matrix, Network, Pack, Pie, Plot, Priestley, Radar, RadialMatrix, Rings, Sankey, StackedArea, Tree, Treemap, Viz, } from "./src/charts/index.js";
|
|
1
|
+
export { AreaPlot, BarChart, BoxWhisker, BumpChart, Chord, Donut, Geomap, LinePlot, Matrix, Network, Pack, Pie, Plot, Priestley, Radar, RadialMatrix, Rings, Sankey, StackedArea, Tree, Treemap, Viz, } from "./src/charts/index.js";
|
|
2
2
|
export { Axis, AxisBottom, AxisLeft, AxisRight, AxisTop, ColorScale, Legend, Message, TextBox, Timeline, Tooltip, } from "./src/components/index.js";
|
|
3
3
|
export { Area, Bar, Box, Circle, Image, Line, Path, Rect, Shape, Whisker, } from "./src/shapes/index.js";
|
|
4
4
|
export { accessor, BaseClass, configPrep, constant, RESET, } from "./src/utils/index.js";
|
package/types/internal.d.ts
CHANGED
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
is implementation detail of the rendering pipeline and may change in any
|
|
10
10
|
minor release. Import it knowingly.
|
|
11
11
|
*/
|
|
12
|
+
export { applyChordLayout } from "./src/charts/Chord/applyLayout.js";
|
|
12
13
|
export { applyGeomapLayout } from "./src/charts/Geomap/applyLayout.js";
|
|
13
14
|
export { applyMatrixLayout } from "./src/charts/Matrix/applyLayout.js";
|
|
14
15
|
export { applyNetworkLayout } from "./src/charts/Network/applyLayout.js";
|
|
@@ -21,6 +22,7 @@ export { applyRadarLayout } from "./src/charts/Radar/applyLayout.js";
|
|
|
21
22
|
export { applyRadialMatrixLayout } from "./src/charts/RadialMatrix/applyLayout.js";
|
|
22
23
|
export { applyTreeLayout } from "./src/charts/Tree/applyLayout.js";
|
|
23
24
|
export { applyTreemapLayout } from "./src/charts/Treemap/applyLayout.js";
|
|
25
|
+
export { chordDef } from "./src/charts/Chord/index.js";
|
|
24
26
|
export { geomapDef } from "./src/charts/Geomap/index.js";
|
|
25
27
|
export { matrixDef } from "./src/charts/Matrix/index.js";
|
|
26
28
|
export { networkDef } from "./src/charts/Network/index.js";
|
|
@@ -44,7 +46,11 @@ export { vizPreDrawPure, vizPostThresholdCtx } from "./src/charts/pipeline/vizPr
|
|
|
44
46
|
export { plotEmit, plotPaint } from "./src/charts/features/plotPaint.js";
|
|
45
47
|
export { renderAxes } from "./src/charts/features/axes.js";
|
|
46
48
|
export { computeAxisLayout, measureAxis } from "./src/components/Axis/Axis.js";
|
|
47
|
-
export {
|
|
49
|
+
export { colorScaleFeature, legendFeature, runLayout, subtitleFeature, timelineFeature, titleFeature, totalFeature, } from "./src/charts/features/features.js";
|
|
50
|
+
export { getTopLeftContributions, topLeftControlsFeature, TOP_LEFT_CONTRIBUTORS, } from "./src/charts/drawSteps/topLeftControls.js";
|
|
51
|
+
export { backContribution } from "./src/charts/drawSteps/backControl.js";
|
|
52
|
+
export { tableViewContribution } from "./src/charts/drawSteps/tableViewControl.js";
|
|
53
|
+
export { searchContribution } from "./src/charts/drawSteps/searchControls.js";
|
|
48
54
|
export type { ResolvedSpec } from "./src/charts/pipeline/resolveSpec.js";
|
|
49
55
|
export type { VizContext } from "./src/charts/pipeline/vizContext.js";
|
|
50
56
|
export type { VizPreDrawResult } from "./src/charts/pipeline/vizPreDrawPure.js";
|
|
@@ -52,3 +58,4 @@ export type { PlotMeasureResult, PlotPaintContext } from "./src/charts/features/
|
|
|
52
58
|
export type { ShapeLike, VizLike } from "./src/charts/features/emitHelpers.js";
|
|
53
59
|
export type { VizInstance, VizRenderer } from "./src/charts/viz/vizTypes.js";
|
|
54
60
|
export type { AxisLayout, AxisLayoutResult } from "./src/components/Axis/Axis.js";
|
|
61
|
+
export type { Contribution } from "./src/charts/drawSteps/topLeftControlsMarkup.js";
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
`applyChordLayout` — Chord's chart-specific layout stage. Resolves nodes +
|
|
3
|
+
links into a square flow matrix, runs the d3-chord layout (directed by
|
|
4
|
+
default), builds the arc (group) + ribbon (chord) path generators, computes
|
|
5
|
+
per-node label geometry, and stashes `chordCtx` + `nodeLookup` + `adjacency`
|
|
6
|
+
on `viz.ctx`.
|
|
7
|
+
|
|
8
|
+
Geometry is generated at the origin (0,0), like Pie/Donut — the chart is
|
|
9
|
+
centered by `chordDef.chartTransform`.
|
|
10
|
+
*/
|
|
11
|
+
import type { Chord, ChordGroup, Chords } from "d3-chord";
|
|
12
|
+
import type { DataPoint } from "@d3plus/data";
|
|
13
|
+
import type { TransformStage } from "../pipeline/stages.js";
|
|
14
|
+
/** A single laid-out Chord node (group), accreted across the layout passes. */
|
|
15
|
+
export interface ChordNode {
|
|
16
|
+
__d3plus__: true;
|
|
17
|
+
data: DataPoint;
|
|
18
|
+
node: DataPoint;
|
|
19
|
+
i: number;
|
|
20
|
+
id: string | number;
|
|
21
|
+
shape: string;
|
|
22
|
+
/** The d3-chord group for this node, set once the layout runs. */
|
|
23
|
+
group?: ChordGroup;
|
|
24
|
+
/** Label anchor point (on the outer radius, centered coords). */
|
|
25
|
+
labelX?: number;
|
|
26
|
+
labelY?: number;
|
|
27
|
+
labelRotate?: number;
|
|
28
|
+
labelAnchor?: "start" | "end";
|
|
29
|
+
labelBounds?: {
|
|
30
|
+
x: number;
|
|
31
|
+
y: number;
|
|
32
|
+
width: number;
|
|
33
|
+
height: number;
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
/** Everything `chordEmit` needs, stashed on `viz.ctx.chordCtx`. */
|
|
37
|
+
export interface ChordCtx {
|
|
38
|
+
nodes: ChordNode[];
|
|
39
|
+
chords: Chords;
|
|
40
|
+
arcFn: (d: ChordGroup) => string;
|
|
41
|
+
ribbonFn: (d: Chord) => string;
|
|
42
|
+
}
|
|
43
|
+
export declare const applyChordLayout: TransformStage;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
`chordEmit` — ribbon Paths (chords) + arc Paths (groups) + rotated group
|
|
3
|
+
labels, from `chordCtx` stashed on `viz.ctx`. Emits flat SceneNodes directly.
|
|
4
|
+
|
|
5
|
+
Ribbons are emitted first so the arcs paint on top of their attach points.
|
|
6
|
+
Ribbon fill is resolved against the *source* node so each flow reads as
|
|
7
|
+
leaving its origin; arc fill is the node's own color.
|
|
8
|
+
*/
|
|
9
|
+
import type { ChartEmit } from "../definition/ChartDefinition.js";
|
|
10
|
+
export declare const chordEmit: ChartEmit;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
Chord — d3-chord relationship diagram.
|
|
3
|
+
|
|
4
|
+
Groups (nodes) are laid out as arcs around a circle; ribbons (chords) connect
|
|
5
|
+
them, sized by the flow (link value) between each pair. Built on the same
|
|
6
|
+
nodes/links data model as Network, Rings, and Sankey.
|
|
7
|
+
|
|
8
|
+
Implementation files in this folder:
|
|
9
|
+
- `applyLayout.ts` — node/link resolution → flow matrix → d3-chord layout +
|
|
10
|
+
arc/ribbon generators + label geometry.
|
|
11
|
+
- `emit.ts` — ribbon Paths + arc Paths + rotated group labels.
|
|
12
|
+
*/
|
|
13
|
+
import type { ChartDefinition } from "../definition/ChartDefinition.js";
|
|
14
|
+
export declare const chordDef: ChartDefinition;
|
|
15
|
+
/**
|
|
16
|
+
Creates a Chord diagram based on a defined set of nodes and links.
|
|
17
|
+
*/
|
|
18
|
+
declare const _default: new () => any;
|
|
19
|
+
export default _default;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
Light/dark basemaps. `tileUrl` and `ocean` accept either one value or a
|
|
3
|
+
`{light, dark}` pair; a pair resolves against the chart's backdrop each
|
|
4
|
+
draw, and the chart redraws when that backdrop flips.
|
|
5
|
+
|
|
6
|
+
@module
|
|
7
|
+
*/
|
|
8
|
+
import type { VizInstance } from "../viz/vizTypes.js";
|
|
9
|
+
/** A value, or one per page theme. */
|
|
10
|
+
export type Themed<T> = T | {
|
|
11
|
+
light: T;
|
|
12
|
+
dark: T;
|
|
13
|
+
};
|
|
14
|
+
/** Esri's Canvas basemaps: muted, nearly label-free bases for data overlays. */
|
|
15
|
+
export declare const DEFAULT_TILE_URL: Themed<string>;
|
|
16
|
+
/** The Canvas basemaps' own water colors, so the ocean around the tiles matches. */
|
|
17
|
+
export declare const DEFAULT_OCEAN: Themed<string>;
|
|
18
|
+
/** Picks a themed value's light or dark side. */
|
|
19
|
+
export declare function resolveThemed<T>(value: Themed<T>, dark: boolean): T;
|
|
20
|
+
/** Whether a Geomap has any themed value that depends on the backdrop. */
|
|
21
|
+
export declare function isThemed(viz: VizInstance): boolean;
|
|
22
|
+
/**
|
|
23
|
+
Whether the chart sits on a dark backdrop: the first non-transparent
|
|
24
|
+
background among its ancestors, or — when none sets one — the browser's
|
|
25
|
+
own page canvas, which is dark only when the page opts into a dark
|
|
26
|
+
`color-scheme` and the system prefers dark. Server renders are light.
|
|
27
|
+
*/
|
|
28
|
+
export declare function pageIsDark(viz: VizInstance): boolean;
|
|
29
|
+
/**
|
|
30
|
+
Redraws the chart when its backdrop changes theme: on a system theme
|
|
31
|
+
change, or when the page flips a theme class/attribute/style on <html>
|
|
32
|
+
or <body> (how most theme toggles work). Installed once per chart, and
|
|
33
|
+
only while it uses a `{light, dark}` pair.
|
|
34
|
+
*/
|
|
35
|
+
export declare function watchPageTheme(viz: VizInstance): void;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type StackOffsetFn, type StackOrderFn, type StackOrderInput } from "./stackHelpers.js";
|
|
2
|
-
import {
|
|
2
|
+
import type { PlotPaintContext } from "../features/plotPaint.js";
|
|
3
|
+
import { type ZoomState } from "./plotZoom.js";
|
|
3
4
|
import Viz from "../viz/Viz.js";
|
|
4
5
|
import type { InteractionPoint, PickResult, Scene, SceneEvent } from "@d3plus/render";
|
|
5
6
|
import type { DataPoint } from "@d3plus/data";
|
|
@@ -63,8 +64,9 @@ export default class Plot extends Viz {
|
|
|
63
64
|
/**
|
|
64
65
|
Picks the interaction point closest to a surface-local cursor position
|
|
65
66
|
along the discrete axis. `event.point` is post-zoom surface space while the
|
|
66
|
-
points are in
|
|
67
|
-
|
|
67
|
+
points are in chart content space (under the `viz-zoom` group and then
|
|
68
|
+
the chart's own `viz-chart-body` transform), so the cursor is un-zoomed
|
|
69
|
+
by `_zoomTransform` and offset by `_chartTransform` before comparing.
|
|
68
70
|
@private
|
|
69
71
|
*/
|
|
70
72
|
_nearestInteractionPoint(points: InteractionPoint[], point: [number, number]): InteractionPoint | null;
|
|
@@ -80,6 +82,13 @@ export default class Plot extends Viz {
|
|
|
80
82
|
scope beyond the explicit context).
|
|
81
83
|
*/
|
|
82
84
|
_paint(pCtx: PlotPaintContext): this;
|
|
85
|
+
/**
|
|
86
|
+
Zooms by rescaling the plot's linear axes instead of scaling the
|
|
87
|
+
rendered picture (see `Plot/plotZoom.ts`). Returns false when no axis
|
|
88
|
+
is linear, so the plot falls back to picture zoom.
|
|
89
|
+
@private
|
|
90
|
+
*/
|
|
91
|
+
_zoomRescale(t: ZoomState, duration?: number): boolean;
|
|
83
92
|
/**
|
|
84
93
|
Allows drawing custom shapes to be used as annotations in the provided x/y plot. This method accepts custom config objects for the [Shape](http://d3plus.org/docs/#Shape) class, either a single config object or an array of config objects. Each config object requires an additional parameter, the "shape", which denotes which [Shape](http://d3plus.org/docs/#Shape) sub-class to use ([Rect](http://d3plus.org/docs/#Rect), [Line](http://d3plus.org/docs/#Line), etc).
|
|
85
94
|
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
Axis-rescaling zoom for the Plot family (#780).
|
|
3
|
+
|
|
4
|
+
Rather than scaling the rendered picture (how every other chart zooms), a
|
|
5
|
+
Plot keeps its axes in place and rescales the domain of each simple linear
|
|
6
|
+
axis, then repaints its axes and shapes at the new scale. Discrete, time,
|
|
7
|
+
and log axes stay fixed — a bar chart zooms and pans along its value axis
|
|
8
|
+
only. The d3-zoom behavior and controls are shared with every other chart
|
|
9
|
+
(`drawSteps/zoomControls.ts`); `zoomed()` hands each transform to
|
|
10
|
+
`Plot._zoomRescale`, which lands here.
|
|
11
|
+
|
|
12
|
+
@module
|
|
13
|
+
*/
|
|
14
|
+
import type { SceneNode } from "@d3plus/render";
|
|
15
|
+
import type { PlotMeasureResult, PlotPaintContext } from "../features/plotPaint.js";
|
|
16
|
+
import type { VizInstance as Viz } from "../viz/vizTypes.js";
|
|
17
|
+
type AxisName = "x" | "x2" | "y" | "y2";
|
|
18
|
+
/** The invertible piece of an axis's d3 scale the rescale needs. */
|
|
19
|
+
interface LinearScale {
|
|
20
|
+
(value: number): number;
|
|
21
|
+
domain(): number[];
|
|
22
|
+
range(): number[];
|
|
23
|
+
invert(value: number): number;
|
|
24
|
+
}
|
|
25
|
+
/** A continuous transform in surface space, as d3-zoom reports it. */
|
|
26
|
+
export interface ZoomState {
|
|
27
|
+
k: number;
|
|
28
|
+
x: number;
|
|
29
|
+
y: number;
|
|
30
|
+
}
|
|
31
|
+
/** The unzoomed draw a zoom rescales from. */
|
|
32
|
+
export interface PlotZoomBase {
|
|
33
|
+
pCtx: PlotPaintContext;
|
|
34
|
+
layout: PlotMeasureResult;
|
|
35
|
+
chartTransform: {
|
|
36
|
+
x: number;
|
|
37
|
+
y: number;
|
|
38
|
+
};
|
|
39
|
+
scales: Partial<Record<AxisName, LinearScale>>;
|
|
40
|
+
labelSpace: Partial<Record<AxisName, number>>;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
Paints a Plot at its natural (unzoomed) scale and records what a zoom
|
|
44
|
+
needs to rescale from. When a zoom is already in effect (the chart was
|
|
45
|
+
re-rendered mid-zoom), the plot is immediately repainted at that zoom so
|
|
46
|
+
the view doesn't snap back.
|
|
47
|
+
*/
|
|
48
|
+
export declare function paintZoomablePlot(viz: Viz, pCtx: PlotPaintContext, current?: ZoomState): SceneNode[];
|
|
49
|
+
/**
|
|
50
|
+
Repaints the plot for a zoom transform. Returns the new chart scene, or
|
|
51
|
+
`undefined` when the plot has no linear axis to rescale (it then falls
|
|
52
|
+
back to picture zoom like any other chart). The content is clipped to the
|
|
53
|
+
plot rect unless the view is at its natural scale (or `keepClip` is set),
|
|
54
|
+
where shapes drawn at the domain edges would otherwise be cut off.
|
|
55
|
+
*/
|
|
56
|
+
export declare function rescalePlot(viz: Viz, t: ZoomState, keepClip?: boolean): SceneNode[] | undefined;
|
|
57
|
+
/**
|
|
58
|
+
Repaints the plot for a zoom transform, animated over `duration`. An
|
|
59
|
+
animated return to the natural scale from a zoomed view keeps the clip until the transition
|
|
60
|
+
settles, so shapes tweening back in from outside the plot don't paint
|
|
61
|
+
over the axes on the way; the clip is then dropped with an instant
|
|
62
|
+
repaint.
|
|
63
|
+
*/
|
|
64
|
+
export declare function zoomPlot(viz: Viz, t: ZoomState, duration: number): SceneNode[] | undefined;
|
|
65
|
+
export {};
|
|
@@ -45,7 +45,9 @@ interface ChartDefinitionBase {
|
|
|
45
45
|
scene coordinates that the chart content is clipped to). Geomap uses this to
|
|
46
46
|
contain projected geography within the map rectangle so it can't spill under
|
|
47
47
|
the legend/timeline; the clip stays put while pan/zoom moves content beneath
|
|
48
|
-
it.
|
|
48
|
+
it. The chart-cells group is untransformed (`chartTransform` applies to a
|
|
49
|
+
group inside it), so the clip is in surface coordinates. Zoomable charts
|
|
50
|
+
without one are clipped to the chart area.
|
|
49
51
|
*/
|
|
50
52
|
chartClip?: (viz: VizInstance) => import("@d3plus/render").ClipShape | undefined;
|
|
51
53
|
/**
|