@deck.gl-community/infovis-layers 9.1.0-beta.8 → 9.2.0-beta.2
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/LICENSE +1 -1
- package/dist/index.cjs +815 -0
- package/dist/index.cjs.map +4 -4
- package/dist/index.d.ts +12 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -1
- package/dist/index.js.map +1 -1
- package/dist/layers/horizon-graph-layer/horizon-graph-layer-uniforms.d.ts +23 -0
- package/dist/layers/horizon-graph-layer/horizon-graph-layer-uniforms.d.ts.map +1 -0
- package/dist/layers/horizon-graph-layer/horizon-graph-layer-uniforms.js +33 -0
- package/dist/layers/horizon-graph-layer/horizon-graph-layer-uniforms.js.map +1 -0
- package/dist/layers/horizon-graph-layer/horizon-graph-layer.d.ts +38 -0
- package/dist/layers/horizon-graph-layer/horizon-graph-layer.d.ts.map +1 -0
- package/dist/layers/horizon-graph-layer/horizon-graph-layer.fs.d.ts +3 -0
- package/dist/layers/horizon-graph-layer/horizon-graph-layer.fs.d.ts.map +1 -0
- package/dist/layers/horizon-graph-layer/horizon-graph-layer.fs.js +53 -0
- package/dist/layers/horizon-graph-layer/horizon-graph-layer.fs.js.map +1 -0
- package/dist/layers/horizon-graph-layer/horizon-graph-layer.js +138 -0
- package/dist/layers/horizon-graph-layer/horizon-graph-layer.js.map +1 -0
- package/dist/layers/horizon-graph-layer/horizon-graph-layer.vs.d.ts +3 -0
- package/dist/layers/horizon-graph-layer/horizon-graph-layer.vs.d.ts.map +1 -0
- package/dist/layers/horizon-graph-layer/horizon-graph-layer.vs.js +24 -0
- package/dist/layers/horizon-graph-layer/horizon-graph-layer.vs.js.map +1 -0
- package/dist/layers/horizon-graph-layer/multi-horizon-graph-layer.d.ts +23 -0
- package/dist/layers/horizon-graph-layer/multi-horizon-graph-layer.d.ts.map +1 -0
- package/dist/layers/horizon-graph-layer/multi-horizon-graph-layer.js +100 -0
- package/dist/layers/horizon-graph-layer/multi-horizon-graph-layer.js.map +1 -0
- package/dist/layers/time-axis-layer.d.ts +56 -0
- package/dist/layers/time-axis-layer.d.ts.map +1 -0
- package/dist/layers/time-axis-layer.js +78 -0
- package/dist/layers/time-axis-layer.js.map +1 -0
- package/dist/layers/time-delta-layer.d.ts +74 -0
- package/dist/layers/time-delta-layer.d.ts.map +1 -0
- package/dist/layers/time-delta-layer.js +136 -0
- package/dist/layers/time-delta-layer.js.map +1 -0
- package/dist/layers/vertical-grid-layer.d.ts +41 -0
- package/dist/layers/vertical-grid-layer.d.ts.map +1 -0
- package/dist/layers/vertical-grid-layer.js +43 -0
- package/dist/layers/vertical-grid-layer.js.map +1 -0
- package/dist/synchronized-views/synchronized-views.d.ts +39 -0
- package/dist/synchronized-views/synchronized-views.d.ts.map +1 -0
- package/dist/synchronized-views/synchronized-views.js +85 -0
- package/dist/synchronized-views/synchronized-views.js.map +1 -0
- package/dist/utils/format-utils.d.ts +7 -0
- package/dist/utils/format-utils.d.ts.map +1 -0
- package/dist/utils/format-utils.js +75 -0
- package/dist/utils/format-utils.js.map +1 -0
- package/dist/utils/tick-utils.d.ts +10 -0
- package/dist/utils/tick-utils.d.ts.map +1 -0
- package/dist/utils/tick-utils.js +32 -0
- package/dist/utils/tick-utils.js.map +1 -0
- package/dist/views/layer-filter.d.ts +8 -0
- package/dist/views/layer-filter.d.ts.map +1 -0
- package/dist/views/layer-filter.js +40 -0
- package/dist/views/layer-filter.js.map +1 -0
- package/dist/views/orthographic-utils.d.ts +11 -0
- package/dist/views/orthographic-utils.d.ts.map +1 -0
- package/dist/views/orthographic-utils.js +41 -0
- package/dist/views/orthographic-utils.js.map +1 -0
- package/dist/views/view-state-utils.d.ts +8 -0
- package/dist/views/view-state-utils.d.ts.map +1 -0
- package/dist/views/view-state-utils.js +41 -0
- package/dist/views/view-state-utils.js.map +1 -0
- package/package.json +11 -18
- package/src/index.ts +4 -0
- package/src/layers/horizon-graph-layer/horizon-graph-layer-uniforms.ts +47 -0
- package/src/layers/horizon-graph-layer/horizon-graph-layer.fs.ts +53 -0
- package/src/layers/horizon-graph-layer/horizon-graph-layer.ts +202 -0
- package/src/layers/horizon-graph-layer/horizon-graph-layer.vs.ts +24 -0
- package/src/layers/horizon-graph-layer/multi-horizon-graph-layer.ts +164 -0
package/dist/index.cjs
CHANGED
|
@@ -1 +1,816 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var __publicField = (obj, key, value) => {
|
|
20
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
21
|
+
return value;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
// dist/index.js
|
|
25
|
+
var dist_exports = {};
|
|
26
|
+
__export(dist_exports, {
|
|
27
|
+
HEADER_VIEW_HEIGHT: () => HEADER_VIEW_HEIGHT,
|
|
28
|
+
HorizonGraphLayer: () => HorizonGraphLayer,
|
|
29
|
+
LEGEND_VIEW_WIDTH: () => LEGEND_VIEW_WIDTH,
|
|
30
|
+
MultiHorizonGraphLayer: () => MultiHorizonGraphLayer,
|
|
31
|
+
SYNCHRONIZED_VIEWS: () => SYNCHRONIZED_VIEWS,
|
|
32
|
+
SYNCHRONIZED_VIEW_STATE_CONSTRAINTS: () => SYNCHRONIZED_VIEW_STATE_CONSTRAINTS,
|
|
33
|
+
TimeAxisLayer: () => TimeAxisLayer,
|
|
34
|
+
TimeDeltaLayer: () => TimeDeltaLayer,
|
|
35
|
+
VerticalGridLayer: () => VerticalGridLayer,
|
|
36
|
+
fitBoundsOrthographic: () => fitBoundsOrthographic,
|
|
37
|
+
fitSynchronizedViewStatesToBounds: () => fitSynchronizedViewStatesToBounds,
|
|
38
|
+
formatTimeMs: () => formatTimeMs,
|
|
39
|
+
formatTimeRangeMs: () => formatTimeRangeMs,
|
|
40
|
+
getSynchronizedViewStates: () => getSynchronizedViewStates,
|
|
41
|
+
makeLayerFilter: () => makeLayerFilter,
|
|
42
|
+
mergeViewStates: () => mergeViewStates,
|
|
43
|
+
validateViewState: () => validateViewState
|
|
44
|
+
});
|
|
45
|
+
module.exports = __toCommonJS(dist_exports);
|
|
46
|
+
|
|
47
|
+
// dist/layers/time-axis-layer.js
|
|
48
|
+
var import_core = require("@deck.gl/core");
|
|
49
|
+
var import_layers = require("@deck.gl/layers");
|
|
50
|
+
|
|
51
|
+
// dist/utils/format-utils.js
|
|
52
|
+
function formatTimeMs(timeMs, space = true) {
|
|
53
|
+
const sep = space ? " " : "";
|
|
54
|
+
const us = timeMs * 1e3;
|
|
55
|
+
if (us === 0) {
|
|
56
|
+
return "0s";
|
|
57
|
+
}
|
|
58
|
+
if (Math.abs(us) < 1e3) {
|
|
59
|
+
return `${floatToStr(us)}${sep}\xB5s`;
|
|
60
|
+
}
|
|
61
|
+
const ms = us / 1e3;
|
|
62
|
+
if (Math.abs(ms) < 1e3) {
|
|
63
|
+
return `${floatToStr(ms)}${sep} ms`;
|
|
64
|
+
}
|
|
65
|
+
const s = ms / 1e3;
|
|
66
|
+
if (Math.abs(s) < 60) {
|
|
67
|
+
return `${floatToStr(s)}${sep} s`;
|
|
68
|
+
}
|
|
69
|
+
const m = s / 60;
|
|
70
|
+
if (Math.abs(m) < 60) {
|
|
71
|
+
return `${floatToStr(m)}${sep} min`;
|
|
72
|
+
}
|
|
73
|
+
const h = m / 60;
|
|
74
|
+
if (Math.abs(h) < 24) {
|
|
75
|
+
return `${floatToStr(h)}${sep} hrs`;
|
|
76
|
+
}
|
|
77
|
+
const d = h / 24;
|
|
78
|
+
return `${floatToStr(d)}${sep} days`;
|
|
79
|
+
}
|
|
80
|
+
function formatTimeRangeMs(startMs, endMs) {
|
|
81
|
+
return `${formatTimeMs(startMs)} - ${formatTimeMs(endMs)}`;
|
|
82
|
+
}
|
|
83
|
+
function floatToStr(f, roundDigits = 5) {
|
|
84
|
+
if (Number.isInteger(f)) {
|
|
85
|
+
return f.toString();
|
|
86
|
+
}
|
|
87
|
+
for (let i = 1; i < roundDigits - 1; i++) {
|
|
88
|
+
const rounded = parseFloat(f.toPrecision(i));
|
|
89
|
+
if (rounded === f) {
|
|
90
|
+
return rounded.toPrecision(i);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
return f.toPrecision(roundDigits);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// dist/utils/tick-utils.js
|
|
97
|
+
function getZoomedRange(startTime, endTime, bounds) {
|
|
98
|
+
const [startTimeZoomed, , endTimeZoomed] = bounds;
|
|
99
|
+
return [Math.max(startTime, startTimeZoomed), Math.min(endTime, endTimeZoomed)];
|
|
100
|
+
}
|
|
101
|
+
function getPrettyTicks(startTime, endTime, tickCount = 5) {
|
|
102
|
+
const range = endTime - startTime;
|
|
103
|
+
const roughStep = range / (tickCount - 1);
|
|
104
|
+
const exponent = Math.floor(Math.log10(roughStep));
|
|
105
|
+
const base = Math.pow(10, exponent);
|
|
106
|
+
const multiples = [1, 2, 5, 10];
|
|
107
|
+
const niceStep = multiples.find((m) => base * m >= roughStep) * base;
|
|
108
|
+
const niceStart = Math.ceil(startTime / niceStep) * niceStep;
|
|
109
|
+
const niceEnd = Math.floor(endTime / niceStep) * niceStep;
|
|
110
|
+
const ticks = [];
|
|
111
|
+
for (let t = niceStart; t <= niceEnd; t += niceStep) {
|
|
112
|
+
ticks.push(t);
|
|
113
|
+
}
|
|
114
|
+
return ticks;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
// dist/layers/time-axis-layer.js
|
|
118
|
+
var TimeAxisLayer = class extends import_core.CompositeLayer {
|
|
119
|
+
// Called whenever props/data/viewports change
|
|
120
|
+
shouldUpdateState(params) {
|
|
121
|
+
return params.changeFlags.viewportChanged || super.shouldUpdateState(params);
|
|
122
|
+
}
|
|
123
|
+
renderLayers() {
|
|
124
|
+
const { startTimeMs, endTimeMs, tickCount = 10, y = 0, color = [0, 0, 0, 255] } = this.props;
|
|
125
|
+
let bounds;
|
|
126
|
+
try {
|
|
127
|
+
bounds = this.context.viewport.getBounds();
|
|
128
|
+
} catch (error) {
|
|
129
|
+
console.log("Error getting bounds from viewport:", error);
|
|
130
|
+
throw error;
|
|
131
|
+
}
|
|
132
|
+
const [startTimeZoomed, endTimeZoomed] = getZoomedRange(startTimeMs, endTimeMs, bounds);
|
|
133
|
+
const ticks = getPrettyTicks(startTimeZoomed, endTimeZoomed, tickCount);
|
|
134
|
+
const tickLines = ticks.map((x) => ({
|
|
135
|
+
sourcePosition: [x, y - 5],
|
|
136
|
+
targetPosition: [x, y + 5]
|
|
137
|
+
}));
|
|
138
|
+
const tickLabels = ticks.map((x) => ({
|
|
139
|
+
position: [x, y - 10],
|
|
140
|
+
text: this.props.unit === "timestamp" ? new Date(x).toLocaleTimeString() : formatTimeMs(x, false)
|
|
141
|
+
}));
|
|
142
|
+
return [
|
|
143
|
+
// Axis line
|
|
144
|
+
new import_layers.LineLayer({
|
|
145
|
+
id: "axis-line",
|
|
146
|
+
data: [{ sourcePosition: [startTimeZoomed, y], targetPosition: [endTimeZoomed, y] }],
|
|
147
|
+
getSourcePosition: (d) => d.sourcePosition,
|
|
148
|
+
getTargetPosition: (d) => d.targetPosition,
|
|
149
|
+
getColor: color,
|
|
150
|
+
getWidth: 2
|
|
151
|
+
}),
|
|
152
|
+
// Tick marks
|
|
153
|
+
new import_layers.LineLayer({
|
|
154
|
+
id: "tick-marks",
|
|
155
|
+
data: tickLines,
|
|
156
|
+
getSourcePosition: (d) => d.sourcePosition,
|
|
157
|
+
getTargetPosition: (d) => d.targetPosition,
|
|
158
|
+
getColor: color,
|
|
159
|
+
getWidth: 1
|
|
160
|
+
}),
|
|
161
|
+
// Tick labels
|
|
162
|
+
new import_layers.TextLayer({
|
|
163
|
+
id: "tick-labels",
|
|
164
|
+
data: tickLabels,
|
|
165
|
+
getPosition: (d) => d.position,
|
|
166
|
+
getText: (d) => d.text,
|
|
167
|
+
getSize: 12,
|
|
168
|
+
getColor: color,
|
|
169
|
+
getTextAnchor: "middle",
|
|
170
|
+
getAlignmentBaseline: "top"
|
|
171
|
+
})
|
|
172
|
+
];
|
|
173
|
+
}
|
|
174
|
+
};
|
|
175
|
+
__publicField(TimeAxisLayer, "layerName", "TimeAxisLayer");
|
|
176
|
+
__publicField(TimeAxisLayer, "defaultProps", {
|
|
177
|
+
startTimeMs: 0,
|
|
178
|
+
endTimeMs: 100,
|
|
179
|
+
tickCount: 5,
|
|
180
|
+
y: 0,
|
|
181
|
+
color: [0, 0, 0, 255],
|
|
182
|
+
unit: "timestamp",
|
|
183
|
+
bounds: void 0
|
|
184
|
+
});
|
|
185
|
+
|
|
186
|
+
// dist/layers/vertical-grid-layer.js
|
|
187
|
+
var import_core2 = require("@deck.gl/core");
|
|
188
|
+
var import_layers2 = require("@deck.gl/layers");
|
|
189
|
+
var VerticalGridLayer = class extends import_core2.CompositeLayer {
|
|
190
|
+
shouldUpdateState(params) {
|
|
191
|
+
return params.changeFlags.viewportChanged || super.shouldUpdateState(params);
|
|
192
|
+
}
|
|
193
|
+
renderLayers() {
|
|
194
|
+
const { xMin, xMax, tickCount = 5, yMin, yMax, color } = this.props;
|
|
195
|
+
const viewport = this.context.viewport;
|
|
196
|
+
const bounds = viewport.getBounds();
|
|
197
|
+
const [startTimeZoomed, endTimeZoomed] = getZoomedRange(xMin, xMax, bounds);
|
|
198
|
+
const tickPositions = getPrettyTicks(startTimeZoomed, endTimeZoomed, tickCount);
|
|
199
|
+
const gridLines = tickPositions.map((x) => ({
|
|
200
|
+
sourcePosition: [x, yMin],
|
|
201
|
+
targetPosition: [x, yMax]
|
|
202
|
+
}));
|
|
203
|
+
return new import_layers2.LineLayer({
|
|
204
|
+
id: `${this.props.id}-lines`,
|
|
205
|
+
data: gridLines,
|
|
206
|
+
getSourcePosition: (d) => d.sourcePosition,
|
|
207
|
+
getTargetPosition: (d) => d.targetPosition,
|
|
208
|
+
getColor: color,
|
|
209
|
+
getWidth: 1
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
};
|
|
213
|
+
__publicField(VerticalGridLayer, "layerName", "VerticalGridLayer");
|
|
214
|
+
__publicField(VerticalGridLayer, "defaultProps", {
|
|
215
|
+
yMin: -1e6,
|
|
216
|
+
yMax: 1e6,
|
|
217
|
+
tickCount: 5,
|
|
218
|
+
width: 1,
|
|
219
|
+
color: [200, 200, 200, 255]
|
|
220
|
+
});
|
|
221
|
+
|
|
222
|
+
// dist/layers/time-delta-layer.js
|
|
223
|
+
var import_core3 = require("@deck.gl/core");
|
|
224
|
+
var import_layers3 = require("@deck.gl/layers");
|
|
225
|
+
var TimeDeltaLayer = class extends import_core3.CompositeLayer {
|
|
226
|
+
renderLayers() {
|
|
227
|
+
const { startTimeMs, endTimeMs, color = [0, 0, 0, 255], yMin, yMax } = this.props;
|
|
228
|
+
const timeDeltaPosition = [(startTimeMs + endTimeMs) / 2, 10];
|
|
229
|
+
const timeDeltaMs = Math.abs(endTimeMs - startTimeMs);
|
|
230
|
+
const timeDeltaLabel = formatTimeMs(timeDeltaMs, false);
|
|
231
|
+
if (!this.props.header) {
|
|
232
|
+
const timeLines2 = [
|
|
233
|
+
{
|
|
234
|
+
sourcePosition: [startTimeMs, yMin],
|
|
235
|
+
targetPosition: [startTimeMs, yMax]
|
|
236
|
+
},
|
|
237
|
+
{
|
|
238
|
+
sourcePosition: [endTimeMs, yMin],
|
|
239
|
+
targetPosition: [endTimeMs, yMax]
|
|
240
|
+
}
|
|
241
|
+
];
|
|
242
|
+
return [
|
|
243
|
+
// Interval end lines
|
|
244
|
+
new import_layers3.LineLayer({
|
|
245
|
+
id: "time-delta-side-bars",
|
|
246
|
+
data: timeLines2,
|
|
247
|
+
getSourcePosition: (d) => d.sourcePosition,
|
|
248
|
+
getTargetPosition: (d) => d.targetPosition,
|
|
249
|
+
getColor: color,
|
|
250
|
+
getWidth: 4,
|
|
251
|
+
widthUnits: "pixels"
|
|
252
|
+
})
|
|
253
|
+
];
|
|
254
|
+
}
|
|
255
|
+
const HEADER_Y = 12;
|
|
256
|
+
const timeLines = [
|
|
257
|
+
{
|
|
258
|
+
sourcePosition: [startTimeMs, -100],
|
|
259
|
+
targetPosition: [startTimeMs, HEADER_Y]
|
|
260
|
+
},
|
|
261
|
+
{
|
|
262
|
+
sourcePosition: [endTimeMs, -100],
|
|
263
|
+
targetPosition: [endTimeMs, HEADER_Y]
|
|
264
|
+
}
|
|
265
|
+
];
|
|
266
|
+
return [
|
|
267
|
+
// Interval end lines
|
|
268
|
+
new import_layers3.LineLayer({
|
|
269
|
+
id: "header-time-delta-side-bars",
|
|
270
|
+
data: timeLines,
|
|
271
|
+
getSourcePosition: (d) => d.sourcePosition,
|
|
272
|
+
getTargetPosition: (d) => d.targetPosition,
|
|
273
|
+
getColor: color,
|
|
274
|
+
getWidth: 4,
|
|
275
|
+
widthUnits: "pixels"
|
|
276
|
+
}),
|
|
277
|
+
// Interval center
|
|
278
|
+
new import_layers3.LineLayer({
|
|
279
|
+
id: "header-time-delta-dotted-line",
|
|
280
|
+
data: [
|
|
281
|
+
{
|
|
282
|
+
sourcePosition: [startTimeMs, HEADER_Y - 7],
|
|
283
|
+
targetPosition: [endTimeMs, HEADER_Y - 7]
|
|
284
|
+
}
|
|
285
|
+
],
|
|
286
|
+
getSourcePosition: (d) => d.sourcePosition,
|
|
287
|
+
getTargetPosition: (d) => d.targetPosition,
|
|
288
|
+
getColor: color,
|
|
289
|
+
getWidth: 1,
|
|
290
|
+
widthUnits: "pixels"
|
|
291
|
+
}),
|
|
292
|
+
// Label
|
|
293
|
+
new import_layers3.TextLayer({
|
|
294
|
+
id: "header-time-delta-label",
|
|
295
|
+
data: [{ position: timeDeltaPosition, text: timeDeltaLabel }],
|
|
296
|
+
getPosition: (d) => d.position,
|
|
297
|
+
getText: (d) => d.text,
|
|
298
|
+
getSize: 12,
|
|
299
|
+
getColor: color,
|
|
300
|
+
getTextAnchor: "middle",
|
|
301
|
+
getAlignmentBaseline: "top",
|
|
302
|
+
background: true,
|
|
303
|
+
getBackgroundColor: [255, 255, 255, 255],
|
|
304
|
+
// Solid green background
|
|
305
|
+
backgroundPadding: [4, 2]
|
|
306
|
+
// Horizontal and vertical padding
|
|
307
|
+
})
|
|
308
|
+
];
|
|
309
|
+
}
|
|
310
|
+
};
|
|
311
|
+
__publicField(TimeDeltaLayer, "layerName", "TimeDeltaLayer");
|
|
312
|
+
__publicField(TimeDeltaLayer, "defaultProps", {
|
|
313
|
+
header: false,
|
|
314
|
+
minTimeMs: 0,
|
|
315
|
+
maxTimeMs: 100,
|
|
316
|
+
startTimeMs: 0,
|
|
317
|
+
endTimeMs: 100,
|
|
318
|
+
y: 0,
|
|
319
|
+
color: [0, 0, 0, 255],
|
|
320
|
+
unit: "timestamp",
|
|
321
|
+
yMin: -1e6,
|
|
322
|
+
// Should cover full viewport height in most cases
|
|
323
|
+
yMax: 1e6
|
|
324
|
+
// Should cover full viewport height in most cases
|
|
325
|
+
});
|
|
326
|
+
|
|
327
|
+
// dist/layers/horizon-graph-layer/horizon-graph-layer.js
|
|
328
|
+
var import_core4 = require("@deck.gl/core");
|
|
329
|
+
var import_engine = require("@luma.gl/engine");
|
|
330
|
+
|
|
331
|
+
// dist/layers/horizon-graph-layer/horizon-graph-layer.vs.js
|
|
332
|
+
var horizon_graph_layer_vs_default = `#version 300 es
|
|
333
|
+
#define SHADER_NAME horizon-graph-layer-vertex-shader
|
|
334
|
+
|
|
335
|
+
in vec3 positions;
|
|
336
|
+
in vec2 uv;
|
|
337
|
+
|
|
338
|
+
out vec2 v_uv;
|
|
339
|
+
|
|
340
|
+
void main(void) {
|
|
341
|
+
geometry.worldPosition = positions;
|
|
342
|
+
|
|
343
|
+
vec4 position_commonspace = project_position(vec4(positions.xy, 0.0, 1.0));
|
|
344
|
+
gl_Position = project_common_position_to_clipspace(position_commonspace);
|
|
345
|
+
geometry.position = position_commonspace;
|
|
346
|
+
|
|
347
|
+
DECKGL_FILTER_GL_POSITION(gl_Position, geometry);
|
|
348
|
+
|
|
349
|
+
v_uv = uv;
|
|
350
|
+
}
|
|
351
|
+
`;
|
|
352
|
+
|
|
353
|
+
// dist/layers/horizon-graph-layer/horizon-graph-layer.fs.js
|
|
354
|
+
var horizon_graph_layer_fs_default = `#version 300 es
|
|
355
|
+
#define SHADER_NAME horizon-graph-layer-fragment-shader
|
|
356
|
+
|
|
357
|
+
precision highp float;
|
|
358
|
+
precision highp int;
|
|
359
|
+
|
|
360
|
+
/******* UNIFORM *******/
|
|
361
|
+
|
|
362
|
+
uniform sampler2D dataTexture;
|
|
363
|
+
|
|
364
|
+
/******* IN *******/
|
|
365
|
+
|
|
366
|
+
in vec2 v_uv;
|
|
367
|
+
|
|
368
|
+
/******* OUT *******/
|
|
369
|
+
|
|
370
|
+
out vec4 fragColor;
|
|
371
|
+
|
|
372
|
+
|
|
373
|
+
/******* MAIN *******/
|
|
374
|
+
|
|
375
|
+
void main(void) {
|
|
376
|
+
// horizontal position to sample index
|
|
377
|
+
float idx = v_uv.x * horizonLayer.dataTextureCount;
|
|
378
|
+
// idx = clamp(idx, 0.0, horizonLayer.dataTextureCount - 1.0); // NEEDED???
|
|
379
|
+
|
|
380
|
+
// fetch single data point & normalize (-1,+1)
|
|
381
|
+
float fy = floor(idx * horizonLayer.dataTextureSizeInv);
|
|
382
|
+
float fx = idx - fy * horizonLayer.dataTextureSize;
|
|
383
|
+
float val = texelFetch(dataTexture, ivec2(int(fx), int(fy)), 0).r;
|
|
384
|
+
val *= horizonLayer.yAxisScaleInv;
|
|
385
|
+
|
|
386
|
+
// band layering
|
|
387
|
+
float fband = abs(val) * horizonLayer.bands;
|
|
388
|
+
float bandIdx = clamp(floor(fband), 0.0, horizonLayer.bands - 1.0);
|
|
389
|
+
float bandFrac = fract(fband);
|
|
390
|
+
|
|
391
|
+
// calc our position value and find out color (using mix+step instead of if...else)
|
|
392
|
+
float positive = step(0.0, val); // 1 if pos, else 0
|
|
393
|
+
vec3 baseCol = mix(horizonLayer.negativeColor, horizonLayer.positiveColor, positive);
|
|
394
|
+
float curPos = mix(v_uv.y, 1.0 - v_uv.y, positive);
|
|
395
|
+
float addOne = step(curPos, bandFrac);
|
|
396
|
+
|
|
397
|
+
float band = bandIdx + addOne;
|
|
398
|
+
float whiten = 1.0 - band * horizonLayer.bandsInv;
|
|
399
|
+
|
|
400
|
+
fragColor = vec4(mix(baseCol, vec3(1.0), whiten), 1.0);
|
|
401
|
+
}
|
|
402
|
+
`;
|
|
403
|
+
|
|
404
|
+
// dist/layers/horizon-graph-layer/horizon-graph-layer-uniforms.js
|
|
405
|
+
var uniformBlock = `layout(std140) uniform horizonLayerUniforms {
|
|
406
|
+
float dataTextureSize; // width = height of the POT texture
|
|
407
|
+
float dataTextureSizeInv;
|
|
408
|
+
float dataTextureCount; // actual number of data points
|
|
409
|
+
|
|
410
|
+
float bands;
|
|
411
|
+
float bandsInv;
|
|
412
|
+
float yAxisScaleInv;
|
|
413
|
+
|
|
414
|
+
vec3 positiveColor;
|
|
415
|
+
vec3 negativeColor;
|
|
416
|
+
} horizonLayer;
|
|
417
|
+
`;
|
|
418
|
+
var horizonLayerUniforms = {
|
|
419
|
+
name: "horizonLayer",
|
|
420
|
+
vs: uniformBlock,
|
|
421
|
+
fs: uniformBlock,
|
|
422
|
+
uniformTypes: {
|
|
423
|
+
dataTextureSize: "f32",
|
|
424
|
+
dataTextureSizeInv: "f32",
|
|
425
|
+
dataTextureCount: "f32",
|
|
426
|
+
bands: "f32",
|
|
427
|
+
bandsInv: "f32",
|
|
428
|
+
yAxisScaleInv: "f32",
|
|
429
|
+
positiveColor: "vec3<f32>",
|
|
430
|
+
negativeColor: "vec3<f32>"
|
|
431
|
+
}
|
|
432
|
+
};
|
|
433
|
+
|
|
434
|
+
// dist/layers/horizon-graph-layer/horizon-graph-layer.js
|
|
435
|
+
var defaultProps = {
|
|
436
|
+
yAxisScale: { type: "number", value: 1e3 },
|
|
437
|
+
bands: { type: "number", value: 2 },
|
|
438
|
+
positiveColor: { type: "color", value: [0, 128, 0] },
|
|
439
|
+
negativeColor: { type: "color", value: [0, 0, 255] },
|
|
440
|
+
x: { type: "number", value: 0 },
|
|
441
|
+
y: { type: "number", value: 0 },
|
|
442
|
+
width: { type: "number", value: 800 },
|
|
443
|
+
height: { type: "number", value: 300 }
|
|
444
|
+
};
|
|
445
|
+
var HorizonGraphLayer = class extends import_core4.Layer {
|
|
446
|
+
state = {};
|
|
447
|
+
initializeState() {
|
|
448
|
+
this.state = {};
|
|
449
|
+
}
|
|
450
|
+
getShaders() {
|
|
451
|
+
return super.getShaders({
|
|
452
|
+
vs: horizon_graph_layer_vs_default,
|
|
453
|
+
fs: horizon_graph_layer_fs_default,
|
|
454
|
+
modules: [import_core4.project32, horizonLayerUniforms]
|
|
455
|
+
});
|
|
456
|
+
}
|
|
457
|
+
_createDataTexture(seriesData) {
|
|
458
|
+
const _data = seriesData instanceof Float32Array ? seriesData : new Float32Array(seriesData);
|
|
459
|
+
const { device } = this.context;
|
|
460
|
+
const count = _data.length;
|
|
461
|
+
let dataTextureSize = 32;
|
|
462
|
+
while (count > dataTextureSize * dataTextureSize) {
|
|
463
|
+
dataTextureSize *= 2;
|
|
464
|
+
}
|
|
465
|
+
const data = new Float32Array(dataTextureSize * dataTextureSize);
|
|
466
|
+
data.set(_data, 0);
|
|
467
|
+
return {
|
|
468
|
+
dataTexture: device.createTexture({
|
|
469
|
+
data,
|
|
470
|
+
format: "r32float",
|
|
471
|
+
dimension: "2d",
|
|
472
|
+
width: dataTextureSize,
|
|
473
|
+
height: dataTextureSize,
|
|
474
|
+
sampler: {
|
|
475
|
+
minFilter: "nearest",
|
|
476
|
+
magFilter: "nearest",
|
|
477
|
+
addressModeU: "clamp-to-edge",
|
|
478
|
+
addressModeV: "clamp-to-edge"
|
|
479
|
+
}
|
|
480
|
+
}),
|
|
481
|
+
dataTextureSize,
|
|
482
|
+
dataTextureCount: count
|
|
483
|
+
};
|
|
484
|
+
}
|
|
485
|
+
_createModel() {
|
|
486
|
+
const { x, y, width, height } = this.props;
|
|
487
|
+
const positions = [
|
|
488
|
+
x,
|
|
489
|
+
y,
|
|
490
|
+
0,
|
|
491
|
+
x + width,
|
|
492
|
+
y,
|
|
493
|
+
0,
|
|
494
|
+
x,
|
|
495
|
+
y + height,
|
|
496
|
+
0,
|
|
497
|
+
x + width,
|
|
498
|
+
y + height,
|
|
499
|
+
0
|
|
500
|
+
];
|
|
501
|
+
const uv = [0, 0, 1, 0, 0, 1, 1, 1];
|
|
502
|
+
const geometry = new import_engine.Geometry({
|
|
503
|
+
topology: "triangle-strip",
|
|
504
|
+
attributes: {
|
|
505
|
+
positions: { value: new Float32Array(positions), size: 3 },
|
|
506
|
+
uv: { value: new Float32Array(uv), size: 2 }
|
|
507
|
+
}
|
|
508
|
+
});
|
|
509
|
+
return new import_engine.Model(this.context.device, {
|
|
510
|
+
...this.getShaders(),
|
|
511
|
+
geometry,
|
|
512
|
+
bufferLayout: this.getAttributeManager().getBufferLayouts()
|
|
513
|
+
});
|
|
514
|
+
}
|
|
515
|
+
updateState(params) {
|
|
516
|
+
var _a, _b;
|
|
517
|
+
super.updateState(params);
|
|
518
|
+
const { changeFlags } = params;
|
|
519
|
+
if (changeFlags.dataChanged) {
|
|
520
|
+
(_a = this.state.dataTexture) == null ? void 0 : _a.destroy();
|
|
521
|
+
this.setState(this._createDataTexture(this.props.data));
|
|
522
|
+
}
|
|
523
|
+
if (changeFlags.extensionsChanged || changeFlags.propsChanged) {
|
|
524
|
+
(_b = this.state.model) == null ? void 0 : _b.destroy();
|
|
525
|
+
this.setState({ model: this._createModel() });
|
|
526
|
+
}
|
|
527
|
+
}
|
|
528
|
+
draw() {
|
|
529
|
+
const { model, dataTexture } = this.state;
|
|
530
|
+
if (!model) {
|
|
531
|
+
this.setState({ model: this._createModel() });
|
|
532
|
+
return;
|
|
533
|
+
}
|
|
534
|
+
if (!dataTexture) {
|
|
535
|
+
this.setState(this._createDataTexture(this.props.data));
|
|
536
|
+
return;
|
|
537
|
+
}
|
|
538
|
+
const { bands, yAxisScale, positiveColor, negativeColor } = this.props;
|
|
539
|
+
model.shaderInputs.setProps({
|
|
540
|
+
horizonLayer: {
|
|
541
|
+
dataTexture: this.state.dataTexture,
|
|
542
|
+
dataTextureSize: this.state.dataTextureSize,
|
|
543
|
+
dataTextureSizeInv: 1 / this.state.dataTextureSize,
|
|
544
|
+
dataTextureCount: this.state.dataTextureCount,
|
|
545
|
+
bands,
|
|
546
|
+
bandsInv: 1 / bands,
|
|
547
|
+
yAxisScaleInv: 1 / yAxisScale,
|
|
548
|
+
positiveColor: positiveColor.map((c) => c / 255),
|
|
549
|
+
negativeColor: negativeColor.map((c) => c / 255)
|
|
550
|
+
}
|
|
551
|
+
});
|
|
552
|
+
model.draw(this.context.renderPass);
|
|
553
|
+
}
|
|
554
|
+
finalizeState(context) {
|
|
555
|
+
var _a, _b;
|
|
556
|
+
(_a = this.state.model) == null ? void 0 : _a.destroy();
|
|
557
|
+
(_b = this.state.dataTexture) == null ? void 0 : _b.destroy();
|
|
558
|
+
super.finalizeState(context);
|
|
559
|
+
}
|
|
560
|
+
};
|
|
561
|
+
__publicField(HorizonGraphLayer, "layerName", "HorizonGraphLayer");
|
|
562
|
+
__publicField(HorizonGraphLayer, "defaultProps", defaultProps);
|
|
563
|
+
|
|
564
|
+
// dist/layers/horizon-graph-layer/multi-horizon-graph-layer.js
|
|
565
|
+
var import_core5 = require("@deck.gl/core");
|
|
566
|
+
var import_layers4 = require("@deck.gl/layers");
|
|
567
|
+
var defaultProps2 = {
|
|
568
|
+
getSeries: { type: "accessor", value: (series) => series.values },
|
|
569
|
+
getScale: { type: "accessor", value: (series) => series.scale },
|
|
570
|
+
bands: { type: "number", value: 2 },
|
|
571
|
+
positiveColor: { type: "color", value: [0, 128, 0] },
|
|
572
|
+
negativeColor: { type: "color", value: [0, 0, 255] },
|
|
573
|
+
dividerColor: { type: "color", value: [0, 0, 0] },
|
|
574
|
+
dividerWidth: { type: "number", value: 2 },
|
|
575
|
+
x: { type: "number", value: 0 },
|
|
576
|
+
y: { type: "number", value: 0 },
|
|
577
|
+
width: { type: "number", value: 800 },
|
|
578
|
+
height: { type: "number", value: 300 }
|
|
579
|
+
};
|
|
580
|
+
var MultiHorizonGraphLayer = class extends import_core5.CompositeLayer {
|
|
581
|
+
renderLayers() {
|
|
582
|
+
const { data, getSeries, getScale, bands, positiveColor, negativeColor, dividerColor, dividerWidth, x, y, width, height } = this.props;
|
|
583
|
+
const seriesCount = data.length;
|
|
584
|
+
if (!seriesCount) {
|
|
585
|
+
return [];
|
|
586
|
+
}
|
|
587
|
+
const totalDividerSpace = dividerWidth * (seriesCount + 1);
|
|
588
|
+
const availableHeight = height - totalDividerSpace;
|
|
589
|
+
const seriesHeight = availableHeight / seriesCount;
|
|
590
|
+
const layers = [];
|
|
591
|
+
if (dividerWidth > 0) {
|
|
592
|
+
const dividerData = [];
|
|
593
|
+
dividerData.push({
|
|
594
|
+
polygon: [
|
|
595
|
+
[x, y],
|
|
596
|
+
[x + width, y],
|
|
597
|
+
[x + width, y + dividerWidth],
|
|
598
|
+
[x, y + dividerWidth]
|
|
599
|
+
]
|
|
600
|
+
});
|
|
601
|
+
for (let i = 0; i < seriesCount - 1; i++) {
|
|
602
|
+
const dividerY = y + dividerWidth + (i + 1) * seriesHeight + i * dividerWidth;
|
|
603
|
+
dividerData.push({
|
|
604
|
+
polygon: [
|
|
605
|
+
[x, dividerY],
|
|
606
|
+
[x + width, dividerY],
|
|
607
|
+
[x + width, dividerY + dividerWidth],
|
|
608
|
+
[x, dividerY + dividerWidth]
|
|
609
|
+
]
|
|
610
|
+
});
|
|
611
|
+
}
|
|
612
|
+
const bottomDividerY = y + height - dividerWidth;
|
|
613
|
+
dividerData.push({
|
|
614
|
+
polygon: [
|
|
615
|
+
[x, bottomDividerY],
|
|
616
|
+
[x + width, bottomDividerY],
|
|
617
|
+
[x + width, y + height],
|
|
618
|
+
[x, y + height]
|
|
619
|
+
]
|
|
620
|
+
});
|
|
621
|
+
layers.push(new import_layers4.SolidPolygonLayer({
|
|
622
|
+
id: `${this.props.id}-dividers`,
|
|
623
|
+
data: dividerData,
|
|
624
|
+
getPolygon: (d) => d.polygon,
|
|
625
|
+
getFillColor: dividerColor,
|
|
626
|
+
pickable: false
|
|
627
|
+
}));
|
|
628
|
+
}
|
|
629
|
+
data.forEach((series, index) => {
|
|
630
|
+
const seriesData = getSeries(series);
|
|
631
|
+
if (!seriesData || seriesData.length === 0) {
|
|
632
|
+
return;
|
|
633
|
+
}
|
|
634
|
+
const seriesY = y + dividerWidth + index * (seriesHeight + dividerWidth);
|
|
635
|
+
const yAxisScale = getScale(series);
|
|
636
|
+
layers.push(new HorizonGraphLayer({
|
|
637
|
+
id: `${this.props.id}-series-${index}`,
|
|
638
|
+
data: seriesData,
|
|
639
|
+
yAxisScale,
|
|
640
|
+
bands,
|
|
641
|
+
positiveColor,
|
|
642
|
+
negativeColor,
|
|
643
|
+
x,
|
|
644
|
+
y: seriesY,
|
|
645
|
+
width,
|
|
646
|
+
height: seriesHeight
|
|
647
|
+
}));
|
|
648
|
+
});
|
|
649
|
+
return layers;
|
|
650
|
+
}
|
|
651
|
+
};
|
|
652
|
+
__publicField(MultiHorizonGraphLayer, "layerName", "MultiHorizonGraphLayer");
|
|
653
|
+
__publicField(MultiHorizonGraphLayer, "defaultProps", defaultProps2);
|
|
654
|
+
|
|
655
|
+
// dist/views/orthographic-utils.js
|
|
656
|
+
function fitBoundsOrthographic(width, height, bounds, zoomMode = "per-axis") {
|
|
657
|
+
const [[minX, minY], [maxX, maxY]] = bounds;
|
|
658
|
+
const centerX = (minX + maxX) / 2;
|
|
659
|
+
const centerY = (minY + maxY) / 2;
|
|
660
|
+
const boxW = maxX - minX;
|
|
661
|
+
const boxH = maxY - minY;
|
|
662
|
+
const scaleX = width / boxW;
|
|
663
|
+
const scaleY = height / boxH;
|
|
664
|
+
const scale = Math.min(scaleX, scaleY);
|
|
665
|
+
const zoom = Math.log2(scale);
|
|
666
|
+
const zoomX = Math.log2(scaleX);
|
|
667
|
+
const zoomY = Math.log2(scaleY);
|
|
668
|
+
if (Number.isNaN(zoom) || Number.isNaN(zoomX) || Number.isNaN(zoom)) {
|
|
669
|
+
console.warn("Invalid zoom values:", { zoom, zoomX, zoomY });
|
|
670
|
+
}
|
|
671
|
+
return {
|
|
672
|
+
target: [centerX, centerY],
|
|
673
|
+
zoom: zoomMode === "single" ? zoom : [zoomX, zoomY]
|
|
674
|
+
};
|
|
675
|
+
}
|
|
676
|
+
|
|
677
|
+
// dist/views/view-state-utils.js
|
|
678
|
+
function mergeViewStates(viewState1, viewState2) {
|
|
679
|
+
var _a, _b, _c, _d;
|
|
680
|
+
const target1 = viewState1.target ?? [0, 0];
|
|
681
|
+
const zoom1 = viewState1.zoom ?? [1, 1];
|
|
682
|
+
const mergedViewState = {
|
|
683
|
+
...viewState1,
|
|
684
|
+
...viewState2,
|
|
685
|
+
target: [((_a = viewState2.target) == null ? void 0 : _a[0]) ?? target1[0], ((_b = viewState2.target) == null ? void 0 : _b[1]) ?? target1[1]],
|
|
686
|
+
zoom: [
|
|
687
|
+
// ts-expect-error view state typing is awfully optional
|
|
688
|
+
((_c = viewState2.zoom) == null ? void 0 : _c[0]) ?? zoom1[0],
|
|
689
|
+
// ts-expect-error view state typing is awfully optional
|
|
690
|
+
((_d = viewState2.zoom) == null ? void 0 : _d[1]) ?? zoom1[1]
|
|
691
|
+
]
|
|
692
|
+
};
|
|
693
|
+
validateViewState(mergedViewState);
|
|
694
|
+
return mergedViewState;
|
|
695
|
+
}
|
|
696
|
+
function validateViewState(viewState) {
|
|
697
|
+
const isTargetValid = Array.isArray(viewState.target) && viewState.target[0] !== void 0 && !Number.isNaN(viewState.target[0]) && viewState.target[1] !== void 0 && !Number.isNaN(viewState.target[1]);
|
|
698
|
+
const isZoomValid = Array.isArray(viewState.zoom) && viewState.zoom[0] !== void 0 && !Number.isNaN(viewState.zoom[0]) && viewState.zoom[1] !== void 0 && !Number.isNaN(viewState.zoom[1]);
|
|
699
|
+
if (!isTargetValid || !isZoomValid) {
|
|
700
|
+
console.warn("Invalid viewState:", viewState);
|
|
701
|
+
}
|
|
702
|
+
return isTargetValid && isZoomValid;
|
|
703
|
+
}
|
|
704
|
+
|
|
705
|
+
// dist/views/layer-filter.js
|
|
706
|
+
function makeLayerFilter(filters) {
|
|
707
|
+
const regexpFilters = {};
|
|
708
|
+
for (const [key, value] of Object.entries(filters)) {
|
|
709
|
+
if ("include" in value) {
|
|
710
|
+
regexpFilters[key] = {
|
|
711
|
+
include: value.include.map((v) => new RegExp(v))
|
|
712
|
+
};
|
|
713
|
+
} else {
|
|
714
|
+
regexpFilters[key] = {
|
|
715
|
+
exclude: value.exclude.map((v) => new RegExp(v))
|
|
716
|
+
};
|
|
717
|
+
}
|
|
718
|
+
}
|
|
719
|
+
return ({ viewport, layer }) => {
|
|
720
|
+
let visible = true;
|
|
721
|
+
const viewFilters = regexpFilters[viewport.id] || {};
|
|
722
|
+
if ("include" in viewFilters) {
|
|
723
|
+
if (!viewFilters.include.some((regexp) => regexp.test(layer.id))) {
|
|
724
|
+
visible = false;
|
|
725
|
+
}
|
|
726
|
+
}
|
|
727
|
+
if ("exclude" in viewFilters) {
|
|
728
|
+
if (viewFilters.exclude.some((regexp) => regexp.test(layer.id))) {
|
|
729
|
+
visible = false;
|
|
730
|
+
}
|
|
731
|
+
}
|
|
732
|
+
return visible;
|
|
733
|
+
};
|
|
734
|
+
}
|
|
735
|
+
|
|
736
|
+
// dist/synchronized-views/synchronized-views.js
|
|
737
|
+
var import_core6 = require("@deck.gl/core");
|
|
738
|
+
var HEADER_VIEW_HEIGHT = 50;
|
|
739
|
+
var LEGEND_VIEW_WIDTH = 150;
|
|
740
|
+
var SYNCHRONIZED_VIEWS = [
|
|
741
|
+
new import_core6.OrthographicView({
|
|
742
|
+
id: "main",
|
|
743
|
+
flipY: false,
|
|
744
|
+
clear: true,
|
|
745
|
+
// [1, 1, 1, 1],
|
|
746
|
+
x: LEGEND_VIEW_WIDTH,
|
|
747
|
+
width: `calc(100% - ${LEGEND_VIEW_WIDTH}px`,
|
|
748
|
+
y: HEADER_VIEW_HEIGHT,
|
|
749
|
+
height: `calc(100% - ${HEADER_VIEW_HEIGHT}px)`,
|
|
750
|
+
controller: {
|
|
751
|
+
type: import_core6.OrthographicController,
|
|
752
|
+
// @ts-expect-error Specific to OrthographicController
|
|
753
|
+
zoomAxis: "X",
|
|
754
|
+
inertia: false,
|
|
755
|
+
scrollZoom: true
|
|
756
|
+
}
|
|
757
|
+
}),
|
|
758
|
+
new import_core6.OrthographicView({
|
|
759
|
+
id: "header",
|
|
760
|
+
flipY: false,
|
|
761
|
+
clear: true,
|
|
762
|
+
// [1, 1, 1, 1],
|
|
763
|
+
x: LEGEND_VIEW_WIDTH,
|
|
764
|
+
width: `calc(100% - ${LEGEND_VIEW_WIDTH}px)`,
|
|
765
|
+
height: 50,
|
|
766
|
+
controller: false
|
|
767
|
+
}),
|
|
768
|
+
new import_core6.OrthographicView({
|
|
769
|
+
id: "legend",
|
|
770
|
+
flipY: false,
|
|
771
|
+
clear: true,
|
|
772
|
+
// [1, 1, 1, 1],
|
|
773
|
+
x: 0,
|
|
774
|
+
width: LEGEND_VIEW_WIDTH,
|
|
775
|
+
y: HEADER_VIEW_HEIGHT,
|
|
776
|
+
height: `calc(100% - ${HEADER_VIEW_HEIGHT}px)`,
|
|
777
|
+
controller: false
|
|
778
|
+
})
|
|
779
|
+
];
|
|
780
|
+
var SYNCHRONIZED_VIEW_STATE_CONSTRAINTS = {
|
|
781
|
+
header: { target: [void 0, 20], zoom: [void 0, 0] },
|
|
782
|
+
legend: { target: [-30, void 0], zoom: [1, void 0] }
|
|
783
|
+
};
|
|
784
|
+
function getSynchronizedViewStates(viewState) {
|
|
785
|
+
return {
|
|
786
|
+
header: mergeViewStates(viewState, SYNCHRONIZED_VIEW_STATE_CONSTRAINTS.header),
|
|
787
|
+
legend: mergeViewStates(viewState, SYNCHRONIZED_VIEW_STATE_CONSTRAINTS.legend),
|
|
788
|
+
main: viewState
|
|
789
|
+
};
|
|
790
|
+
}
|
|
791
|
+
function fitSynchronizedViewStatesToBounds(props) {
|
|
792
|
+
const { viewState, initialize } = props;
|
|
793
|
+
const { headerHeight = HEADER_VIEW_HEIGHT, legendWidth = LEGEND_VIEW_WIDTH } = props;
|
|
794
|
+
const width = Math.max(props.width - legendWidth, 1);
|
|
795
|
+
const height = Math.max(props.height - headerHeight, 1);
|
|
796
|
+
const { target, zoom } = fitBoundsOrthographic(width, height, props.bounds, "per-axis");
|
|
797
|
+
target[1] = target[1] - 1.5;
|
|
798
|
+
let mainViewState;
|
|
799
|
+
if (initialize) {
|
|
800
|
+
mainViewState = { ...viewState.main, target, zoom };
|
|
801
|
+
} else {
|
|
802
|
+
mainViewState = {
|
|
803
|
+
...viewState.main,
|
|
804
|
+
target: [viewState.main.target[0], target[1]],
|
|
805
|
+
zoom: [viewState.main.zoom[0], zoom[1]]
|
|
806
|
+
};
|
|
807
|
+
}
|
|
808
|
+
const newViewState = {
|
|
809
|
+
...viewState,
|
|
810
|
+
main: mainViewState,
|
|
811
|
+
header: mergeViewStates(mainViewState, SYNCHRONIZED_VIEW_STATE_CONSTRAINTS.header),
|
|
812
|
+
legend: mergeViewStates(mainViewState, SYNCHRONIZED_VIEW_STATE_CONSTRAINTS.legend)
|
|
813
|
+
};
|
|
814
|
+
return newViewState;
|
|
815
|
+
}
|
|
1
816
|
//# sourceMappingURL=index.cjs.map
|