@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,1139 @@
|
|
|
1
|
+
var We = Object.defineProperty;
|
|
2
|
+
var Be = (n, c, e) => c in n ? We(n, c, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[c] = e;
|
|
3
|
+
var $ = (n, c, e) => Be(n, typeof c != "symbol" ? c + "" : c, e);
|
|
4
|
+
import { commonMeasureBounds as U, NovaUiComponentNode as Y, buildBoxSchema as qe, registerFlex as Ge, NovaUIKit as W } from "@nova-lab/ui-kit";
|
|
5
|
+
import { a as Ue, t as Ye, r as Ve, G as je } from "./GeometryIndex-DDQ34Jf4.js";
|
|
6
|
+
import { parseNovaColor as Xe, reconcileNovaTemplateChildren as Ke } from "@nova-lab/core";
|
|
7
|
+
import { a as V, b as j, z as Q, A as ee, C as te, D as ie, N as Ze, E as Pe, c as Ae } from "./host-DLDeDU5k.js";
|
|
8
|
+
import { r as O, a as ze } from "./chart-runtime-resolver-DwwXp3X8.js";
|
|
9
|
+
import { r as Z, s as B } from "./state-C5pICb11.js";
|
|
10
|
+
function De(n) {
|
|
11
|
+
var y, C, T, P, S, z;
|
|
12
|
+
const c = { count: n.length, x: [], y: [], width: [], height: [], colors: [] }, e = c.x, i = c.y, l = c.width, o = c.height, h = c.colors;
|
|
13
|
+
for (const m of n) {
|
|
14
|
+
if (m.type !== "line" || m.clip || m.active === !1 || (C = (y = m.styles) == null ? void 0 : y.dashPattern) != null && C.length || ((T = m.styles) == null ? void 0 : T.widthUnits) === "screen" || m.x1 !== m.x2 && m.y1 !== m.y2)
|
|
15
|
+
return null;
|
|
16
|
+
const E = ((P = m.styles) == null ? void 0 : P.color) ?? "#000";
|
|
17
|
+
if (!/^(?:#(?:[\da-f]{3,4}|[\da-f]{6}|[\da-f]{8})$|rgba?\(|(?:black|white|red|green|blue|transparent)$)/i.test(E))
|
|
18
|
+
return null;
|
|
19
|
+
const _ = Xe(E), I = ((S = m.styles) == null ? void 0 : S.width) || 1, w = ((z = m.styles) == null ? void 0 : z.opacity) ?? 1;
|
|
20
|
+
if (I < 0 || w < 0 || w > 1 || ![m.x1, m.x2, m.y1, m.y2, I, w].every(Number.isFinite))
|
|
21
|
+
return null;
|
|
22
|
+
const A = m.x1 === m.x2;
|
|
23
|
+
e.push(Math.min(m.x1, m.x2) - (A ? I / 2 : 0)), i.push(Math.min(m.y1, m.y2) - (A ? 0 : I / 2)), l.push(A ? I : Math.abs(m.x2 - m.x1)), o.push(A ? Math.abs(m.y2 - m.y1) : I), h.push(_.r, _.g, _.b, _.a * w);
|
|
24
|
+
}
|
|
25
|
+
return c;
|
|
26
|
+
}
|
|
27
|
+
const Je = "NovaCharts.Axis";
|
|
28
|
+
function Fe(n) {
|
|
29
|
+
const c = {
|
|
30
|
+
type: Je,
|
|
31
|
+
name: "NovaCharts.Axis",
|
|
32
|
+
title: "NovaCharts.Axis",
|
|
33
|
+
version: "0.2.0",
|
|
34
|
+
kind: "node-component",
|
|
35
|
+
dirtyPolicy: j,
|
|
36
|
+
fields: {
|
|
37
|
+
...V,
|
|
38
|
+
chartRef: { type: "string" },
|
|
39
|
+
scaleId: { type: "string" },
|
|
40
|
+
orientation: { type: "string" },
|
|
41
|
+
tickSide: { type: "string" },
|
|
42
|
+
labelSide: { type: "string" },
|
|
43
|
+
labelRotation: { type: "string" },
|
|
44
|
+
tickSize: { type: "number" },
|
|
45
|
+
labelPadding: { type: "number" },
|
|
46
|
+
ticks: { type: "record" },
|
|
47
|
+
lineColor: { type: "string" },
|
|
48
|
+
tickColor: { type: "string" },
|
|
49
|
+
labelColor: { type: "string" }
|
|
50
|
+
},
|
|
51
|
+
normalize: (e) => Q(e.props),
|
|
52
|
+
measureBounds: (e, i) => U(i, Q)
|
|
53
|
+
};
|
|
54
|
+
return n && (c.createNode = n), c;
|
|
55
|
+
}
|
|
56
|
+
const Qe = Fe();
|
|
57
|
+
class et extends Y {
|
|
58
|
+
/**
|
|
59
|
+
* Создает экземпляр ChartAxis и подготавливает базовое состояние.
|
|
60
|
+
*/
|
|
61
|
+
constructor(e, i, l, o = {}, h = Qe) {
|
|
62
|
+
super(e, i, h, l, { componentId: o.componentId });
|
|
63
|
+
$(this, "_api");
|
|
64
|
+
this.options({ zIndex: 20 }), this.configureRenderPolicy({ group: "always", updateMode: "static" }), this._api = {
|
|
65
|
+
refresh: () => this.runtime.batch(() => {
|
|
66
|
+
this.invalidate({ update: !0, render: !0 });
|
|
67
|
+
}),
|
|
68
|
+
getTickCount: () => this._readTicks().length
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
/** Входы оси изменяются только через props и явную инвалидацию её шкалы. */
|
|
72
|
+
getRenderRetentionKey() {
|
|
73
|
+
return 0;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Обновляет значение состояния ChartAxis.
|
|
77
|
+
*/
|
|
78
|
+
setProps(e) {
|
|
79
|
+
return super.setProps(e);
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Возвращает значение состояния ChartAxis.
|
|
83
|
+
*/
|
|
84
|
+
getApi() {
|
|
85
|
+
return this._api;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Выполняет отрисовку ChartAxis.
|
|
89
|
+
*/
|
|
90
|
+
render() {
|
|
91
|
+
const e = this.props.orientation === "horizontal" ? this.width : this.height, i = this._readTicks().filter((S) => S.position >= 0 && S.position <= e), l = O(this, this.props.chartRef), o = this._resolvePartStyle("axisTick", {
|
|
92
|
+
color: this.props.lineColor,
|
|
93
|
+
stroke: this.props.lineColor,
|
|
94
|
+
width: 1,
|
|
95
|
+
strokeWidth: 1
|
|
96
|
+
}, l), h = this._resolvePartStyle("axisTick", {
|
|
97
|
+
color: this.props.tickColor,
|
|
98
|
+
stroke: this.props.tickColor,
|
|
99
|
+
width: 1,
|
|
100
|
+
strokeWidth: 1
|
|
101
|
+
}, l), y = this._resolvePartStyle("axisLabel", {
|
|
102
|
+
color: this.props.labelColor,
|
|
103
|
+
fontFamily: this.props.fontFamily,
|
|
104
|
+
fontSize: this.props.fontSize,
|
|
105
|
+
fontWeight: String(this.props.fontWeight ?? "500")
|
|
106
|
+
}, l), C = [], T = [], P = Math.max(14, Math.ceil((y.fontSize ?? 11) * 1.3), y.lineHeight ?? 0);
|
|
107
|
+
if (this.props.orientation === "horizontal") {
|
|
108
|
+
const S = this.props.tickSide === "start" ? this.height - 1 : 0.5, z = this.props.tickSide === "start" ? -1 : 1, m = this._resolveHorizontalLabelRotation(i), E = this.props.labelSide === "start" ? Math.max(0, S - this.props.tickSize - this.props.labelPadding - P) : S + this.props.tickSize + this.props.labelPadding;
|
|
109
|
+
C.push({
|
|
110
|
+
type: "line",
|
|
111
|
+
x1: 0,
|
|
112
|
+
y1: S,
|
|
113
|
+
x2: this.width,
|
|
114
|
+
y2: S,
|
|
115
|
+
styles: { color: o.color ?? o.stroke ?? this.props.lineColor, width: o.width ?? o.strokeWidth ?? 1, opacity: o.opacity }
|
|
116
|
+
});
|
|
117
|
+
for (const _ of i) {
|
|
118
|
+
const I = _.position;
|
|
119
|
+
if (C.push({
|
|
120
|
+
type: "line",
|
|
121
|
+
x1: I,
|
|
122
|
+
y1: S,
|
|
123
|
+
x2: I,
|
|
124
|
+
y2: S + this.props.tickSize * z,
|
|
125
|
+
styles: { color: h.color ?? h.stroke ?? this.props.tickColor, width: h.width ?? h.strokeWidth ?? 1, opacity: h.opacity }
|
|
126
|
+
}), m === 0) {
|
|
127
|
+
const w = Math.min(80, this.width), A = Math.max(0, Math.min(this.width - w, I - w / 2)), L = I < w / 2 ? "left" : I > this.width - w / 2 ? "right" : "center";
|
|
128
|
+
T.push(J(_.label, A, E, w, P, y.color ?? this.props.labelColor, L, y));
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
if (C.length > 0 && this._renderLines(C), m !== 0)
|
|
132
|
+
for (const _ of i)
|
|
133
|
+
this._renderRotatedLabel(_.label, _.position, E, m, P, y);
|
|
134
|
+
else
|
|
135
|
+
for (const _ of T)
|
|
136
|
+
this.renderer.text(_);
|
|
137
|
+
this._publishSemantics(l, i.length);
|
|
138
|
+
return;
|
|
139
|
+
} else {
|
|
140
|
+
const S = this.props.tickSide === "start" ? this.width - 0.5 : 0.5, z = this.props.tickSide === "start" ? -1 : 1, m = this.props.labelSide === "start" ? 0 : S + this.props.tickSize + this.props.labelPadding, E = this.props.labelSide === "start" ? Math.max(1, S - this.props.tickSize - this.props.labelPadding) : Math.max(1, this.width - m);
|
|
141
|
+
C.push({
|
|
142
|
+
type: "line",
|
|
143
|
+
x1: S,
|
|
144
|
+
y1: 0,
|
|
145
|
+
x2: S,
|
|
146
|
+
y2: this.height,
|
|
147
|
+
styles: { color: o.color ?? o.stroke ?? this.props.lineColor, width: o.width ?? o.strokeWidth ?? 1, opacity: o.opacity }
|
|
148
|
+
});
|
|
149
|
+
for (const _ of i) {
|
|
150
|
+
const I = _.position, w = {
|
|
151
|
+
x: this.props.labelSide === "start" ? m + 2 : m,
|
|
152
|
+
width: Math.max(1, E - 2)
|
|
153
|
+
};
|
|
154
|
+
C.push({
|
|
155
|
+
type: "line",
|
|
156
|
+
x1: S,
|
|
157
|
+
y1: I,
|
|
158
|
+
x2: S + this.props.tickSize * z,
|
|
159
|
+
y2: I,
|
|
160
|
+
styles: { color: h.color ?? h.stroke ?? this.props.tickColor, width: h.width ?? h.strokeWidth ?? 1, opacity: h.opacity }
|
|
161
|
+
});
|
|
162
|
+
const A = J(
|
|
163
|
+
_.label,
|
|
164
|
+
w.x,
|
|
165
|
+
Math.max(0, Math.min(this.height - P, I - P / 2)),
|
|
166
|
+
w.width,
|
|
167
|
+
P,
|
|
168
|
+
y.color ?? this.props.labelColor,
|
|
169
|
+
this.props.labelSide === "start" ? "right" : "left",
|
|
170
|
+
y
|
|
171
|
+
);
|
|
172
|
+
T.push(A);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
C.length > 0 && this._renderLines(C);
|
|
176
|
+
for (const S of T)
|
|
177
|
+
this.renderer.text(S);
|
|
178
|
+
this._publishSemantics(l, i.length);
|
|
179
|
+
}
|
|
180
|
+
_renderLines(e) {
|
|
181
|
+
const i = De(e);
|
|
182
|
+
i ? this.renderer.rects(i) : this.renderSchema(e);
|
|
183
|
+
}
|
|
184
|
+
onUnmount() {
|
|
185
|
+
const e = O(this, this.props.chartRef);
|
|
186
|
+
e == null || e.clearSemanticRegions(`${this.componentId}:axis`), super.onUnmount();
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Обрабатывает входящее событие ChartAxis.
|
|
190
|
+
*/
|
|
191
|
+
onPropsChanged(e) {
|
|
192
|
+
this.applyCommonPropsChanged(e);
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* Выполняет внутренний шаг readTicks для ChartAxis.
|
|
196
|
+
*/
|
|
197
|
+
_readTicks() {
|
|
198
|
+
const e = O(this, this.props.chartRef), i = e == null ? void 0 : e.getScale(this.props.scaleId);
|
|
199
|
+
return i && this._ensureRenderableScaleRange(i), (i == null ? void 0 : i.ticks(this.props.ticks)) ?? [];
|
|
200
|
+
}
|
|
201
|
+
_publishSemantics(e, i) {
|
|
202
|
+
e == null || e.publishSemanticRegions(`${this.componentId}:axis`, [{
|
|
203
|
+
id: `${e.id}:${this.componentId}:axis`,
|
|
204
|
+
role: "axis",
|
|
205
|
+
label: `${this.props.orientation} axis ${this.props.scaleId}`,
|
|
206
|
+
bounds: this.getWorldBounds(),
|
|
207
|
+
focusable: !1,
|
|
208
|
+
order: 30,
|
|
209
|
+
data: {
|
|
210
|
+
scaleId: this.props.scaleId,
|
|
211
|
+
orientation: this.props.orientation,
|
|
212
|
+
tickCount: i
|
|
213
|
+
},
|
|
214
|
+
source: {
|
|
215
|
+
type: "synthetic",
|
|
216
|
+
componentId: this.componentId,
|
|
217
|
+
part: "axis"
|
|
218
|
+
}
|
|
219
|
+
}]);
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* Выполняет внутренний шаг ensureRenderableScaleRange для ChartAxis.
|
|
223
|
+
*/
|
|
224
|
+
_ensureRenderableScaleRange(e) {
|
|
225
|
+
const i = e.getRange();
|
|
226
|
+
if (!(i[0] !== 0 || i[1] !== 1)) {
|
|
227
|
+
if (this.props.orientation === "horizontal" && this.width > 1) {
|
|
228
|
+
e.setRange([0, this.width]);
|
|
229
|
+
return;
|
|
230
|
+
}
|
|
231
|
+
this.props.orientation === "vertical" && this.height > 1 && e.setRange([this.height, 0]);
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* Нормализует и возвращает итоговое значение ChartAxis.
|
|
236
|
+
*/
|
|
237
|
+
_resolveHorizontalLabelRotation(e) {
|
|
238
|
+
if (this.props.labelRotation !== "auto")
|
|
239
|
+
return tt(this.props.labelRotation);
|
|
240
|
+
if (e.length <= 1)
|
|
241
|
+
return 0;
|
|
242
|
+
const i = e[0], l = e[e.length - 1], h = Math.max(1, Math.abs(l.position - i.position)) / Math.max(1, e.length - 1), y = e.reduce((C, T) => Math.max(C, T.label.length * 6.6), 0);
|
|
243
|
+
return h >= y + 10 ? 0 : h >= y * 0.68 ? Math.PI / 6 : h >= y * 0.42 ? Math.PI / 4 : Math.PI / 2;
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* Выполняет отрисовку ChartAxis.
|
|
247
|
+
*/
|
|
248
|
+
_renderRotatedLabel(e, i, l, o, h, y) {
|
|
249
|
+
const C = Math.min(86, this.width), T = Math.cos(o), P = Math.sin(o), S = [[0, -h / 2], [C, -h / 2], [0, h / 2], [C, h / 2]].map(([w, A]) => [w * T - A * P, w * P + A * T]), z = Math.min(...S.map((w) => w[0])), m = Math.max(...S.map((w) => w[0])), E = Math.min(...S.map((w) => w[1])), _ = Math.max(...S.map((w) => w[1])), I = Ue(this.matrix);
|
|
250
|
+
Ye(I, I, [Math.max(-z, Math.min(this.width - m, i)), Math.max(-E, Math.min(this.height - _, l))]), Ve(I, I, o), this.renderer.save(), this.renderer.setTransform(I), this.renderer.text(J(e, 0, -h / 2, C, h, y.color ?? this.props.labelColor, "left", y)), this.renderer.restore();
|
|
251
|
+
}
|
|
252
|
+
_resolvePartStyle(e, i, l) {
|
|
253
|
+
return (l == null ? void 0 : l.customization.resolveMarkStyle({
|
|
254
|
+
componentId: this.componentId,
|
|
255
|
+
componentName: "Axis",
|
|
256
|
+
part: e,
|
|
257
|
+
seriesKind: "custom",
|
|
258
|
+
state: "normal",
|
|
259
|
+
tokens: l.customization.tokens,
|
|
260
|
+
className: this.props.className,
|
|
261
|
+
attrs: this.props.attrs
|
|
262
|
+
}, { legacy: i })) ?? i;
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
function tt(n) {
|
|
266
|
+
return !Number.isFinite(n) || n === 0 ? 0 : n * Math.PI / 180;
|
|
267
|
+
}
|
|
268
|
+
function J(n, c, e, i, l, o, h, y = {}) {
|
|
269
|
+
return {
|
|
270
|
+
type: "text",
|
|
271
|
+
text: n,
|
|
272
|
+
x: c,
|
|
273
|
+
y: e,
|
|
274
|
+
width: i,
|
|
275
|
+
height: l,
|
|
276
|
+
styles: {
|
|
277
|
+
color: o,
|
|
278
|
+
font: {
|
|
279
|
+
family: y.fontFamily ?? "Inter, Arial, sans-serif",
|
|
280
|
+
size: y.fontSize ?? 11,
|
|
281
|
+
weight: String(y.fontWeight ?? "500")
|
|
282
|
+
},
|
|
283
|
+
lineHeight: y.lineHeight ?? l,
|
|
284
|
+
opacity: y.opacity,
|
|
285
|
+
align: {
|
|
286
|
+
horizontal: h,
|
|
287
|
+
vertical: "middle"
|
|
288
|
+
},
|
|
289
|
+
ellipsis: !0
|
|
290
|
+
},
|
|
291
|
+
meta: {
|
|
292
|
+
textRole: "ui-label",
|
|
293
|
+
textMode: "run-atlas",
|
|
294
|
+
textLod: "always"
|
|
295
|
+
}
|
|
296
|
+
};
|
|
297
|
+
}
|
|
298
|
+
const q = Fe((n, c) => new et(
|
|
299
|
+
n.app,
|
|
300
|
+
n.surface,
|
|
301
|
+
Q(c.props),
|
|
302
|
+
{ componentId: c.id },
|
|
303
|
+
q
|
|
304
|
+
)), it = "NovaCharts.Grid";
|
|
305
|
+
function $e(n) {
|
|
306
|
+
const c = {
|
|
307
|
+
type: it,
|
|
308
|
+
name: "NovaCharts.Grid",
|
|
309
|
+
title: "NovaCharts.Grid",
|
|
310
|
+
version: "0.2.0",
|
|
311
|
+
kind: "node-component",
|
|
312
|
+
dirtyPolicy: j,
|
|
313
|
+
fields: {
|
|
314
|
+
...V,
|
|
315
|
+
chartRef: { type: "string" },
|
|
316
|
+
xScaleId: { type: "string" },
|
|
317
|
+
yScaleId: { type: "string" },
|
|
318
|
+
xTicks: { type: "record" },
|
|
319
|
+
yTicks: { type: "record" },
|
|
320
|
+
lineColor: { type: "string" }
|
|
321
|
+
},
|
|
322
|
+
normalize: (e) => ee(e.props),
|
|
323
|
+
measureBounds: (e, i) => U(i, ee)
|
|
324
|
+
};
|
|
325
|
+
return n && (c.createNode = n), c;
|
|
326
|
+
}
|
|
327
|
+
const st = $e();
|
|
328
|
+
class ot extends Y {
|
|
329
|
+
/**
|
|
330
|
+
* Создает экземпляр ChartGrid и подготавливает базовое состояние.
|
|
331
|
+
*/
|
|
332
|
+
constructor(e, i, l, o = {}, h = st) {
|
|
333
|
+
super(e, i, h, l, { componentId: o.componentId });
|
|
334
|
+
$(this, "_lineCount", 0);
|
|
335
|
+
$(this, "_api");
|
|
336
|
+
this.options({ zIndex: 0 }), this._api = {
|
|
337
|
+
refresh: () => this.runtime.batch(() => {
|
|
338
|
+
this.invalidate({ update: !0, render: !0 });
|
|
339
|
+
}),
|
|
340
|
+
getLineCount: () => this._lineCount
|
|
341
|
+
};
|
|
342
|
+
}
|
|
343
|
+
/**
|
|
344
|
+
* Обновляет значение состояния ChartGrid.
|
|
345
|
+
*/
|
|
346
|
+
setProps(e) {
|
|
347
|
+
return super.setProps(e);
|
|
348
|
+
}
|
|
349
|
+
/**
|
|
350
|
+
* Возвращает значение состояния ChartGrid.
|
|
351
|
+
*/
|
|
352
|
+
getApi() {
|
|
353
|
+
return this._api;
|
|
354
|
+
}
|
|
355
|
+
/**
|
|
356
|
+
* Выполняет отрисовку ChartGrid.
|
|
357
|
+
*/
|
|
358
|
+
render() {
|
|
359
|
+
const e = O(this, this.props.chartRef);
|
|
360
|
+
if (!e)
|
|
361
|
+
return;
|
|
362
|
+
const i = [], l = e.customization.resolveMarkStyle({
|
|
363
|
+
componentId: this.componentId,
|
|
364
|
+
componentName: "Grid",
|
|
365
|
+
part: "gridLine",
|
|
366
|
+
seriesKind: "custom",
|
|
367
|
+
state: "normal",
|
|
368
|
+
tokens: e.customization.tokens,
|
|
369
|
+
className: this.props.className,
|
|
370
|
+
attrs: this.props.attrs
|
|
371
|
+
}, {
|
|
372
|
+
legacy: {
|
|
373
|
+
color: this.props.lineColor,
|
|
374
|
+
stroke: this.props.lineColor,
|
|
375
|
+
width: 1,
|
|
376
|
+
strokeWidth: 1
|
|
377
|
+
},
|
|
378
|
+
part: void 0
|
|
379
|
+
});
|
|
380
|
+
if (this.props.xScaleId) {
|
|
381
|
+
const o = e.getScale(this.props.xScaleId);
|
|
382
|
+
for (const h of (o == null ? void 0 : o.ticks(this.props.xTicks)) ?? [])
|
|
383
|
+
i.push({
|
|
384
|
+
type: "line",
|
|
385
|
+
x1: h.position,
|
|
386
|
+
y1: 0,
|
|
387
|
+
x2: h.position,
|
|
388
|
+
y2: this.height,
|
|
389
|
+
styles: { color: l.color ?? l.stroke ?? this.props.lineColor, width: l.width ?? l.strokeWidth ?? 1, opacity: l.opacity }
|
|
390
|
+
});
|
|
391
|
+
}
|
|
392
|
+
if (this.props.yScaleId) {
|
|
393
|
+
const o = e.getScale(this.props.yScaleId);
|
|
394
|
+
for (const h of (o == null ? void 0 : o.ticks(this.props.yTicks)) ?? [])
|
|
395
|
+
i.push({
|
|
396
|
+
type: "line",
|
|
397
|
+
x1: 0,
|
|
398
|
+
y1: h.position,
|
|
399
|
+
x2: this.width,
|
|
400
|
+
y2: h.position,
|
|
401
|
+
styles: { color: l.color ?? l.stroke ?? this.props.lineColor, width: l.width ?? l.strokeWidth ?? 1, opacity: l.opacity }
|
|
402
|
+
});
|
|
403
|
+
}
|
|
404
|
+
if (this._lineCount = i.length, i.length > 0) {
|
|
405
|
+
const o = De(i);
|
|
406
|
+
o ? this.renderer.rects(o) : this.renderer.schema(i);
|
|
407
|
+
}
|
|
408
|
+
e.publishSemanticRegions(`${this.componentId}:grid`, [{
|
|
409
|
+
id: `${e.id}:${this.componentId}:grid`,
|
|
410
|
+
role: "grid",
|
|
411
|
+
label: "Chart grid",
|
|
412
|
+
bounds: this.getWorldBounds(),
|
|
413
|
+
focusable: !1,
|
|
414
|
+
order: 40,
|
|
415
|
+
data: {
|
|
416
|
+
xScaleId: this.props.xScaleId,
|
|
417
|
+
yScaleId: this.props.yScaleId,
|
|
418
|
+
lineCount: this._lineCount
|
|
419
|
+
},
|
|
420
|
+
source: {
|
|
421
|
+
type: "synthetic",
|
|
422
|
+
componentId: this.componentId,
|
|
423
|
+
part: "grid"
|
|
424
|
+
}
|
|
425
|
+
}]);
|
|
426
|
+
}
|
|
427
|
+
onUnmount() {
|
|
428
|
+
const e = O(this, this.props.chartRef);
|
|
429
|
+
e == null || e.clearSemanticRegions(`${this.componentId}:grid`), super.onUnmount();
|
|
430
|
+
}
|
|
431
|
+
/**
|
|
432
|
+
* Обрабатывает входящее событие ChartGrid.
|
|
433
|
+
*/
|
|
434
|
+
onPropsChanged(e) {
|
|
435
|
+
this.applyCommonPropsChanged(e);
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
const se = $e((n, c) => new ot(
|
|
439
|
+
n.app,
|
|
440
|
+
n.surface,
|
|
441
|
+
ee(c.props),
|
|
442
|
+
{ componentId: c.id },
|
|
443
|
+
se
|
|
444
|
+
)), nt = "NovaCharts.Plot";
|
|
445
|
+
function Oe(n) {
|
|
446
|
+
const c = {
|
|
447
|
+
type: nt,
|
|
448
|
+
name: "NovaCharts.Plot",
|
|
449
|
+
title: "NovaCharts.Plot",
|
|
450
|
+
version: "0.2.0",
|
|
451
|
+
kind: "node-component",
|
|
452
|
+
dirtyPolicy: j,
|
|
453
|
+
fields: {
|
|
454
|
+
...V,
|
|
455
|
+
chartRef: { type: "string" },
|
|
456
|
+
xScaleId: { type: "string" },
|
|
457
|
+
yScaleId: { type: "string" },
|
|
458
|
+
xScaleIds: { type: "array" },
|
|
459
|
+
yScaleIds: { type: "array" }
|
|
460
|
+
},
|
|
461
|
+
normalize: (e) => te(e.props),
|
|
462
|
+
measureBounds: (e, i) => U(i, te)
|
|
463
|
+
};
|
|
464
|
+
return n && (c.createNode = n), c;
|
|
465
|
+
}
|
|
466
|
+
const rt = Oe();
|
|
467
|
+
class at extends Y {
|
|
468
|
+
/**
|
|
469
|
+
* Создает экземпляр ChartPlot и подготавливает базовое состояние.
|
|
470
|
+
*/
|
|
471
|
+
constructor(e, i, l, o = {}, h = rt) {
|
|
472
|
+
super(e, i, h, l, { componentId: o.componentId });
|
|
473
|
+
$(this, "_managedChildren", []);
|
|
474
|
+
$(this, "_api");
|
|
475
|
+
this._api = {
|
|
476
|
+
refresh: () => this._refresh(),
|
|
477
|
+
setChildren: (y) => this.setChildren(y),
|
|
478
|
+
getRect: () => ({ x: this.x, y: this.y, width: this.width, height: this.height })
|
|
479
|
+
}, this.setChildren(o.children ?? []);
|
|
480
|
+
}
|
|
481
|
+
/**
|
|
482
|
+
* Обновляет значение состояния ChartPlot.
|
|
483
|
+
*/
|
|
484
|
+
setProps(e) {
|
|
485
|
+
return super.setProps(e);
|
|
486
|
+
}
|
|
487
|
+
/**
|
|
488
|
+
* Возвращает значение состояния ChartPlot.
|
|
489
|
+
*/
|
|
490
|
+
getApi() {
|
|
491
|
+
return this._api;
|
|
492
|
+
}
|
|
493
|
+
/**
|
|
494
|
+
* Применяет подготовленное состояние ChartPlot.
|
|
495
|
+
*/
|
|
496
|
+
applyLayoutRect(e) {
|
|
497
|
+
const i = super.applyLayoutRect(e);
|
|
498
|
+
return i && this._refresh(), i;
|
|
499
|
+
}
|
|
500
|
+
/**
|
|
501
|
+
* Обновляет runtime-состояние ChartPlot.
|
|
502
|
+
*/
|
|
503
|
+
update() {
|
|
504
|
+
this._updateScaleRanges(), this._applyChildrenRect();
|
|
505
|
+
}
|
|
506
|
+
/**
|
|
507
|
+
* Выполняет отрисовку ChartPlot.
|
|
508
|
+
*/
|
|
509
|
+
render() {
|
|
510
|
+
const e = qe(this.props, this.width, this.height);
|
|
511
|
+
e.length > 0 && this.renderSchema(e);
|
|
512
|
+
}
|
|
513
|
+
/**
|
|
514
|
+
* Обновляет значение состояния ChartPlot.
|
|
515
|
+
*/
|
|
516
|
+
setChildren(e) {
|
|
517
|
+
const i = O(this, this.props.chartRef), l = Ke(this, this._managedChildren, e, i == null ? void 0 : i.refScope);
|
|
518
|
+
this._managedChildren.length = 0, this._managedChildren.push(...l.nodes), this._applyChildrenRect(), this._refresh();
|
|
519
|
+
}
|
|
520
|
+
/**
|
|
521
|
+
* Обрабатывает входящее событие ChartPlot.
|
|
522
|
+
*/
|
|
523
|
+
onPropsChanged(e) {
|
|
524
|
+
this.applyCommonPropsChanged(e), this._refresh();
|
|
525
|
+
}
|
|
526
|
+
/**
|
|
527
|
+
* Выполняет отрисовку ChartPlot.
|
|
528
|
+
*/
|
|
529
|
+
renderChildren() {
|
|
530
|
+
const e = O(this, this.props.chartRef);
|
|
531
|
+
if (!this.props.clip) {
|
|
532
|
+
this._renderPluginLayer("underlay", e), super.renderChildren(), this._renderPluginLayer("overlay", e);
|
|
533
|
+
return;
|
|
534
|
+
}
|
|
535
|
+
this.renderer.clip(0, 0, this.width, this.height);
|
|
536
|
+
try {
|
|
537
|
+
this._renderPluginLayer("underlay", e), super.renderChildren(), this._renderPluginLayer("overlay", e);
|
|
538
|
+
} finally {
|
|
539
|
+
this.renderer.clearClip();
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
/**
|
|
543
|
+
* Синхронизирует актуальное состояние ChartPlot.
|
|
544
|
+
*/
|
|
545
|
+
_refresh() {
|
|
546
|
+
this._updateScaleRanges(), this._applyChildrenRect(), this.runtime.batch(() => {
|
|
547
|
+
this.invalidate({ update: !0, render: !0 });
|
|
548
|
+
});
|
|
549
|
+
for (const e of this._managedChildren)
|
|
550
|
+
e.runtime.batch(() => {
|
|
551
|
+
e.invalidate({ update: !0, render: !0 });
|
|
552
|
+
});
|
|
553
|
+
}
|
|
554
|
+
/**
|
|
555
|
+
* Обновляет runtime-состояние ChartPlot.
|
|
556
|
+
*/
|
|
557
|
+
_updateScaleRanges() {
|
|
558
|
+
const e = O(this, this.props.chartRef);
|
|
559
|
+
if (e) {
|
|
560
|
+
for (const i of /* @__PURE__ */ new Set([this.props.xScaleId, ...this.props.xScaleIds ?? []]))
|
|
561
|
+
i && Te(e, i, [0, this.width]);
|
|
562
|
+
for (const i of /* @__PURE__ */ new Set([this.props.yScaleId, ...this.props.yScaleIds ?? []])) {
|
|
563
|
+
if (!i)
|
|
564
|
+
continue;
|
|
565
|
+
const l = e.getScale(i);
|
|
566
|
+
Te(e, i, (l == null ? void 0 : l.type) === "band" ? [0, this.height] : [this.height, 0]);
|
|
567
|
+
}
|
|
568
|
+
}
|
|
569
|
+
}
|
|
570
|
+
/**
|
|
571
|
+
* Применяет подготовленное состояние ChartPlot.
|
|
572
|
+
*/
|
|
573
|
+
_applyChildrenRect() {
|
|
574
|
+
const e = { x: 0, y: 0, width: this.width, height: this.height };
|
|
575
|
+
for (const i of this._managedChildren)
|
|
576
|
+
typeof i.applyLayoutRect == "function" && i.applyLayoutRect(e);
|
|
577
|
+
}
|
|
578
|
+
_renderPluginLayer(e, i) {
|
|
579
|
+
if (!i)
|
|
580
|
+
return;
|
|
581
|
+
const l = i.customization.renderPluginLayer(e, {
|
|
582
|
+
componentId: this.componentId,
|
|
583
|
+
componentName: "Plot",
|
|
584
|
+
width: this.width,
|
|
585
|
+
height: this.height,
|
|
586
|
+
runtime: {
|
|
587
|
+
id: i.id,
|
|
588
|
+
getData: () => i.dataStore.getData(),
|
|
589
|
+
getScale: (o) => i.getScale(o),
|
|
590
|
+
getSeriesMetadata: () => i.getSeriesMetadata(),
|
|
591
|
+
getInteractionState: () => i.getInteractionState()
|
|
592
|
+
},
|
|
593
|
+
tokens: i.customization.tokens
|
|
594
|
+
});
|
|
595
|
+
l.length > 0 && this.renderer.schema(l);
|
|
596
|
+
}
|
|
597
|
+
}
|
|
598
|
+
function Te(n, c, e) {
|
|
599
|
+
var l;
|
|
600
|
+
const i = (l = n.getScale(c)) == null ? void 0 : l.getRange();
|
|
601
|
+
i && (i[0] === e[0] && i[1] === e[1] || n.setScaleRange(c, e));
|
|
602
|
+
}
|
|
603
|
+
const oe = Oe((n, c) => new at(
|
|
604
|
+
n.app,
|
|
605
|
+
n.surface,
|
|
606
|
+
te(c.props),
|
|
607
|
+
{
|
|
608
|
+
componentId: c.id,
|
|
609
|
+
children: c.children ?? []
|
|
610
|
+
},
|
|
611
|
+
oe
|
|
612
|
+
)), lt = "NovaCharts.Scale";
|
|
613
|
+
function Le(n) {
|
|
614
|
+
const c = {
|
|
615
|
+
type: lt,
|
|
616
|
+
name: "NovaCharts.Scale",
|
|
617
|
+
title: "NovaCharts.Scale",
|
|
618
|
+
version: "0.2.0",
|
|
619
|
+
kind: "node-component",
|
|
620
|
+
dirtyPolicy: j,
|
|
621
|
+
fields: {
|
|
622
|
+
...V,
|
|
623
|
+
scaleId: { type: "string" },
|
|
624
|
+
scaleType: { type: "string" },
|
|
625
|
+
field: { type: "field" },
|
|
626
|
+
domain: { type: "array" },
|
|
627
|
+
zero: { type: "boolean" },
|
|
628
|
+
nice: { type: "boolean" },
|
|
629
|
+
clamp: { type: "boolean" },
|
|
630
|
+
paddingInner: { type: "number" },
|
|
631
|
+
paddingOuter: { type: "number" },
|
|
632
|
+
locale: { type: "string" },
|
|
633
|
+
timezone: { type: "string" }
|
|
634
|
+
},
|
|
635
|
+
normalize: (e) => ie(e.props),
|
|
636
|
+
measureBounds: (e, i) => U(i, ie)
|
|
637
|
+
};
|
|
638
|
+
return n && (c.createNode = n), c;
|
|
639
|
+
}
|
|
640
|
+
const ct = Le();
|
|
641
|
+
class ht extends Y {
|
|
642
|
+
/**
|
|
643
|
+
* Создает экземпляр ChartScaleNode и подготавливает базовое состояние.
|
|
644
|
+
*/
|
|
645
|
+
constructor(e, i, l, o = {}, h = ct) {
|
|
646
|
+
super(e, i, h, l, { componentId: o.componentId });
|
|
647
|
+
$(this, "_scale", null);
|
|
648
|
+
$(this, "_api");
|
|
649
|
+
$(this, "_mountedInRuntime", !1);
|
|
650
|
+
this._api = {
|
|
651
|
+
getScaleId: () => this._scaleId,
|
|
652
|
+
getScale: () => this._scale,
|
|
653
|
+
refresh: () => this._refresh()
|
|
654
|
+
};
|
|
655
|
+
}
|
|
656
|
+
/**
|
|
657
|
+
* Обновляет значение состояния ChartScaleNode.
|
|
658
|
+
*/
|
|
659
|
+
setProps(e) {
|
|
660
|
+
return super.setProps(e);
|
|
661
|
+
}
|
|
662
|
+
/**
|
|
663
|
+
* Возвращает значение состояния ChartScaleNode.
|
|
664
|
+
*/
|
|
665
|
+
getApi() {
|
|
666
|
+
return this._api;
|
|
667
|
+
}
|
|
668
|
+
/**
|
|
669
|
+
* Выполняет отрисовку ChartScaleNode.
|
|
670
|
+
*/
|
|
671
|
+
render() {
|
|
672
|
+
}
|
|
673
|
+
/**
|
|
674
|
+
* Обрабатывает входящее событие ChartScaleNode.
|
|
675
|
+
*/
|
|
676
|
+
onMount() {
|
|
677
|
+
super.onMount(), this._register();
|
|
678
|
+
}
|
|
679
|
+
/**
|
|
680
|
+
* Обрабатывает входящее событие ChartScaleNode.
|
|
681
|
+
*/
|
|
682
|
+
onUnmount() {
|
|
683
|
+
if (this._mountedInRuntime) {
|
|
684
|
+
const e = this.injectOptional(Ze);
|
|
685
|
+
e == null || e.unregisterScale(this._scaleId);
|
|
686
|
+
}
|
|
687
|
+
this._mountedInRuntime = !1, super.onUnmount();
|
|
688
|
+
}
|
|
689
|
+
/**
|
|
690
|
+
* Обрабатывает входящее событие ChartScaleNode.
|
|
691
|
+
*/
|
|
692
|
+
onPropsChanged(e) {
|
|
693
|
+
this.applyCommonPropsChanged(e), e.some((i) => i !== "x" && i !== "y" && i !== "width" && i !== "height") && this._refresh();
|
|
694
|
+
}
|
|
695
|
+
/**
|
|
696
|
+
* Возвращает scale Id для ChartScaleNode.
|
|
697
|
+
*/
|
|
698
|
+
get _scaleId() {
|
|
699
|
+
return this.props.scaleId ?? this.componentId;
|
|
700
|
+
}
|
|
701
|
+
/**
|
|
702
|
+
* Регистрирует сущность в runtime-слое ChartScaleNode.
|
|
703
|
+
*/
|
|
704
|
+
_register() {
|
|
705
|
+
const e = ze(this);
|
|
706
|
+
this._scale = Pe(this._scaleId, this.props, e.dataStore), e.registerScale({
|
|
707
|
+
id: this._scaleId,
|
|
708
|
+
props: this.props,
|
|
709
|
+
scale: this._scale
|
|
710
|
+
}), this._mountedInRuntime = !0;
|
|
711
|
+
}
|
|
712
|
+
/**
|
|
713
|
+
* Синхронизирует актуальное состояние ChartScaleNode.
|
|
714
|
+
*/
|
|
715
|
+
_refresh() {
|
|
716
|
+
const e = ze(this);
|
|
717
|
+
if (!this._scale) {
|
|
718
|
+
this._register();
|
|
719
|
+
return;
|
|
720
|
+
}
|
|
721
|
+
this._scale = Pe(this._scaleId, this.props, e.dataStore), e.registerScale({
|
|
722
|
+
id: this._scaleId,
|
|
723
|
+
props: this.props,
|
|
724
|
+
scale: this._scale
|
|
725
|
+
}), e.refreshScale(this._scaleId);
|
|
726
|
+
}
|
|
727
|
+
}
|
|
728
|
+
const ne = Le((n, c) => new ht(
|
|
729
|
+
n.app,
|
|
730
|
+
n.surface,
|
|
731
|
+
ie(c.props),
|
|
732
|
+
{ componentId: c.id },
|
|
733
|
+
ne
|
|
734
|
+
)), G = /* @__PURE__ */ new WeakMap();
|
|
735
|
+
function re(n, c) {
|
|
736
|
+
if (!c.id.trim())
|
|
737
|
+
throw new Error("[NovaCharts] Series id must be nonempty");
|
|
738
|
+
const e = { ...c, type: n.kind };
|
|
739
|
+
return G.set(e, n), e;
|
|
740
|
+
}
|
|
741
|
+
function bt(n) {
|
|
742
|
+
const c = (i) => {
|
|
743
|
+
const l = re(n, { ...i, id: i.seriesId ?? "main" }), o = i.scales ?? [
|
|
744
|
+
{ id: l.xScaleId ?? "x", axis: "x", type: n.kind === "heatmap" || n.kind === "bar" && l.orientation !== "horizontal" ? "band" : "linear", field: l.x, zero: n.kind === "bar" && l.orientation === "horizontal", nice: !1 },
|
|
745
|
+
{ id: l.yScaleId ?? "y", axis: "y", type: n.kind === "heatmap" || n.kind === "bar" && l.orientation === "horizontal" ? "band" : "linear", field: l.y, zero: n.kind === "bar" && l.orientation !== "horizontal" || n.kind === "area", nice: !1 }
|
|
746
|
+
];
|
|
747
|
+
return { ...i, series: [l], scales: o };
|
|
748
|
+
};
|
|
749
|
+
return {
|
|
750
|
+
series: (i) => re(n, i),
|
|
751
|
+
mount(i, l) {
|
|
752
|
+
return e().mount(i, l);
|
|
753
|
+
},
|
|
754
|
+
attach(i, l) {
|
|
755
|
+
return e().attach(i, l);
|
|
756
|
+
}
|
|
757
|
+
};
|
|
758
|
+
function e() {
|
|
759
|
+
return Ae({
|
|
760
|
+
rows: (i) => i.data,
|
|
761
|
+
key: (i) => i.key,
|
|
762
|
+
create(i, l) {
|
|
763
|
+
const o = He(i, c(l), n.kind);
|
|
764
|
+
return { ...o, configure: (h) => o.configure(c(h)), extend: (h, y) => o.extend(h, y) };
|
|
765
|
+
}
|
|
766
|
+
});
|
|
767
|
+
}
|
|
768
|
+
}
|
|
769
|
+
const St = {
|
|
770
|
+
mount(n, c) {
|
|
771
|
+
return Ee().mount(n, c);
|
|
772
|
+
},
|
|
773
|
+
attach(n, c) {
|
|
774
|
+
return Ee().attach(n, c);
|
|
775
|
+
}
|
|
776
|
+
};
|
|
777
|
+
function Ee(n = "composed") {
|
|
778
|
+
return Ae({
|
|
779
|
+
rows: (c) => c.data,
|
|
780
|
+
key: (c) => c.key,
|
|
781
|
+
create: (c, e) => He(c, e, n)
|
|
782
|
+
});
|
|
783
|
+
}
|
|
784
|
+
function He(n, c, e) {
|
|
785
|
+
const i = n.getNovaChartRuntime(), l = i.dataStore;
|
|
786
|
+
let o = c, h, y = null;
|
|
787
|
+
const C = /* @__PURE__ */ new Map(), T = `${n.componentId}:plot`;
|
|
788
|
+
Ge(n.nova.schema), n.nova.schema.register(ne, { override: !0 }), n.nova.schema.register(oe, { override: !0 }), n.nova.schema.register(q, { override: !0 }), n.nova.schema.register(se, { override: !0 });
|
|
789
|
+
const P = (r) => `${n.componentId}:series:${r}`, S = () => n.nova.components.get(T), z = () => {
|
|
790
|
+
const r = S();
|
|
791
|
+
if (!r)
|
|
792
|
+
return { x: 0, y: 0 };
|
|
793
|
+
const f = r.matrix, [u, p] = n.toLocal(f[6], f[7]);
|
|
794
|
+
return { x: u, y: p };
|
|
795
|
+
}, m = (r) => typeof o.key == "function" ? o.key(r) : r[o.key], E = (r, f) => typeof f == "function" ? f(r) : r[f], _ = (r) => {
|
|
796
|
+
const f = n.nova.components.api(P(r.id)), u = f == null ? void 0 : f.getLayoutPlan(), p = (u == null ? void 0 : u.items) ?? (u == null ? void 0 : u.points) ?? (u == null ? void 0 : u.marks) ?? [], x = C.get(r.id);
|
|
797
|
+
if ((x == null ? void 0 : x.marks) === p)
|
|
798
|
+
return x;
|
|
799
|
+
const b = z(), t = p.map((a) => ({
|
|
800
|
+
ref: a.row ? { type: "datum", seriesId: r.id, key: m(a.row) } : { type: "bucket", seriesId: r.id, key: a.key },
|
|
801
|
+
row: a.row,
|
|
802
|
+
label: a.label ?? a.category ?? String(a.row ? E(a.row, r.x) : a.key),
|
|
803
|
+
value: a.value ?? a.yValue,
|
|
804
|
+
point: { x: b.x + a.x + (a.width ?? 0) / 2, y: b.y + a.y + (a.height ?? 0) / 2 },
|
|
805
|
+
bounds: { x: b.x + a.x - (a.radius ?? 0), y: b.y + a.y - (a.radius ?? 0), width: a.width ?? (a.radius ?? 1) * 2, height: a.height ?? (a.radius ?? 1) * 2 },
|
|
806
|
+
members: a.members
|
|
807
|
+
})), d = { marks: p, items: t, byRef: new Map(t.map((a) => [Z(a.ref), a])), index: new je(t, (a) => a.bounds) };
|
|
808
|
+
return C.set(r.id, d), d;
|
|
809
|
+
};
|
|
810
|
+
function I() {
|
|
811
|
+
var v, M, N, k;
|
|
812
|
+
const r = o.scales.find((s) => s.axis === "x"), f = o.scales.find((s) => s.axis === "y");
|
|
813
|
+
if (!r || !f)
|
|
814
|
+
throw new Error("[NovaCharts] Cartesian charts require x and y scales");
|
|
815
|
+
const u = o.axes === !1 ? [] : o.scales.filter((s) => s.axis === "y" && s.visible !== !1), p = o.axes === !1 ? [] : o.scales.filter((s) => s.axis === "x" && s.visible !== !1), x = o.palette ?? ["#2674b8", "#e68a42", "#69a84f", "#8f6fc0", "#bd5276"], b = o.theme === "dark" ? "#c6d0dc" : "#475569", t = o.series.filter((s) => (y == null ? void 0 : y.visibility[s.id]) ?? s.visible !== !1).map((s, F) => {
|
|
816
|
+
var ae, le, ce, he, de, pe, fe, ue, ye, ge, me, xe, be, Se, we, Ce, Ie, ve, _e, Re, ke, Me;
|
|
817
|
+
const D = G.get(s);
|
|
818
|
+
if (!D)
|
|
819
|
+
throw new Error(`[NovaCharts] Create ${s.type} series with its chart factory.series()`);
|
|
820
|
+
return D.register(n.nova.schema), { type: D.schemaType, id: P(s.id), props: {
|
|
821
|
+
...s,
|
|
822
|
+
...((ae = D.props) == null ? void 0 : ae.call(D, s)) ?? {},
|
|
823
|
+
styleSheet: s.styleSheet ?? o.styleSheet,
|
|
824
|
+
opacity: ((ce = (le = s.styles) == null ? void 0 : le.normal) == null ? void 0 : ce.opacity) ?? ((de = (he = o.styles) == null ? void 0 : he.normal) == null ? void 0 : de.opacity) ?? s.opacity,
|
|
825
|
+
strokeWidth: ((fe = (pe = s.styles) == null ? void 0 : pe.normal) == null ? void 0 : fe.strokeWidth) ?? ((ye = (ue = o.styles) == null ? void 0 : ue.normal) == null ? void 0 : ye.strokeWidth) ?? s.strokeWidth,
|
|
826
|
+
xScaleId: s.xScaleId ?? r.id,
|
|
827
|
+
yScaleId: s.yScaleId ?? f.id,
|
|
828
|
+
xField: s.x,
|
|
829
|
+
yField: s.y,
|
|
830
|
+
categoryField: s.orientation === "horizontal" ? s.y : s.x,
|
|
831
|
+
valueField: s.value ?? (s.orientation === "horizontal" ? s.x : s.y),
|
|
832
|
+
seriesField: s.series,
|
|
833
|
+
labelField: s.label,
|
|
834
|
+
sizeField: s.size,
|
|
835
|
+
openField: s.open,
|
|
836
|
+
highField: s.high,
|
|
837
|
+
lowField: s.low,
|
|
838
|
+
closeField: s.close,
|
|
839
|
+
kind: s.type,
|
|
840
|
+
mode: s.mode === "grouped" ? "grouped" : s.mode === "stacked" ? "stacked" : s.mode === "percent" ? "percent" : "single",
|
|
841
|
+
baselineValue: s.baseline ?? 0,
|
|
842
|
+
stroke: ((me = (ge = s.styles) == null ? void 0 : ge.normal) == null ? void 0 : me.stroke) ?? ((be = (xe = o.styles) == null ? void 0 : xe.normal) == null ? void 0 : be.stroke) ?? (typeof s.color == "string" ? s.color : x[F % x.length]),
|
|
843
|
+
fill: ((we = (Se = s.styles) == null ? void 0 : Se.normal) == null ? void 0 : we.fill) ?? ((Ie = (Ce = o.styles) == null ? void 0 : Ce.normal) == null ? void 0 : Ie.fill) ?? s.fill ?? (typeof s.color == "string" ? s.color : x[F % x.length]),
|
|
844
|
+
colors: { palette: [...x], ...typeof s.color == "function" ? { stroke: (H) => typeof s.color == "function" ? s.color(H.row) : void 0, fill: (H) => typeof s.color == "function" ? s.color(H.row) : void 0 } : {} },
|
|
845
|
+
markers: { visible: s.markers ?? !1 },
|
|
846
|
+
labels: { visible: !1 },
|
|
847
|
+
defined: s.defined ? (H) => {
|
|
848
|
+
var Ne;
|
|
849
|
+
return (Ne = s.defined) == null ? void 0 : Ne.call(s, H.row);
|
|
850
|
+
} : void 0,
|
|
851
|
+
virtualization: { enabled: ((ve = s.sampling) == null ? void 0 : ve.enabled) ?? !0, maxRenderedPoints: ((_e = s.sampling) == null ? void 0 : _e.maxPoints) ?? Math.max(16, Math.floor(n.width * 4)), maxRenderedBars: ((Re = s.sampling) == null ? void 0 : Re.maxPoints) ?? Math.max(16, Math.floor(n.width * 2)), sampling: "stride", minBarWidthPx: (ke = s.sampling) == null ? void 0 : ke.minBarWidthPx, aggregation: (Me = s.sampling) == null ? void 0 : Me.aggregation }
|
|
852
|
+
} };
|
|
853
|
+
}), d = (s, F, D) => ({ type: W.Flex, id: `${n.componentId}:${s}`, layout: { width: F, height: D, flexShrink: 0 } }), a = { fontFamily: (v = o.font) == null ? void 0 : v.family, fontSize: (M = o.font) == null ? void 0 : M.size, fontWeight: (N = o.font) == null ? void 0 : N.weight }, g = Math.max(14, Math.ceil((((k = o.font) == null ? void 0 : k.size) ?? 11) * 1.3)), R = (s) => s.labelRotation === "auto" ? 86 + g : s.labelRotation ? Math.max(28, Math.ceil(Math.abs(Math.sin(s.labelRotation * Math.PI / 180)) * 86 + Math.abs(Math.cos(s.labelRotation * Math.PI / 180)) * g + 12)) : Math.max(28, g + 12);
|
|
854
|
+
return [
|
|
855
|
+
...o.scales.map((s) => ({ type: ne.name, id: `${n.componentId}:scale:${s.id}`, props: {
|
|
856
|
+
scaleId: s.id,
|
|
857
|
+
scaleType: s.type,
|
|
858
|
+
field: s.field,
|
|
859
|
+
domain: s.domain,
|
|
860
|
+
zero: s.zero ?? !1,
|
|
861
|
+
nice: s.nice ?? !1,
|
|
862
|
+
paddingInner: s.paddingInner,
|
|
863
|
+
paddingOuter: s.paddingOuter,
|
|
864
|
+
timezone: o.timezone,
|
|
865
|
+
locale: o.locale
|
|
866
|
+
} })),
|
|
867
|
+
{ type: W.Flex, id: `${n.componentId}:layout`, props: { direction: "column", gap: 0, alignItems: "stretch" }, children: [
|
|
868
|
+
{ type: W.Flex, id: `${n.componentId}:main`, props: { direction: "row", gap: 0, alignItems: "stretch" }, layout: { width: "100%", flexBasis: 0, flexGrow: 1, minHeight: 1 }, children: [
|
|
869
|
+
...u.map((s) => ({ type: q.name, id: `${n.componentId}:${s.id}-axis`, props: { ...a, scaleId: s.id, orientation: "vertical", tickSide: "start", labelSide: "start", labelColor: b, lineColor: b, ticks: s.ticks }, layout: { width: 52, height: "100%", flexShrink: 0 } })),
|
|
870
|
+
{ type: oe.name, id: T, props: { xScaleId: r.id, yScaleId: f.id, xScaleIds: o.scales.filter((s) => s.axis === "x").map((s) => s.id), yScaleIds: o.scales.filter((s) => s.axis === "y").map((s) => s.id), clip: !0 }, layout: { flexBasis: 0, flexGrow: 1, minWidth: 1, height: "100%" }, children: [
|
|
871
|
+
...o.grid !== !1 ? [{ type: se.name, id: `${n.componentId}:grid`, props: { xScaleId: r.id, yScaleId: f.id, xTicks: r.ticks, yTicks: f.ticks, lineColor: o.theme === "dark" ? "#263447" : "#e8edf3" } }] : [],
|
|
872
|
+
...t
|
|
873
|
+
] }
|
|
874
|
+
] },
|
|
875
|
+
...p.map((s) => ({ type: W.Flex, id: `${n.componentId}:axis-row:${s.id}`, props: { direction: "row", gap: 0 }, layout: { width: "100%", height: R(s), flexShrink: 0 }, children: [
|
|
876
|
+
d(`axis-spacer:${s.id}`, 52 * u.length, R(s)),
|
|
877
|
+
{ type: q.name, id: `${n.componentId}:${s.id}-axis`, props: { ...a, scaleId: s.id, orientation: "horizontal", labelColor: b, lineColor: b, ticks: s.ticks, labelRotation: s.labelRotation }, layout: { flexBasis: 0, flexGrow: 1, minWidth: 1, height: R(s) } }
|
|
878
|
+
] }))
|
|
879
|
+
] }
|
|
880
|
+
];
|
|
881
|
+
}
|
|
882
|
+
function w(r) {
|
|
883
|
+
var p, x, b;
|
|
884
|
+
const f = /* @__PURE__ */ new Set();
|
|
885
|
+
for (const t of r.series) {
|
|
886
|
+
if (t.gap !== void 0 && (!Number.isFinite(t.gap) || t.gap < 0))
|
|
887
|
+
throw new RangeError("[NovaCharts] Cell gap must be finite and nonnegative");
|
|
888
|
+
if (f.has(t.id))
|
|
889
|
+
throw new Error(`[NovaCharts] Duplicate series id: ${t.id}`);
|
|
890
|
+
if (f.add(t.id), !G.has(t))
|
|
891
|
+
throw new Error(`[NovaCharts] Missing factory for series: ${t.id}`);
|
|
892
|
+
for (const d of [t.xScaleId ?? ((p = r.scales.find((a) => a.axis === "x")) == null ? void 0 : p.id), t.yScaleId ?? ((x = r.scales.find((a) => a.axis === "y")) == null ? void 0 : x.id)])
|
|
893
|
+
if (!r.scales.some((a) => a.id === d))
|
|
894
|
+
throw new Error(`[NovaCharts] Unknown scale: ${String(d)}`);
|
|
895
|
+
}
|
|
896
|
+
const u = /* @__PURE__ */ new Set();
|
|
897
|
+
for (const t of r.scales) {
|
|
898
|
+
if (t.paddingInner !== void 0 && (!Number.isFinite(t.paddingInner) || t.paddingInner < 0 || t.paddingInner > 1) || t.paddingOuter !== void 0 && (!Number.isFinite(t.paddingOuter) || t.paddingOuter < 0))
|
|
899
|
+
throw new RangeError("[NovaCharts] Band padding requires inner in [0, 1] and finite nonnegative outer");
|
|
900
|
+
if (!t.id.trim() || u.has(t.id))
|
|
901
|
+
throw new Error(`[NovaCharts] Invalid or duplicate scale id: ${t.id}`);
|
|
902
|
+
if (t.labelRotation !== void 0 && t.labelRotation !== "auto" && !Number.isFinite(t.labelRotation))
|
|
903
|
+
throw new RangeError("[NovaCharts] Label rotation must be finite or auto");
|
|
904
|
+
if (t.minSpan !== void 0 && (!Number.isFinite(t.minSpan) || t.minSpan <= 0))
|
|
905
|
+
throw new RangeError("[NovaCharts] minSpan must be finite and positive");
|
|
906
|
+
if (t.limits && (t.limits.length !== 2 || !t.limits.every(Number.isFinite) || t.limits[0] >= t.limits[1] || (t.minSpan ?? 0) > t.limits[1] - t.limits[0]))
|
|
907
|
+
throw new RangeError("[NovaCharts] Scale limits must be finite, increasing and accommodate minSpan");
|
|
908
|
+
if (t.domain && t.type !== "band" && (t.domain.length !== 2 || !t.domain.every((d) => typeof d == "number" && Number.isFinite(d)) || Number(t.domain[0]) >= Number(t.domain[1])))
|
|
909
|
+
throw new RangeError("[NovaCharts] Explicit domain must be finite and increasing");
|
|
910
|
+
u.add(t.id);
|
|
911
|
+
}
|
|
912
|
+
if (o = r, n.setChildren(I()), !y)
|
|
913
|
+
for (const t of o.series)
|
|
914
|
+
(b = n.nova.components.api(P(t.id))) == null || b.refresh();
|
|
915
|
+
C.clear(), y && L(y, y);
|
|
916
|
+
}
|
|
917
|
+
function A(r) {
|
|
918
|
+
var u;
|
|
919
|
+
const f = {};
|
|
920
|
+
for (const p of o.scales) {
|
|
921
|
+
const x = ((u = r.viewport) == null ? void 0 : u.ranges[p.id]) ?? X(p);
|
|
922
|
+
if (p.type === "band") {
|
|
923
|
+
if (!x.every((b) => typeof b == "string"))
|
|
924
|
+
throw new Error(`[NovaCharts] Band scale ${p.id} requires categories`);
|
|
925
|
+
f[p.id] = [...x];
|
|
926
|
+
} else {
|
|
927
|
+
if (x.length !== 2 || !x.every((a) => typeof a == "number" && Number.isFinite(a)))
|
|
928
|
+
throw new Error(`[NovaCharts] Continuous scale ${p.id} requires two finite values`);
|
|
929
|
+
let [b, t] = x;
|
|
930
|
+
if (t <= b)
|
|
931
|
+
throw new Error(`[NovaCharts] Scale ${p.id} requires an increasing range`);
|
|
932
|
+
const d = p.minSpan ?? Number.EPSILON;
|
|
933
|
+
if (t - b < d && (t = b + d), p.limits) {
|
|
934
|
+
const a = Math.min(t - b, p.limits[1] - p.limits[0]);
|
|
935
|
+
b = Math.max(p.limits[0], Math.min(p.limits[1] - a, b)), t = b + a;
|
|
936
|
+
}
|
|
937
|
+
f[p.id] = [b, t];
|
|
938
|
+
}
|
|
939
|
+
}
|
|
940
|
+
return { selection: r.selection.filter((p) => {
|
|
941
|
+
const x = o.series.find((b) => b.id === p.seriesId);
|
|
942
|
+
return x ? p.type === "bucket" ? !!_(x).byRef.get(Z(p)) : l.getRow(p.key) !== void 0 : !1;
|
|
943
|
+
}), visibility: { ...r.visibility }, viewport: { ...r.viewport, ranges: f } };
|
|
944
|
+
}
|
|
945
|
+
function L(r, f) {
|
|
946
|
+
var u;
|
|
947
|
+
y = f, B(r.visibility, f.visibility) || n.setChildren(I());
|
|
948
|
+
for (const [p, x] of Object.entries(((u = f.viewport) == null ? void 0 : u.ranges) ?? {}))
|
|
949
|
+
i.getScale(p) && !B(i.requireScale(p).getDomain(), x) && i.setScaleDomain(p, x);
|
|
950
|
+
(!B(r.visibility, f.visibility) || !B(r.viewport, f.viewport)) && C.clear();
|
|
951
|
+
}
|
|
952
|
+
w(c);
|
|
953
|
+
function X(r) {
|
|
954
|
+
const f = i.getScaleSourceDomain(r.id) ?? (r.type === "band" ? [] : [0, 1]);
|
|
955
|
+
if (r.type !== "band" && f.length === 2 && f[0] === f[1]) {
|
|
956
|
+
const u = Number(f[0]), p = Math.max(1, Math.abs(u) * 0.01);
|
|
957
|
+
return [u - p, u + p];
|
|
958
|
+
}
|
|
959
|
+
return f;
|
|
960
|
+
}
|
|
961
|
+
const K = {
|
|
962
|
+
capabilities: { kind: e, rows: !0, scales: !0, viewport: !0, camera: !1, drilldown: !1, expansion: !1, layout: !1, detail: !1, playback: !1, selection: !0, export: { image: ["png", "jpeg", "webp"], data: ["json", "csv"] } },
|
|
963
|
+
defaults: () => ({ selection: [], visibility: Object.fromEntries(o.series.map((r) => [r.id, r.visible !== !1])), viewport: { ranges: Object.fromEntries(o.scales.map((r) => [r.id, X(r)])) } }),
|
|
964
|
+
normalize: A,
|
|
965
|
+
configure: w,
|
|
966
|
+
applyState: L,
|
|
967
|
+
getData: () => l.getSourceData(),
|
|
968
|
+
setData: (r) => l.setData(r),
|
|
969
|
+
dataChanged() {
|
|
970
|
+
C.clear(), y && L(y, y);
|
|
971
|
+
},
|
|
972
|
+
getItem(r) {
|
|
973
|
+
const f = o.series.find((t) => t.id === r.seriesId);
|
|
974
|
+
if (!f)
|
|
975
|
+
return null;
|
|
976
|
+
const u = _(f).byRef.get(Z(r));
|
|
977
|
+
if (u)
|
|
978
|
+
return { ...u, ref: { ...u.ref }, bounds: u.bounds ? { ...u.bounds } : void 0, point: u.point ? { ...u.point } : void 0 };
|
|
979
|
+
if (r.type === "bucket")
|
|
980
|
+
return null;
|
|
981
|
+
const p = l.getRow(r.key);
|
|
982
|
+
if (!p)
|
|
983
|
+
return null;
|
|
984
|
+
const x = E(p, f.x), b = E(p, f.y);
|
|
985
|
+
return { ref: { ...r }, row: p, label: String(x), value: Number.isFinite(Number(b)) ? Number(b) : void 0 };
|
|
986
|
+
},
|
|
987
|
+
getVisibleItems: () => o.series.filter((r) => (y == null ? void 0 : y.visibility[r.id]) !== !1).flatMap((r) => _(r).items),
|
|
988
|
+
plotBounds: () => {
|
|
989
|
+
var r, f;
|
|
990
|
+
return { ...z(), width: ((r = S()) == null ? void 0 : r.width) ?? n.width, height: ((f = S()) == null ? void 0 : f.height) ?? n.height };
|
|
991
|
+
},
|
|
992
|
+
hitTest(r, f) {
|
|
993
|
+
let u = null, p = f;
|
|
994
|
+
for (const x of o.series)
|
|
995
|
+
if ((y == null ? void 0 : y.visibility[x.id]) !== !1)
|
|
996
|
+
for (const b of _(x).index.query(r.x, r.y, f)) {
|
|
997
|
+
const t = b.bounds, d = Math.max(t.x - r.x, 0, r.x - t.x - t.width), a = Math.max(t.y - r.y, 0, r.y - t.y - t.height), g = Math.hypot(r.x - b.point.x, r.y - b.point.y), R = x.type === "line" || x.type === "area" ? g : x.type === "scatter" || x.type === "bubble" ? Math.max(0, g - t.width / 2) : Math.hypot(d, a);
|
|
998
|
+
R <= p && (u = b, p = R);
|
|
999
|
+
}
|
|
1000
|
+
return u ? K.getItem(u.ref) : null;
|
|
1001
|
+
},
|
|
1002
|
+
resize() {
|
|
1003
|
+
C.clear(), n.getApi().refresh();
|
|
1004
|
+
},
|
|
1005
|
+
refresh() {
|
|
1006
|
+
var r;
|
|
1007
|
+
C.clear();
|
|
1008
|
+
for (const f of o.series)
|
|
1009
|
+
(r = n.nova.components.api(P(f.id))) == null || r.refresh();
|
|
1010
|
+
},
|
|
1011
|
+
dispose() {
|
|
1012
|
+
C.clear();
|
|
1013
|
+
},
|
|
1014
|
+
extend(r, f) {
|
|
1015
|
+
h = f;
|
|
1016
|
+
const u = () => h.readState().viewport, p = (t, d) => {
|
|
1017
|
+
h.request("viewport", { ...u(), ranges: t, followTail: void 0 }, d);
|
|
1018
|
+
}, x = () => Object.fromEntries(o.scales.map((t) => [t.id, X(t)]));
|
|
1019
|
+
return {
|
|
1020
|
+
...e === "composed" ? {
|
|
1021
|
+
addSeries(t) {
|
|
1022
|
+
if (o.series.some((d) => d.id === t.id))
|
|
1023
|
+
throw new Error(`[NovaCharts] Duplicate series: ${t.id}`);
|
|
1024
|
+
r.setOptions({ series: [...o.series, t] });
|
|
1025
|
+
},
|
|
1026
|
+
updateSeries(t, d) {
|
|
1027
|
+
const a = o.series.find((v) => v.id === t);
|
|
1028
|
+
if (!a)
|
|
1029
|
+
throw new Error(`[NovaCharts] Unknown series: ${t}`);
|
|
1030
|
+
const g = G.get(a), R = re(g, { ...a, ...d, id: t });
|
|
1031
|
+
r.setOptions({ series: o.series.map((v) => v.id === t ? R : v) });
|
|
1032
|
+
},
|
|
1033
|
+
removeSeries(t) {
|
|
1034
|
+
if (!o.series.some((d) => d.id === t))
|
|
1035
|
+
throw new Error(`[NovaCharts] Unknown series: ${t}`);
|
|
1036
|
+
r.setOptions({ series: o.series.filter((d) => d.id !== t) });
|
|
1037
|
+
},
|
|
1038
|
+
setSeries(t) {
|
|
1039
|
+
r.setOptions({ series: t });
|
|
1040
|
+
}
|
|
1041
|
+
} : {},
|
|
1042
|
+
getSeries: () => o.series.map((t) => ({ id: t.id, type: t.type, visible: h.readState().visibility[t.id] !== !1 })),
|
|
1043
|
+
setSeriesVisible(t, d, a) {
|
|
1044
|
+
if (!o.series.some((g) => g.id === t))
|
|
1045
|
+
throw new Error(`[NovaCharts] Unknown series: ${t}`);
|
|
1046
|
+
h.request("visibility", { ...h.readState().visibility, [t]: d }, a == null ? void 0 : a.origin);
|
|
1047
|
+
},
|
|
1048
|
+
getScale(t) {
|
|
1049
|
+
const d = o.scales.find((a) => a.id === t);
|
|
1050
|
+
if (!d)
|
|
1051
|
+
throw new Error(`[NovaCharts] Unknown scale: ${t}`);
|
|
1052
|
+
return {
|
|
1053
|
+
getType: () => (h.readState(), d.type),
|
|
1054
|
+
getAxis: () => (h.readState(), d.axis),
|
|
1055
|
+
getDomain: () => [...i.requireScale(t).getDomain()],
|
|
1056
|
+
setDomain: (a, g) => p({ ...u().ranges, [t]: a }, g == null ? void 0 : g.origin),
|
|
1057
|
+
getRange: () => [...i.requireScale(t).getRange()],
|
|
1058
|
+
map: (a) => i.requireScale(t).toPx(a) + (d.axis === "x" ? z().x : z().y),
|
|
1059
|
+
invert: (a) => i.requireScale(t).fromPx(a - (d.axis === "x" ? z().x : z().y)),
|
|
1060
|
+
getTicks: (a) => i.requireScale(t).ticks(a ?? d.ticks)
|
|
1061
|
+
};
|
|
1062
|
+
},
|
|
1063
|
+
getViewport: () => structuredClone(u()),
|
|
1064
|
+
setViewport: (t, d) => {
|
|
1065
|
+
h.request("viewport", t, d == null ? void 0 : d.origin);
|
|
1066
|
+
},
|
|
1067
|
+
panBy(t, d) {
|
|
1068
|
+
if (![t.x, t.y].every(Number.isFinite))
|
|
1069
|
+
throw new RangeError("[NovaCharts] Pan delta must be finite");
|
|
1070
|
+
const a = { ...u().ranges };
|
|
1071
|
+
for (const g of o.scales) {
|
|
1072
|
+
const R = g.axis === "x" ? t.x : t.y, [v, M] = i.requireScale(g.id).getRange(), N = a[g.id];
|
|
1073
|
+
if (g.type === "band") {
|
|
1074
|
+
const k = i.getScaleSourceDomain(g.id), s = k.indexOf(String(N[0])), F = Math.round(-R * N.length / (M - v)), D = Math.max(0, Math.min(k.length - N.length, s + F));
|
|
1075
|
+
a[g.id] = k.slice(D, D + N.length);
|
|
1076
|
+
} else {
|
|
1077
|
+
const [k, s] = N, F = -R * (s - k) / (M - v);
|
|
1078
|
+
a[g.id] = [k + F, s + F];
|
|
1079
|
+
}
|
|
1080
|
+
}
|
|
1081
|
+
p(a, d == null ? void 0 : d.origin);
|
|
1082
|
+
},
|
|
1083
|
+
zoomAt(t, d, a) {
|
|
1084
|
+
if (!Number.isFinite(t) || t <= 0)
|
|
1085
|
+
throw new RangeError("[NovaCharts] Zoom factor must be positive");
|
|
1086
|
+
const g = { ...u().ranges };
|
|
1087
|
+
for (const R of o.scales) {
|
|
1088
|
+
const v = g[R.id];
|
|
1089
|
+
if (R.type === "band") {
|
|
1090
|
+
const M = i.getScaleSourceDomain(R.id), N = M.indexOf(String(v[Math.floor(v.length / 2)])), k = Math.max(1, Math.min(M.length, Math.round(v.length / t))), s = Math.max(0, Math.min(M.length - k, N - Math.floor(k / 2)));
|
|
1091
|
+
g[R.id] = M.slice(s, s + k);
|
|
1092
|
+
} else {
|
|
1093
|
+
const [M, N] = v, k = d ? Number(i.requireScale(R.id).fromPx(R.axis === "x" ? d.x - z().x : d.y - z().y)) : (M + N) / 2;
|
|
1094
|
+
g[R.id] = [k + (M - k) / t, k + (N - k) / t];
|
|
1095
|
+
}
|
|
1096
|
+
}
|
|
1097
|
+
p(g, a == null ? void 0 : a.origin);
|
|
1098
|
+
},
|
|
1099
|
+
fitContent: (t) => p(x(), t == null ? void 0 : t.origin),
|
|
1100
|
+
resetViewport: (t) => p(x(), t == null ? void 0 : t.origin),
|
|
1101
|
+
fitSelection(t) {
|
|
1102
|
+
const d = h.readState().selection.map((g) => K.getItem(g)).filter((g) => !!(g != null && g.row));
|
|
1103
|
+
if (!d.length)
|
|
1104
|
+
return;
|
|
1105
|
+
const a = { ...u().ranges };
|
|
1106
|
+
for (const g of o.scales) {
|
|
1107
|
+
if (!g.field)
|
|
1108
|
+
continue;
|
|
1109
|
+
const R = d.map((v) => E(v.row, g.field));
|
|
1110
|
+
if (g.type === "band")
|
|
1111
|
+
a[g.id] = [...new Set(R.map(String))];
|
|
1112
|
+
else {
|
|
1113
|
+
let v = 1 / 0, M = -1 / 0;
|
|
1114
|
+
for (const N of R) {
|
|
1115
|
+
const k = Number(N);
|
|
1116
|
+
Number.isFinite(k) && (v = Math.min(v, k), M = Math.max(M, k));
|
|
1117
|
+
}
|
|
1118
|
+
if (Number.isFinite(v)) {
|
|
1119
|
+
const N = (M - v) * 0.05 || 1;
|
|
1120
|
+
a[g.id] = [v - N, M + N];
|
|
1121
|
+
}
|
|
1122
|
+
}
|
|
1123
|
+
}
|
|
1124
|
+
p(a, t == null ? void 0 : t.origin);
|
|
1125
|
+
},
|
|
1126
|
+
followTail(t, d) {
|
|
1127
|
+
if (t && (!o.scales.some((a) => a.id === t.scaleId && a.type !== "band") || !Number.isFinite(t.span) || t.span <= 0))
|
|
1128
|
+
throw new Error("[NovaCharts] followTail requires a continuous scale and positive span");
|
|
1129
|
+
h.request("viewport", { ...u(), followTail: t || void 0 }, d == null ? void 0 : d.origin), t && h.invalidate(!0);
|
|
1130
|
+
}
|
|
1131
|
+
};
|
|
1132
|
+
}
|
|
1133
|
+
};
|
|
1134
|
+
return K;
|
|
1135
|
+
}
|
|
1136
|
+
export {
|
|
1137
|
+
St as C,
|
|
1138
|
+
bt as c
|
|
1139
|
+
};
|