@nova-lab/charts 0.0.0-stage → 1.0.0-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
package/dist/bar.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** Самостоятельный BarChart и его серия для композиции. */
|
|
2
|
+
export declare const BarChart: {
|
|
3
|
+
series: <T = never, const S extends import('./public').SeriesOptions<never> = import('./public').SeriesOptions<T>>(options: S) => Omit<S, "type"> & {
|
|
4
|
+
readonly type: import('./public').CartesianKind;
|
|
5
|
+
};
|
|
6
|
+
mount<T>(target: string | HTMLElement, options: import('./public').CartesianOptions<T>): import('./public').CartesianHandle<T>;
|
|
7
|
+
attach<T>(target: import('./public').ChartAttachTarget, options: import('./public').CartesianOptions<T>): import('./public').CartesianHandle<T>;
|
|
8
|
+
};
|
|
9
|
+
export type { CartesianHandle as BarChartHandle, CartesianOptions as BarChartOptions, SeriesOptions as BarSeriesOptions } from './api/types';
|
package/dist/bar.js
ADDED
|
@@ -0,0 +1,554 @@
|
|
|
1
|
+
var x = Object.defineProperty;
|
|
2
|
+
var v = (a, i, t) => i in a ? x(a, i, { enumerable: !0, configurable: !0, writable: !0, value: t }) : a[i] = t;
|
|
3
|
+
var d = (a, i, t) => v(a, typeof i != "symbol" ? i + "" : i, t);
|
|
4
|
+
import { c as w } from "./cartesian-k_WIYsGp.js";
|
|
5
|
+
import { commonMeasureBounds as C, NovaUiComponentNode as m } from "@nova-lab/ui-kit";
|
|
6
|
+
import { a as k, b as P, n as u, r as N, d as R, e as M, f as T } from "./host-DLDeDU5k.js";
|
|
7
|
+
import { r as y } from "./chart-runtime-resolver-DwwXp3X8.js";
|
|
8
|
+
import { C as B, p as E } from "./chart-series-runtime-C0P7h8Tl.js";
|
|
9
|
+
const L = "NovaCharts.BarSeries";
|
|
10
|
+
function S(a) {
|
|
11
|
+
const i = {
|
|
12
|
+
type: L,
|
|
13
|
+
name: "NovaCharts.BarSeries",
|
|
14
|
+
title: "NovaCharts.BarSeries",
|
|
15
|
+
version: "0.2.0",
|
|
16
|
+
kind: "node-component",
|
|
17
|
+
dirtyPolicy: P,
|
|
18
|
+
fields: {
|
|
19
|
+
...k,
|
|
20
|
+
chartRef: { type: "string" },
|
|
21
|
+
xScaleId: { type: "string" },
|
|
22
|
+
yScaleId: { type: "string" },
|
|
23
|
+
xField: { type: "field" },
|
|
24
|
+
yField: { type: "field" },
|
|
25
|
+
categoryField: { type: "field" },
|
|
26
|
+
valueField: { type: "field" },
|
|
27
|
+
seriesField: { type: "field" },
|
|
28
|
+
labelField: { type: "field" },
|
|
29
|
+
orientation: { type: "string" },
|
|
30
|
+
mode: { type: "string" },
|
|
31
|
+
fill: { type: "string" },
|
|
32
|
+
radius: { type: "number" },
|
|
33
|
+
minBarSize: { type: "number" },
|
|
34
|
+
virtualization: { type: "record" },
|
|
35
|
+
highlight: { type: "record" },
|
|
36
|
+
labels: { type: "record" },
|
|
37
|
+
colors: { type: "record" }
|
|
38
|
+
},
|
|
39
|
+
normalize: (t) => u(t.props),
|
|
40
|
+
measureBounds: (t, e) => C(e, u)
|
|
41
|
+
};
|
|
42
|
+
return a && (i.createNode = a), i;
|
|
43
|
+
}
|
|
44
|
+
const z = S();
|
|
45
|
+
function D(a, i, t) {
|
|
46
|
+
const e = i.items;
|
|
47
|
+
if (e.length === 0)
|
|
48
|
+
return null;
|
|
49
|
+
const s = t.mode ?? "exact", o = F(e, t.x, t.y);
|
|
50
|
+
if (o)
|
|
51
|
+
return g(a, i, o, t.x, t.y, 0);
|
|
52
|
+
if (s !== "nearest")
|
|
53
|
+
return null;
|
|
54
|
+
const n = t.maxDistancePx ?? 16, r = V(e, t.x, t.y, n);
|
|
55
|
+
return r ? g(a, i, r.item, t.x, t.y, r.distance) : null;
|
|
56
|
+
}
|
|
57
|
+
function F(a, i, t) {
|
|
58
|
+
for (const e of a)
|
|
59
|
+
if (i >= e.x && i <= e.x + e.width && t >= e.y && t <= e.y + e.height)
|
|
60
|
+
return e;
|
|
61
|
+
return null;
|
|
62
|
+
}
|
|
63
|
+
function V(a, i, t, e) {
|
|
64
|
+
let s = null;
|
|
65
|
+
for (const o of a) {
|
|
66
|
+
const n = o.x + o.width / 2, r = o.y + o.height / 2, l = Math.hypot(n - i, r - t);
|
|
67
|
+
l > e || (!s || l < s.distance) && (s = { item: o, distance: l });
|
|
68
|
+
}
|
|
69
|
+
return s;
|
|
70
|
+
}
|
|
71
|
+
function g(a, i, t, e, s, o) {
|
|
72
|
+
return {
|
|
73
|
+
seriesId: a,
|
|
74
|
+
seriesKind: "bar",
|
|
75
|
+
key: t.key,
|
|
76
|
+
mode: t.row ? "datum" : "bucket",
|
|
77
|
+
row: t.row,
|
|
78
|
+
value: t.value,
|
|
79
|
+
rawValue: t.rawValue,
|
|
80
|
+
xValue: i.orientation === "horizontal" ? t.value : t.category,
|
|
81
|
+
yValue: i.orientation === "horizontal" ? t.category : t.value,
|
|
82
|
+
label: t.label,
|
|
83
|
+
category: t.category,
|
|
84
|
+
seriesKey: t.seriesKey,
|
|
85
|
+
seriesLabel: t.seriesLabel,
|
|
86
|
+
color: t.color,
|
|
87
|
+
point: {
|
|
88
|
+
x: t.x + t.width / 2,
|
|
89
|
+
y: t.y + t.height / 2
|
|
90
|
+
},
|
|
91
|
+
bounds: {
|
|
92
|
+
x: t.x,
|
|
93
|
+
y: t.y,
|
|
94
|
+
width: t.width,
|
|
95
|
+
height: t.height
|
|
96
|
+
},
|
|
97
|
+
distancePx: o || A(t, e, s)
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
function A(a, i, t) {
|
|
101
|
+
const e = Math.max(a.x - i, 0, i - (a.x + a.width)), s = Math.max(a.y - t, 0, t - (a.y + a.height));
|
|
102
|
+
return Math.hypot(e, s);
|
|
103
|
+
}
|
|
104
|
+
const O = {
|
|
105
|
+
kind: "bar",
|
|
106
|
+
inputRows: 0,
|
|
107
|
+
visibleRows: 0,
|
|
108
|
+
renderedBars: 0,
|
|
109
|
+
aggregatedBuckets: 0,
|
|
110
|
+
mode: "direct",
|
|
111
|
+
domainMs: 0,
|
|
112
|
+
layoutMs: 0,
|
|
113
|
+
schemaMs: 0,
|
|
114
|
+
totalMs: 0
|
|
115
|
+
}, f = {
|
|
116
|
+
items: [],
|
|
117
|
+
orientation: "vertical",
|
|
118
|
+
mode: "single",
|
|
119
|
+
categories: [],
|
|
120
|
+
series: [],
|
|
121
|
+
diagnostics: O
|
|
122
|
+
};
|
|
123
|
+
class W extends m {
|
|
124
|
+
/**
|
|
125
|
+
* Создает экземпляр ChartBarSeries и подготавливает базовое состояние.
|
|
126
|
+
*/
|
|
127
|
+
constructor(t, e, s, o = {}, n = z) {
|
|
128
|
+
super(t, e, n, s, { componentId: o.componentId });
|
|
129
|
+
d(this, "_layoutPlan", f);
|
|
130
|
+
d(this, "_layoutEpoch", 0);
|
|
131
|
+
d(this, "_computedEpoch", "");
|
|
132
|
+
d(this, "_api");
|
|
133
|
+
d(this, "_runtimeBinding");
|
|
134
|
+
this.options({ zIndex: 10 }), this._api = {
|
|
135
|
+
getLayoutPlan: () => (this._computeLayout(), this._layoutPlan),
|
|
136
|
+
getDiagnostics: () => this._layoutPlan.diagnostics,
|
|
137
|
+
hitTest: (r) => this._hitTestSeries(r),
|
|
138
|
+
refresh: () => this._refresh(),
|
|
139
|
+
setVirtualization: (r) => this.setVirtualization(r)
|
|
140
|
+
}, this._runtimeBinding = new B(this, {
|
|
141
|
+
hitTest: (r) => this._hitTestSeries(r)
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Обновляет значение состояния ChartBarSeries.
|
|
146
|
+
*/
|
|
147
|
+
setProps(t) {
|
|
148
|
+
return super.setProps(u({
|
|
149
|
+
...this.props,
|
|
150
|
+
...t
|
|
151
|
+
}));
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Возвращает значение состояния ChartBarSeries.
|
|
155
|
+
*/
|
|
156
|
+
getApi() {
|
|
157
|
+
return this._api;
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Обновляет runtime-состояние ChartBarSeries.
|
|
161
|
+
*/
|
|
162
|
+
update() {
|
|
163
|
+
this._computeLayout();
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Выполняет отрисовку ChartBarSeries.
|
|
167
|
+
*/
|
|
168
|
+
render() {
|
|
169
|
+
var n;
|
|
170
|
+
const t = _(), e = y(this, this.props.chartRef), s = [];
|
|
171
|
+
for (const r of this._layoutPlan.items) {
|
|
172
|
+
const l = this._createStyleContext("bar", r, e), h = this._resolveBarStyle(r, l, e);
|
|
173
|
+
N(
|
|
174
|
+
s,
|
|
175
|
+
(n = this.props.renderers) == null ? void 0 : n.bar,
|
|
176
|
+
{ ...l, style: h },
|
|
177
|
+
{
|
|
178
|
+
type: "rect",
|
|
179
|
+
x: r.x,
|
|
180
|
+
y: r.y,
|
|
181
|
+
width: r.width,
|
|
182
|
+
height: r.height,
|
|
183
|
+
styles: {
|
|
184
|
+
background: h.background ?? h.fill ?? r.color ?? this.props.fill,
|
|
185
|
+
opacity: h.opacity ?? this.props.opacity,
|
|
186
|
+
border: h.strokeWidth && h.strokeWidth > 0 ? {
|
|
187
|
+
color: h.strokeColor ?? h.stroke,
|
|
188
|
+
width: h.strokeWidth,
|
|
189
|
+
radius: h.borderRadius ?? h.radius ?? this.props.radius
|
|
190
|
+
} : h.borderRadius !== void 0 || h.radius !== void 0 ? { radius: h.borderRadius ?? h.radius } : void 0
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
);
|
|
194
|
+
}
|
|
195
|
+
const o = _() - t;
|
|
196
|
+
this._layoutPlan = {
|
|
197
|
+
...this._layoutPlan,
|
|
198
|
+
diagnostics: {
|
|
199
|
+
...this._layoutPlan.diagnostics,
|
|
200
|
+
schemaMs: o,
|
|
201
|
+
totalMs: this._layoutPlan.diagnostics.domainMs + this._layoutPlan.diagnostics.layoutMs + o
|
|
202
|
+
}
|
|
203
|
+
}, this._publishDiagnostics(), s.length > 0 && this.renderer.schema(s), this._renderLabels(e);
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* Обновляет значение состояния ChartBarSeries.
|
|
207
|
+
*/
|
|
208
|
+
setVirtualization(t) {
|
|
209
|
+
this.props.virtualization = {
|
|
210
|
+
...this.props.virtualization,
|
|
211
|
+
...t
|
|
212
|
+
}, this._refresh();
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* Обрабатывает входящее событие ChartBarSeries.
|
|
216
|
+
*/
|
|
217
|
+
onMount() {
|
|
218
|
+
super.onMount(), this._runtimeBinding.syncInteractive();
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* Обрабатывает входящее событие ChartBarSeries.
|
|
222
|
+
*/
|
|
223
|
+
onUnmount() {
|
|
224
|
+
this._runtimeBinding.cleanup(), super.onUnmount();
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* Обрабатывает входящее событие ChartBarSeries.
|
|
228
|
+
*/
|
|
229
|
+
onPropsChanged(t) {
|
|
230
|
+
this.applyCommonPropsChanged(t), t.includes("chartRef") && this._runtimeBinding.syncInteractive(), this._refresh();
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* Выполняет hit-test для runtime-геометрии ChartBarSeries.
|
|
234
|
+
*/
|
|
235
|
+
_hitTestSeries(t) {
|
|
236
|
+
return D(this.componentId, this._layoutPlan, t);
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* Синхронизирует актуальное состояние ChartBarSeries.
|
|
240
|
+
*/
|
|
241
|
+
_refresh() {
|
|
242
|
+
this._layoutEpoch++, this._computeLayout(), this.runtime.batch(() => {
|
|
243
|
+
this.invalidate({ update: !0, render: !0 });
|
|
244
|
+
});
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* Вычисляет производное значение ChartBarSeries.
|
|
248
|
+
*/
|
|
249
|
+
_computeLayout() {
|
|
250
|
+
const t = y(this, this.props.chartRef), e = t == null ? void 0 : t.getScale(this.props.xScaleId), s = t == null ? void 0 : t.getScale(this.props.yScaleId);
|
|
251
|
+
if (!t || !e || !s) {
|
|
252
|
+
this._layoutPlan = {
|
|
253
|
+
...f,
|
|
254
|
+
orientation: this.props.orientation,
|
|
255
|
+
mode: this.props.mode
|
|
256
|
+
};
|
|
257
|
+
return;
|
|
258
|
+
}
|
|
259
|
+
`${t.dataStore.revision}:${t.scales.revision}:${this._layoutEpoch}:${this.width}:${this.height}` !== this._computedEpoch && (this._publishDomainContributions(t), this._layoutPlan = R({
|
|
260
|
+
props: this.props,
|
|
261
|
+
dataStore: t.dataStore,
|
|
262
|
+
xScale: e,
|
|
263
|
+
yScale: s,
|
|
264
|
+
width: this.width,
|
|
265
|
+
height: this.height
|
|
266
|
+
}), this._publishDiagnostics(), t.setSeriesMetadata(this.componentId, this._layoutPlan.series.map((n) => ({
|
|
267
|
+
...n,
|
|
268
|
+
kind: "bar",
|
|
269
|
+
sourceSeriesId: this.componentId,
|
|
270
|
+
scaleIds: {
|
|
271
|
+
x: this.props.xScaleId,
|
|
272
|
+
y: this.props.yScaleId
|
|
273
|
+
}
|
|
274
|
+
}))), E(t, `${this.componentId}:marks`, this.componentId, "bar", this._layoutPlan.items.map((n) => ({
|
|
275
|
+
key: n.key,
|
|
276
|
+
x: n.x,
|
|
277
|
+
y: n.y,
|
|
278
|
+
width: n.width,
|
|
279
|
+
height: n.height,
|
|
280
|
+
value: n.value,
|
|
281
|
+
rawValue: n.rawValue,
|
|
282
|
+
category: n.category,
|
|
283
|
+
seriesKey: n.seriesKey,
|
|
284
|
+
seriesLabel: n.seriesLabel,
|
|
285
|
+
color: n.color
|
|
286
|
+
}))), this._computedEpoch = `${t.dataStore.revision}:${t.scales.revision}:${this._layoutEpoch}:${this.width}:${this.height}`);
|
|
287
|
+
}
|
|
288
|
+
/**
|
|
289
|
+
* Публикует вклад BarSeries в shared scale source domains.
|
|
290
|
+
*/
|
|
291
|
+
_publishDomainContributions(t) {
|
|
292
|
+
this._runtimeBinding.publishContributions(t, [
|
|
293
|
+
{
|
|
294
|
+
id: this._categoryContributionId,
|
|
295
|
+
scaleId: this._categoryScaleId,
|
|
296
|
+
domain: this._resolveCategoryDomain(t)
|
|
297
|
+
},
|
|
298
|
+
{
|
|
299
|
+
id: this._valueContributionId,
|
|
300
|
+
scaleId: this._valueScaleId,
|
|
301
|
+
domain: this._resolveValueDomain(t)
|
|
302
|
+
}
|
|
303
|
+
]);
|
|
304
|
+
}
|
|
305
|
+
/**
|
|
306
|
+
* Возвращает полный category domain этой series.
|
|
307
|
+
*/
|
|
308
|
+
_resolveCategoryDomain(t) {
|
|
309
|
+
return [...t.dataStore.categoryDomain(this.props.categoryField)];
|
|
310
|
+
}
|
|
311
|
+
/**
|
|
312
|
+
* Возвращает полный value domain этой series с учетом stacked totals.
|
|
313
|
+
*/
|
|
314
|
+
_resolveValueDomain(t) {
|
|
315
|
+
const e = t.dataStore.getData();
|
|
316
|
+
if (e.length === 0)
|
|
317
|
+
return [0, 1];
|
|
318
|
+
if (this.props.mode === "stacked") {
|
|
319
|
+
const o = /* @__PURE__ */ new Map();
|
|
320
|
+
e.forEach((r, l) => {
|
|
321
|
+
const h = String(t.dataStore.readField(r, l, this.props.categoryField) ?? ""), c = Number(t.dataStore.readField(r, l, this.props.valueField));
|
|
322
|
+
if (!Number.isFinite(c))
|
|
323
|
+
return;
|
|
324
|
+
let p = o.get(h);
|
|
325
|
+
p || (p = { positive: 0, negative: 0 }, o.set(h, p)), c >= 0 ? p.positive += c : p.negative += c;
|
|
326
|
+
});
|
|
327
|
+
const n = Array.from(o.values()).flatMap((r) => [r.negative, r.positive]);
|
|
328
|
+
return b(n);
|
|
329
|
+
}
|
|
330
|
+
const s = e.map((o, n) => Number(t.dataStore.readField(o, n, this.props.valueField)));
|
|
331
|
+
return b(s);
|
|
332
|
+
}
|
|
333
|
+
/**
|
|
334
|
+
* Возвращает scale id, на котором лежит category axis.
|
|
335
|
+
*/
|
|
336
|
+
get _categoryScaleId() {
|
|
337
|
+
return this.props.orientation === "horizontal" ? this.props.yScaleId : this.props.xScaleId;
|
|
338
|
+
}
|
|
339
|
+
/**
|
|
340
|
+
* Возвращает scale id, на котором лежит value axis.
|
|
341
|
+
*/
|
|
342
|
+
get _valueScaleId() {
|
|
343
|
+
return this.props.orientation === "horizontal" ? this.props.xScaleId : this.props.yScaleId;
|
|
344
|
+
}
|
|
345
|
+
get _categoryContributionId() {
|
|
346
|
+
return `${this.componentId}:category-domain`;
|
|
347
|
+
}
|
|
348
|
+
get _valueContributionId() {
|
|
349
|
+
return `${this.componentId}:value-domain`;
|
|
350
|
+
}
|
|
351
|
+
/**
|
|
352
|
+
* Выполняет внутренний шаг publishDiagnostics для ChartBarSeries.
|
|
353
|
+
*/
|
|
354
|
+
_publishDiagnostics() {
|
|
355
|
+
const t = y(this, this.props.chartRef);
|
|
356
|
+
t && this._runtimeBinding.publishDiagnostics(t, this._layoutPlan.diagnostics);
|
|
357
|
+
}
|
|
358
|
+
/**
|
|
359
|
+
* Выполняет внутренний шаг isItemHighlighted для ChartBarSeries.
|
|
360
|
+
*/
|
|
361
|
+
_isItemHighlighted(t, e) {
|
|
362
|
+
return this.props.highlight.enabled && (e == null ? void 0 : e.seriesId) === this.componentId && e.key === t;
|
|
363
|
+
}
|
|
364
|
+
/**
|
|
365
|
+
* Рисует подписи баров поверх bounded schema.
|
|
366
|
+
*/
|
|
367
|
+
_renderLabels(t) {
|
|
368
|
+
var e;
|
|
369
|
+
if (this.props.labels.visible)
|
|
370
|
+
for (const s of this._layoutPlan.items) {
|
|
371
|
+
if (!s.labelText)
|
|
372
|
+
continue;
|
|
373
|
+
const o = $(this.props.orientation, this.props.labels.position, s), n = this._createStyleContext("barLabel", s, t), r = this._resolveLabelStyle(n, t), l = {
|
|
374
|
+
type: "text",
|
|
375
|
+
text: s.labelText,
|
|
376
|
+
x: o.x,
|
|
377
|
+
y: o.y,
|
|
378
|
+
width: o.width,
|
|
379
|
+
height: o.height,
|
|
380
|
+
styles: {
|
|
381
|
+
color: r.color ?? this.props.labels.color,
|
|
382
|
+
font: {
|
|
383
|
+
family: r.fontFamily ?? this.props.fontFamily ?? "Inter, Arial, sans-serif",
|
|
384
|
+
size: r.fontSize ?? this.props.labels.fontSize,
|
|
385
|
+
weight: String(r.fontWeight ?? this.props.labels.fontWeight)
|
|
386
|
+
},
|
|
387
|
+
lineHeight: r.lineHeight,
|
|
388
|
+
opacity: r.opacity,
|
|
389
|
+
align: {
|
|
390
|
+
horizontal: o.align,
|
|
391
|
+
vertical: "middle"
|
|
392
|
+
},
|
|
393
|
+
ellipsis: !0
|
|
394
|
+
},
|
|
395
|
+
meta: {
|
|
396
|
+
textRole: "ui-label",
|
|
397
|
+
textMode: "run-atlas",
|
|
398
|
+
textLod: "always"
|
|
399
|
+
}
|
|
400
|
+
};
|
|
401
|
+
if ((e = this.props.renderers) != null && e.barLabel) {
|
|
402
|
+
const h = [], c = this.props.renderers.barLabel({ ...n, style: r, defaultSchema: l });
|
|
403
|
+
c !== null && M(h, c ?? l), h.length > 0 && this.renderer.schema(h);
|
|
404
|
+
} else
|
|
405
|
+
this.renderer.text(l);
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
_createStyleContext(t, e, s) {
|
|
409
|
+
const o = s == null ? void 0 : s.getInteractionState().hovered, n = T(this.componentId, e.key, {
|
|
410
|
+
hovered: o,
|
|
411
|
+
attrs: this.props.attrs,
|
|
412
|
+
disabled: this.props.disabled
|
|
413
|
+
});
|
|
414
|
+
return {
|
|
415
|
+
componentId: this.componentId,
|
|
416
|
+
componentName: "BarSeries",
|
|
417
|
+
part: t,
|
|
418
|
+
datum: {
|
|
419
|
+
seriesId: this.componentId,
|
|
420
|
+
seriesKind: "bar",
|
|
421
|
+
key: e.key,
|
|
422
|
+
mode: "datum",
|
|
423
|
+
row: e.row,
|
|
424
|
+
value: e.value,
|
|
425
|
+
rawValue: e.rawValue,
|
|
426
|
+
category: e.category,
|
|
427
|
+
seriesKey: e.seriesKey,
|
|
428
|
+
seriesLabel: e.seriesLabel,
|
|
429
|
+
color: e.color,
|
|
430
|
+
bounds: { x: e.x, y: e.y, width: e.width, height: e.height },
|
|
431
|
+
distancePx: 0
|
|
432
|
+
},
|
|
433
|
+
row: e.row,
|
|
434
|
+
seriesKind: "bar",
|
|
435
|
+
state: n,
|
|
436
|
+
geometry: e,
|
|
437
|
+
tokens: (s == null ? void 0 : s.customization.tokens) ?? {},
|
|
438
|
+
scaleIds: { x: this.props.xScaleId, y: this.props.yScaleId },
|
|
439
|
+
className: this.props.className,
|
|
440
|
+
attrs: this.props.attrs
|
|
441
|
+
};
|
|
442
|
+
}
|
|
443
|
+
_resolveBarStyle(t, e, s) {
|
|
444
|
+
var l, h, c, p;
|
|
445
|
+
const o = this._isItemHighlighted(t.key, s == null ? void 0 : s.getInteractionState().hovered), n = {
|
|
446
|
+
...((l = this.props.states) == null ? void 0 : l[e.state]) ?? {},
|
|
447
|
+
...o ? {
|
|
448
|
+
background: this.props.highlight.fill,
|
|
449
|
+
fill: this.props.highlight.fill,
|
|
450
|
+
opacity: this.props.highlight.opacity,
|
|
451
|
+
strokeColor: this.props.highlight.strokeColor,
|
|
452
|
+
strokeWidth: this.props.highlight.strokeWidth
|
|
453
|
+
} : {}
|
|
454
|
+
}, r = (c = (h = this.props.style) == null ? void 0 : h.datum) == null ? void 0 : c.call(h, e);
|
|
455
|
+
return (s == null ? void 0 : s.customization.resolveMarkStyle(e, {
|
|
456
|
+
legacy: {
|
|
457
|
+
background: t.color ?? this.props.fill,
|
|
458
|
+
fill: t.color ?? this.props.fill,
|
|
459
|
+
opacity: this.props.opacity,
|
|
460
|
+
radius: this.props.radius,
|
|
461
|
+
borderRadius: this.props.radius
|
|
462
|
+
},
|
|
463
|
+
series: this.props.style,
|
|
464
|
+
part: (p = this.props.parts) == null ? void 0 : p.bar,
|
|
465
|
+
state: n,
|
|
466
|
+
datum: r
|
|
467
|
+
})) ?? {
|
|
468
|
+
background: o ? this.props.highlight.fill : t.color ?? this.props.fill,
|
|
469
|
+
opacity: o ? this.props.highlight.opacity : this.props.opacity,
|
|
470
|
+
strokeColor: o ? this.props.highlight.strokeColor : void 0,
|
|
471
|
+
strokeWidth: o ? this.props.highlight.strokeWidth : 0,
|
|
472
|
+
borderRadius: this.props.radius
|
|
473
|
+
};
|
|
474
|
+
}
|
|
475
|
+
_resolveLabelStyle(t, e) {
|
|
476
|
+
var s, o;
|
|
477
|
+
return (e == null ? void 0 : e.customization.resolveMarkStyle(t, {
|
|
478
|
+
legacy: {
|
|
479
|
+
color: this.props.labels.color,
|
|
480
|
+
fontFamily: this.props.fontFamily,
|
|
481
|
+
fontSize: this.props.labels.fontSize,
|
|
482
|
+
fontWeight: String(this.props.labels.fontWeight)
|
|
483
|
+
},
|
|
484
|
+
part: (s = this.props.parts) == null ? void 0 : s.barLabel,
|
|
485
|
+
state: (o = this.props.states) == null ? void 0 : o[t.state]
|
|
486
|
+
})) ?? {
|
|
487
|
+
color: this.props.labels.color,
|
|
488
|
+
fontSize: this.props.labels.fontSize,
|
|
489
|
+
fontWeight: String(this.props.labels.fontWeight)
|
|
490
|
+
};
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
function _() {
|
|
494
|
+
return typeof performance < "u" ? performance.now() : Date.now();
|
|
495
|
+
}
|
|
496
|
+
function b(a) {
|
|
497
|
+
let i = Number.POSITIVE_INFINITY, t = Number.NEGATIVE_INFINITY;
|
|
498
|
+
for (const e of a)
|
|
499
|
+
Number.isFinite(e) && (e < i && (i = e), e > t && (t = e));
|
|
500
|
+
return i === Number.POSITIVE_INFINITY ? [0, 1] : [i, t];
|
|
501
|
+
}
|
|
502
|
+
function $(a, i, t) {
|
|
503
|
+
return a === "horizontal" ? i === "inside" || i === "end" ? {
|
|
504
|
+
x: t.x + 4,
|
|
505
|
+
y: t.y + (t.height - 16) / 2,
|
|
506
|
+
width: Math.max(1, t.width - 8),
|
|
507
|
+
height: 16,
|
|
508
|
+
align: "right"
|
|
509
|
+
} : i === "center" ? {
|
|
510
|
+
x: t.x,
|
|
511
|
+
y: t.y + (t.height - 16) / 2,
|
|
512
|
+
width: Math.max(1, t.width),
|
|
513
|
+
height: 16,
|
|
514
|
+
align: "center"
|
|
515
|
+
} : {
|
|
516
|
+
x: t.x + t.width + 4,
|
|
517
|
+
y: t.y + (t.height - 16) / 2,
|
|
518
|
+
width: 72,
|
|
519
|
+
height: 16,
|
|
520
|
+
align: "left"
|
|
521
|
+
} : i === "inside" || i === "end" ? {
|
|
522
|
+
x: t.x,
|
|
523
|
+
y: t.y + 2,
|
|
524
|
+
width: t.width,
|
|
525
|
+
height: 16,
|
|
526
|
+
align: "center"
|
|
527
|
+
} : i === "center" ? {
|
|
528
|
+
x: t.x,
|
|
529
|
+
y: t.y + t.height / 2 - 16 / 2,
|
|
530
|
+
width: t.width,
|
|
531
|
+
height: 16,
|
|
532
|
+
align: "center"
|
|
533
|
+
} : {
|
|
534
|
+
x: t.x - 12,
|
|
535
|
+
y: t.y - 16 - 2,
|
|
536
|
+
width: t.width + 24,
|
|
537
|
+
height: 16,
|
|
538
|
+
align: "center"
|
|
539
|
+
};
|
|
540
|
+
}
|
|
541
|
+
const I = S((a, i) => new W(
|
|
542
|
+
a.app,
|
|
543
|
+
a.surface,
|
|
544
|
+
u(i.props),
|
|
545
|
+
{ componentId: i.id },
|
|
546
|
+
I
|
|
547
|
+
));
|
|
548
|
+
function H(a) {
|
|
549
|
+
a.register(I, { override: !0 });
|
|
550
|
+
}
|
|
551
|
+
const q = w({ kind: "bar", schemaType: "NovaCharts.BarSeries", register: H });
|
|
552
|
+
export {
|
|
553
|
+
q as BarChart
|
|
554
|
+
};
|
package/dist/brush.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { BrushState, ChartPlugin } from './api/types';
|
|
2
|
+
export interface BrushOptions {
|
|
3
|
+
id?: string;
|
|
4
|
+
axes?: ReadonlyArray<string>;
|
|
5
|
+
activation?: 'shift' | 'always';
|
|
6
|
+
color?: string;
|
|
7
|
+
}
|
|
8
|
+
export interface BrushPlugin extends ChartPlugin {
|
|
9
|
+
getBrush: () => BrushState;
|
|
10
|
+
setBrush: (value: BrushState) => void;
|
|
11
|
+
clear: () => void;
|
|
12
|
+
}
|
|
13
|
+
export declare const Brush: {
|
|
14
|
+
create: typeof createBrush;
|
|
15
|
+
};
|
|
16
|
+
declare function createBrush(options?: BrushOptions): BrushPlugin;
|
|
17
|
+
export {};
|
package/dist/brush.js
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { s as D } from "./state-C5pICb11.js";
|
|
2
|
+
const K = { create: j };
|
|
3
|
+
function j(b = {}) {
|
|
4
|
+
let h = null, a = null, r = null;
|
|
5
|
+
const M = () => {
|
|
6
|
+
var t, f;
|
|
7
|
+
r && ((f = h == null ? void 0 : (t = h.chart.canvas).hasPointerCapture) != null && f.call(t, r.id)) && h.chart.canvas.releasePointerCapture(r.id), r = null;
|
|
8
|
+
}, C = () => (h == null ? void 0 : h.chart.getViewState().brush) ?? { ranges: {} }, z = (t) => {
|
|
9
|
+
if (!h)
|
|
10
|
+
throw new Error("[Brush] Plugin is not attached");
|
|
11
|
+
h.request("brush", t);
|
|
12
|
+
};
|
|
13
|
+
return {
|
|
14
|
+
id: b.id ?? "brush",
|
|
15
|
+
getBrush: C,
|
|
16
|
+
setBrush: z,
|
|
17
|
+
clear: () => z({ ranges: {} }),
|
|
18
|
+
attach(t) {
|
|
19
|
+
if (h)
|
|
20
|
+
throw new Error("[Brush] Plugin is already attached");
|
|
21
|
+
if (!t.chart.getCapabilities().scales && !t.chart.getCapabilities().camera)
|
|
22
|
+
throw new Error("[Brush] Cartesian scales or a scene camera are required");
|
|
23
|
+
h = t;
|
|
24
|
+
const f = b.axes ?? (t.chart.getCapabilities().scales ? ["x"] : ["x", "y"]), u = (e) => t.chart.getCapabilities().scales ? t.axis(e) === "x" : e === "x", S = (e, s, n) => {
|
|
25
|
+
if (t.chart.getCapabilities().scales)
|
|
26
|
+
return t.map(e, s);
|
|
27
|
+
const i = t.chart.getViewState().camera, o = t.size();
|
|
28
|
+
return (u(e) ? o.width / 2 - i.center.x * i.zoom : o.height / 2 - i.center.y * i.zoom) + Number(s) * i.zoom;
|
|
29
|
+
}, P = (e, s, n) => {
|
|
30
|
+
if (t.chart.getCapabilities().scales)
|
|
31
|
+
return t.invert(e, s);
|
|
32
|
+
const i = t.chart.getViewState().camera, o = t.size();
|
|
33
|
+
return (s - (u(e) ? o.width : o.height) / 2) / i.zoom + (u(e) ? i.center.x : i.center.y);
|
|
34
|
+
};
|
|
35
|
+
a = t.overlay(() => {
|
|
36
|
+
const e = t.plotBounds();
|
|
37
|
+
let { x: s, y: n, width: i, height: o } = e;
|
|
38
|
+
if (r)
|
|
39
|
+
f.some(u) && (s = Math.min(r.start.x, r.current.x), i = Math.abs(r.current.x - r.start.x)), f.some((m) => !u(m)) && (n = Math.min(r.start.y, r.current.y), o = Math.abs(r.current.y - r.start.y));
|
|
40
|
+
else {
|
|
41
|
+
const m = C();
|
|
42
|
+
if (!Object.keys(m.ranges).length)
|
|
43
|
+
return [];
|
|
44
|
+
f.forEach((p, B) => {
|
|
45
|
+
const l = m.ranges[p];
|
|
46
|
+
if (!(l != null && l.length))
|
|
47
|
+
return;
|
|
48
|
+
const d = S(p, l[0]), c = S(p, l.at(-1));
|
|
49
|
+
u(p) ? (s = Math.min(d, c), i = Math.abs(c - d)) : (n = Math.min(d, c), o = Math.abs(c - d));
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
return [{ type: "rect", x: s, y: n, width: i, height: o, clip: e, styles: { background: b.color ?? "#388bcc", opacity: 0.15, border: { color: b.color ?? "#388bcc", width: 1 } } }];
|
|
53
|
+
});
|
|
54
|
+
const I = t.pointer((e, s) => {
|
|
55
|
+
var m, p, B, l;
|
|
56
|
+
const n = t.plotBounds(), i = s.x >= n.x && s.y >= n.y && s.x <= n.x + n.width && s.y <= n.y + n.height, o = { x: Math.max(n.x, Math.min(n.x + n.width, s.x)), y: Math.max(n.y, Math.min(n.y + n.height, s.y)) };
|
|
57
|
+
if (e.type === "pointerdown" && (b.activation === "always" || e.shiftKey)) {
|
|
58
|
+
if (!i)
|
|
59
|
+
return;
|
|
60
|
+
r = { id: e.pointerId, start: o, current: o }, (p = (m = t.chart.canvas).setPointerCapture) == null || p.call(m, e.pointerId), e.preventDefault(), a == null || a.invalidate();
|
|
61
|
+
} else if (r && r.id === e.pointerId && e.type === "pointermove")
|
|
62
|
+
r.current = o, e.preventDefault(), a == null || a.invalidate();
|
|
63
|
+
else if (r && r.id === e.pointerId && e.type === "pointerup") {
|
|
64
|
+
const d = Object.fromEntries(f.map((c, k) => {
|
|
65
|
+
var E;
|
|
66
|
+
const g = P(c, u(c) ? r.start.x : r.start.y), w = P(c, u(c) ? o.x : o.y);
|
|
67
|
+
if (typeof g == "number" && typeof w == "number")
|
|
68
|
+
return [c, [Math.min(g, w), Math.max(g, w)]];
|
|
69
|
+
const y = (E = t.chart.getViewState().viewport) == null ? void 0 : E.ranges[c];
|
|
70
|
+
if (!y)
|
|
71
|
+
throw new Error("[Brush] Categorical brush requires a band domain");
|
|
72
|
+
const x = y.indexOf(String(g)), q = y.indexOf(String(w));
|
|
73
|
+
return [c, y.slice(Math.min(x, q), Math.max(x, q) + 1)];
|
|
74
|
+
}));
|
|
75
|
+
M(), t.request("brush", { ranges: d }, "user"), e.preventDefault(), a == null || a.invalidate();
|
|
76
|
+
} else (r == null ? void 0 : r.id) === e.pointerId && (e.type === "pointercancel" || e.type === "pointerleave" && !((l = (B = t.chart.canvas).hasPointerCapture) != null && l.call(B, e.pointerId))) && (M(), a == null || a.invalidate());
|
|
77
|
+
}), O = t.chart.on("viewStateChange", () => a == null ? void 0 : a.invalidate()), V = t.port("brush", { read: C, write: (e, s) => t.request("brush", e, "sync", s), equals: D });
|
|
78
|
+
return () => {
|
|
79
|
+
M(), I(), O(), V(), a == null || a.dispose(), a = null, h = null, r = null;
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
export {
|
|
85
|
+
K as Brush
|
|
86
|
+
};
|
package/dist/bubble.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare const BubbleChart: {
|
|
2
|
+
series: <T = never, const S extends import('./public').SeriesOptions<never> = import('./public').SeriesOptions<T>>(options: S) => Omit<S, "type"> & {
|
|
3
|
+
readonly type: import('./public').CartesianKind;
|
|
4
|
+
};
|
|
5
|
+
mount<T>(target: string | HTMLElement, options: import('./public').CartesianOptions<T>): import('./public').CartesianHandle<T>;
|
|
6
|
+
attach<T>(target: import('./public').ChartAttachTarget, options: import('./public').CartesianOptions<T>): import('./public').CartesianHandle<T>;
|
|
7
|
+
};
|
|
8
|
+
export type { CartesianHandle as BubbleChartHandle, CartesianOptions as BubbleChartOptions, SeriesOptions as BubbleSeriesOptions } from './api/types';
|