@deck.gl-community/timeline-layers 9.2.0-beta.8
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 +19 -0
- package/README.md +20 -0
- package/dist/index.cjs +538 -0
- package/dist/index.cjs.map +7 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -0
- 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/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/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/package.json +48 -0
- package/src/index.ts +13 -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/src/layers/time-axis-layer.ts +102 -0
- package/src/layers/vertical-grid-layer.ts +69 -0
- package/src/utils/format-utils.ts +80 -0
- package/src/utils/tick-utils.ts +41 -0
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
// deck.gl-community
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
import { CompositeLayer } from '@deck.gl/core';
|
|
5
|
+
import { LineLayer, TextLayer } from '@deck.gl/layers';
|
|
6
|
+
import { formatTimeMs } from "../utils/format-utils.js";
|
|
7
|
+
import { getPrettyTicks, getZoomedRange } from "../utils/tick-utils.js";
|
|
8
|
+
export class TimeAxisLayer extends CompositeLayer {
|
|
9
|
+
static layerName = 'TimeAxisLayer';
|
|
10
|
+
static defaultProps = {
|
|
11
|
+
startTimeMs: 0,
|
|
12
|
+
endTimeMs: 100,
|
|
13
|
+
tickCount: 5,
|
|
14
|
+
y: 0,
|
|
15
|
+
color: [0, 0, 0, 255],
|
|
16
|
+
unit: 'timestamp',
|
|
17
|
+
bounds: undefined
|
|
18
|
+
};
|
|
19
|
+
// Called whenever props/data/viewports change
|
|
20
|
+
shouldUpdateState(params) {
|
|
21
|
+
return params.changeFlags.viewportChanged || super.shouldUpdateState(params);
|
|
22
|
+
}
|
|
23
|
+
renderLayers() {
|
|
24
|
+
const { startTimeMs, endTimeMs, tickCount = 10, y = 0, color = [0, 0, 0, 255] } = this.props;
|
|
25
|
+
let bounds;
|
|
26
|
+
try {
|
|
27
|
+
bounds = this.context.viewport.getBounds();
|
|
28
|
+
}
|
|
29
|
+
catch (error) {
|
|
30
|
+
// eslint-disable-next-line no-console
|
|
31
|
+
console.log('Error getting bounds from viewport:', error);
|
|
32
|
+
throw error;
|
|
33
|
+
}
|
|
34
|
+
const [startTimeZoomed, endTimeZoomed] = getZoomedRange(startTimeMs, endTimeMs, bounds);
|
|
35
|
+
// Generate tick positions and labels
|
|
36
|
+
const ticks = getPrettyTicks(startTimeZoomed, endTimeZoomed, tickCount);
|
|
37
|
+
const tickLines = ticks.map((x) => ({
|
|
38
|
+
sourcePosition: [x, y - 5],
|
|
39
|
+
targetPosition: [x, y + 5]
|
|
40
|
+
}));
|
|
41
|
+
const tickLabels = ticks.map((x) => ({
|
|
42
|
+
position: [x, y - 10],
|
|
43
|
+
text: this.props.unit === 'timestamp' ? new Date(x).toLocaleTimeString() : formatTimeMs(x, false)
|
|
44
|
+
}));
|
|
45
|
+
return [
|
|
46
|
+
// Axis line
|
|
47
|
+
new LineLayer({
|
|
48
|
+
id: 'axis-line',
|
|
49
|
+
data: [{ sourcePosition: [startTimeZoomed, y], targetPosition: [endTimeZoomed, y] }],
|
|
50
|
+
getSourcePosition: (d) => d.sourcePosition,
|
|
51
|
+
getTargetPosition: (d) => d.targetPosition,
|
|
52
|
+
getColor: color,
|
|
53
|
+
getWidth: 2
|
|
54
|
+
}),
|
|
55
|
+
// Tick marks
|
|
56
|
+
new LineLayer({
|
|
57
|
+
id: 'tick-marks',
|
|
58
|
+
data: tickLines,
|
|
59
|
+
getSourcePosition: (d) => d.sourcePosition,
|
|
60
|
+
getTargetPosition: (d) => d.targetPosition,
|
|
61
|
+
getColor: color,
|
|
62
|
+
getWidth: 1
|
|
63
|
+
}),
|
|
64
|
+
// Tick labels
|
|
65
|
+
new TextLayer({
|
|
66
|
+
id: 'tick-labels',
|
|
67
|
+
data: tickLabels,
|
|
68
|
+
getPosition: (d) => d.position,
|
|
69
|
+
getText: (d) => d.text,
|
|
70
|
+
getSize: 12,
|
|
71
|
+
getColor: color,
|
|
72
|
+
getTextAnchor: 'middle',
|
|
73
|
+
getAlignmentBaseline: 'top'
|
|
74
|
+
})
|
|
75
|
+
];
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
//# sourceMappingURL=time-axis-layer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"time-axis-layer.js","sourceRoot":"","sources":["../../src/layers/time-axis-layer.ts"],"names":[],"mappings":"AAAA,oBAAoB;AACpB,+BAA+B;AAC/B,oCAAoC;AAEpC,OAAO,EAAC,cAAc,EAAkD,MAAM,eAAe,CAAC;AAC9F,OAAO,EAAC,SAAS,EAAE,SAAS,EAAC,MAAM,iBAAiB,CAAC;AAErD,OAAO,EAAC,YAAY,EAAC,iCAA8B;AACnD,OAAO,EAAC,cAAc,EAAE,cAAc,EAAC,+BAA4B;AAkBnE,MAAM,OAAO,aAAc,SAAQ,cAAkC;IACnE,MAAM,CAAU,SAAS,GAAG,eAAe,CAAC;IAC5C,MAAM,CAAU,YAAY,GAAkE;QAC5F,WAAW,EAAE,CAAC;QACd,SAAS,EAAE,GAAG;QACd,SAAS,EAAE,CAA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AC,CAAC,CAAC,IAAI;gBACtB,OAAO,EAAE,EAAE;gBACX,QAAQ,EAAE,KAAK;gBACf,aAAa,EAAE,QAAQ;gBACvB,oBAAoB,EAAE,KAAK;aAC5B,CAAC;SACH,CAAC;IACJ,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { CompositeLayer, type CompositeLayerProps, type UpdateParameters } from '@deck.gl/core';
|
|
2
|
+
import { LineLayer } from '@deck.gl/layers';
|
|
3
|
+
export type VerticalGridLayerProps = CompositeLayerProps & {
|
|
4
|
+
/** Start time in milliseconds since epoch */
|
|
5
|
+
xMin: number;
|
|
6
|
+
/** End time in milliseconds since epoch */
|
|
7
|
+
xMax: number;
|
|
8
|
+
/** Optional: Number of tick marks (default: 5) */
|
|
9
|
+
tickCount?: number;
|
|
10
|
+
/** Minimum Y-coordinate for grid lines */
|
|
11
|
+
yMin?: number;
|
|
12
|
+
/** Maximum Y-coordinate for grid lines */
|
|
13
|
+
yMax?: number;
|
|
14
|
+
/** Optional: Width of the grid lines (default: 1) */
|
|
15
|
+
width?: number;
|
|
16
|
+
/** Optional: RGBA color for grid lines (default: [200, 200, 200, 255]) */
|
|
17
|
+
color?: [number, number, number, number];
|
|
18
|
+
};
|
|
19
|
+
export declare class VerticalGridLayer extends CompositeLayer<VerticalGridLayerProps> {
|
|
20
|
+
static layerName: string;
|
|
21
|
+
static defaultProps: {
|
|
22
|
+
yMin: number;
|
|
23
|
+
yMax: number;
|
|
24
|
+
tickCount: number;
|
|
25
|
+
width: number;
|
|
26
|
+
color: number[];
|
|
27
|
+
};
|
|
28
|
+
shouldUpdateState(params: UpdateParameters<VerticalGridLayer>): boolean;
|
|
29
|
+
renderLayers(): LineLayer<any, {
|
|
30
|
+
id: `${string}-lines`;
|
|
31
|
+
data: {
|
|
32
|
+
sourcePosition: any[];
|
|
33
|
+
targetPosition: any[];
|
|
34
|
+
}[];
|
|
35
|
+
getSourcePosition: (d: any) => any;
|
|
36
|
+
getTargetPosition: (d: any) => any;
|
|
37
|
+
getColor: [number, number, number, number];
|
|
38
|
+
getWidth: 1;
|
|
39
|
+
}>;
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=vertical-grid-layer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vertical-grid-layer.d.ts","sourceRoot":"","sources":["../../src/layers/vertical-grid-layer.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,cAAc,EAAE,KAAK,mBAAmB,EAAE,KAAK,gBAAgB,EAAC,MAAM,eAAe,CAAC;AAC9F,OAAO,EAAC,SAAS,EAAC,MAAM,iBAAiB,CAAC;AAI1C,MAAM,MAAM,sBAAsB,GAAG,mBAAmB,GAAG;IACzD,6CAA6C;IAC7C,IAAI,EAAE,MAAM,CAAC;IACb,2CAA2C;IAC3C,IAAI,EAAE,MAAM,CAAC;IACb,kDAAkD;IAClD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,0CAA0C;IAC1C,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,0CAA0C;IAC1C,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,qDAAqD;IACrD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,0EAA0E;IAC1E,KAAK,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;CAC1C,CAAC;AAEF,qBAAa,iBAAkB,SAAQ,cAAc,CAAC,sBAAsB,CAAC;IAC3E,OAAgB,SAAS,SAAuB;IAChD,OAAgB,YAAY;;;;;;MAM1B;IAEO,iBAAiB,CAAC,MAAM,EAAE,gBAAgB,CAAC,iBAAiB,CAAC,GAAG,OAAO;IAIvE,YAAY;;;;;;;;;;;CA4BtB"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
// deck.gl-community
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
import { CompositeLayer } from '@deck.gl/core';
|
|
5
|
+
import { LineLayer } from '@deck.gl/layers';
|
|
6
|
+
import { getPrettyTicks, getZoomedRange } from "../utils/tick-utils.js";
|
|
7
|
+
export class VerticalGridLayer extends CompositeLayer {
|
|
8
|
+
static layerName = 'VerticalGridLayer';
|
|
9
|
+
static defaultProps = {
|
|
10
|
+
yMin: -1e6,
|
|
11
|
+
yMax: 1e6,
|
|
12
|
+
tickCount: 5,
|
|
13
|
+
width: 1,
|
|
14
|
+
color: [200, 200, 200, 255]
|
|
15
|
+
};
|
|
16
|
+
shouldUpdateState(params) {
|
|
17
|
+
return params.changeFlags.viewportChanged || super.shouldUpdateState(params);
|
|
18
|
+
}
|
|
19
|
+
renderLayers() {
|
|
20
|
+
const { xMin, xMax, tickCount = 5, yMin, yMax, color } = this.props;
|
|
21
|
+
// Access the current viewport
|
|
22
|
+
const viewport = this.context.viewport;
|
|
23
|
+
const bounds = viewport.getBounds(); // Returns [minX, minY, maxX, maxY]
|
|
24
|
+
// Calculate the visible time range based on the viewport bounds
|
|
25
|
+
const [startTimeZoomed, endTimeZoomed] = getZoomedRange(xMin, xMax, bounds);
|
|
26
|
+
// Generate tick positions
|
|
27
|
+
const tickPositions = getPrettyTicks(startTimeZoomed, endTimeZoomed, tickCount);
|
|
28
|
+
// Create vertical grid lines at each tick position
|
|
29
|
+
const gridLines = tickPositions.map((x) => ({
|
|
30
|
+
sourcePosition: [x, yMin],
|
|
31
|
+
targetPosition: [x, yMax]
|
|
32
|
+
}));
|
|
33
|
+
return new LineLayer({
|
|
34
|
+
id: `${this.props.id}-lines`,
|
|
35
|
+
data: gridLines,
|
|
36
|
+
getSourcePosition: (d) => d.sourcePosition,
|
|
37
|
+
getTargetPosition: (d) => d.targetPosition,
|
|
38
|
+
getColor: color,
|
|
39
|
+
getWidth: 1
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=vertical-grid-layer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":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;QACnD,MAAM,SAAS,GAAG,aAAa,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;YAC1C,cAAc,EAAE,CAAC,CAAC,EAAE,IAAI,CAAC;YACzB,cAAc,EAAE,CAAC,CAAC,EAAE,IAAI,CAAC;SAC1B,CAAC,CAAC,CAAC;QAEJ,OAAO,IAAI,SAAS,CAAC;YACnB,EAAE,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,EAAE,QAAQ;YAC5B,IAAI,EAAE,SAAS;YACf,iBAAiB,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,cAAc;YAC1C,iBAAiB,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,cAAc;YAC1C,QAAQ,EAAE,KAAK;YACf,QAAQ,EAAE,CAAC;SACZ,CAAC,CAAC;IACL,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Convert a time in microseconds to a human-readable string
|
|
3
|
+
* @param us Time in microseconds
|
|
4
|
+
*/
|
|
5
|
+
export declare function formatTimeMs(timeMs: number, space?: boolean): string;
|
|
6
|
+
export declare function formatTimeRangeMs(startMs: number, endMs: number): string;
|
|
7
|
+
//# sourceMappingURL=format-utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"format-utils.d.ts","sourceRoot":"","sources":["../../src/utils/format-utils.ts"],"names":[],"mappings":"AAIA;;;GAGG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,GAAE,OAAc,GAAG,MAAM,CA2B1E;AAED,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAExE"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
// deck.gl-community
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
/**
|
|
5
|
+
* Convert a time in microseconds to a human-readable string
|
|
6
|
+
* @param us Time in microseconds
|
|
7
|
+
*/
|
|
8
|
+
export function formatTimeMs(timeMs, space = true) {
|
|
9
|
+
const sep = space ? ' ' : '';
|
|
10
|
+
const us = timeMs * 1000;
|
|
11
|
+
if (us === 0) {
|
|
12
|
+
return '0s';
|
|
13
|
+
}
|
|
14
|
+
if (Math.abs(us) < 1000) {
|
|
15
|
+
return `${floatToStr(us)}${sep}µs`;
|
|
16
|
+
}
|
|
17
|
+
const ms = us / 1000;
|
|
18
|
+
if (Math.abs(ms) < 1000) {
|
|
19
|
+
return `${floatToStr(ms)}${sep} ms`;
|
|
20
|
+
}
|
|
21
|
+
const s = ms / 1000;
|
|
22
|
+
if (Math.abs(s) < 60) {
|
|
23
|
+
return `${floatToStr(s)}${sep} s`;
|
|
24
|
+
}
|
|
25
|
+
const m = s / 60;
|
|
26
|
+
if (Math.abs(m) < 60) {
|
|
27
|
+
return `${floatToStr(m)}${sep} min`;
|
|
28
|
+
}
|
|
29
|
+
const h = m / 60;
|
|
30
|
+
if (Math.abs(h) < 24) {
|
|
31
|
+
return `${floatToStr(h)}${sep} hrs`;
|
|
32
|
+
}
|
|
33
|
+
const d = h / 24;
|
|
34
|
+
return `${floatToStr(d)}${sep} days`;
|
|
35
|
+
}
|
|
36
|
+
export function formatTimeRangeMs(startMs, endMs) {
|
|
37
|
+
return `${formatTimeMs(startMs)} - ${formatTimeMs(endMs)}`;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Convert a float to a string
|
|
41
|
+
*/
|
|
42
|
+
function floatToStr(f, roundDigits = 5) {
|
|
43
|
+
if (Number.isInteger(f)) {
|
|
44
|
+
return f.toString();
|
|
45
|
+
}
|
|
46
|
+
for (let i = 1; i < roundDigits - 1; i++) {
|
|
47
|
+
const rounded = parseFloat(f.toPrecision(i));
|
|
48
|
+
if (rounded === f) {
|
|
49
|
+
return rounded.toPrecision(i);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return f.toPrecision(roundDigits);
|
|
53
|
+
}
|
|
54
|
+
// export function formatTimesUs(ticks: number[]): string {
|
|
55
|
+
// // Try from 0 up to a reasonable max (e.g. 20)
|
|
56
|
+
// for (let d = 0; d <= 20; d++) {
|
|
57
|
+
// const seen = new Set<string>();
|
|
58
|
+
// let allDistinct = true;
|
|
59
|
+
// for (const t of ticks) {
|
|
60
|
+
// // Format each tick with d decimals
|
|
61
|
+
// const str = t.toFixed(d);
|
|
62
|
+
// if (seen.has(str)) {
|
|
63
|
+
// allDistinct = false;
|
|
64
|
+
// break;
|
|
65
|
+
// }
|
|
66
|
+
// seen.add(str);
|
|
67
|
+
// }
|
|
68
|
+
// if (allDistinct) {
|
|
69
|
+
// return d;
|
|
70
|
+
// }
|
|
71
|
+
// }
|
|
72
|
+
// // Fallback if somehow not distinct even at 20 decimals
|
|
73
|
+
// return 20;
|
|
74
|
+
// }
|
|
75
|
+
//# sourceMappingURL=format-utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"format-utils.js","sourceRoot":"","sources":["../../src/utils/format-utils.ts"],"names":[],"mappings":"AAAA,oBAAoB;AACpB,+BAA+B;AAC/B,oCAAoC;AAEpC;;;GAGG;AACH,MAAM,UAAU,YAAY,CAAC,MAAc,EAAE,QAAiB,IAAI;IAChE,MAAM,GAAG,GAAG,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;IAC7B,MAAM,EAAE,GAAG,MAAM,GAAG,IAAI,CAAC;IACzB,IAAI,EAAE,KAAK,CAAC,EAAE,CAAC;QACb,OAAO,IAAI,CAAC;IACd,CAAC;IACD,IAAI,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,EAAE,CAAC;QACxB,OAAO,GAAG,UAAU,CAAC,EAAE,CAAC,GAAG,GAAG,IAAI,CAAC;IACrC,CAAC;IACD,MAAM,EAAE,GAAG,EAAE,GAAG,IAAI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,EAAE,CAAC,GAAG,WAAW,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;QACzC,MAAM,OAAO,GAAG,UAAU,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC;QAC7C,IAAI,OAAO,KAAK,CAAC,EAAE,CAAC;YAClB,OAAO,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;QAChC,CAAC;IACH,CAAC;IAED,OAAO,CAAC,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC;AACpC,CAAC;AAED,2DAA2D;AAC3D,mDAAmD;AACnD,oCAAoC;AACpC,sCAAsC;AACtC,8BAA8B;AAC9B,+BAA+B;AAC/B,4CAA4C;AAC5C,kCAAkC;AAClC,6BAA6B;AAC7B,+BAA+B;AAC/B,iBAAiB;AACjB,UAAU;AACV,uBAAuB;AACvB,QAAQ;AACR,yBAAyB;AACzB,kBAAkB;AAClB,QAAQ;AACR,MAAM;AACN,4DAA4D;AAC5D,eAAe;AACf,IAAI"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare function getZoomedRange(startTime: number, endTime: number, bounds: [number, number, number, number]): number[];
|
|
2
|
+
/**
|
|
3
|
+
* Get nicely rounded tick close to the natural spacing
|
|
4
|
+
* @param startTime
|
|
5
|
+
* @param endTime
|
|
6
|
+
* @param tickCount
|
|
7
|
+
* @returns
|
|
8
|
+
*/
|
|
9
|
+
export declare function getPrettyTicks(startTime: number, endTime: number, tickCount?: number): any[];
|
|
10
|
+
//# sourceMappingURL=tick-utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tick-utils.d.ts","sourceRoot":"","sources":["../../src/utils/tick-utils.ts"],"names":[],"mappings":"AAIA,wBAAgB,cAAc,CAC5B,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,YAKzC;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,GAAE,MAAU,SAmBvF"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
// deck.gl-community
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
export function getZoomedRange(startTime, endTime, bounds) {
|
|
5
|
+
const [startTimeZoomed, , endTimeZoomed] = bounds;
|
|
6
|
+
// console.log(`startTimeZoomed: ${startTimeZoomed}, endTimeZoomed: ${endTimeZoomed}, tickInterval: ${tickInterval} tickCountZoomed: ${tickCountZoomed}`);
|
|
7
|
+
return [Math.max(startTime, startTimeZoomed), Math.min(endTime, endTimeZoomed)];
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Get nicely rounded tick close to the natural spacing
|
|
11
|
+
* @param startTime
|
|
12
|
+
* @param endTime
|
|
13
|
+
* @param tickCount
|
|
14
|
+
* @returns
|
|
15
|
+
*/
|
|
16
|
+
export function getPrettyTicks(startTime, endTime, tickCount = 5) {
|
|
17
|
+
const range = endTime - startTime;
|
|
18
|
+
const roughStep = range / (tickCount - 1);
|
|
19
|
+
const exponent = Math.floor(Math.log10(roughStep));
|
|
20
|
+
const base = Math.pow(10, exponent);
|
|
21
|
+
const multiples = [1, 2, 5, 10];
|
|
22
|
+
// Find the smallest multiple that is greater than or equal to roughStep
|
|
23
|
+
const niceStep = multiples.find((m) => base * m >= roughStep) * base;
|
|
24
|
+
const niceStart = Math.ceil(startTime / niceStep) * niceStep;
|
|
25
|
+
const niceEnd = Math.floor(endTime / niceStep) * niceStep;
|
|
26
|
+
const ticks = [];
|
|
27
|
+
for (let t = niceStart; t <= niceEnd; t += niceStep) {
|
|
28
|
+
ticks.push(t);
|
|
29
|
+
}
|
|
30
|
+
return ticks;
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=tick-utils.js.map
|
|
@@ -0,0 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AC;IAE1D,MAAM,KAAK,GAAG,EAAE,CAAC;IACjB,KAAK,IAAI,CAAC,GAAG,SAAS,EAAE,CAAC,IAAI,OAAO,EAAE,CAAC,IAAI,QAAQ,EAAE,CAAC;QACpD,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAChB,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@deck.gl-community/timeline-layers",
|
|
3
|
+
"version": "9.2.0-beta.8",
|
|
4
|
+
"description": "Layers for compact timeline visualizations in deck.gl",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"publishConfig": {
|
|
7
|
+
"access": "public"
|
|
8
|
+
},
|
|
9
|
+
"keywords": [
|
|
10
|
+
"layers",
|
|
11
|
+
"visualization",
|
|
12
|
+
"gpu",
|
|
13
|
+
"deck.gl"
|
|
14
|
+
],
|
|
15
|
+
"type": "module",
|
|
16
|
+
"sideEffects": false,
|
|
17
|
+
"types": "./dist/index.d.ts",
|
|
18
|
+
"main": "./dist/index.cjs",
|
|
19
|
+
"module": "./dist/index.js",
|
|
20
|
+
"exports": {
|
|
21
|
+
".": {
|
|
22
|
+
"types": "./dist/index.d.ts",
|
|
23
|
+
"require": "./dist/index.cjs",
|
|
24
|
+
"import": "./dist/index.js"
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
"files": [
|
|
28
|
+
"dist",
|
|
29
|
+
"src"
|
|
30
|
+
],
|
|
31
|
+
"scripts": {
|
|
32
|
+
"test": "vitest run",
|
|
33
|
+
"test-watch": "vitest"
|
|
34
|
+
},
|
|
35
|
+
"dependencies": {
|
|
36
|
+
"@deck.gl/core": "~9.2.1",
|
|
37
|
+
"@deck.gl/layers": "~9.2.1",
|
|
38
|
+
"@luma.gl/core": "~9.2.0",
|
|
39
|
+
"@luma.gl/engine": "~9.2.0",
|
|
40
|
+
"@luma.gl/shadertools": "~9.2.0"
|
|
41
|
+
},
|
|
42
|
+
"devDependencies": {
|
|
43
|
+
"@deck.gl/test-utils": "~9.2.1",
|
|
44
|
+
"@luma.gl/webgpu": "~9.2.0",
|
|
45
|
+
"@probe.gl/test-utils": "^4.0.4"
|
|
46
|
+
},
|
|
47
|
+
"gitHead": "cc866d0fda6b21627421d6168d2f0abec86ab425"
|
|
48
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// deck.gl-community
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
export type {HorizonGraphLayerProps} from './layers/horizon-graph-layer/horizon-graph-layer';
|
|
6
|
+
export {HorizonGraphLayer} from './layers/horizon-graph-layer/horizon-graph-layer';
|
|
7
|
+
export type {MultiHorizonGraphLayerProps} from './layers/horizon-graph-layer/multi-horizon-graph-layer';
|
|
8
|
+
export {MultiHorizonGraphLayer} from './layers/horizon-graph-layer/multi-horizon-graph-layer';
|
|
9
|
+
export type {TimeAxisLayerProps} from './layers/time-axis-layer';
|
|
10
|
+
export {TimeAxisLayer} from './layers/time-axis-layer';
|
|
11
|
+
export type {VerticalGridLayerProps} from './layers/vertical-grid-layer';
|
|
12
|
+
export {VerticalGridLayer} from './layers/vertical-grid-layer';
|
|
13
|
+
export {formatTimeMs, formatTimeRangeMs} from './utils/format-utils';
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
// deck.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
import type {ShaderModule} from '@luma.gl/shadertools';
|
|
6
|
+
import {Texture} from '@luma.gl/core';
|
|
7
|
+
|
|
8
|
+
const uniformBlock = `\
|
|
9
|
+
layout(std140) uniform horizonLayerUniforms {
|
|
10
|
+
float dataTextureSize; // width = height of the POT texture
|
|
11
|
+
float dataTextureSizeInv;
|
|
12
|
+
float dataTextureCount; // actual number of data points
|
|
13
|
+
|
|
14
|
+
float bands;
|
|
15
|
+
float bandsInv;
|
|
16
|
+
float yAxisScaleInv;
|
|
17
|
+
|
|
18
|
+
vec3 positiveColor;
|
|
19
|
+
vec3 negativeColor;
|
|
20
|
+
} horizonLayer;
|
|
21
|
+
`;
|
|
22
|
+
|
|
23
|
+
type HorizonLayerBindingProps = {
|
|
24
|
+
dataTexture: Texture;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
type HorizonLayerUniformProps = {};
|
|
28
|
+
|
|
29
|
+
export type HorizonLayerProps = HorizonLayerBindingProps & HorizonLayerUniformProps;
|
|
30
|
+
|
|
31
|
+
export const horizonLayerUniforms = {
|
|
32
|
+
name: 'horizonLayer',
|
|
33
|
+
vs: uniformBlock,
|
|
34
|
+
fs: uniformBlock,
|
|
35
|
+
uniformTypes: {
|
|
36
|
+
dataTextureSize: 'f32',
|
|
37
|
+
dataTextureSizeInv: 'f32',
|
|
38
|
+
dataTextureCount: 'f32',
|
|
39
|
+
|
|
40
|
+
bands: 'f32',
|
|
41
|
+
bandsInv: 'f32',
|
|
42
|
+
yAxisScaleInv: 'f32',
|
|
43
|
+
|
|
44
|
+
positiveColor: 'vec3<f32>',
|
|
45
|
+
negativeColor: 'vec3<f32>'
|
|
46
|
+
}
|
|
47
|
+
} as const satisfies ShaderModule<HorizonLayerProps>;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
// deck.gl-community
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
export default `#version 300 es
|
|
6
|
+
#define SHADER_NAME horizon-graph-layer-fragment-shader
|
|
7
|
+
|
|
8
|
+
precision highp float;
|
|
9
|
+
precision highp int;
|
|
10
|
+
|
|
11
|
+
/******* UNIFORM *******/
|
|
12
|
+
|
|
13
|
+
uniform sampler2D dataTexture;
|
|
14
|
+
|
|
15
|
+
/******* IN *******/
|
|
16
|
+
|
|
17
|
+
in vec2 v_uv;
|
|
18
|
+
|
|
19
|
+
/******* OUT *******/
|
|
20
|
+
|
|
21
|
+
out vec4 fragColor;
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
/******* MAIN *******/
|
|
25
|
+
|
|
26
|
+
void main(void) {
|
|
27
|
+
// horizontal position to sample index
|
|
28
|
+
float idx = v_uv.x * horizonLayer.dataTextureCount;
|
|
29
|
+
// idx = clamp(idx, 0.0, horizonLayer.dataTextureCount - 1.0); // NEEDED???
|
|
30
|
+
|
|
31
|
+
// fetch single data point & normalize (-1,+1)
|
|
32
|
+
float fy = floor(idx * horizonLayer.dataTextureSizeInv);
|
|
33
|
+
float fx = idx - fy * horizonLayer.dataTextureSize;
|
|
34
|
+
float val = texelFetch(dataTexture, ivec2(int(fx), int(fy)), 0).r;
|
|
35
|
+
val *= horizonLayer.yAxisScaleInv;
|
|
36
|
+
|
|
37
|
+
// band layering
|
|
38
|
+
float fband = abs(val) * horizonLayer.bands;
|
|
39
|
+
float bandIdx = clamp(floor(fband), 0.0, horizonLayer.bands - 1.0);
|
|
40
|
+
float bandFrac = fract(fband);
|
|
41
|
+
|
|
42
|
+
// calc our position value and find out color (using mix+step instead of if...else)
|
|
43
|
+
float positive = step(0.0, val); // 1 if pos, else 0
|
|
44
|
+
vec3 baseCol = mix(horizonLayer.negativeColor, horizonLayer.positiveColor, positive);
|
|
45
|
+
float curPos = mix(v_uv.y, 1.0 - v_uv.y, positive);
|
|
46
|
+
float addOne = step(curPos, bandFrac);
|
|
47
|
+
|
|
48
|
+
float band = bandIdx + addOne;
|
|
49
|
+
float whiten = 1.0 - band * horizonLayer.bandsInv;
|
|
50
|
+
|
|
51
|
+
fragColor = vec4(mix(baseCol, vec3(1.0), whiten), 1.0);
|
|
52
|
+
}
|
|
53
|
+
`;
|