@d3plus/core 4.6.0 → 4.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +728 -1454
- package/es/index.js.map +1 -1
- package/es/internal.js +5 -0
- package/es/internal.js.map +1 -1
- package/es/src/charts/Chord/index.js +2 -0
- package/es/src/charts/Chord/index.js.map +1 -1
- package/es/src/charts/Geomap/applyLayout.js +3 -1
- package/es/src/charts/Geomap/applyLayout.js.map +1 -1
- package/es/src/charts/Geomap/index.js +3 -1
- package/es/src/charts/Geomap/index.js.map +1 -1
- package/es/src/charts/Matrix/emit.js +5 -4
- package/es/src/charts/Matrix/emit.js.map +1 -1
- package/es/src/charts/Network/index.js +4 -0
- package/es/src/charts/Network/index.js.map +1 -1
- package/es/src/charts/Pack/emit.js +6 -6
- package/es/src/charts/Pack/emit.js.map +1 -1
- package/es/src/charts/Pack/index.js +2 -0
- package/es/src/charts/Pack/index.js.map +1 -1
- package/es/src/charts/Pie/emit.js +5 -6
- package/es/src/charts/Pie/emit.js.map +1 -1
- package/es/src/charts/Pie/index.js +2 -0
- package/es/src/charts/Pie/index.js.map +1 -1
- package/es/src/charts/Plot/index.js +15 -1
- package/es/src/charts/Plot/index.js.map +1 -1
- package/es/src/charts/Plot/insetRegion.js +21 -0
- package/es/src/charts/Plot/insetRegion.js.map +1 -0
- package/es/src/charts/Plot/sharedHover.js +117 -16
- package/es/src/charts/Plot/sharedHover.js.map +1 -1
- package/es/src/charts/Plot/sharedTooltip.js +35 -15
- package/es/src/charts/Plot/sharedTooltip.js.map +1 -1
- package/es/src/charts/Plot/trendLines.js +140 -38
- package/es/src/charts/Plot/trendLines.js.map +1 -1
- package/es/src/charts/Plot/trendProjection.js +120 -0
- package/es/src/charts/Plot/trendProjection.js.map +1 -0
- package/es/src/charts/Plot/trendScene.js +33 -19
- package/es/src/charts/Plot/trendScene.js.map +1 -1
- package/es/src/charts/Plot/trendTooltip.js +79 -17
- package/es/src/charts/Plot/trendTooltip.js.map +1 -1
- package/es/src/charts/Priestley/emit.js +3 -4
- package/es/src/charts/Priestley/emit.js.map +1 -1
- package/es/src/charts/RadialMatrix/emit.js +4 -4
- package/es/src/charts/RadialMatrix/emit.js.map +1 -1
- package/es/src/charts/Rings/index.js +5 -1
- package/es/src/charts/Rings/index.js.map +1 -1
- package/es/src/charts/Sankey/index.js +2 -0
- package/es/src/charts/Sankey/index.js.map +1 -1
- package/es/src/charts/Tree/index.js +2 -0
- package/es/src/charts/Tree/index.js.map +1 -1
- package/es/src/charts/Treemap/emit.js +3 -4
- package/es/src/charts/Treemap/emit.js.map +1 -1
- package/es/src/charts/definition/ChartDefinition.js.map +1 -1
- package/es/src/charts/definition/makeChart.js +8 -2
- package/es/src/charts/definition/makeChart.js.map +1 -1
- package/es/src/charts/drawSteps/bottomRightControls.js +3 -0
- package/es/src/charts/drawSteps/bottomRightControls.js.map +1 -1
- package/es/src/charts/drawSteps/bottomRightControlsMarkup.js +135 -4
- package/es/src/charts/drawSteps/bottomRightControlsMarkup.js.map +1 -1
- package/es/src/charts/drawSteps/searchControlsMarkup.js +15 -38
- package/es/src/charts/drawSteps/searchControlsMarkup.js.map +1 -1
- package/es/src/charts/events/click.legend.js +10 -5
- package/es/src/charts/events/click.legend.js.map +1 -1
- package/es/src/charts/events/mousemove.shape.js +8 -1
- package/es/src/charts/events/mousemove.shape.js.map +1 -1
- package/es/src/charts/features/emitHelpers.js +19 -5
- package/es/src/charts/features/emitHelpers.js.map +1 -1
- package/es/src/charts/features/features.js +3 -108
- package/es/src/charts/features/features.js.map +1 -1
- package/es/src/charts/features/featuresColorScale.js +161 -0
- package/es/src/charts/features/featuresColorScale.js.map +1 -0
- package/es/src/charts/features/featuresLegend.js +145 -32
- package/es/src/charts/features/featuresLegend.js.map +1 -1
- package/es/src/charts/features/insetState.js +174 -0
- package/es/src/charts/features/insetState.js.map +1 -0
- package/es/src/charts/features/sceneBounds.js +271 -0
- package/es/src/charts/features/sceneBounds.js.map +1 -0
- package/es/src/charts/features/tooltipSwatch.js +73 -0
- package/es/src/charts/features/tooltipSwatch.js.map +1 -0
- package/es/src/charts/pipeline/insetPlacement.js +406 -0
- package/es/src/charts/pipeline/insetPlacement.js.map +1 -0
- package/es/src/charts/pipeline/runVizPipeline.js +6 -2
- package/es/src/charts/pipeline/runVizPipeline.js.map +1 -1
- package/es/src/charts/viz/Viz.js +18 -3
- package/es/src/charts/viz/Viz.js.map +1 -1
- package/es/src/charts/viz/VizBaseConfig.js +20 -24
- package/es/src/charts/viz/VizBaseConfig.js.map +1 -1
- package/es/src/charts/viz/interactionOpacity.js +21 -13
- package/es/src/charts/viz/interactionOpacity.js.map +1 -1
- package/es/src/charts/viz/linkGroup.js +386 -0
- package/es/src/charts/viz/linkGroup.js.map +1 -0
- package/es/src/charts/viz/sceneRows.js +33 -0
- package/es/src/charts/viz/sceneRows.js.map +1 -0
- package/es/src/charts/viz/vizDefaults.js +13 -8
- package/es/src/charts/viz/vizDefaults.js.map +1 -1
- package/es/src/charts/viz/vizTypes.js.map +1 -1
- package/es/src/components/Axis/AxisBottom.js +1 -1
- package/es/src/components/Axis/AxisBottom.js.map +1 -1
- package/es/src/components/Axis/AxisLeft.js +1 -1
- package/es/src/components/Axis/AxisLeft.js.map +1 -1
- package/es/src/components/Axis/AxisRight.js +1 -1
- package/es/src/components/Axis/AxisRight.js.map +1 -1
- package/es/src/components/Axis/AxisTop.js +1 -1
- package/es/src/components/Axis/AxisTop.js.map +1 -1
- package/es/src/components/Axis/axisLayoutLabels.js +13 -1
- package/es/src/components/Axis/axisLayoutLabels.js.map +1 -1
- package/es/src/components/ColorScale/ColorScale.js.map +1 -1
- package/es/src/components/Legend/legendConfig.js +2 -1
- package/es/src/components/Legend/legendConfig.js.map +1 -1
- package/es/src/components/Legend/legendRender.js +42 -5
- package/es/src/components/Legend/legendRender.js.map +1 -1
- package/es/src/components/TextBox.js +1 -1
- package/es/src/components/TextBox.js.map +1 -1
- package/es/src/shapes/Bar.js +1 -1
- package/es/src/shapes/Bar.js.map +1 -1
- package/es/src/shapes/Box.js +1 -1
- package/es/src/shapes/Box.js.map +1 -1
- package/es/src/shapes/Rect.js +1 -1
- package/es/src/shapes/Rect.js.map +1 -1
- package/es/src/shapes/Shape.js +9 -36
- package/es/src/shapes/Shape.js.map +1 -1
- package/es/src/shapes/Whisker.js +1 -1
- package/es/src/shapes/Whisker.js.map +1 -1
- package/es/src/shapes/textureKey.js +104 -0
- package/es/src/shapes/textureKey.js.map +1 -0
- package/es/src/utils/D3plusConfig.js.map +1 -1
- package/package.json +10 -9
- package/types/index.d.ts +1 -0
- package/types/internal.d.ts +7 -0
- package/types/src/charts/Plot/index.d.ts +8 -0
- package/types/src/charts/Plot/insetRegion.d.ts +4 -0
- package/types/src/charts/Plot/sharedHover.d.ts +5 -0
- package/types/src/charts/Plot/sharedTooltip.d.ts +10 -0
- package/types/src/charts/Plot/trendLines.d.ts +23 -3
- package/types/src/charts/Plot/trendProjection.d.ts +28 -0
- package/types/src/charts/Plot/trendScene.d.ts +2 -1
- package/types/src/charts/Plot/trendTooltip.d.ts +16 -5
- package/types/src/charts/definition/ChartDefinition.d.ts +9 -0
- package/types/src/charts/definition/makeChart.d.ts +2 -2
- package/types/src/charts/drawSteps/bottomRightControlsMarkup.d.ts +2 -0
- package/types/src/charts/drawSteps/searchControlsMarkup.d.ts +7 -5
- package/types/src/charts/features/emitHelpers.d.ts +10 -4
- package/types/src/charts/features/features.d.ts +1 -8
- package/types/src/charts/features/featuresColorScale.d.ts +24 -0
- package/types/src/charts/features/featuresLegend.d.ts +15 -0
- package/types/src/charts/features/insetState.d.ts +95 -0
- package/types/src/charts/features/sceneBounds.d.ts +18 -0
- package/types/src/charts/features/tooltipSwatch.d.ts +31 -0
- package/types/src/charts/pipeline/insetPlacement.d.ts +45 -0
- package/types/src/charts/pipeline/runVizPipeline.d.ts +2 -1
- package/types/src/charts/viz/Viz.d.ts +9 -1
- package/types/src/charts/viz/VizBaseConfig.d.ts +8 -12
- package/types/src/charts/viz/linkGroup.d.ts +96 -0
- package/types/src/charts/viz/sceneRows.d.ts +13 -0
- package/types/src/charts/viz/vizTypes.d.ts +17 -0
- package/types/src/components/Axis/AxisBottom.d.ts +1 -1
- package/types/src/components/Axis/AxisLeft.d.ts +1 -1
- package/types/src/components/Axis/AxisRight.d.ts +1 -1
- package/types/src/components/Axis/AxisTop.d.ts +1 -1
- package/types/src/components/ColorScale/ColorScale.d.ts +4 -4
- package/types/src/components/Legend/legendRender.d.ts +1 -1
- package/types/src/components/TextBox.d.ts +1 -1
- package/types/src/shapes/Bar.d.ts +1 -1
- package/types/src/shapes/Box.d.ts +1 -1
- package/types/src/shapes/Rect.d.ts +1 -1
- package/types/src/shapes/Whisker.d.ts +1 -1
- package/types/src/shapes/textureKey.d.ts +9 -0
- package/types/src/utils/D3plusConfig.d.ts +42 -1
- package/umd/d3plus-core.full.js +2393 -594
- package/umd/d3plus-core.full.js.map +1 -1
- package/umd/d3plus-core.full.min.js +1945 -1601
- package/umd/d3plus-core.js +1744 -404
- package/umd/d3plus-core.js.map +1 -1
- package/umd/d3plus-core.min.js +1401 -1087
|
@@ -0,0 +1,406 @@
|
|
|
1
|
+
function _define_property(obj, key, value) {
|
|
2
|
+
if (key in obj) {
|
|
3
|
+
Object.defineProperty(obj, key, {
|
|
4
|
+
value: value,
|
|
5
|
+
enumerable: true,
|
|
6
|
+
configurable: true,
|
|
7
|
+
writable: true
|
|
8
|
+
});
|
|
9
|
+
} else {
|
|
10
|
+
obj[key] = value;
|
|
11
|
+
}
|
|
12
|
+
return obj;
|
|
13
|
+
}
|
|
14
|
+
function _object_spread(target) {
|
|
15
|
+
for(var i = 1; i < arguments.length; i++){
|
|
16
|
+
var source = arguments[i] != null ? arguments[i] : {};
|
|
17
|
+
var ownKeys = Object.keys(source);
|
|
18
|
+
if (typeof Object.getOwnPropertySymbols === "function") {
|
|
19
|
+
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
20
|
+
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
21
|
+
}));
|
|
22
|
+
}
|
|
23
|
+
ownKeys.forEach(function(key) {
|
|
24
|
+
_define_property(target, key, source[key]);
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
return target;
|
|
28
|
+
}
|
|
29
|
+
function _type_of(obj) {
|
|
30
|
+
"@swc/helpers - typeof";
|
|
31
|
+
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
Draws one piece of chart chrome — the size legend, else the legend, else
|
|
35
|
+
the colorScale — inside the chart's negative space instead of in a
|
|
36
|
+
margin, when the chart offers a region (`ChartDefinition.insetRegion`)
|
|
37
|
+
and `legendInset` is on.
|
|
38
|
+
|
|
39
|
+
Placement needs the chart's laid-out marks, but chrome normally claims
|
|
40
|
+
its margin before the chart lays out, so the draw runs optimistically:
|
|
41
|
+
1. Every candidate skips its margin claim, and the chart lays out in
|
|
42
|
+
the full area.
|
|
43
|
+
2. The open space around the marks (`negativeSpace`) is searched for
|
|
44
|
+
the first candidate, in priority order, that fits.
|
|
45
|
+
3. If one fits and nothing else is waiting on a margin, that draw
|
|
46
|
+
stands. If other candidates are showing, the chart lays out again
|
|
47
|
+
with them back in their margins, and the winner is fitted again in
|
|
48
|
+
the (smaller) chart. When nothing fits, the chart lays out normally.
|
|
49
|
+
|
|
50
|
+
@module
|
|
51
|
+
*/ import { negativeSpace } from "@d3plus/math";
|
|
52
|
+
import { chartBounds } from "../features/chartGeometry.js";
|
|
53
|
+
import { paintColorScaleInset } from "../features/featuresColorScale.js";
|
|
54
|
+
import { buildLegendData, paintLegendInset } from "../features/featuresLegend.js";
|
|
55
|
+
import { sanitizePosition } from "../features/features.js";
|
|
56
|
+
import { markBoxes } from "../features/sceneBounds.js";
|
|
57
|
+
import { INSET_PRIORITY, insetFrame, insetStyle } from "../features/insetState.js";
|
|
58
|
+
import { bottomRightControlsBox } from "../drawSteps/bottomRightControlsMarkup.js";
|
|
59
|
+
import { MINIMAP_RIGHT_INSET } from "../drawSteps/minimapMarkup.js";
|
|
60
|
+
import { getTopLeftContributions } from "../drawSteps/topLeftControls.js";
|
|
61
|
+
import { topLeftControlsBox } from "../drawSteps/topLeftControlsMarkup.js";
|
|
62
|
+
import { zoomControlsBox } from "../drawSteps/zoomControlsMarkup.js";
|
|
63
|
+
import { resolveSpec } from "./resolveSpec.js";
|
|
64
|
+
/**
|
|
65
|
+
The default inset region: the chart area (or `bounds`, in surface
|
|
66
|
+
coordinates), with the boxes of every data mark in the chart's scene as
|
|
67
|
+
obstacles (less any subtree `skip` excludes). Charts opt in by returning
|
|
68
|
+
this from their `insetRegion`.
|
|
69
|
+
*/ export function sceneInsetRegion(viz, bounds, skip) {
|
|
70
|
+
var _chartBounds = chartBounds(viz), width = _chartBounds.width, height = _chartBounds.height;
|
|
71
|
+
return {
|
|
72
|
+
bounds: bounds !== null && bounds !== void 0 ? bounds : {
|
|
73
|
+
x: viz._margin.left,
|
|
74
|
+
y: viz._margin.top,
|
|
75
|
+
width: width,
|
|
76
|
+
height: height
|
|
77
|
+
},
|
|
78
|
+
obstacles: markBoxes(viz._chartScene || [], viz._chartTransform, skip)
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
/** Whether `legendInset` is on for this draw. */ function insetEnabled(viz) {
|
|
82
|
+
var flag = viz.schema.legendInset;
|
|
83
|
+
return typeof flag === "function" ? Boolean(flag.bind(viz)(resolveSpec(viz))) : Boolean(flag);
|
|
84
|
+
}
|
|
85
|
+
/** The smallest a legend entry can be: a swatch (1.4× the 12px label font) plus its padding. */ var MIN_LEGEND_ENTRY = 12 * 1.4 + 5;
|
|
86
|
+
/**
|
|
87
|
+
Whether the legend could possibly lay out inside the chart: its entries,
|
|
88
|
+
even with their labels dropped, must fit the largest frame an inset
|
|
89
|
+
legend may take (see `insetFrame`). Rules out laying out a legend of
|
|
90
|
+
hundreds of entries just to find it doesn't fit.
|
|
91
|
+
*/ function legendCouldFit(viz) {
|
|
92
|
+
var frame = insetFrame("column", {
|
|
93
|
+
width: viz.schema.width || 0,
|
|
94
|
+
height: viz.schema.height || 0
|
|
95
|
+
});
|
|
96
|
+
var entries = buildLegendData(viz).legendData.length;
|
|
97
|
+
return entries * MIN_LEGEND_ENTRY * MIN_LEGEND_ENTRY <= frame.width * frame.height;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
The candidates this draw may place inside the chart, in priority order.
|
|
101
|
+
A legend or colorScale whose position the user set explicitly stays
|
|
102
|
+
where they put it.
|
|
103
|
+
*/ function insetCandidates(viz) {
|
|
104
|
+
var auto = viz._insetAutoPositions;
|
|
105
|
+
return INSET_PRIORITY.filter(function(key) {
|
|
106
|
+
if (key === "legend") return (!auto || viz.schema.legendPosition === auto.legend) && legendCouldFit(viz);
|
|
107
|
+
if (key === "colorScale") return !auto || viz.schema.colorScalePosition === auto.colorScale;
|
|
108
|
+
return true;
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
/** The orientations a candidate may take inside the chart. */ var ORIENTS = {
|
|
112
|
+
sizeLegend: [
|
|
113
|
+
"column"
|
|
114
|
+
],
|
|
115
|
+
legend: [
|
|
116
|
+
"column",
|
|
117
|
+
"row"
|
|
118
|
+
],
|
|
119
|
+
colorScale: [
|
|
120
|
+
"column",
|
|
121
|
+
"row"
|
|
122
|
+
]
|
|
123
|
+
};
|
|
124
|
+
/** Whether a candidate laid out for the chart's interior this pass is showing at all. */ function isShowing(viz, key) {
|
|
125
|
+
var _bottomRightControlsBox, _viz__legendClass__data, _viz__legendClass;
|
|
126
|
+
if (key === "sizeLegend") return Boolean((_bottomRightControlsBox = bottomRightControlsBox(viz)) === null || _bottomRightControlsBox === void 0 ? void 0 : _bottomRightControlsBox.inset);
|
|
127
|
+
if (key === "legend") return Boolean((_viz__legendClass = viz._legendClass) === null || _viz__legendClass === void 0 ? void 0 : (_viz__legendClass__data = _viz__legendClass._data) === null || _viz__legendClass__data === void 0 ? void 0 : _viz__legendClass__data.length);
|
|
128
|
+
return Boolean(viz.schema.colorScale) && sanitizePosition(viz.schema.colorScalePosition.bind(viz)(resolveSpec(viz))) !== false && !viz.schema.colorScaleConfig.select;
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
Lays a showing candidate out for the chart's interior in `orient` and
|
|
132
|
+
returns its content size, or null when it can't lay out that way.
|
|
133
|
+
*/ function measure(viz, key, orient, area) {
|
|
134
|
+
if (key === "sizeLegend") {
|
|
135
|
+
var box = bottomRightControlsBox(viz);
|
|
136
|
+
return box ? {
|
|
137
|
+
width: box.width,
|
|
138
|
+
height: box.height
|
|
139
|
+
} : null;
|
|
140
|
+
}
|
|
141
|
+
return key === "legend" ? paintLegendInset(viz, orient, area) : paintColorScaleInset(viz, orient, area);
|
|
142
|
+
}
|
|
143
|
+
/** The chart corners an inset box is tried in, most preferred first. */ var CORNERS = [
|
|
144
|
+
{
|
|
145
|
+
alignX: "right",
|
|
146
|
+
alignY: "bottom"
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
alignX: "right",
|
|
150
|
+
alignY: "top"
|
|
151
|
+
},
|
|
152
|
+
{
|
|
153
|
+
alignX: "left",
|
|
154
|
+
alignY: "bottom"
|
|
155
|
+
},
|
|
156
|
+
{
|
|
157
|
+
alignX: "left",
|
|
158
|
+
alignY: "top"
|
|
159
|
+
}
|
|
160
|
+
];
|
|
161
|
+
/**
|
|
162
|
+
Where a box of `width` × `height` sits in the open rects (sorted largest
|
|
163
|
+
first): in the first chart corner, in `CORNERS` order, that some rect
|
|
164
|
+
reaching that corner has room for. When it fits in no corner, it goes in
|
|
165
|
+
the first rect it fits, against whichever of the rect's sides lie on the
|
|
166
|
+
region's edges (bottom-right when it touches both), centered along an
|
|
167
|
+
axis otherwise.
|
|
168
|
+
*/ export function fitInset(rects, bounds, width, height) {
|
|
169
|
+
var eps = 0.5;
|
|
170
|
+
var fits = rects.filter(function(r) {
|
|
171
|
+
return r.width >= width && r.height >= height;
|
|
172
|
+
});
|
|
173
|
+
if (!fits.length) return null;
|
|
174
|
+
var edges = function edges(r) {
|
|
175
|
+
return {
|
|
176
|
+
right: Math.abs(r.x + r.width - (bounds.x + bounds.width)) < eps,
|
|
177
|
+
left: Math.abs(r.x - bounds.x) < eps,
|
|
178
|
+
bottom: Math.abs(r.y + r.height - (bounds.y + bounds.height)) < eps,
|
|
179
|
+
top: Math.abs(r.y - bounds.y) < eps
|
|
180
|
+
};
|
|
181
|
+
};
|
|
182
|
+
var place = function place(r, alignX, alignY) {
|
|
183
|
+
return {
|
|
184
|
+
x: alignX === "right" ? r.x + r.width - width : alignX === "left" ? r.x : r.x + (r.width - width) / 2,
|
|
185
|
+
y: alignY === "bottom" ? r.y + r.height - height : alignY === "top" ? r.y : r.y + (r.height - height) / 2,
|
|
186
|
+
width: width,
|
|
187
|
+
height: height,
|
|
188
|
+
alignX: alignX,
|
|
189
|
+
alignY: alignY
|
|
190
|
+
};
|
|
191
|
+
};
|
|
192
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
193
|
+
try {
|
|
194
|
+
var _loop = function() {
|
|
195
|
+
var _step_value = _step.value, alignX = _step_value.alignX, alignY = _step_value.alignY;
|
|
196
|
+
var rect = fits.find(function(r) {
|
|
197
|
+
var e = edges(r);
|
|
198
|
+
return e[alignX] && e[alignY];
|
|
199
|
+
});
|
|
200
|
+
if (rect) return {
|
|
201
|
+
v: place(rect, alignX, alignY)
|
|
202
|
+
};
|
|
203
|
+
};
|
|
204
|
+
for(var _iterator = CORNERS[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
205
|
+
var _ret = _loop();
|
|
206
|
+
if (_type_of(_ret) === "object") return _ret.v;
|
|
207
|
+
}
|
|
208
|
+
} catch (err) {
|
|
209
|
+
_didIteratorError = true;
|
|
210
|
+
_iteratorError = err;
|
|
211
|
+
} finally{
|
|
212
|
+
try {
|
|
213
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
214
|
+
_iterator.return();
|
|
215
|
+
}
|
|
216
|
+
} finally{
|
|
217
|
+
if (_didIteratorError) {
|
|
218
|
+
throw _iteratorError;
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
var rect = fits[0], e = edges(rect);
|
|
223
|
+
return place(rect, e.right ? "right" : e.left ? "left" : "center", e.bottom ? "bottom" : e.top ? "top" : "middle");
|
|
224
|
+
}
|
|
225
|
+
/** Rough height of the attribution credit, a single line of small text. */ var ATTRIBUTION_HEIGHT = 22;
|
|
226
|
+
/**
|
|
227
|
+
Boxes of the chrome overlaid on the chart that inset chrome must also
|
|
228
|
+
stay clear of: the zoom buttons (and the minimap that opens beneath
|
|
229
|
+
them once zoomed), the top-left controls, and the attribution credit in
|
|
230
|
+
the chart area's bottom-right corner (sized from its rendered node when
|
|
231
|
+
there is one, otherwise from its text, up to the half of the chart it
|
|
232
|
+
may span before collapsing to a badge).
|
|
233
|
+
*/ function chromeBoxes(viz) {
|
|
234
|
+
var boxes = [];
|
|
235
|
+
var _chartBounds = chartBounds(viz), width = _chartBounds.width, height = _chartBounds.height;
|
|
236
|
+
var zoom = zoomControlsBox(viz);
|
|
237
|
+
if (zoom) {
|
|
238
|
+
var minimap = viz.schema.minimap ? (zoom.width - MINIMAP_RIGHT_INSET) * (height / Math.max(1, width)) : 0;
|
|
239
|
+
boxes.push({
|
|
240
|
+
x: viz.schema.width - zoom.width,
|
|
241
|
+
y: 0,
|
|
242
|
+
width: zoom.width,
|
|
243
|
+
height: zoom.height + minimap
|
|
244
|
+
});
|
|
245
|
+
}
|
|
246
|
+
var topLeft = topLeftControlsBox(viz, getTopLeftContributions(viz));
|
|
247
|
+
if (topLeft) boxes.push({
|
|
248
|
+
x: 0,
|
|
249
|
+
y: 0,
|
|
250
|
+
width: topLeft.width,
|
|
251
|
+
height: topLeft.height
|
|
252
|
+
});
|
|
253
|
+
if (viz.schema.attribution) {
|
|
254
|
+
var _viz__select_node, _viz__select_node1, _viz__select, _parent_querySelector;
|
|
255
|
+
var parent = (_viz__select = viz._select) === null || _viz__select === void 0 ? void 0 : (_viz__select_node1 = _viz__select.node) === null || _viz__select_node1 === void 0 ? void 0 : (_viz__select_node = _viz__select_node1.call(_viz__select)) === null || _viz__select_node === void 0 ? void 0 : _viz__select_node.parentNode;
|
|
256
|
+
var node = parent === null || parent === void 0 ? void 0 : (_parent_querySelector = parent.querySelector) === null || _parent_querySelector === void 0 ? void 0 : _parent_querySelector.call(parent, "div.d3plus-attribution");
|
|
257
|
+
var text = String(viz.schema.attribution).replace(/<[^>]*>/g, "");
|
|
258
|
+
var w = Math.min((node === null || node === void 0 ? void 0 : node.offsetWidth) || text.length * 6 + 30, width / 2);
|
|
259
|
+
var h = (node === null || node === void 0 ? void 0 : node.offsetHeight) || ATTRIBUTION_HEIGHT;
|
|
260
|
+
var right = viz.schema.width - viz._margin.right, bottom = viz.schema.height - viz._margin.bottom;
|
|
261
|
+
boxes.push({
|
|
262
|
+
x: right - w,
|
|
263
|
+
y: bottom - h,
|
|
264
|
+
width: w,
|
|
265
|
+
height: h
|
|
266
|
+
});
|
|
267
|
+
}
|
|
268
|
+
return boxes;
|
|
269
|
+
}
|
|
270
|
+
/** The open rects in the chart's region, kept `padding` clear of the marks and the region's edges. */ function openSpace(viz) {
|
|
271
|
+
var _viz__insetRegion;
|
|
272
|
+
var region = (_viz__insetRegion = viz._insetRegion) === null || _viz__insetRegion === void 0 ? void 0 : _viz__insetRegion.call(viz);
|
|
273
|
+
if (!region) return null;
|
|
274
|
+
var padding = insetStyle(viz).padding;
|
|
275
|
+
var b = region.bounds;
|
|
276
|
+
var bounds = {
|
|
277
|
+
x: b.x + padding,
|
|
278
|
+
y: b.y + padding,
|
|
279
|
+
width: b.width - padding * 2,
|
|
280
|
+
height: b.height - padding * 2
|
|
281
|
+
};
|
|
282
|
+
if (bounds.width <= 0 || bounds.height <= 0) return null;
|
|
283
|
+
var exclude = chromeBoxes(viz);
|
|
284
|
+
return {
|
|
285
|
+
rects: negativeSpace(bounds, region.obstacles, {
|
|
286
|
+
padding: padding,
|
|
287
|
+
exclude: exclude
|
|
288
|
+
}),
|
|
289
|
+
bounds: bounds,
|
|
290
|
+
area: b
|
|
291
|
+
};
|
|
292
|
+
}
|
|
293
|
+
/**
|
|
294
|
+
Fits the first of `keys` that has room inside the chart. Returns the
|
|
295
|
+
placement (or null) and which candidates are showing at all.
|
|
296
|
+
*/ function choose(viz, keys) {
|
|
297
|
+
var showing = keys.filter(function(key) {
|
|
298
|
+
return isShowing(viz, key);
|
|
299
|
+
});
|
|
300
|
+
var space = showing.length ? openSpace(viz) : null;
|
|
301
|
+
if (!space || !space.rects.length) return {
|
|
302
|
+
placement: null,
|
|
303
|
+
showing: showing
|
|
304
|
+
};
|
|
305
|
+
var margin = insetStyle(viz).margin;
|
|
306
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
307
|
+
try {
|
|
308
|
+
for(var _iterator = showing[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
309
|
+
var key = _step.value;
|
|
310
|
+
var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
|
|
311
|
+
try {
|
|
312
|
+
for(var _iterator1 = ORIENTS[key][Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true){
|
|
313
|
+
var orient = _step1.value;
|
|
314
|
+
var size = measure(viz, key, orient, space.area);
|
|
315
|
+
var spot = size && fitInset(space.rects, space.bounds, size.width + margin * 2, size.height + margin * 2);
|
|
316
|
+
if (spot) {
|
|
317
|
+
return {
|
|
318
|
+
placement: _object_spread({
|
|
319
|
+
key: key,
|
|
320
|
+
orient: orient
|
|
321
|
+
}, spot),
|
|
322
|
+
showing: showing
|
|
323
|
+
};
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
} catch (err) {
|
|
327
|
+
_didIteratorError1 = true;
|
|
328
|
+
_iteratorError1 = err;
|
|
329
|
+
} finally{
|
|
330
|
+
try {
|
|
331
|
+
if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
|
|
332
|
+
_iterator1.return();
|
|
333
|
+
}
|
|
334
|
+
} finally{
|
|
335
|
+
if (_didIteratorError1) {
|
|
336
|
+
throw _iteratorError1;
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
} catch (err) {
|
|
342
|
+
_didIteratorError = true;
|
|
343
|
+
_iteratorError = err;
|
|
344
|
+
} finally{
|
|
345
|
+
try {
|
|
346
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
347
|
+
_iterator.return();
|
|
348
|
+
}
|
|
349
|
+
} finally{
|
|
350
|
+
if (_didIteratorError) {
|
|
351
|
+
throw _iteratorError;
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
return {
|
|
356
|
+
placement: null,
|
|
357
|
+
showing: showing
|
|
358
|
+
};
|
|
359
|
+
}
|
|
360
|
+
/** Runs `_draw()` again from the margins the render started with. */ function redraw(viz, start) {
|
|
361
|
+
viz._margin = _object_spread({}, start.margin);
|
|
362
|
+
viz._padding = _object_spread({}, start.padding);
|
|
363
|
+
viz._draw();
|
|
364
|
+
}
|
|
365
|
+
/**
|
|
366
|
+
`viz._draw()`, placing chrome inside the chart's negative space when it
|
|
367
|
+
fits (see the module docs). Leaves `viz._insetPlacement` set to what was
|
|
368
|
+
placed, or null.
|
|
369
|
+
*/ export function drawWithInset(viz) {
|
|
370
|
+
viz._insetPlacement = null;
|
|
371
|
+
var keys = typeof viz._insetRegion === "function" && insetEnabled(viz) ? insetCandidates(viz) : [];
|
|
372
|
+
if (!keys.length) {
|
|
373
|
+
viz._insetPending = null;
|
|
374
|
+
viz._draw();
|
|
375
|
+
return;
|
|
376
|
+
}
|
|
377
|
+
var start = {
|
|
378
|
+
margin: _object_spread({}, viz._margin),
|
|
379
|
+
padding: _object_spread({}, viz._padding)
|
|
380
|
+
};
|
|
381
|
+
viz._insetPending = new Set(keys);
|
|
382
|
+
viz._draw();
|
|
383
|
+
var first = choose(viz, keys);
|
|
384
|
+
var showing = first.showing;
|
|
385
|
+
var placement = first.placement;
|
|
386
|
+
if (!showing.length) return;
|
|
387
|
+
if (placement && showing.some(function(k) {
|
|
388
|
+
return k !== placement.key;
|
|
389
|
+
})) {
|
|
390
|
+
viz._insetPending = new Set([
|
|
391
|
+
placement.key
|
|
392
|
+
]);
|
|
393
|
+
redraw(viz, start);
|
|
394
|
+
placement = choose(viz, [
|
|
395
|
+
placement.key
|
|
396
|
+
]).placement;
|
|
397
|
+
}
|
|
398
|
+
if (!placement) {
|
|
399
|
+
viz._insetPending = new Set();
|
|
400
|
+
redraw(viz, start);
|
|
401
|
+
return;
|
|
402
|
+
}
|
|
403
|
+
viz._insetPlacement = placement;
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
//# sourceMappingURL=insetPlacement.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/charts/pipeline/insetPlacement.ts"],"sourcesContent":["/**\n Draws one piece of chart chrome — the size legend, else the legend, else\n the colorScale — inside the chart's negative space instead of in a\n margin, when the chart offers a region (`ChartDefinition.insetRegion`)\n and `legendInset` is on.\n\n Placement needs the chart's laid-out marks, but chrome normally claims\n its margin before the chart lays out, so the draw runs optimistically:\n 1. Every candidate skips its margin claim, and the chart lays out in\n the full area.\n 2. The open space around the marks (`negativeSpace`) is searched for\n the first candidate, in priority order, that fits.\n 3. If one fits and nothing else is waiting on a margin, that draw\n stands. If other candidates are showing, the chart lays out again\n with them back in their margins, and the winner is fitted again in\n the (smaller) chart. When nothing fits, the chart lays out normally.\n\n @module\n*/\n\nimport {negativeSpace} from \"@d3plus/math\";\nimport type {Bounds} from \"@d3plus/math\";\nimport type {SceneNode} from \"@d3plus/render\";\n\nimport {chartBounds} from \"../features/chartGeometry.js\";\nimport {paintColorScaleInset} from \"../features/featuresColorScale.js\";\nimport {buildLegendData, paintLegendInset} from \"../features/featuresLegend.js\";\nimport {sanitizePosition} from \"../features/features.js\";\nimport {markBoxes} from \"../features/sceneBounds.js\";\nimport {INSET_PRIORITY, insetFrame, insetStyle} from \"../features/insetState.js\";\nimport type {InsetKey, InsetOrient, InsetPlacement, InsetRegion} from \"../features/insetState.js\";\nimport {bottomRightControlsBox} from \"../drawSteps/bottomRightControlsMarkup.js\";\nimport {MINIMAP_RIGHT_INSET} from \"../drawSteps/minimapMarkup.js\";\nimport {getTopLeftContributions} from \"../drawSteps/topLeftControls.js\";\nimport {topLeftControlsBox} from \"../drawSteps/topLeftControlsMarkup.js\";\nimport {zoomControlsBox} from \"../drawSteps/zoomControlsMarkup.js\";\nimport type {VizInstance} from \"../viz/vizTypes.js\";\nimport {resolveSpec} from \"./resolveSpec.js\";\n\n/**\n The default inset region: the chart area (or `bounds`, in surface\n coordinates), with the boxes of every data mark in the chart's scene as\n obstacles (less any subtree `skip` excludes). Charts opt in by returning\n this from their `insetRegion`.\n*/\nexport function sceneInsetRegion(\n viz: VizInstance,\n bounds?: Bounds,\n skip?: (node: SceneNode) => boolean,\n): InsetRegion {\n const {width, height} = chartBounds(viz);\n return {\n bounds: bounds ?? {x: viz._margin.left, y: viz._margin.top, width, height},\n obstacles: markBoxes(viz._chartScene || [], viz._chartTransform, skip),\n };\n}\n\n/** Whether `legendInset` is on for this draw. */\nfunction insetEnabled(viz: VizInstance): boolean {\n const flag = viz.schema.legendInset;\n return typeof flag === \"function\" ? Boolean(flag.bind(viz)(resolveSpec(viz))) : Boolean(flag);\n}\n\n/** The smallest a legend entry can be: a swatch (1.4× the 12px label font) plus its padding. */\nconst MIN_LEGEND_ENTRY = 12 * 1.4 + 5;\n\n/**\n Whether the legend could possibly lay out inside the chart: its entries,\n even with their labels dropped, must fit the largest frame an inset\n legend may take (see `insetFrame`). Rules out laying out a legend of\n hundreds of entries just to find it doesn't fit.\n*/\nfunction legendCouldFit(viz: VizInstance): boolean {\n const frame = insetFrame(\"column\", {width: viz.schema.width || 0, height: viz.schema.height || 0});\n const entries = buildLegendData(viz).legendData.length;\n return entries * MIN_LEGEND_ENTRY * MIN_LEGEND_ENTRY <= frame.width * frame.height;\n}\n\n/**\n The candidates this draw may place inside the chart, in priority order.\n A legend or colorScale whose position the user set explicitly stays\n where they put it.\n*/\nfunction insetCandidates(viz: VizInstance): InsetKey[] {\n const auto = viz._insetAutoPositions;\n return INSET_PRIORITY.filter(key => {\n if (key === \"legend\")\n return (!auto || viz.schema.legendPosition === auto.legend) && legendCouldFit(viz);\n if (key === \"colorScale\") return !auto || viz.schema.colorScalePosition === auto.colorScale;\n return true;\n });\n}\n\n/** The orientations a candidate may take inside the chart. */\nconst ORIENTS: Record<InsetKey, InsetOrient[]> = {\n sizeLegend: [\"column\"],\n legend: [\"column\", \"row\"],\n colorScale: [\"column\", \"row\"],\n};\n\n/** Whether a candidate laid out for the chart's interior this pass is showing at all. */\nfunction isShowing(viz: VizInstance, key: InsetKey): boolean {\n if (key === \"sizeLegend\") return Boolean(bottomRightControlsBox(viz)?.inset);\n if (key === \"legend\") return Boolean(viz._legendClass?._data?.length);\n return Boolean(viz.schema.colorScale) &&\n sanitizePosition(viz.schema.colorScalePosition.bind(viz)(resolveSpec(viz))) !== false &&\n !viz.schema.colorScaleConfig.select;\n}\n\n/**\n Lays a showing candidate out for the chart's interior in `orient` and\n returns its content size, or null when it can't lay out that way.\n*/\nfunction measure(\n viz: VizInstance,\n key: InsetKey,\n orient: InsetOrient,\n area: {width: number; height: number},\n): {width: number; height: number} | null {\n if (key === \"sizeLegend\") {\n const box = bottomRightControlsBox(viz);\n return box ? {width: box.width, height: box.height} : null;\n }\n return key === \"legend\"\n ? paintLegendInset(viz, orient, area)\n : paintColorScaleInset(viz, orient, area);\n}\n\n/** The chart corners an inset box is tried in, most preferred first. */\nconst CORNERS: Array<Pick<InsetPlacement, \"alignX\" | \"alignY\">> = [\n {alignX: \"right\", alignY: \"bottom\"},\n {alignX: \"right\", alignY: \"top\"},\n {alignX: \"left\", alignY: \"bottom\"},\n {alignX: \"left\", alignY: \"top\"},\n];\n\n/**\n Where a box of `width` × `height` sits in the open rects (sorted largest\n first): in the first chart corner, in `CORNERS` order, that some rect\n reaching that corner has room for. When it fits in no corner, it goes in\n the first rect it fits, against whichever of the rect's sides lie on the\n region's edges (bottom-right when it touches both), centered along an\n axis otherwise.\n*/\nexport function fitInset(\n rects: Bounds[],\n bounds: Bounds,\n width: number,\n height: number,\n): (Bounds & Pick<InsetPlacement, \"alignX\" | \"alignY\">) | null {\n const eps = 0.5;\n const fits = rects.filter(r => r.width >= width && r.height >= height);\n if (!fits.length) return null;\n const edges = (r: Bounds) => ({\n right: Math.abs(r.x + r.width - (bounds.x + bounds.width)) < eps,\n left: Math.abs(r.x - bounds.x) < eps,\n bottom: Math.abs(r.y + r.height - (bounds.y + bounds.height)) < eps,\n top: Math.abs(r.y - bounds.y) < eps,\n });\n const place = (r: Bounds, alignX: InsetPlacement[\"alignX\"], alignY: InsetPlacement[\"alignY\"]) => ({\n x: alignX === \"right\" ? r.x + r.width - width : alignX === \"left\" ? r.x : r.x + (r.width - width) / 2,\n y: alignY === \"bottom\" ? r.y + r.height - height : alignY === \"top\" ? r.y : r.y + (r.height - height) / 2,\n width,\n height,\n alignX,\n alignY,\n });\n for (const {alignX, alignY} of CORNERS) {\n const rect = fits.find(r => {\n const e = edges(r);\n return e[alignX as \"left\" | \"right\"] && e[alignY as \"top\" | \"bottom\"];\n });\n if (rect) return place(rect, alignX, alignY);\n }\n const rect = fits[0], e = edges(rect);\n return place(\n rect,\n e.right ? \"right\" : e.left ? \"left\" : \"center\",\n e.bottom ? \"bottom\" : e.top ? \"top\" : \"middle\",\n );\n}\n\n/** Rough height of the attribution credit, a single line of small text. */\nconst ATTRIBUTION_HEIGHT = 22;\n\n/**\n Boxes of the chrome overlaid on the chart that inset chrome must also\n stay clear of: the zoom buttons (and the minimap that opens beneath\n them once zoomed), the top-left controls, and the attribution credit in\n the chart area's bottom-right corner (sized from its rendered node when\n there is one, otherwise from its text, up to the half of the chart it\n may span before collapsing to a badge).\n*/\nfunction chromeBoxes(viz: VizInstance): Bounds[] {\n const boxes: Bounds[] = [];\n const {width, height} = chartBounds(viz);\n const zoom = zoomControlsBox(viz as never);\n if (zoom) {\n const minimap = viz.schema.minimap ? (zoom.width - MINIMAP_RIGHT_INSET) * (height / Math.max(1, width)) : 0;\n boxes.push({x: viz.schema.width - zoom.width, y: 0, width: zoom.width, height: zoom.height + minimap});\n }\n const topLeft = topLeftControlsBox(viz as never, getTopLeftContributions(viz as never));\n if (topLeft) boxes.push({x: 0, y: 0, width: topLeft.width, height: topLeft.height});\n if (viz.schema.attribution) {\n const parent = viz._select?.node?.()?.parentNode as Element | null | undefined;\n const node = parent?.querySelector?.(\"div.d3plus-attribution\") as HTMLElement | null | undefined;\n const text = String(viz.schema.attribution).replace(/<[^>]*>/g, \"\");\n const w = Math.min(node?.offsetWidth || text.length * 6 + 30, width / 2);\n const h = node?.offsetHeight || ATTRIBUTION_HEIGHT;\n const right = viz.schema.width - viz._margin.right, bottom = viz.schema.height - viz._margin.bottom;\n boxes.push({x: right - w, y: bottom - h, width: w, height: h});\n }\n return boxes;\n}\n\n/** The open rects in the chart's region, kept `padding` clear of the marks and the region's edges. */\nfunction openSpace(viz: VizInstance): {rects: Bounds[]; bounds: Bounds; area: {width: number; height: number}} | null {\n const region = viz._insetRegion?.();\n if (!region) return null;\n const {padding} = insetStyle(viz);\n const b = region.bounds;\n const bounds = {\n x: b.x + padding,\n y: b.y + padding,\n width: b.width - padding * 2,\n height: b.height - padding * 2,\n };\n if (bounds.width <= 0 || bounds.height <= 0) return null;\n const exclude = chromeBoxes(viz);\n return {rects: negativeSpace(bounds, region.obstacles, {padding, exclude}), bounds, area: b};\n}\n\n/**\n Fits the first of `keys` that has room inside the chart. Returns the\n placement (or null) and which candidates are showing at all.\n*/\nfunction choose(viz: VizInstance, keys: InsetKey[]): {placement: InsetPlacement | null; showing: InsetKey[]} {\n const showing = keys.filter(key => isShowing(viz, key));\n const space = showing.length ? openSpace(viz) : null;\n if (!space || !space.rects.length) return {placement: null, showing};\n const {margin} = insetStyle(viz);\n for (const key of showing) {\n for (const orient of ORIENTS[key]) {\n const size = measure(viz, key, orient, space.area);\n const spot = size && fitInset(space.rects, space.bounds, size.width + margin * 2, size.height + margin * 2);\n if (spot) {\n return {placement: {key, orient, ...spot}, showing};\n }\n }\n }\n return {placement: null, showing};\n}\n\n/** Runs `_draw()` again from the margins the render started with. */\nfunction redraw(viz: VizInstance, start: {margin: VizInstance[\"_margin\"]; padding: VizInstance[\"_padding\"]}): void {\n viz._margin = {...start.margin};\n viz._padding = {...start.padding};\n viz._draw();\n}\n\n/**\n `viz._draw()`, placing chrome inside the chart's negative space when it\n fits (see the module docs). Leaves `viz._insetPlacement` set to what was\n placed, or null.\n*/\nexport function drawWithInset(viz: VizInstance): void {\n viz._insetPlacement = null;\n const keys = typeof viz._insetRegion === \"function\" && insetEnabled(viz) ? insetCandidates(viz) : [];\n if (!keys.length) {\n viz._insetPending = null;\n viz._draw();\n return;\n }\n const start = {margin: {...viz._margin}, padding: {...viz._padding}};\n viz._insetPending = new Set(keys);\n viz._draw();\n\n const first = choose(viz, keys);\n const {showing} = first;\n let {placement} = first;\n if (!showing.length) return;\n if (placement && showing.some(k => k !== placement!.key)) {\n viz._insetPending = new Set([placement.key]);\n redraw(viz, start);\n placement = choose(viz, [placement.key]).placement;\n }\n if (!placement) {\n viz._insetPending = new Set();\n redraw(viz, start);\n return;\n }\n viz._insetPlacement = placement;\n}\n"],"names":["negativeSpace","chartBounds","paintColorScaleInset","buildLegendData","paintLegendInset","sanitizePosition","markBoxes","INSET_PRIORITY","insetFrame","insetStyle","bottomRightControlsBox","MINIMAP_RIGHT_INSET","getTopLeftContributions","topLeftControlsBox","zoomControlsBox","resolveSpec","sceneInsetRegion","viz","bounds","skip","width","height","x","_margin","left","y","top","obstacles","_chartScene","_chartTransform","insetEnabled","flag","schema","legendInset","Boolean","bind","MIN_LEGEND_ENTRY","legendCouldFit","frame","entries","legendData","length","insetCandidates","auto","_insetAutoPositions","filter","key","legendPosition","legend","colorScalePosition","colorScale","ORIENTS","sizeLegend","isShowing","inset","_legendClass","_data","colorScaleConfig","select","measure","orient","area","box","CORNERS","alignX","alignY","fitInset","rects","eps","fits","r","edges","right","Math","abs","bottom","place","rect","find","e","ATTRIBUTION_HEIGHT","chromeBoxes","boxes","zoom","minimap","max","push","topLeft","attribution","parent","_select","node","parentNode","querySelector","text","String","replace","w","min","offsetWidth","h","offsetHeight","openSpace","region","_insetRegion","padding","b","exclude","choose","keys","showing","space","placement","margin","size","spot","redraw","start","_padding","_draw","drawWithInset","_insetPlacement","_insetPending","Set","first","some","k"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;AAkBA,GAEA,SAAQA,aAAa,QAAO,eAAe;AAI3C,SAAQC,WAAW,QAAO,+BAA+B;AACzD,SAAQC,oBAAoB,QAAO,oCAAoC;AACvE,SAAQC,eAAe,EAAEC,gBAAgB,QAAO,gCAAgC;AAChF,SAAQC,gBAAgB,QAAO,0BAA0B;AACzD,SAAQC,SAAS,QAAO,6BAA6B;AACrD,SAAQC,cAAc,EAAEC,UAAU,EAAEC,UAAU,QAAO,4BAA4B;AAEjF,SAAQC,sBAAsB,QAAO,4CAA4C;AACjF,SAAQC,mBAAmB,QAAO,gCAAgC;AAClE,SAAQC,uBAAuB,QAAO,kCAAkC;AACxE,SAAQC,kBAAkB,QAAO,wCAAwC;AACzE,SAAQC,eAAe,QAAO,qCAAqC;AAEnE,SAAQC,WAAW,QAAO,mBAAmB;AAE7C;;;;;AAKA,GACA,OAAO,SAASC,iBACdC,GAAgB,EAChBC,MAAe,EACfC,I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AC3CsE,OAAOnG,KAAKoG;QACZL,YAAYJ,OAAO3F,KAAK;YAAC+F,UAAUlE,GAAG;SAAC,EAAEkE,SAAS;IACpD;IACA,IAAI,CAACA,WAAW;QACd/F,IAAIyG,aAAa,GAAG,IAAIC;QACxBP,OAAOnG,KAAKoG;QACZ;IACF;IACApG,IAAIwG,eAAe,GAAGT;AACxB"}
|
|
@@ -38,7 +38,8 @@ function _unsupported_iterable_to_array(o, minLen) {
|
|
|
38
38
|
callback:
|
|
39
39
|
|
|
40
40
|
1. `viz._preDraw()` — data filtering + legend-data + drawDepth
|
|
41
|
-
2. `viz._draw()` — chart-specific layout + scene absorption
|
|
41
|
+
2. `viz._draw()` — chart-specific layout + scene absorption, re-run
|
|
42
|
+
when chrome is placed inside the chart (`drawWithInset`)
|
|
42
43
|
3. `zoomControls(viz)` — zoom HTML overlay (architectural carve-out)
|
|
43
44
|
4. `minimapFeature.layout(viz)` — zoomed-chart viewport indicator
|
|
44
45
|
5. `topLeftControlsFeature.layout(viz)` — back/table-view/search panel
|
|
@@ -59,6 +60,7 @@ function _unsupported_iterable_to_array(o, minLen) {
|
|
|
59
60
|
import { minimapFeature } from "../drawSteps/minimap.js";
|
|
60
61
|
import { zoomFeature } from "../drawSteps/zoomControls.js";
|
|
61
62
|
import { resolveDrillMorph } from "./drillMorph.js";
|
|
63
|
+
import { drawWithInset } from "./insetPlacement.js";
|
|
62
64
|
import { topLeftControlsFeature } from "../drawSteps/topLeftControls.js";
|
|
63
65
|
import { bottomRightControlsFeature } from "../drawSteps/bottomRightControls.js";
|
|
64
66
|
import { tableViewFeature } from "../drawSteps/tableView.js";
|
|
@@ -69,7 +71,9 @@ export function runVizPipeline(viz) {
|
|
|
69
71
|
// hold the BASE Viz behavior; subclasses' `super._preDraw()`/`super._draw()`
|
|
70
72
|
// calls hit the shim which delegates to the free functions.
|
|
71
73
|
viz._preDraw();
|
|
72
|
-
|
|
74
|
+
// `_draw()`, possibly more than once: chrome that fits inside the chart's
|
|
75
|
+
// negative space is placed there after layout (see insetPlacement.ts).
|
|
76
|
+
drawWithInset(viz);
|
|
73
77
|
// Post-draw features: zoom + brush event wiring, the minimap, the shared
|
|
74
78
|
// top-left controls panel (back / table-view button / search), the
|
|
75
79
|
// attribution overlay, and the table-view data-table overlay. All run
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/charts/pipeline/runVizPipeline.ts"],"sourcesContent":["/**\n `runVizPipeline(viz)` — the chart pipeline as a free function.\n\n Draws the boundary between \"lifecycle/DOM/data-loading\" (which lives on\n `Viz.render()`, inherently instance-bound) and\n \"transform-the-data-into-a-scene\" (callable without the lifecycle). The\n transform side isn't fully pure yet — `_preDraw`/`_draw` still mutate\n `this` rather than threading an explicit context\n (`UserConfig → ResolvedSpec → transform stages → SceneGraph → renderer`).\n\n Calling this function on a Viz instance runs the same four steps\n `Viz.render()` previously inlined inside its `Promise.all().then()`\n callback:\n\n 1. `viz._preDraw()` — data filtering + legend-data + drawDepth\n 2. `viz._draw()` — chart-specific layout + scene absorption\n 3. `zoomControls(viz)` — zoom HTML overlay (architectural carve-out)\n 4. `minimapFeature.layout(viz)` — zoomed-chart viewport indicator\n 5. `topLeftControlsFeature.layout(viz)` — back/table-view/search panel\n 5b. `bottomRightControlsFeature.layout(viz)` — size-legend corner panel\n 6. `attributionFeature.layout(viz)` — bottom-right attribution panel\n 7. `tableViewFeature.layout(viz)` — chart-sized data-table overlay\n 8. `viz._drawSceneToTarget()` — paint scene via SvgRenderer/CanvasRenderer\n\n Future work:\n - Extract a `ResolvedSpec` so step 1 takes (config) not (this).\n - Decouple step 2 so it takes (ctx) not (this); stages already follow\n this pattern but `_draw` itself doesn't.\n - Replace step 8's `this._sceneRenderer` slot with a returned handle\n so callers can pick/destroy/diff without instance lookup.\n\n @param viz A Viz instance (or any subclass: Plot, Treemap, Pack, …).\n*/\n\nimport {attributionFeature, runLayout} from \"../features/features.js\";\nimport {minimapFeature} from \"../drawSteps/minimap.js\";\nimport {zoomFeature} from \"../drawSteps/zoomControls.js\";\nimport {resolveDrillMorph} from \"./drillMorph.js\";\nimport {topLeftControlsFeature} from \"../drawSteps/topLeftControls.js\";\nimport {bottomRightControlsFeature} from \"../drawSteps/bottomRightControls.js\";\nimport {tableViewFeature} from \"../drawSteps/tableView.js\";\nimport type {VizInstance as Viz} from \"../viz/vizTypes.js\";\n\nexport function runVizPipeline(viz: Viz): void {\n // Goes through `viz._preDraw()` / `viz._draw()` (not the free functions\n // directly) so subclass overrides (Plot._preDraw, Treemap._draw, Plot._draw,\n // Pack/Pie/Matrix/…) still run. The free functions `vizPreDraw` / `vizDraw`\n // hold the BASE Viz behavior; subclasses' `super._preDraw()`/`super._draw()`\n // calls hit the shim which delegates to the free functions.\n viz._preDraw();\n
|
|
1
|
+
{"version":3,"sources":["../../../../src/charts/pipeline/runVizPipeline.ts"],"sourcesContent":["/**\n `runVizPipeline(viz)` — the chart pipeline as a free function.\n\n Draws the boundary between \"lifecycle/DOM/data-loading\" (which lives on\n `Viz.render()`, inherently instance-bound) and\n \"transform-the-data-into-a-scene\" (callable without the lifecycle). The\n transform side isn't fully pure yet — `_preDraw`/`_draw` still mutate\n `this` rather than threading an explicit context\n (`UserConfig → ResolvedSpec → transform stages → SceneGraph → renderer`).\n\n Calling this function on a Viz instance runs the same four steps\n `Viz.render()` previously inlined inside its `Promise.all().then()`\n callback:\n\n 1. `viz._preDraw()` — data filtering + legend-data + drawDepth\n 2. `viz._draw()` — chart-specific layout + scene absorption, re-run\n when chrome is placed inside the chart (`drawWithInset`)\n 3. `zoomControls(viz)` — zoom HTML overlay (architectural carve-out)\n 4. `minimapFeature.layout(viz)` — zoomed-chart viewport indicator\n 5. `topLeftControlsFeature.layout(viz)` — back/table-view/search panel\n 5b. `bottomRightControlsFeature.layout(viz)` — size-legend corner panel\n 6. `attributionFeature.layout(viz)` — bottom-right attribution panel\n 7. `tableViewFeature.layout(viz)` — chart-sized data-table overlay\n 8. `viz._drawSceneToTarget()` — paint scene via SvgRenderer/CanvasRenderer\n\n Future work:\n - Extract a `ResolvedSpec` so step 1 takes (config) not (this).\n - Decouple step 2 so it takes (ctx) not (this); stages already follow\n this pattern but `_draw` itself doesn't.\n - Replace step 8's `this._sceneRenderer` slot with a returned handle\n so callers can pick/destroy/diff without instance lookup.\n\n @param viz A Viz instance (or any subclass: Plot, Treemap, Pack, …).\n*/\n\nimport {attributionFeature, runLayout} from \"../features/features.js\";\nimport {minimapFeature} from \"../drawSteps/minimap.js\";\nimport {zoomFeature} from \"../drawSteps/zoomControls.js\";\nimport {resolveDrillMorph} from \"./drillMorph.js\";\nimport {drawWithInset} from \"./insetPlacement.js\";\nimport {topLeftControlsFeature} from \"../drawSteps/topLeftControls.js\";\nimport {bottomRightControlsFeature} from \"../drawSteps/bottomRightControls.js\";\nimport {tableViewFeature} from \"../drawSteps/tableView.js\";\nimport type {VizInstance as Viz} from \"../viz/vizTypes.js\";\n\nexport function runVizPipeline(viz: Viz): void {\n // Goes through `viz._preDraw()` / `viz._draw()` (not the free functions\n // directly) so subclass overrides (Plot._preDraw, Treemap._draw, Plot._draw,\n // Pack/Pie/Matrix/…) still run. The free functions `vizPreDraw` / `vizDraw`\n // hold the BASE Viz behavior; subclasses' `super._preDraw()`/`super._draw()`\n // calls hit the shim which delegates to the free functions.\n viz._preDraw();\n // `_draw()`, possibly more than once: chrome that fits inside the chart's\n // negative space is placed there after layout (see insetPlacement.ts).\n drawWithInset(viz);\n // Post-draw features: zoom + brush event wiring, the minimap, the shared\n // top-left controls panel (back / table-view button / search), the\n // attribution overlay, and the table-view data-table overlay. All run\n // after `_draw()` (zoom needs the rendered chart body + `_container`/\n // `_zoomGroup`), claim zero margin, and wire DOM the serializable scene\n // graph can't carry. `minimapFeature` runs right after `zoomFeature` — it\n // needs `_zoomBehavior`'s `translateExtent()`/`scaleExtent()` already\n // configured for this draw — and before `attributionFeature` to preserve\n // the prior step order; `topLeftControlsFeature` has no ordering\n // dependency on either. `tableViewFeature` runs LAST so its panel — a\n // chart-sized overlay, present only while table view is active — stacks\n // above every other panel in the overlay host (siblings paint in scene\n // order), covering zoom/minimap/top-left-controls/attribution while\n // showing.\n // Each of these returns its overlay as a panel rather than mutating\n // `viz._featurePanels` from inside `layout()` (the FeatureModule\n // contract). The engine appends the returned panels to the instance\n // buffer that `toScene()` reads — including on later repaints (a zoom\n // event, a table-view toggle), which re-walk `toScene()` outside this\n // pipeline pass.\n runPostDrawFeatures(viz);\n // Resolve the drill-down morph's enter/exit boxes (if a drill click armed\n // one) now that this draw's _bodyRect/_chartScene are final.\n resolveDrillMorph(viz);\n viz._drawSceneToTarget();\n}\n\n/**\n Runs the post-draw features (see above) and appends their panels. Anything\n that re-runs `viz._draw()` outside this pipeline — Rings re-centering on a\n click, say — must call this after it: `_draw()` resets the feature panels,\n so skipping it drops the corner controls, size legend, and attribution.\n*/\nexport function runPostDrawFeatures(viz: Viz): void {\n const post = runLayout({viz}, [\n zoomFeature,\n minimapFeature,\n topLeftControlsFeature,\n bottomRightControlsFeature,\n attributionFeature,\n tableViewFeature,\n ]);\n if (post.panels.length)\n viz._featurePanels = [...(viz._featurePanels || []), ...post.panels];\n}\n"],"names":["attributionFeature","runLayout","minimapFeature","zoomFeature","resolveDrillMorph","drawWithInset","topLeftControlsFeature","bottomRightControlsFeature","tableViewFeature","runVizPipeline","viz","_preDraw","runPostDrawFeatures","_drawSceneToTarget","post","panels","length","_featurePanels"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiCA,GAEA,SAAQA,kBAAkB,EAAEC,SAAS,QAAO,0BAA0B;AACtE,SAAQC,cAAc,QAAO,0BAA0B;AACvD,SAAQC,WAAW,QAAO,+BAA+B;AACzD,SAAQC,iBAAiB,QAAO,kBAAkB;AAClD,SAAQC,aAAa,QAAO,sBAAsB;AAClD,SAAQC,sBAAsB,QAAO,kCAAkC;AACvE,SAAQC,0BAA0B,QAAO,sCAAsC;AAC/E,SAAQC,gBAAgB,QAAO,4BAA4B;AAG3D,OAAO,SAASC,eAAeC,GAAQ;IACrC,wEAAwE;IACxE,6EAA6E;IAC7E,4EAA4E;IAC5E,6EAA6E;IAC7E,4DAA4D;IAC5DA,IAAIC,QAAQ;IACZ,0EAA0E;IAC1E,uEAAuE;IACvEN,cAAcK;IACd,yEAAyE;IACzE,mEAAmE;IACnE,sEAAsE;IACtE,sEAAsE;IACtE,wEAAwE;IACxE,0EAA0E;IAC1E,sEAAsE;IACtE,yEAAyE;IACzE,iEAAiE;IACjE,sEAAsE;IACtE,wEAAwE;IACxE,uEAAuE;IACvE,oEAAoE;IACpE,WAAW;IACX,oEAAoE;IACpE,iEAAiE;IACjE,oEAAoE;IACpE,sEAAsE;IACtE,sEAAsE;IACtE,iBAAiB;IACjBE,oBAAoBF;IACpB,0EAA0E;IAC1E,6DAA6D;IAC7DN,kBAAkBM;IAClBA,IAAIG,kBAAkB;AACxB;AAEA;;;;;AAKA,GACA,OAAO,SAASD,oBAAoBF,GAAQ;IAC1C,IAAMI,OAAOb,UAAU;QAACS,KAAAA;IAAG,GAAG;QAC5BP;QACAD;QACAI;QACAC;QACAP;QACAQ;KACD;IACD,IAAIM,KAAKC,MAAM,CAACC,MAAM,EACpBN,IAAIO,cAAc,GAAG,AAAC,qBAAIP,IAAIO,cAAc,IAAI,EAAE,SAAG,qBAAGH,KAAKC,MAAM;AACvE"}
|
package/es/src/charts/viz/Viz.js
CHANGED
|
@@ -324,8 +324,10 @@ import { CanvasRenderer, SvgRenderer } from "@d3plus/render";
|
|
|
324
324
|
import VizBase from "./VizBase.js";
|
|
325
325
|
import { applyColorScaleBucketOpacity, applyInteractionOpacity } from "./interactionOpacity.js";
|
|
326
326
|
import { chartAreaRect } from "../features/chartGeometry.js";
|
|
327
|
+
import { initInsetDefaults, insetComponentScene } from "../features/insetState.js";
|
|
327
328
|
import { applyZoomPointerEvents, bindCanvasZoom } from "../drawSteps/zoomControls.js";
|
|
328
329
|
import { initVizDefaults } from "./vizDefaults.js";
|
|
330
|
+
import { unregisterLink } from "./linkGroup.js";
|
|
329
331
|
import { vizRender } from "./vizRender.js";
|
|
330
332
|
import { vizDraw } from "../pipeline/vizDraw.js";
|
|
331
333
|
import { vizPreDraw } from "../pipeline/vizPreDraw.js";
|
|
@@ -375,6 +377,7 @@ var Viz = /*#__PURE__*/ function(VizBase) {
|
|
|
375
377
|
var _this;
|
|
376
378
|
_this = _call_super(this, Viz);
|
|
377
379
|
initVizDefaults(_this);
|
|
380
|
+
initInsetDefaults(_this);
|
|
378
381
|
return _this;
|
|
379
382
|
}
|
|
380
383
|
_create_class(Viz, [
|
|
@@ -526,9 +529,9 @@ var Viz = /*#__PURE__*/ function(VizBase) {
|
|
|
526
529
|
children.push({
|
|
527
530
|
type: "group",
|
|
528
531
|
key: "viz-".concat(name),
|
|
529
|
-
children: [
|
|
532
|
+
children: name === "timeline" ? [
|
|
530
533
|
compScene
|
|
531
|
-
]
|
|
534
|
+
] : insetComponentScene(this, name, compScene, comp.outerBounds())
|
|
532
535
|
});
|
|
533
536
|
}
|
|
534
537
|
}
|
|
@@ -587,6 +590,17 @@ var Viz = /*#__PURE__*/ function(VizBase) {
|
|
|
587
590
|
},
|
|
588
591
|
{
|
|
589
592
|
/**
|
|
593
|
+
The region chart chrome may be drawn inside, with the chart's mark boxes
|
|
594
|
+
as obstacles (see `ChartDefinition.insetRegion`). Charts that leave
|
|
595
|
+
negative space override this; the base chart offers none.
|
|
596
|
+
@private
|
|
597
|
+
*/ key: "_insetRegion",
|
|
598
|
+
value: function _insetRegion() {
|
|
599
|
+
return null;
|
|
600
|
+
}
|
|
601
|
+
},
|
|
602
|
+
{
|
|
603
|
+
/**
|
|
590
604
|
* Applies the threshold algorithm according to the type of chart used.
|
|
591
605
|
* @param {Array} data The data to process.
|
|
592
606
|
* @private
|
|
@@ -1035,6 +1049,7 @@ var Viz = /*#__PURE__*/ function(VizBase) {
|
|
|
1035
1049
|
*/ key: "destroy",
|
|
1036
1050
|
value: function destroy() {
|
|
1037
1051
|
var _this__resizeObserver, _this__fontsUnsubscribe, _this, _this__visibleUnobserve, _this1, _this__unloadUnobserve, _this2;
|
|
1052
|
+
unregisterLink(this);
|
|
1038
1053
|
(_this__resizeObserver = this._resizeObserver) === null || _this__resizeObserver === void 0 ? void 0 : _this__resizeObserver.disconnect();
|
|
1039
1054
|
(_this__fontsUnsubscribe = (_this = this)._fontsUnsubscribe) === null || _this__fontsUnsubscribe === void 0 ? void 0 : _this__fontsUnsubscribe.call(_this);
|
|
1040
1055
|
this._fontsUnsubscribe = undefined;
|
|
@@ -1076,7 +1091,7 @@ var Viz = /*#__PURE__*/ function(VizBase) {
|
|
|
1076
1091
|
return Viz;
|
|
1077
1092
|
}(VizBase);
|
|
1078
1093
|
/**
|
|
1079
|
-
|
|
1094
|
+
The base class every d3plus chart extends. Owns the shared configuration surface (data, groupBy, size and color accessors, title, legend, tooltip, timeline, zoom, table view) and the render lifecycle that each chart type's definition plugs its layout into. Not used directly; see the chart classes (BarChart, Treemap, …).
|
|
1080
1095
|
*/ export { Viz as default };
|
|
1081
1096
|
|
|
1082
1097
|
//# sourceMappingURL=Viz.js.map
|