@nova-lab/charts 0.0.0-stage → 1.0.1-dev.32
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 +202 -0
- package/README.md +158 -2
- package/dist/GeometryIndex-DDQ34Jf4.js +104 -0
- package/dist/MarkSeries-CQCAnV4s.js +245 -0
- package/dist/aggregation.d.ts +6 -0
- package/dist/aggregation.js +124 -0
- package/dist/annotations.d.ts +34 -0
- package/dist/annotations.js +71 -0
- package/dist/api/camera.d.ts +8 -0
- package/dist/api/cartesian.d.ts +21 -0
- package/dist/api/events.d.ts +13 -0
- package/dist/api/font.d.ts +3 -0
- package/dist/api/handle.d.ts +5 -0
- package/dist/api/host.d.ts +23 -0
- package/dist/api/internal.d.ts +41 -0
- package/dist/api/map-background.d.ts +12 -0
- package/dist/api/mark-paint.d.ts +5 -0
- package/dist/api/mark-style.d.ts +4 -0
- package/dist/api/navigation.d.ts +4 -0
- package/dist/api/overlay.d.ts +7 -0
- package/dist/api/partition.d.ts +11 -0
- package/dist/api/scene.d.ts +42 -0
- package/dist/api/state.d.ts +34 -0
- package/dist/api/types.d.ts +743 -0
- package/dist/area.d.ts +9 -0
- package/dist/area.js +706 -0
- package/dist/bar.d.ts +9 -0
- package/dist/bar.js +554 -0
- package/dist/brush.d.ts +17 -0
- package/dist/brush.js +86 -0
- package/dist/bubble.d.ts +8 -0
- package/dist/bubble.js +434 -0
- package/dist/camera-CUJAMfpx.js +57 -0
- package/dist/candlestick.d.ts +8 -0
- package/dist/candlestick.js +42 -0
- package/dist/cartesian-k_WIYsGp.js +1139 -0
- package/dist/chart-runtime-resolver-DwwXp3X8.js +20 -0
- package/dist/chart-series-runtime-C0P7h8Tl.js +127 -0
- package/dist/charts.js +1 -0
- package/dist/composed.d.ts +2 -0
- package/dist/composed.js +4 -0
- package/dist/crosshair.d.ts +23 -0
- package/dist/crosshair.js +60 -0
- package/dist/donut.d.ts +5 -0
- package/dist/donut.js +7 -0
- package/dist/funnel.d.ts +5 -0
- package/dist/funnel.js +40 -0
- package/dist/graph.d.ts +6 -0
- package/dist/graph.js +260 -0
- package/dist/heatmap.d.ts +8 -0
- package/dist/heatmap.js +37 -0
- package/dist/host-DLDeDU5k.js +4373 -0
- package/dist/index.d.ts +1 -0
- package/dist/internal-I5BDhahD.js +4 -0
- package/dist/layout-donut-BG4ubBtU.js +39 -0
- package/dist/line.d.ts +9 -0
- package/dist/line.js +452 -0
- package/dist/mark-paint-CMHKGegE.js +14 -0
- package/dist/mark-style-Cpl-ARQM.js +10 -0
- package/dist/model/area/create-area-series-layout.d.ts +15 -0
- package/dist/model/area/hit-test-area-layout.d.ts +2 -0
- package/dist/model/axis/ChartAxisModel.d.ts +28 -0
- package/dist/model/bar/create-bar-series-layout.d.ts +19 -0
- package/dist/model/bar/hit-test-bar-layout.d.ts +2 -0
- package/dist/model/bubble/create-bubble-series-layout.d.ts +15 -0
- package/dist/model/bubble/hit-test-bubble-layout.d.ts +2 -0
- package/dist/model/cartesian/append-line-contours.d.ts +4 -0
- package/dist/model/cartesian/axis-line-batch.d.ts +3 -0
- package/dist/model/cartesian/numeric-window.d.ts +7 -0
- package/dist/model/cartesian/point-series.d.ts +54 -0
- package/dist/model/cartesian/sample-extrema.d.ts +7 -0
- package/dist/model/cartesian/smooth-y.d.ts +4 -0
- package/dist/model/cartesian/translation-window.d.ts +17 -0
- package/dist/model/context/nova-chart-runtime.d.ts +54 -0
- package/dist/model/customization/chart-customization.d.ts +47 -0
- package/dist/model/customization/chart-presets.d.ts +6 -0
- package/dist/model/customization/chart-style-sheet.d.ts +9 -0
- package/dist/model/data/ChartDataStore.d.ts +113 -0
- package/dist/model/exploration/create-graph-layout.d.ts +11 -0
- package/dist/model/exploration/exploration-chart.types.d.ts +150 -0
- package/dist/model/exploration/force-layout.d.ts +9 -0
- package/dist/model/exploration/presets/airplane.d.ts +2 -0
- package/dist/model/exploration/presets/apartment.d.ts +2 -0
- package/dist/model/exploration/presets/botanical-park.d.ts +2 -0
- package/dist/model/exploration/presets/ferry.d.ts +2 -0
- package/dist/model/exploration/presets/ice-arena.d.ts +2 -0
- package/dist/model/exploration/presets/planetarium.d.ts +2 -0
- package/dist/model/exploration/presets/science-museum.d.ts +2 -0
- package/dist/model/exploration/presets/train.d.ts +2 -0
- package/dist/model/exploration/route-geometry.d.ts +9 -0
- package/dist/model/exploration/seat-shape.d.ts +7 -0
- package/dist/model/interaction/GeometryIndex.d.ts +14 -0
- package/dist/model/line/create-line-series-layout.d.ts +15 -0
- package/dist/model/line/hit-test-line-layout.d.ts +2 -0
- package/dist/model/novel/create-novel-layout.d.ts +5 -0
- package/dist/model/novel/hit-test-novel-layout.d.ts +3 -0
- package/dist/model/novel/layout-candlestick.d.ts +3 -0
- package/dist/model/novel/layout-donut.d.ts +3 -0
- package/dist/model/novel/layout-funnel.d.ts +3 -0
- package/dist/model/novel/layout-heatmap.d.ts +3 -0
- package/dist/model/novel/layout-input.d.ts +12 -0
- package/dist/model/novel/layout-radar.d.ts +3 -0
- package/dist/model/novel/layout-tree.d.ts +3 -0
- package/dist/model/novel/layout-treemap.d.ts +3 -0
- package/dist/model/novel/layout-values.d.ts +10 -0
- package/dist/model/novel/novel-chart.types.d.ts +140 -0
- package/dist/model/novel/novel-domains.d.ts +5 -0
- package/dist/model/scale/BandScale.d.ts +86 -0
- package/dist/model/scale/ChartScaleRegistry.d.ts +45 -0
- package/dist/model/scale/LinearScale.d.ts +48 -0
- package/dist/model/scale/TimeScale.d.ts +48 -0
- package/dist/model/scale/create-chart-scale.d.ts +3 -0
- package/dist/model/scale/resolve-chart-scale.d.ts +5 -0
- package/dist/model/scatter/create-scatter-series-layout.d.ts +14 -0
- package/dist/model/scatter/hit-test-scatter-layout.d.ts +4 -0
- package/dist/model/time/calendar-time.d.ts +16 -0
- package/dist/model/types/chart-axis.types.d.ts +43 -0
- package/dist/model/types/chart-components.types.d.ts +1393 -0
- package/dist/model/types/chart-scale.types.d.ts +78 -0
- package/dist/model/viewport-controller/viewport-controller.d.ts +5 -0
- package/dist/novel-domains-DBpA_AOT.js +24 -0
- package/dist/partition-D-0LTCr3.js +221 -0
- package/dist/presets/route-map/apartment.d.ts +2 -0
- package/dist/presets/route-map/apartment.js +116 -0
- package/dist/presets/route-map/botanical-park.d.ts +2 -0
- package/dist/presets/route-map/botanical-park.js +116 -0
- package/dist/presets/route-map/science-museum.d.ts +2 -0
- package/dist/presets/route-map/science-museum.js +45 -0
- package/dist/presets/seat-map/airplane.d.ts +2 -0
- package/dist/presets/seat-map/airplane.js +95 -0
- package/dist/presets/seat-map/ferry.d.ts +2 -0
- package/dist/presets/seat-map/ferry.js +54 -0
- package/dist/presets/seat-map/ice-arena.d.ts +2 -0
- package/dist/presets/seat-map/ice-arena.js +67 -0
- package/dist/presets/seat-map/planetarium.d.ts +2 -0
- package/dist/presets/seat-map/planetarium.js +54 -0
- package/dist/presets/seat-map/train.d.ts +2 -0
- package/dist/presets/seat-map/train.js +66 -0
- package/dist/presets.d.ts +78 -0
- package/dist/presets.js +14 -0
- package/dist/public.d.ts +2 -0
- package/dist/radar.d.ts +5 -0
- package/dist/radar.js +47 -0
- package/dist/rose.d.ts +5 -0
- package/dist/rose.js +7 -0
- package/dist/route-map.d.ts +6 -0
- package/dist/route-map.js +200 -0
- package/dist/scatter.d.ts +8 -0
- package/dist/scatter.js +433 -0
- package/dist/scene-CPvPzTaB.js +137 -0
- package/dist/seat-map.d.ts +6 -0
- package/dist/seat-map.js +84 -0
- package/dist/seat-shape--kEFiUXX.js +66 -0
- package/dist/state-C5pICb11.js +134 -0
- package/dist/sync.d.ts +82 -0
- package/dist/sync.js +326 -0
- package/dist/translation-window-Ca_rCenJ.js +57 -0
- package/dist/tree.d.ts +6 -0
- package/dist/tree.js +114 -0
- package/dist/treemap.d.ts +5 -0
- package/dist/treemap.js +85 -0
- package/dist/ui/area-series/AreaSeries.d.ts +44 -0
- package/dist/ui/area-series/area-series.config.d.ts +10 -0
- package/dist/ui/area-series/area-series.registry.d.ts +4 -0
- package/dist/ui/axis/Axis.d.ts +55 -0
- package/dist/ui/axis/axis.config.d.ts +10 -0
- package/dist/ui/axis/axis.registry.d.ts +4 -0
- package/dist/ui/bar-chart/BarChart.d.ts +124 -0
- package/dist/ui/bar-chart/bar-chart.config.d.ts +10 -0
- package/dist/ui/bar-chart/bar-chart.registry.d.ts +2 -0
- package/dist/ui/bar-series/BarSeries.d.ts +102 -0
- package/dist/ui/bar-series/bar-series.config.d.ts +10 -0
- package/dist/ui/bar-series/bar-series.registry.d.ts +4 -0
- package/dist/ui/bubble-series/BubbleSeries.d.ts +33 -0
- package/dist/ui/bubble-series/bubble-series.config.d.ts +10 -0
- package/dist/ui/bubble-series/bubble-series.registry.d.ts +4 -0
- package/dist/ui/composed-chart/ComposedChart.d.ts +41 -0
- package/dist/ui/composed-chart/composed-chart.config.d.ts +10 -0
- package/dist/ui/composed-chart/composed-chart.registry.d.ts +4 -0
- package/dist/ui/exploration-chart/ExplorationChart.d.ts +83 -0
- package/dist/ui/exploration-chart/exploration-chart.config.d.ts +7 -0
- package/dist/ui/exploration-chart/exploration-chart.registry.d.ts +6 -0
- package/dist/ui/grid/Grid.d.ts +35 -0
- package/dist/ui/grid/grid.config.d.ts +10 -0
- package/dist/ui/grid/grid.registry.d.ts +4 -0
- package/dist/ui/interaction/Interaction.d.ts +53 -0
- package/dist/ui/interaction/interaction.config.d.ts +10 -0
- package/dist/ui/interaction/interaction.registry.d.ts +4 -0
- package/dist/ui/legend/Legend.d.ts +38 -0
- package/dist/ui/legend/legend.config.d.ts +10 -0
- package/dist/ui/legend/legend.registry.d.ts +2 -0
- package/dist/ui/line-series/LineSeries.d.ts +67 -0
- package/dist/ui/line-series/line-series.config.d.ts +10 -0
- package/dist/ui/line-series/line-series.registry.d.ts +4 -0
- package/dist/ui/mark-series/MarkSeries.d.ts +55 -0
- package/dist/ui/novel-series/NovelSeries.d.ts +34 -0
- package/dist/ui/novel-series/novel-series.config.d.ts +9 -0
- package/dist/ui/novel-series/novel-series.registry.d.ts +4 -0
- package/dist/ui/partition-chart/PartitionChart.d.ts +24 -0
- package/dist/ui/partition-chart/partition-chart.config.d.ts +7 -0
- package/dist/ui/partition-chart/partition-chart.registry.d.ts +9 -0
- package/dist/ui/plot/Plot.d.ts +64 -0
- package/dist/ui/plot/plot.config.d.ts +10 -0
- package/dist/ui/plot/plot.registry.d.ts +4 -0
- package/dist/ui/root/Root.d.ts +206 -0
- package/dist/ui/root/root.config.d.ts +10 -0
- package/dist/ui/root/root.registry.d.ts +5 -0
- package/dist/ui/scale/Scale.d.ts +55 -0
- package/dist/ui/scale/scale.config.d.ts +10 -0
- package/dist/ui/scale/scale.registry.d.ts +4 -0
- package/dist/ui/scatter-series/ScatterSeries.d.ts +33 -0
- package/dist/ui/scatter-series/scatter-series.config.d.ts +10 -0
- package/dist/ui/scatter-series/scatter-series.registry.d.ts +4 -0
- package/dist/ui/shared/chart-props.d.ts +150 -0
- package/dist/ui/shared/chart-runtime-resolver.d.ts +4 -0
- package/dist/ui/shared/chart-semantic-marks.d.ts +20 -0
- package/dist/ui/shared/chart-series-runtime.d.ts +48 -0
- package/dist/ui/shared/schema-types.d.ts +34 -0
- package/dist/ui/tooltip/Tooltip.d.ts +64 -0
- package/dist/ui/tooltip/tooltip.config.d.ts +10 -0
- package/dist/ui/tooltip/tooltip.registry.d.ts +4 -0
- package/dist/ui/viewport/Viewport.d.ts +81 -0
- package/dist/ui/viewport/viewport.config.d.ts +10 -0
- package/dist/ui/viewport/viewport.registry.d.ts +2 -0
- package/dist/ui/viewport-controller/ViewportController.d.ts +30 -0
- package/dist/ui/viewport-controller/viewport-controller.config.d.ts +10 -0
- package/dist/ui/viewport-controller/viewport-controller.registry.d.ts +2 -0
- package/package.json +179 -4
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
var V = Object.defineProperty;
|
|
2
|
+
var P = (t, i, e) => i in t ? V(t, i, { enumerable: !0, configurable: !0, writable: !0, value: e }) : t[i] = e;
|
|
3
|
+
var c = (t, i, e) => P(t, typeof i != "symbol" ? i + "" : i, e);
|
|
4
|
+
import { commonMeasureBounds as T, finiteNumber as N, normalizeCommonProps as B, NovaUiComponentNode as D } from "@nova-lab/ui-kit";
|
|
5
|
+
import { a as A } from "./mark-style-Cpl-ARQM.js";
|
|
6
|
+
import { G as $, f as O, m as E } from "./GeometryIndex-DDQ34Jf4.js";
|
|
7
|
+
import { a as k, b as L } from "./host-DLDeDU5k.js";
|
|
8
|
+
import { C as H, p as Y } from "./chart-series-runtime-C0P7h8Tl.js";
|
|
9
|
+
function tt(t) {
|
|
10
|
+
const { props: i, dataStore: e } = t;
|
|
11
|
+
return e.getData().flatMap((n, o) => {
|
|
12
|
+
const s = Number(e.readField(n, o, i.valueField));
|
|
13
|
+
return !Number.isFinite(s) || s <= 0 ? [] : [{ row: n, index: o, value: s, label: String(e.readField(n, o, i.categoryField) ?? "") }];
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
function et(t, i) {
|
|
17
|
+
return t[Math.max(0, i) % t.length] ?? "#2563eb";
|
|
18
|
+
}
|
|
19
|
+
function it(t) {
|
|
20
|
+
let i = 1 / 0, e = -1 / 0;
|
|
21
|
+
for (const n of t)
|
|
22
|
+
Number.isFinite(n) && (i = Math.min(i, n), e = Math.max(e, n));
|
|
23
|
+
return i === 1 / 0 ? [0, 1] : i === e ? [i - 1, e + 1] : [i, e];
|
|
24
|
+
}
|
|
25
|
+
function nt(t) {
|
|
26
|
+
return t instanceof Date ? t.getTime() : Number(t);
|
|
27
|
+
}
|
|
28
|
+
function K(t, i, e) {
|
|
29
|
+
for (const s of i.marks)
|
|
30
|
+
if (U(s, e.x, e.y))
|
|
31
|
+
return z(t, s, 0);
|
|
32
|
+
let n = null, o = e.maxDistancePx ?? 16;
|
|
33
|
+
for (const s of i.marks) {
|
|
34
|
+
const l = s.x + s.width / 2, d = s.y + s.height / 2, h = Math.hypot(e.x - l, e.y - d);
|
|
35
|
+
h <= o && (n = s, o = h);
|
|
36
|
+
}
|
|
37
|
+
return n ? z(t, n, o) : null;
|
|
38
|
+
}
|
|
39
|
+
function U(t, i, e) {
|
|
40
|
+
if (t.kind === "funnel" && t.points) {
|
|
41
|
+
let r = !1;
|
|
42
|
+
for (let p = 0, m = t.points.length - 1; p < t.points.length; m = p++) {
|
|
43
|
+
const u = t.points[p], _ = t.points[m];
|
|
44
|
+
u.y > e != _.y > e && i < (_.x - u.x) * (e - u.y) / (_.y - u.y) + u.x && (r = !r);
|
|
45
|
+
}
|
|
46
|
+
return r;
|
|
47
|
+
}
|
|
48
|
+
if (t.kind === "tree" && t.labelBounds) {
|
|
49
|
+
const r = t.labelBounds;
|
|
50
|
+
if (i >= r.x && i <= r.x + r.width && e >= r.y && e <= r.y + r.height)
|
|
51
|
+
return !0;
|
|
52
|
+
}
|
|
53
|
+
if (t.kind === "radar" || t.kind === "tree")
|
|
54
|
+
return Math.hypot(i - t.x - t.width / 2, e - t.y - t.height / 2) <= t.width / 2;
|
|
55
|
+
if (t.kind !== "donut" && t.kind !== "rose") {
|
|
56
|
+
if (t.kind === "candlestick" && t.wickTop !== void 0 && t.wickBottom !== void 0) {
|
|
57
|
+
const r = t.x + t.width / 2;
|
|
58
|
+
if (Math.abs(i - r) <= 4 && e >= Math.min(t.wickTop, t.wickBottom) && e <= Math.max(t.wickTop, t.wickBottom))
|
|
59
|
+
return !0;
|
|
60
|
+
}
|
|
61
|
+
return i >= t.x && i <= t.x + t.width && e >= t.y && e <= t.y + t.height;
|
|
62
|
+
}
|
|
63
|
+
const n = t.radius ?? 0, o = t.ringWidth ?? 0, s = t.x + t.width / 2, l = t.y + t.height / 2, d = Math.hypot(i - s, e - l);
|
|
64
|
+
if (d < Math.max(0, n - o / 2) || d > n + o / 2)
|
|
65
|
+
return !1;
|
|
66
|
+
let h = Math.atan2(e - l, i - s);
|
|
67
|
+
return h < -Math.PI / 2 && (h += Math.PI * 2), h >= (t.startAngle ?? 0) && h <= (t.endAngle ?? 0);
|
|
68
|
+
}
|
|
69
|
+
function z(t, i, e) {
|
|
70
|
+
return {
|
|
71
|
+
seriesId: t,
|
|
72
|
+
seriesKind: i.kind,
|
|
73
|
+
key: i.key,
|
|
74
|
+
mode: "datum",
|
|
75
|
+
row: i.row,
|
|
76
|
+
value: i.value,
|
|
77
|
+
rawValue: i.value,
|
|
78
|
+
xValue: i.xValue,
|
|
79
|
+
yValue: i.yValue,
|
|
80
|
+
label: i.label,
|
|
81
|
+
category: i.label,
|
|
82
|
+
color: i.color,
|
|
83
|
+
point: { x: i.x + i.width / 2, y: i.y + i.height / 2 },
|
|
84
|
+
bounds: { x: i.x, y: i.y, width: i.width, height: i.height },
|
|
85
|
+
distancePx: e
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
const f = "NovaCharts.NovelSeries";
|
|
89
|
+
function g(t) {
|
|
90
|
+
var s;
|
|
91
|
+
const { style: i, motion: e, ...n } = t;
|
|
92
|
+
if ((t.kind === "candlestick" ? [t.xField, t.openField, t.highField, t.lowField, t.closeField] : t.kind === "heatmap" ? [t.xField, t.yField, t.valueField] : t.kind === "tree" ? [t.categoryField, t.parentField] : [t.categoryField, t.valueField]).includes(void 0))
|
|
93
|
+
throw new Error(`[NovaCharts] ${t.kind} series requires its data fields`);
|
|
94
|
+
return {
|
|
95
|
+
...t,
|
|
96
|
+
...B(n, { width: 560, height: 300, clip: !0 }),
|
|
97
|
+
palette: (s = t.palette) != null && s.length ? [...t.palette] : ["#245a70", "#c85c36", "#7aad9c", "#8d6a9f", "#c7a46a"],
|
|
98
|
+
upColor: t.upColor ?? "#2d8b79",
|
|
99
|
+
downColor: t.downColor ?? "#c85c36",
|
|
100
|
+
innerRadiusRatio: Math.max(0, Math.min(0.9, N(t.innerRadiusRatio, 0.58))),
|
|
101
|
+
gap: Math.max(0, N(t.gap, 2)),
|
|
102
|
+
maxValue: t.maxValue !== void 0 && Number.isFinite(t.maxValue) && t.maxValue > 0 ? t.maxValue : void 0,
|
|
103
|
+
showValues: t.showValues ?? !1,
|
|
104
|
+
interactivePalette: t.interactivePalette ?? !1
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
function x(t) {
|
|
108
|
+
const i = {
|
|
109
|
+
type: f,
|
|
110
|
+
name: f,
|
|
111
|
+
title: f,
|
|
112
|
+
version: "0.1.0",
|
|
113
|
+
kind: "node-component",
|
|
114
|
+
dirtyPolicy: L,
|
|
115
|
+
fields: {
|
|
116
|
+
...k,
|
|
117
|
+
chartRef: { type: "string" },
|
|
118
|
+
kind: { type: "string" },
|
|
119
|
+
xScaleId: { type: "string" },
|
|
120
|
+
yScaleId: { type: "string" },
|
|
121
|
+
xField: { type: "field" },
|
|
122
|
+
yField: { type: "field" },
|
|
123
|
+
categoryField: { type: "field" },
|
|
124
|
+
parentField: { type: "field" },
|
|
125
|
+
collapsedField: { type: "field" },
|
|
126
|
+
valueField: { type: "field" },
|
|
127
|
+
openField: { type: "field" },
|
|
128
|
+
highField: { type: "field" },
|
|
129
|
+
lowField: { type: "field" },
|
|
130
|
+
closeField: { type: "field" },
|
|
131
|
+
palette: { type: "array" },
|
|
132
|
+
upColor: { type: "string" },
|
|
133
|
+
downColor: { type: "string" },
|
|
134
|
+
innerRadiusRatio: { type: "number" },
|
|
135
|
+
gap: { type: "number" },
|
|
136
|
+
maxValue: { type: "number" },
|
|
137
|
+
showValues: { type: "boolean" },
|
|
138
|
+
interactivePalette: { type: "boolean" }
|
|
139
|
+
},
|
|
140
|
+
normalize: (e) => g(e.props),
|
|
141
|
+
measureBounds: (e, n) => T(n, g)
|
|
142
|
+
};
|
|
143
|
+
return t && (i.createNode = t), i;
|
|
144
|
+
}
|
|
145
|
+
x();
|
|
146
|
+
class q extends D {
|
|
147
|
+
constructor(e, n, o, s, l) {
|
|
148
|
+
super(e, n, x(), o, { componentId: l });
|
|
149
|
+
c(this, "_plan");
|
|
150
|
+
c(this, "_index", null);
|
|
151
|
+
c(this, "_binding");
|
|
152
|
+
c(this, "_collapsed");
|
|
153
|
+
c(this, "_layoutRevision", 0);
|
|
154
|
+
c(this, "_computedRevision", "");
|
|
155
|
+
c(this, "_camera", null);
|
|
156
|
+
c(this, "_presentation", {});
|
|
157
|
+
c(this, "_schema", null);
|
|
158
|
+
c(this, "_schemaInteraction", -1);
|
|
159
|
+
c(this, "_schemaCustomization", -1);
|
|
160
|
+
c(this, "_api");
|
|
161
|
+
this._paint = s, this._plan = { marks: [], diagnostics: { kind: s.kind, inputRows: 0, renderedMarks: 0, domainMs: 0, layoutMs: 0, schemaMs: 0, totalMs: 0 } }, this._api = { getLayoutPlan: () => (this.update(), this._plan), getDiagnostics: () => this._plan.diagnostics, hitTest: (d) => this._hitTest(d), refresh: () => {
|
|
162
|
+
this._layoutRevision++, this.update(), this.invalidate({ update: !0, render: !0 });
|
|
163
|
+
} }, this._binding = new H(this, { hitTest: (d) => this._hitTest(d) });
|
|
164
|
+
}
|
|
165
|
+
getApi() {
|
|
166
|
+
return this._api;
|
|
167
|
+
}
|
|
168
|
+
setCamera(e) {
|
|
169
|
+
this._camera = e, this.invalidate({ render: !0 });
|
|
170
|
+
}
|
|
171
|
+
setPresentation(e) {
|
|
172
|
+
this._presentation = e, this._schema = null, this.invalidate({ render: !0 });
|
|
173
|
+
}
|
|
174
|
+
setCollapsed(e) {
|
|
175
|
+
this._collapsed = e, this._layoutRevision++, this.invalidate({ update: !0, render: !0 });
|
|
176
|
+
}
|
|
177
|
+
update() {
|
|
178
|
+
const e = this._binding.runtime();
|
|
179
|
+
if (!e)
|
|
180
|
+
return;
|
|
181
|
+
const n = `${e.dataStore.revision}:${this._layoutRevision}:${e.scales.revision}`;
|
|
182
|
+
if (this._computedRevision === n)
|
|
183
|
+
return;
|
|
184
|
+
const o = performance.now(), s = { props: this.props, dataStore: e.dataStore, width: this.width, height: this.height, xScale: this.props.xScaleId ? e.getScale(this.props.xScaleId) : void 0, yScale: this.props.yScaleId ? e.getScale(this.props.yScaleId) : void 0, collapsedOverrides: this._collapsed };
|
|
185
|
+
this._paint.domains && this._binding.publishContributions(e, this._paint.domains(s).map((h, r) => ({ ...h, id: `${this.componentId}:domain:${r}` })));
|
|
186
|
+
const l = this._paint.layout(s);
|
|
187
|
+
this._schema = null;
|
|
188
|
+
const d = performance.now() - o;
|
|
189
|
+
this._plan = { marks: l, diagnostics: { kind: this._paint.kind, inputRows: e.dataStore.rowCount, renderedMarks: l.length, domainMs: 0, layoutMs: d, schemaMs: 0, totalMs: d } }, this._index = new $(l, (h) => h.labelBounds ? G(h, h.labelBounds) : h), this._computedRevision = `${e.dataStore.revision}:${this._layoutRevision}:${e.scales.revision}`, this._binding.publishDiagnostics(e, this._plan.diagnostics), this._binding.publishMetadata(e, [{ id: this.componentId, kind: this._paint.kind, label: this._paint.kind, visible: !0, color: this.props.palette[0] }]), Y(e, `${this.componentId}:marks`, this.componentId, this._paint.kind, l);
|
|
190
|
+
}
|
|
191
|
+
render() {
|
|
192
|
+
const e = this._binding.runtime(), n = (e == null ? void 0 : e.getInteractionState().revision) ?? 0, o = (e == null ? void 0 : e.customization.revision) ?? 0;
|
|
193
|
+
if ((!this._schema || this._schemaInteraction !== n || this._schemaCustomization !== o || e != null && e.customization.contextualStyles) && (this._schema = this._createSchema(e), this._schema.contentVersion = 0, this._schema.snapshotVersion = 0, this._schemaInteraction = n, this._schemaCustomization = o), this.renderer.save(), this._camera) {
|
|
194
|
+
const s = this._camera, l = O(s.zoom, 0, 0, 0, s.zoom, 0, this.width / 2 - s.center.x * s.zoom, this.height / 2 - s.center.y * s.zoom, 1);
|
|
195
|
+
this.renderer.setTransform(E(l, this.matrix, l));
|
|
196
|
+
}
|
|
197
|
+
this.renderer.schema(this._schema), this.renderer.restore();
|
|
198
|
+
}
|
|
199
|
+
_createSchema(e) {
|
|
200
|
+
var s, l, d, h, r, p, m, u, _, v, w, b, M, S;
|
|
201
|
+
const n = [...((l = (s = this._paint).decoration) == null ? void 0 : l.call(s, this._plan.marks, this.width, this.height)) ?? []], o = e == null ? void 0 : e.getInteractionState().hovered;
|
|
202
|
+
for (const a of this._plan.marks) {
|
|
203
|
+
const y = e == null ? void 0 : e.customization.resolveMarkStyle({ componentId: this.componentId, componentName: this._paint.kind, part: this._paint.kind, row: a.row, seriesKind: this._paint.kind, state: (o == null ? void 0 : o.seriesId) === this.componentId && o.key === a.key ? "hovered" : "normal", tokens: e.customization.tokens }, { legacy: { fill: a.color, background: a.color } });
|
|
204
|
+
if (n.push(...A(this._paint.mark(a, (y == null ? void 0 : y.fill) ?? (y == null ? void 0 : y.background) ?? a.color), (d = this._presentation.styles) == null ? void 0 : d.normal)), (((h = this._presentation.labels) == null ? void 0 : h.visible) ?? this._paint.labels) && (a.labelBounds || a.width > 40 && a.height > 18)) {
|
|
205
|
+
const I = e.dataStore.getRowKey(a.row, -1), C = { row: a.row, ref: this._paint.kind === "tree" ? { type: "node", key: I } : { type: "datum", seriesId: "main", key: I }, label: a.label, value: a.value, bounds: a.labelBounds ?? a }, F = ((r = this._presentation.font) == null ? void 0 : r.size) ?? 12, R = Math.ceil(F * 1.3);
|
|
206
|
+
n.push({ type: "text", text: ((m = (p = this._presentation.labels) == null ? void 0 : p.format) == null ? void 0 : m.call(p, C)) ?? ((_ = (u = this._presentation.formatters) == null ? void 0 : u.label) == null ? void 0 : _.call(u, C)) ?? a.label, x: ((v = a.labelBounds) == null ? void 0 : v.x) ?? a.x + 4, y: ((w = a.labelBounds) == null ? void 0 : w.y) ?? a.y + a.height / 2 - R / 2, width: ((b = a.labelBounds) == null ? void 0 : b.width) ?? a.width - 8, height: R, styles: { align: { vertical: "middle" }, color: this._presentation.theme === "dark" ? "#c6d0dc" : "#475569", font: { size: F, family: ((M = this._presentation.font) == null ? void 0 : M.family) ?? "Arial", weight: ((S = this._presentation.font) == null ? void 0 : S.weight) ?? "normal" }, ellipsis: !0 } });
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
return n;
|
|
210
|
+
}
|
|
211
|
+
applyLayoutRect(e) {
|
|
212
|
+
const n = super.applyLayoutRect(e);
|
|
213
|
+
return n && this._layoutRevision++, n;
|
|
214
|
+
}
|
|
215
|
+
onPropsChanged(e) {
|
|
216
|
+
this.applyCommonPropsChanged(e), this._layoutRevision++, this.invalidate({ update: !0, render: !0 });
|
|
217
|
+
}
|
|
218
|
+
onMount() {
|
|
219
|
+
super.onMount(), this._binding.syncInteractive();
|
|
220
|
+
}
|
|
221
|
+
onUnmount() {
|
|
222
|
+
this._binding.cleanup(), this._index = null, this._schema = null, super.onUnmount();
|
|
223
|
+
}
|
|
224
|
+
_hitTest(e) {
|
|
225
|
+
var o;
|
|
226
|
+
this.update(), this._camera && (e = { ...e, x: (e.x - this.width / 2) / this._camera.zoom + this._camera.center.x, y: (e.y - this.height / 2) / this._camera.zoom + this._camera.center.y, maxDistancePx: (e.maxDistancePx ?? 12) / this._camera.zoom });
|
|
227
|
+
const n = ((o = this._index) == null ? void 0 : o.query(e.x, e.y, e.maxDistancePx ?? 12).reverse()) ?? [];
|
|
228
|
+
return K(this.componentId, { ...this._plan, marks: n }, { ...e });
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
function st(t, i) {
|
|
232
|
+
const e = `NovaCharts.${i.kind}.Marks`, n = x((o, s) => new q(o.app, o.surface, g({ ...s.props, kind: i.kind }), i, s.id ?? e));
|
|
233
|
+
return t.register({ ...n, name: e, type: e }, { override: !0 }), e;
|
|
234
|
+
}
|
|
235
|
+
function G(t, i) {
|
|
236
|
+
const e = Math.min(t.x, i.x), n = Math.min(t.y, i.y);
|
|
237
|
+
return { x: e, y: n, width: Math.max(t.x + t.width, i.x + i.width) - e, height: Math.max(t.y + t.height, i.y + i.height) - n };
|
|
238
|
+
}
|
|
239
|
+
export {
|
|
240
|
+
et as c,
|
|
241
|
+
it as e,
|
|
242
|
+
tt as p,
|
|
243
|
+
st as r,
|
|
244
|
+
nt as t
|
|
245
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { AggregationHandle, AggregationOptions } from './api/types';
|
|
2
|
+
export declare const AggregationChart: {
|
|
3
|
+
mount<T>(target: string | HTMLElement, options: AggregationOptions<T>): AggregationHandle<T>;
|
|
4
|
+
attach<T>(target: import('./api/types').ChartAttachTarget, options: AggregationOptions<T>): AggregationHandle<T>;
|
|
5
|
+
};
|
|
6
|
+
export type { AggregationHandle as AggregationChartHandle, AggregationOptions as AggregationChartOptions } from './api/types';
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { c as U } from "./host-DLDeDU5k.js";
|
|
2
|
+
import { c as W } from "./scene-CPvPzTaB.js";
|
|
3
|
+
function $(u, w) {
|
|
4
|
+
const l = u.getNovaChartRuntime().dataStore;
|
|
5
|
+
let v = w, m = /* @__PURE__ */ new Map();
|
|
6
|
+
const b = (e, t) => typeof t == "function" ? t(e) : e[t], g = (e) => b(e, v.group), S = (e) => b(e, v.key);
|
|
7
|
+
let x = -1, I = [];
|
|
8
|
+
function C(e) {
|
|
9
|
+
for (const t of e) {
|
|
10
|
+
const a = g(t);
|
|
11
|
+
if (!(typeof a == "string" && a.trim() || typeof a == "number" && Number.isFinite(a)))
|
|
12
|
+
throw new Error("[NovaCharts] Aggregation group requires a stable key");
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
l.setValidator(C);
|
|
16
|
+
const y = () => {
|
|
17
|
+
if (x !== l.revision) {
|
|
18
|
+
const e = /* @__PURE__ */ new Map();
|
|
19
|
+
for (const t of l.getSourceData()) {
|
|
20
|
+
const a = g(t);
|
|
21
|
+
e.set(a, (e.get(a) ?? 0) + 1);
|
|
22
|
+
}
|
|
23
|
+
I = [...e].map(([t, a]) => ({ key: t, count: a })), x = l.revision;
|
|
24
|
+
}
|
|
25
|
+
return I;
|
|
26
|
+
}, G = (e) => {
|
|
27
|
+
var r, n;
|
|
28
|
+
if (e.viewport || e.playback || e.graph)
|
|
29
|
+
throw new Error("[NovaCharts] Unsupported Aggregation view state");
|
|
30
|
+
const t = e.detail ?? { level: ((r = v.detail) == null ? void 0 : r.level) ?? 1, groups: [] };
|
|
31
|
+
if (!Number.isInteger(t.level) || t.level < 0 || t.level > 2)
|
|
32
|
+
throw new Error("[NovaCharts] Detail level must be 0, 1 or 2");
|
|
33
|
+
const a = new Set(y().map((s) => s.key)), f = ((n = e.navigation) == null ? void 0 : n.drilldown) ?? [];
|
|
34
|
+
return { ...e, detail: { level: t.level, groups: [...new Set(t.groups)].filter((s) => a.has(s)) }, navigation: { expanded: [], drilldown: f.filter((s) => a.has(s)) }, selection: e.selection.filter((s) => s.type === "datum" ? s.seriesId === "main" && !!l.getRow(s.key) : s.type === "bucket" && s.seriesId === "main" && m.has(s.key)) };
|
|
35
|
+
};
|
|
36
|
+
return y(), W(u, w, {
|
|
37
|
+
capabilities: { kind: "aggregation", rows: !0, scales: !1, viewport: !1, camera: !0, drilldown: !0, expansion: !1, layout: !1, detail: !0, playback: !1, selection: !0, export: { image: ["png", "jpeg", "webp"], data: ["json", "csv"] } },
|
|
38
|
+
legend: () => y().map((e) => ({ id: JSON.stringify([typeof e.key, e.key]), label: String(e.key) })),
|
|
39
|
+
defaults: () => {
|
|
40
|
+
var e;
|
|
41
|
+
return { detail: { level: ((e = w.detail) == null ? void 0 : e.level) ?? 1, groups: [] }, navigation: { expanded: [], drilldown: [] } };
|
|
42
|
+
},
|
|
43
|
+
normalize: G,
|
|
44
|
+
getData: () => l.getSourceData(),
|
|
45
|
+
setData: (e) => l.setData([...e]),
|
|
46
|
+
configure(e) {
|
|
47
|
+
var t;
|
|
48
|
+
if (((t = e.detail) == null ? void 0 : t.cellSize) !== void 0 && (!Number.isFinite(e.detail.cellSize) || e.detail.cellSize <= 0))
|
|
49
|
+
throw new Error("[NovaCharts] Aggregation cellSize must be positive");
|
|
50
|
+
v = e, C(l.getSourceData()), x = -1, y();
|
|
51
|
+
},
|
|
52
|
+
changed: () => {
|
|
53
|
+
m.clear(), y();
|
|
54
|
+
},
|
|
55
|
+
plan(e, t) {
|
|
56
|
+
var R, A, O, j, J;
|
|
57
|
+
const a = new Set(t.detail.groups), f = t.navigation.drilldown.at(-1), r = l.getData().filter((i) => (a.size === 0 || a.has(g(i))) && (f === void 0 || g(i) === f) && t.visibility[JSON.stringify([typeof g(i), g(i)])] !== !1);
|
|
58
|
+
let n = 1 / 0, s = -1 / 0, k = 1 / 0, M = -1 / 0;
|
|
59
|
+
const B = r.flatMap((i) => {
|
|
60
|
+
const o = Number(b(i, e.x)), d = Number(b(i, e.y));
|
|
61
|
+
return !Number.isFinite(o) || !Number.isFinite(d) ? [] : (n = Math.min(n, o), s = Math.max(s, o), k = Math.min(k, d), M = Math.max(M, d), [{ row: i, x: o, y: d }]);
|
|
62
|
+
}), q = e.palette ?? ["#2674b8", "#e68a42", "#69a84f"], T = new Map(y().map((i, o) => [i.key, o])), z = ((R = e.detail) == null ? void 0 : R.cellSize) ?? 32, N = /* @__PURE__ */ new Map();
|
|
63
|
+
for (const i of B) {
|
|
64
|
+
const o = 12 + (i.x - n) / Math.max(1e-9, s - n) * Math.max(1, u.width - 24), d = 12 + (i.y - k) / Math.max(1e-9, M - k) * Math.max(1, u.height - 24), p = JSON.stringify([typeof g(i.row), g(i.row), t.detail.level, ...t.detail.level === 0 ? [] : t.detail.level === 1 ? [Math.floor(o / z), Math.floor(d / z)] : [typeof S(i.row), S(i.row)]]);
|
|
65
|
+
let c = N.get(p);
|
|
66
|
+
c || (c = { group: g(i.row), x: 0, y: 0, members: [], rows: [] }, N.set(p, c)), c.x += o, c.y += d, c.members.push(S(i.row)), c.rows.push(i.row);
|
|
67
|
+
}
|
|
68
|
+
const E = [], F = [];
|
|
69
|
+
m = /* @__PURE__ */ new Map();
|
|
70
|
+
for (const [i, o] of N) {
|
|
71
|
+
const d = { x: o.x / o.members.length, y: o.y / o.members.length }, p = t.detail.level === 2 ? 3 : Math.min(28, 4 + Math.sqrt(o.members.length));
|
|
72
|
+
E.push({ type: "circle", ...d, radius: p, styles: { background: ((O = (A = e.styles) == null ? void 0 : A.normal) == null ? void 0 : O.fill) ?? q[T.get(o.group) % q.length] ?? "#2674b8", opacity: ((J = (j = e.styles) == null ? void 0 : j.normal) == null ? void 0 : J.opacity) ?? 0.85 } });
|
|
73
|
+
const c = { ref: t.detail.level === 2 ? { type: "datum", seriesId: "main", key: o.members[0] } : { type: "bucket", seriesId: "main", key: i }, row: t.detail.level === 2 ? o.rows[0] : void 0, members: t.detail.level === 2 ? void 0 : o.members, label: `${String(o.group)}: ${o.members.length}`, value: o.members.length, point: d, bounds: { x: d.x - p, y: d.y - p, width: p * 2, height: p * 2 }, contains: (h, D) => Math.hypot(h.x - d.x, h.y - d.y) <= p + D, overlay: (h, D, V) => [{ type: "circle", ...D(d), radius: (h.radius ?? p) * V, styles: { background: h.fill ?? "transparent", border: { color: h.stroke ?? "#287bc1", width: h.strokeWidth ?? 2 }, opacity: h.opacity ?? 1 } }] };
|
|
74
|
+
F.push(c), c.ref.type === "bucket" && m.set(c.ref.key, c);
|
|
75
|
+
}
|
|
76
|
+
return { schema: E, items: F };
|
|
77
|
+
},
|
|
78
|
+
lookup(e) {
|
|
79
|
+
if (e.type === "bucket")
|
|
80
|
+
return m.get(e.key) ?? null;
|
|
81
|
+
const t = l.getRow(e.key);
|
|
82
|
+
return t && e.seriesId === "main" ? { ref: e, row: t, label: String(g(t)) } : null;
|
|
83
|
+
},
|
|
84
|
+
extend(e) {
|
|
85
|
+
const t = () => e.readState().detail, a = () => e.readState().navigation, f = (r) => {
|
|
86
|
+
if (!y().some((n) => Object.is(n.key, r)))
|
|
87
|
+
throw new Error(`[NovaCharts] Unknown group ${String(r)}`);
|
|
88
|
+
};
|
|
89
|
+
return {
|
|
90
|
+
getDetail: () => ({ ...t(), groups: [...t().groups] }),
|
|
91
|
+
setDetail: (r, n) => {
|
|
92
|
+
e.request("detail", { ...t(), level: r }, n == null ? void 0 : n.origin);
|
|
93
|
+
},
|
|
94
|
+
getGroups: () => y().map((r) => ({ ...r })),
|
|
95
|
+
setGroups: (r, n) => {
|
|
96
|
+
for (const s of r)
|
|
97
|
+
f(s);
|
|
98
|
+
e.request("detail", { ...t(), groups: [...r] }, n == null ? void 0 : n.origin);
|
|
99
|
+
},
|
|
100
|
+
getDrilldown: () => [...a().drilldown],
|
|
101
|
+
drillTo: (r, n) => {
|
|
102
|
+
f(r), e.request("navigation", { expanded: [], drilldown: [...a().drilldown, r] }, n == null ? void 0 : n.origin);
|
|
103
|
+
},
|
|
104
|
+
drillUp: (r) => {
|
|
105
|
+
e.request("navigation", { expanded: [], drilldown: a().drilldown.slice(0, -1) }, r == null ? void 0 : r.origin);
|
|
106
|
+
},
|
|
107
|
+
resetDrilldown: (r) => {
|
|
108
|
+
e.request("navigation", { expanded: [], drilldown: [] }, r == null ? void 0 : r.origin);
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
const L = {
|
|
115
|
+
mount(u, w) {
|
|
116
|
+
return U({ rows: (l) => l.data, key: (l) => l.key, create: $ }).mount(u, w);
|
|
117
|
+
},
|
|
118
|
+
attach(u, w) {
|
|
119
|
+
return U({ rows: (l) => l.data, key: (l) => l.key, create: $ }).attach(u, w);
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
export {
|
|
123
|
+
L as AggregationChart
|
|
124
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { ChartKey, ChartMarkStyle, ChartPlugin, ItemRef } from './api/types';
|
|
2
|
+
export interface ChartAnnotation {
|
|
3
|
+
key: ChartKey;
|
|
4
|
+
type: 'line' | 'range' | 'point' | 'text';
|
|
5
|
+
x?: number | string;
|
|
6
|
+
y?: number | string;
|
|
7
|
+
x2?: number | string;
|
|
8
|
+
y2?: number | string;
|
|
9
|
+
xScaleId?: string;
|
|
10
|
+
yScaleId?: string;
|
|
11
|
+
text?: string;
|
|
12
|
+
item?: ItemRef;
|
|
13
|
+
style?: ChartMarkStyle;
|
|
14
|
+
}
|
|
15
|
+
export interface AnnotationOptions {
|
|
16
|
+
id?: string;
|
|
17
|
+
data?: ReadonlyArray<ChartAnnotation>;
|
|
18
|
+
}
|
|
19
|
+
export interface AnnotationsPlugin extends ChartPlugin {
|
|
20
|
+
getData: () => ReadonlyArray<ChartAnnotation>;
|
|
21
|
+
setData: (values: ReadonlyArray<ChartAnnotation>) => void;
|
|
22
|
+
upsert: (values: ReadonlyArray<ChartAnnotation>) => void;
|
|
23
|
+
patch: (values: ReadonlyArray<{
|
|
24
|
+
key: ChartKey;
|
|
25
|
+
changes: Partial<ChartAnnotation>;
|
|
26
|
+
}>) => void;
|
|
27
|
+
remove: (keys: ReadonlyArray<ChartKey>) => void;
|
|
28
|
+
clear: () => void;
|
|
29
|
+
}
|
|
30
|
+
export declare const Annotations: {
|
|
31
|
+
create: typeof createAnnotations;
|
|
32
|
+
};
|
|
33
|
+
declare function createAnnotations(options?: AnnotationOptions): AnnotationsPlugin;
|
|
34
|
+
export {};
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { k as w } from "./scene-CPvPzTaB.js";
|
|
2
|
+
const F = { create: q };
|
|
3
|
+
function q(f = {}) {
|
|
4
|
+
let l = w(f.data ?? [], "annotation"), m = null, o = null;
|
|
5
|
+
const y = (e) => {
|
|
6
|
+
const i = w(e, "annotation");
|
|
7
|
+
for (const n of e) {
|
|
8
|
+
if (!["line", "range", "point", "text"].includes(n.type))
|
|
9
|
+
throw new Error("[Annotations] Unknown annotation type");
|
|
10
|
+
for (const s of [n.x, n.y, n.x2, n.y2])
|
|
11
|
+
if (typeof s == "number" && !Number.isFinite(s))
|
|
12
|
+
throw new TypeError("[Annotations] Coordinates must be finite");
|
|
13
|
+
}
|
|
14
|
+
l = i, o == null || o.invalidate();
|
|
15
|
+
};
|
|
16
|
+
return y(f.data ?? []), {
|
|
17
|
+
id: f.id ?? "annotations",
|
|
18
|
+
getData: () => [...l.values()],
|
|
19
|
+
setData: y,
|
|
20
|
+
upsert(e) {
|
|
21
|
+
w(e, "annotation");
|
|
22
|
+
const i = new Map(l);
|
|
23
|
+
for (const n of e)
|
|
24
|
+
i.set(n.key, n);
|
|
25
|
+
y([...i.values()]);
|
|
26
|
+
},
|
|
27
|
+
patch(e) {
|
|
28
|
+
const i = new Map(l);
|
|
29
|
+
for (const n of e) {
|
|
30
|
+
const s = i.get(n.key);
|
|
31
|
+
if (!s || n.changes.key !== void 0 && n.changes.key !== n.key)
|
|
32
|
+
throw new Error("[Annotations] patch requires an existing immutable key");
|
|
33
|
+
i.set(n.key, { ...s, ...n.changes });
|
|
34
|
+
}
|
|
35
|
+
y([...i.values()]);
|
|
36
|
+
},
|
|
37
|
+
remove(e) {
|
|
38
|
+
const i = new Set(e);
|
|
39
|
+
y([...l.values()].filter((n) => !i.has(n.key)));
|
|
40
|
+
},
|
|
41
|
+
clear: () => y([]),
|
|
42
|
+
attach(e) {
|
|
43
|
+
if (m)
|
|
44
|
+
throw new Error("[Annotations] Plugin is already attached");
|
|
45
|
+
m = e, o = e.overlay(() => {
|
|
46
|
+
var b, v, S, z, A, M, I, C, E, D;
|
|
47
|
+
const s = [], k = e.size(), c = e.plotBounds(), u = (t, a) => {
|
|
48
|
+
if (e.chart.getCapabilities().scales)
|
|
49
|
+
return e.map(t, a);
|
|
50
|
+
const r = e.chart.getViewState().camera;
|
|
51
|
+
return r ? (t === "x" ? k.width / 2 - r.center.x * r.zoom : k.height / 2 - r.center.y * r.zoom) + Number(a) * r.zoom : Number(a);
|
|
52
|
+
};
|
|
53
|
+
for (const t of l.values()) {
|
|
54
|
+
const a = t.item ? e.chart.getItem(t.item) : null;
|
|
55
|
+
if (t.item && !(a != null && a.point))
|
|
56
|
+
continue;
|
|
57
|
+
const r = t.type === "line" && t.x === void 0 && t.y !== void 0 && !t.item, h = ((b = a == null ? void 0 : a.point) == null ? void 0 : b.x) ?? (r ? c.x : u(t.xScaleId ?? "x", t.x ?? 0)), p = ((v = a == null ? void 0 : a.point) == null ? void 0 : v.y) ?? (t.y === void 0 ? c.y : u(t.yScaleId ?? "y", t.y)), x = t.x2 === void 0 ? r ? c.x + c.width : h : u(t.xScaleId ?? "x", t.x2), g = t.y2 === void 0 ? r ? p : c.y + c.height : u(t.yScaleId ?? "y", t.y2), d = ((S = t.style) == null ? void 0 : S.stroke) ?? "#c85c36", N = ((z = t.style) == null ? void 0 : z.strokeWidth) ?? 1.5;
|
|
58
|
+
t.type === "line" && s.push({ clip: c, type: "line", x1: h, y1: p, x2: x, y2: g, styles: { color: d, width: N, opacity: ((A = t.style) == null ? void 0 : A.opacity) ?? 1 } }), t.type === "range" && s.push({ clip: c, type: "rect", x: Math.min(h, x), y: Math.min(p, g), width: Math.abs(x - h), height: Math.abs(g - p), styles: { background: ((M = t.style) == null ? void 0 : M.fill) ?? d, opacity: ((I = t.style) == null ? void 0 : I.opacity) ?? 0.15 } }), t.type === "point" && s.push({ clip: c, type: "circle", x: h, y: p, radius: ((C = t.style) == null ? void 0 : C.radius) ?? 5, styles: { background: ((E = t.style) == null ? void 0 : E.fill) ?? d, opacity: ((D = t.style) == null ? void 0 : D.opacity) ?? 1 } }), t.text && s.push({ type: "text", text: t.text, x: h + 6, y: p + 4, width: 160, height: 18, styles: { color: d, font: { size: 12, family: "Arial" } } });
|
|
59
|
+
}
|
|
60
|
+
return s;
|
|
61
|
+
});
|
|
62
|
+
const i = e.chart.on("viewStateChange", () => o == null ? void 0 : o.invalidate()), n = e.chart.on("dataChange", () => o == null ? void 0 : o.invalidate());
|
|
63
|
+
return () => {
|
|
64
|
+
i(), n(), o == null || o.dispose(), o = null, m = null;
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
export {
|
|
70
|
+
F as Annotations
|
|
71
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { DriverContext } from './internal';
|
|
2
|
+
import { CameraApi, CameraState, ChartItem, ItemRef } from './types';
|
|
3
|
+
/** Общая сценовая камера; команды проходят через того же controlled-владельца. */
|
|
4
|
+
export declare function cameraApi<T, R extends ItemRef>(context: DriverContext<T, R>, size: () => {
|
|
5
|
+
width: number;
|
|
6
|
+
height: number;
|
|
7
|
+
}, items: (refs: ReadonlyArray<R>) => ReadonlyArray<ChartItem<T, R>>, home?: () => CameraState, content?: () => ReadonlyArray<ChartItem<T, R>>): CameraApi;
|
|
8
|
+
export declare function normalizeCamera(camera: CameraState): CameraState;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { NovaSchemaRegistry } from '@nova-lab/core';
|
|
2
|
+
import { CartesianHandle, CartesianKind, CartesianOptions, ChartAttachTarget, ComposedHandle, ComposedOptions, SeriesDefinition, SeriesOptions } from './types';
|
|
3
|
+
export interface CartesianRenderer {
|
|
4
|
+
kind: CartesianKind;
|
|
5
|
+
schemaType: string;
|
|
6
|
+
register: (registry: NovaSchemaRegistry) => void;
|
|
7
|
+
props?: (series: SeriesOptions<unknown>) => Record<string, unknown>;
|
|
8
|
+
}
|
|
9
|
+
/** Series сохраняет свою реализацию; Composed не импортирует остальные типы. */
|
|
10
|
+
export declare function defineSeries<T>(renderer: CartesianRenderer, options: SeriesOptions<T>): SeriesDefinition<T>;
|
|
11
|
+
export declare function createCartesianChart(renderer: CartesianRenderer): {
|
|
12
|
+
series: <T = never, const S extends SeriesOptions<never> = SeriesOptions<T>>(options: S) => Omit<S, "type"> & {
|
|
13
|
+
readonly type: CartesianKind;
|
|
14
|
+
};
|
|
15
|
+
mount<T>(target: string | HTMLElement, options: CartesianOptions<T>): CartesianHandle<T>;
|
|
16
|
+
attach<T>(target: ChartAttachTarget, options: CartesianOptions<T>): CartesianHandle<T>;
|
|
17
|
+
};
|
|
18
|
+
export declare const ComposedChart: {
|
|
19
|
+
mount<T>(target: string | HTMLElement, options: ComposedOptions<T>): ComposedHandle<T>;
|
|
20
|
+
attach<T>(target: ChartAttachTarget, options: ComposedOptions<T>): ComposedHandle<T>;
|
|
21
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ChartEvent } from './types';
|
|
2
|
+
/** Coalescing сохраняет первое previous и последнее current внутри batch. */
|
|
3
|
+
export declare class ChartEventHub {
|
|
4
|
+
private readonly _listeners;
|
|
5
|
+
private readonly _queued;
|
|
6
|
+
private _depth;
|
|
7
|
+
get size(): number;
|
|
8
|
+
has(name: string): boolean;
|
|
9
|
+
on<T>(name: string, listener: (value: ChartEvent<T>) => void): () => void;
|
|
10
|
+
emit<T>(name: string, event: ChartEvent<T>): void;
|
|
11
|
+
batch<V>(callback: () => V): V;
|
|
12
|
+
dispose(): void;
|
|
13
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { ChartHost } from './host';
|
|
2
|
+
import { ChartDriver } from './internal';
|
|
3
|
+
import { ChartHandle, ChartKey, ChartOptions, Field, ItemRef } from './types';
|
|
4
|
+
/** Объединяет один ChartRoot, family driver, persistent state и локальный transient state. */
|
|
5
|
+
export declare function createChartHandle<D, T, R extends ItemRef, O extends ChartOptions<D, R>>(host: ChartHost<T>, driver: ChartDriver<D, T, R, O>, initialOptions: O, key: Field<T, ChartKey>): ChartHandle<D, R, T, O> & Record<string, unknown>;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { NovaApp } from '@nova-lab/core';
|
|
2
|
+
import { ChartDriver } from './internal';
|
|
3
|
+
import { ChartAttachTarget, ChartKey, ChartOptions, Field, ItemRef, ResizeOptions } from './types';
|
|
4
|
+
import { ChartRoot } from '../ui/root/Root';
|
|
5
|
+
export interface ChartHost<T> {
|
|
6
|
+
app: NovaApp;
|
|
7
|
+
root: ChartRoot<T>;
|
|
8
|
+
canvas: HTMLCanvasElement;
|
|
9
|
+
target: HTMLElement | null;
|
|
10
|
+
owned: boolean;
|
|
11
|
+
resize: (options?: ResizeOptions) => void;
|
|
12
|
+
destroy: () => void;
|
|
13
|
+
}
|
|
14
|
+
export interface FactoryDriver<D, T, R extends ItemRef, O extends ChartOptions<D, R>> {
|
|
15
|
+
rows: (options: O) => ReadonlyArray<T>;
|
|
16
|
+
key: (options: O) => Field<T, ChartKey>;
|
|
17
|
+
create: (root: ChartRoot<T>, options: O) => ChartDriver<D, T, R, O>;
|
|
18
|
+
}
|
|
19
|
+
/** Единственный DOM/App owner; attach освобождает только собственное поддерево. */
|
|
20
|
+
export declare function createChartFactory<D, T, R extends ItemRef, O extends ChartOptions<D, R>>(definition: FactoryDriver<D, T, R, O>): {
|
|
21
|
+
attach: (target: ChartAttachTarget, options: O) => import('./types').ChartHandle<D, R, T, O> & Record<string, unknown>;
|
|
22
|
+
mount(targetInput: string | HTMLElement, options: O): import('./types').ChartHandle<D, R, T, O> & Record<string, unknown>;
|
|
23
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { NovaSchema, NovaSyncParticipant, NovaSyncTransaction } from '@nova-lab/core';
|
|
2
|
+
import { ChartCapabilities, ChartHandle, ChartItem, ChartKey, ChartLegendItem, ChartMarkStyle, ChartOptions, ChartViewState, ItemRef, Point } from './types';
|
|
3
|
+
import { ChartDataStore } from '../model/data/ChartDataStore';
|
|
4
|
+
import { ChartRoot } from '../ui/root/Root';
|
|
5
|
+
/** Семейство предоставляет реальную геометрию и команды своему общему владельцу. */
|
|
6
|
+
export interface ChartDriver<D, T, R extends ItemRef, O extends ChartOptions<D, R>> {
|
|
7
|
+
capabilities: ChartCapabilities;
|
|
8
|
+
defaults: () => ChartViewState<R>;
|
|
9
|
+
normalize: (value: ChartViewState<R>) => ChartViewState<R>;
|
|
10
|
+
configure: (options: O) => void;
|
|
11
|
+
applyState: (previous: ChartViewState<R>, current: ChartViewState<R>) => void;
|
|
12
|
+
dataChanged: () => void;
|
|
13
|
+
getData: () => D;
|
|
14
|
+
setData: (value: D) => void;
|
|
15
|
+
getItem: (ref: R) => ChartItem<T, R> | null;
|
|
16
|
+
hitTest: (point: Point, radius: number) => ChartItem<T, R> | null;
|
|
17
|
+
getLegendItems?: () => ReadonlyArray<ChartLegendItem>;
|
|
18
|
+
getVisibleItems: () => ReadonlyArray<ChartItem<T, R>>;
|
|
19
|
+
plotBounds?: () => {
|
|
20
|
+
x: number;
|
|
21
|
+
y: number;
|
|
22
|
+
width: number;
|
|
23
|
+
height: number;
|
|
24
|
+
};
|
|
25
|
+
overlay?: (ref: R, style: ChartMarkStyle) => NovaSchema;
|
|
26
|
+
resize: () => void;
|
|
27
|
+
refresh?: () => void;
|
|
28
|
+
dispose: () => void;
|
|
29
|
+
extend: (chart: ChartHandle<D, R, T, O>, context: DriverContext<T, R>) => Record<string, unknown>;
|
|
30
|
+
}
|
|
31
|
+
export interface DriverContext<T, R extends ItemRef> {
|
|
32
|
+
root: ChartRoot<T>;
|
|
33
|
+
store: ChartDataStore<T>;
|
|
34
|
+
readState: () => ChartViewState<R>;
|
|
35
|
+
request: (channel: keyof ChartViewState, value: unknown, origin?: 'user' | 'api' | 'sync', transaction?: NovaSyncTransaction, signal?: AbortSignal) => ReturnType<NovaSyncParticipant['ports'][string]['write']>;
|
|
36
|
+
invalidate: (data?: boolean) => void;
|
|
37
|
+
reportError: (error: unknown) => void;
|
|
38
|
+
keyOf: (row: T) => ChartKey;
|
|
39
|
+
}
|
|
40
|
+
/** Связь handle с endpoint скрыта от пользовательского контракта и от других пакетов. */
|
|
41
|
+
export declare const chartParticipants: WeakMap<object, NovaSyncParticipant>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { NovaSchema } from '@nova-lab/core';
|
|
2
|
+
import { MapBackground } from './types';
|
|
3
|
+
/** Lifecycle изображения принадлежит сцене и не создаёт постоянного animation loop. */
|
|
4
|
+
export declare class MapImage {
|
|
5
|
+
private readonly _invalidate;
|
|
6
|
+
private _image;
|
|
7
|
+
private _source;
|
|
8
|
+
constructor(_invalidate: () => void);
|
|
9
|
+
set(background: MapBackground | undefined): void;
|
|
10
|
+
schema(x: number, y: number, width: number, height: number): NovaSchema;
|
|
11
|
+
dispose(): void;
|
|
12
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { NovaSchema } from '@nova-lab/core';
|
|
2
|
+
import { NovaChartNovelMark } from '../model/novel/novel-chart.types';
|
|
3
|
+
export declare function arcMark(mark: NovaChartNovelMark<unknown>, color: string): NovaSchema;
|
|
4
|
+
export declare function rectMark(mark: NovaChartNovelMark<unknown>, color: string): NovaSchema;
|
|
5
|
+
export declare function pointMark(mark: NovaChartNovelMark<unknown>, color: string): NovaSchema;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { DriverContext } from './internal';
|
|
2
|
+
import { ChartKey, ExpansionApi, ItemRef, NavigationApi } from './types';
|
|
3
|
+
/** Проверяет идентичность навигации и хранит её только в ChartState. */
|
|
4
|
+
export declare function navigationApi<T, R extends ItemRef>(context: DriverContext<T, R>, parentOf?: (key: ChartKey) => ChartKey | null): NavigationApi & ExpansionApi;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { NovaSchema } from '@nova-lab/core';
|
|
2
|
+
import { ChartRoot } from '../ui/root/Root';
|
|
3
|
+
/** Overlay не меняет data/geometry план и принадлежит lifecycle корня. */
|
|
4
|
+
export declare function createOverlay(root: ChartRoot<any>, schema: () => NovaSchema): {
|
|
5
|
+
invalidate: () => void;
|
|
6
|
+
dispose: () => void;
|
|
7
|
+
};
|