minerva-design 1.1.0 → 1.2.0
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/CHANGELOG.md +8 -0
- package/dist/charts/canvas.d.cts +7 -0
- package/dist/charts/canvas.d.ts +7 -0
- package/dist/charts/core.cjs +1 -1
- package/dist/charts/core.d.cts +5 -1
- package/dist/charts/core.d.ts +5 -1
- package/dist/charts/core.js +4 -1
- package/dist/charts/engine/canvas.cjs +2 -0
- package/dist/charts/engine/canvas.cjs.map +1 -0
- package/dist/charts/engine/canvas.d.cts +85 -0
- package/dist/charts/engine/canvas.d.ts +85 -0
- package/dist/charts/engine/canvas.js +165 -0
- package/dist/charts/engine/canvas.js.map +1 -0
- package/dist/charts/engine/chart.cjs +2 -2
- package/dist/charts/engine/chart.cjs.map +1 -1
- package/dist/charts/engine/chart.js +382 -440
- package/dist/charts/engine/chart.js.map +1 -1
- package/dist/charts/engine/color.cjs +1 -1
- package/dist/charts/engine/color.cjs.map +1 -1
- package/dist/charts/engine/color.d.cts +10 -0
- package/dist/charts/engine/color.d.ts +10 -0
- package/dist/charts/engine/color.js +75 -3
- package/dist/charts/engine/color.js.map +1 -1
- package/dist/charts/engine/controller.cjs +3 -0
- package/dist/charts/engine/controller.cjs.map +1 -0
- package/dist/charts/engine/controller.d.cts +182 -0
- package/dist/charts/engine/controller.d.ts +182 -0
- package/dist/charts/engine/controller.js +528 -0
- package/dist/charts/engine/controller.js.map +1 -0
- package/dist/charts/engine/model.cjs +1 -1
- package/dist/charts/engine/model.cjs.map +1 -1
- package/dist/charts/engine/model.d.cts +2 -2
- package/dist/charts/engine/model.d.ts +2 -2
- package/dist/charts/engine/model.js +72 -72
- package/dist/charts/engine/model.js.map +1 -1
- package/dist/charts/engine/overlay.cjs +1 -1
- package/dist/charts/engine/overlay.cjs.map +1 -1
- package/dist/charts/engine/overlay.d.cts +17 -1
- package/dist/charts/engine/overlay.d.ts +17 -1
- package/dist/charts/engine/overlay.js +63 -49
- package/dist/charts/engine/overlay.js.map +1 -1
- package/dist/charts/engine/presets.cjs +3 -0
- package/dist/charts/engine/presets.cjs.map +1 -0
- package/dist/charts/engine/presets.d.cts +103 -0
- package/dist/charts/engine/presets.d.ts +103 -0
- package/dist/charts/engine/presets.js +153 -0
- package/dist/charts/engine/presets.js.map +1 -0
- package/dist/charts/engine/renderers/canvas2d.cjs +1 -1
- package/dist/charts/engine/renderers/canvas2d.cjs.map +1 -1
- package/dist/charts/engine/renderers/canvas2d.d.cts +17 -1
- package/dist/charts/engine/renderers/canvas2d.d.ts +17 -1
- package/dist/charts/engine/renderers/canvas2d.js +88 -51
- package/dist/charts/engine/renderers/canvas2d.js.map +1 -1
- package/dist/charts/engine/scene.cjs +2 -0
- package/dist/charts/engine/scene.cjs.map +1 -0
- package/dist/charts/engine/scene.d.cts +89 -0
- package/dist/charts/engine/scene.d.ts +89 -0
- package/dist/charts/engine/scene.js +241 -0
- package/dist/charts/engine/scene.js.map +1 -0
- package/dist/charts/engine/theme.cjs +1 -1
- package/dist/charts/engine/theme.cjs.map +1 -1
- package/dist/charts/engine/theme.d.cts +25 -1
- package/dist/charts/engine/theme.d.ts +25 -1
- package/dist/charts/engine/theme.js +42 -26
- package/dist/charts/engine/theme.js.map +1 -1
- package/dist/charts/engine/types.d.cts +69 -2
- package/dist/charts/engine/types.d.ts +69 -2
- package/dist/charts/index.cjs +1 -1
- package/dist/charts/index.d.cts +1 -1
- package/dist/charts/index.d.ts +1 -1
- package/dist/charts/index.js +5 -2
- package/dist/charts/react/Chart.cjs +1 -1
- package/dist/charts/react/Chart.cjs.map +1 -1
- package/dist/charts/react/Chart.d.cts +11 -4
- package/dist/charts/react/Chart.d.ts +11 -4
- package/dist/charts/react/Chart.js +81 -39
- package/dist/charts/react/Chart.js.map +1 -1
- package/dist/charts/react/charts.cjs +1 -1
- package/dist/charts/react/charts.cjs.map +1 -1
- package/dist/charts/react/charts.d.cts +1 -1
- package/dist/charts/react/charts.d.ts +1 -1
- package/dist/charts/react/charts.js +99 -145
- package/dist/charts/react/charts.js.map +1 -1
- package/dist/charts/react/types.d.cts +29 -61
- package/dist/charts/react/types.d.ts +29 -61
- package/dist/native/charts/src/canvas.cjs +1 -0
- package/dist/native/charts/src/canvas.js +6 -0
- package/dist/native/charts/src/engine/axis.cjs +2 -0
- package/dist/native/charts/src/engine/axis.cjs.map +1 -0
- package/dist/native/charts/src/engine/axis.js +38 -0
- package/dist/native/charts/src/engine/axis.js.map +1 -0
- package/dist/native/charts/src/engine/canvas.cjs +1 -0
- package/dist/native/charts/src/engine/canvas.js +1 -0
- package/dist/native/charts/src/engine/color.cjs +2 -0
- package/dist/native/charts/src/engine/color.cjs.map +1 -0
- package/dist/native/charts/src/engine/color.js +130 -0
- package/dist/native/charts/src/engine/color.js.map +1 -0
- package/dist/native/charts/src/engine/controller.cjs +3 -0
- package/dist/native/charts/src/engine/controller.cjs.map +1 -0
- package/dist/native/charts/src/engine/controller.js +528 -0
- package/dist/native/charts/src/engine/controller.js.map +1 -0
- package/dist/native/charts/src/engine/data.cjs +2 -0
- package/dist/native/charts/src/engine/data.cjs.map +1 -0
- package/dist/native/charts/src/engine/data.js +104 -0
- package/dist/native/charts/src/engine/data.js.map +1 -0
- package/dist/native/charts/src/engine/decimate.cjs +2 -0
- package/dist/native/charts/src/engine/decimate.cjs.map +1 -0
- package/dist/native/charts/src/engine/decimate.js +28 -0
- package/dist/native/charts/src/engine/decimate.js.map +1 -0
- package/dist/native/charts/src/engine/format.cjs +2 -0
- package/dist/native/charts/src/engine/format.cjs.map +1 -0
- package/dist/native/charts/src/engine/format.js +34 -0
- package/dist/native/charts/src/engine/format.js.map +1 -0
- package/dist/native/charts/src/engine/layout.cjs +2 -0
- package/dist/native/charts/src/engine/layout.cjs.map +1 -0
- package/dist/native/charts/src/engine/layout.js +26 -0
- package/dist/native/charts/src/engine/layout.js.map +1 -0
- package/dist/native/charts/src/engine/model.cjs +2 -0
- package/dist/native/charts/src/engine/model.cjs.map +1 -0
- package/dist/native/charts/src/engine/model.js +175 -0
- package/dist/native/charts/src/engine/model.js.map +1 -0
- package/dist/native/charts/src/engine/overlay.cjs +2 -0
- package/dist/native/charts/src/engine/overlay.cjs.map +1 -0
- package/dist/native/charts/src/engine/overlay.js +49 -0
- package/dist/native/charts/src/engine/overlay.js.map +1 -0
- package/dist/native/charts/src/engine/presets.cjs +3 -0
- package/dist/native/charts/src/engine/presets.cjs.map +1 -0
- package/dist/native/charts/src/engine/presets.js +147 -0
- package/dist/native/charts/src/engine/presets.js.map +1 -0
- package/dist/native/charts/src/engine/scale.cjs +2 -0
- package/dist/native/charts/src/engine/scale.cjs.map +1 -0
- package/dist/native/charts/src/engine/scale.js +37 -0
- package/dist/native/charts/src/engine/scale.js.map +1 -0
- package/dist/native/charts/src/engine/scene.cjs +2 -0
- package/dist/native/charts/src/engine/scene.cjs.map +1 -0
- package/dist/native/charts/src/engine/scene.js +241 -0
- package/dist/native/charts/src/engine/scene.js.map +1 -0
- package/dist/native/charts/src/engine/spatial.cjs +2 -0
- package/dist/native/charts/src/engine/spatial.cjs.map +1 -0
- package/dist/native/charts/src/engine/spatial.js +53 -0
- package/dist/native/charts/src/engine/spatial.js.map +1 -0
- package/dist/native/charts/src/engine/theme.cjs +2 -0
- package/dist/native/charts/src/engine/theme.cjs.map +1 -0
- package/dist/native/charts/src/engine/theme.js +62 -0
- package/dist/native/charts/src/engine/theme.js.map +1 -0
- package/dist/native/charts/src/engine/time.cjs +2 -0
- package/dist/native/charts/src/engine/time.cjs.map +1 -0
- package/dist/native/charts/src/engine/time.js +189 -0
- package/dist/native/charts/src/engine/time.js.map +1 -0
- package/dist/native/charts/src/engine/viewport.cjs +2 -0
- package/dist/native/charts/src/engine/viewport.cjs.map +1 -0
- package/dist/native/charts/src/engine/viewport.js +12 -0
- package/dist/native/charts/src/engine/viewport.js.map +1 -0
- package/dist/native/components/Chart/ChartBase.cjs +2 -0
- package/dist/native/components/Chart/ChartBase.cjs.map +1 -0
- package/dist/native/components/Chart/ChartBase.d.cts +29 -0
- package/dist/native/components/Chart/ChartBase.d.ts +29 -0
- package/dist/native/components/Chart/ChartBase.js +287 -0
- package/dist/native/components/Chart/ChartBase.js.map +1 -0
- package/dist/native/components/Chart/charts.cjs +2 -0
- package/dist/native/components/Chart/charts.cjs.map +1 -0
- package/dist/native/components/Chart/charts.d.cts +19 -0
- package/dist/native/components/Chart/charts.d.ts +19 -0
- package/dist/native/components/Chart/charts.js +173 -0
- package/dist/native/components/Chart/charts.js.map +1 -0
- package/dist/native/components/Chart/index.cjs +1 -0
- package/dist/native/components/Chart/index.d.cts +2 -0
- package/dist/native/components/Chart/index.d.ts +2 -0
- package/dist/native/components/Chart/index.js +2 -0
- package/dist/native/components/Chart/measure.cjs +2 -0
- package/dist/native/components/Chart/measure.cjs.map +1 -0
- package/dist/native/components/Chart/measure.d.cts +5 -0
- package/dist/native/components/Chart/measure.d.ts +5 -0
- package/dist/native/components/Chart/measure.js +11 -0
- package/dist/native/components/Chart/measure.js.map +1 -0
- package/dist/native/components/Chart/scene.cjs +2 -0
- package/dist/native/components/Chart/scene.cjs.map +1 -0
- package/dist/native/components/Chart/scene.d.cts +41 -0
- package/dist/native/components/Chart/scene.d.ts +41 -0
- package/dist/native/components/Chart/scene.js +419 -0
- package/dist/native/components/Chart/scene.js.map +1 -0
- package/dist/native/components/Chart/theme.cjs +2 -0
- package/dist/native/components/Chart/theme.cjs.map +1 -0
- package/dist/native/components/Chart/theme.d.cts +10 -0
- package/dist/native/components/Chart/theme.d.ts +10 -0
- package/dist/native/components/Chart/theme.js +10 -0
- package/dist/native/components/Chart/theme.js.map +1 -0
- package/dist/native/components/Chart/types.d.cts +129 -0
- package/dist/native/components/Chart/types.d.ts +129 -0
- package/dist/native/index.cjs +1 -1
- package/dist/native/index.d.cts +1 -0
- package/dist/native/index.d.ts +1 -0
- package/dist/native/index.js +6 -4
- package/dist/native/manifest.d.cts +7 -0
- package/dist/native/manifest.d.ts +7 -0
- package/dist/native/source/components/Chart/ChartBase.tsx +545 -0
- package/dist/native/source/components/Chart/charts.tsx +291 -0
- package/dist/native/source/components/Chart/index.ts +8 -0
- package/dist/native/source/components/Chart/measure.ts +50 -0
- package/dist/native/source/components/Chart/scene.tsx +987 -0
- package/dist/native/source/components/Chart/theme.ts +16 -0
- package/dist/native/source/components/Chart/types.ts +194 -0
- package/dist/native/source/index.ts +1 -0
- package/dist/native/source/manifest.ts +14 -0
- package/dist/taro/charts.d.ts +144 -0
- package/dist/taro/index.d.ts +1 -0
- package/dist/taro/index.js +3064 -618
- package/dist/uni/BarChart.vue +75 -0
- package/dist/uni/BarChart.vue.d.ts +111 -0
- package/dist/uni/Chart.vue +68 -0
- package/dist/uni/Chart.vue.d.ts +100 -0
- package/dist/uni/LineChart.vue +75 -0
- package/dist/uni/LineChart.vue.d.ts +111 -0
- package/dist/uni/ProgressIndicator.vue.d.ts +1 -1
- package/dist/uni/QuadrantChart.vue +184 -0
- package/dist/uni/QuadrantChart.vue.d.ts +173 -0
- package/dist/uni/ScatterChart.vue +69 -0
- package/dist/uni/ScatterChart.vue.d.ts +100 -0
- package/dist/uni/chart-canvas.d.ts +68 -0
- package/dist/uni/chart-canvas.js +363 -0
- package/dist/uni/chart-types.d.ts +135 -0
- package/dist/uni/chart-types.js +84 -0
- package/dist/uni/charts-canvas.d.ts +1 -0
- package/dist/uni/charts-canvas.js +8 -0
- package/dist/uni/index.d.ts +6 -0
- package/dist/uni/index.js +6 -0
- package/dist/weapp/bar-chart/index.js +1 -0
- package/dist/weapp/bar-chart/index.json +1 -0
- package/dist/weapp/bar-chart/index.wxml +1 -0
- package/dist/weapp/bar-chart/index.wxss +1 -0
- package/dist/weapp/chart/index.js +1 -0
- package/dist/weapp/chart/index.json +1 -0
- package/dist/weapp/chart/index.wxml +1 -0
- package/dist/weapp/chart/index.wxss +1 -0
- package/dist/weapp/controls.js +4019 -266
- package/dist/weapp/line-chart/index.js +1 -0
- package/dist/weapp/line-chart/index.json +1 -0
- package/dist/weapp/line-chart/index.wxml +1 -0
- package/dist/weapp/line-chart/index.wxss +1 -0
- package/dist/weapp/quadrant-chart/index.js +1 -0
- package/dist/weapp/quadrant-chart/index.json +1 -0
- package/dist/weapp/quadrant-chart/index.wxml +1 -0
- package/dist/weapp/quadrant-chart/index.wxss +1 -0
- package/dist/weapp/scatter-chart/index.js +1 -0
- package/dist/weapp/scatter-chart/index.json +1 -0
- package/dist/weapp/scatter-chart/index.wxml +1 -0
- package/dist/weapp/scatter-chart/index.wxss +1 -0
- package/dist/weapp/types.d.ts +295 -0
- package/package.json +21 -1
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { ChartBase as e, engineOptions as t } from "./Chart.js";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { barSeries as n, lineSeries as r, quadrantChartOptions as i, quadrantOf as a, scatterSeries as o } from "../engine/presets.js";
|
|
4
|
+
import { useMemo as s } from "react";
|
|
5
|
+
import { jsx as c } from "react/jsx-runtime";
|
|
5
6
|
//#region src/react/charts.tsx
|
|
6
|
-
var
|
|
7
|
-
...e,
|
|
8
|
-
type: e.type ?? t,
|
|
9
|
-
...n !== void 0 && (e.type ?? t) === "bar" ? { stack: e.stack ?? n } : {}
|
|
10
|
-
})), a = (e) => ({
|
|
7
|
+
var l = (e) => ({
|
|
11
8
|
height: e.height,
|
|
12
9
|
width: e.width,
|
|
13
10
|
className: e.className,
|
|
@@ -15,165 +12,122 @@ var i = (e, t, n) => e.map((e) => ({
|
|
|
15
12
|
handleRef: e.ref,
|
|
16
13
|
onHover: e.onHover,
|
|
17
14
|
onPointClick: e.onPointClick,
|
|
15
|
+
onPlotClick: e.onPlotClick,
|
|
18
16
|
onZoom: e.onZoom,
|
|
19
|
-
onRendererChange: e.onRendererChange
|
|
17
|
+
onRendererChange: e.onRendererChange,
|
|
18
|
+
renderTooltip: e.renderTooltip
|
|
20
19
|
});
|
|
21
|
-
function
|
|
22
|
-
let { series:
|
|
23
|
-
return /* @__PURE__ */
|
|
20
|
+
function u(n) {
|
|
21
|
+
let { series: i, area: a = !1 } = n, o = s(() => r(i, a), [i, a]);
|
|
22
|
+
return /* @__PURE__ */ c(e, {
|
|
24
23
|
options: t({
|
|
25
|
-
...
|
|
26
|
-
series:
|
|
24
|
+
...n,
|
|
25
|
+
series: o
|
|
27
26
|
}),
|
|
28
|
-
...
|
|
27
|
+
...l(n)
|
|
29
28
|
});
|
|
30
29
|
}
|
|
31
|
-
function
|
|
32
|
-
let { series:
|
|
33
|
-
return /* @__PURE__ */
|
|
30
|
+
function d(r) {
|
|
31
|
+
let { series: i, stacked: a = !1 } = r, o = s(() => n(i, a), [i, a]);
|
|
32
|
+
return /* @__PURE__ */ c(e, {
|
|
34
33
|
options: t({
|
|
35
|
-
...
|
|
36
|
-
series:
|
|
34
|
+
...r,
|
|
35
|
+
series: o
|
|
37
36
|
}),
|
|
38
|
-
...
|
|
37
|
+
...l(r)
|
|
39
38
|
});
|
|
40
39
|
}
|
|
41
|
-
function
|
|
42
|
-
let { series:
|
|
43
|
-
return /* @__PURE__ */
|
|
40
|
+
function f(n) {
|
|
41
|
+
let { series: r } = n, i = s(() => o(r), [r]);
|
|
42
|
+
return /* @__PURE__ */ c(e, {
|
|
44
43
|
options: t({
|
|
45
|
-
...
|
|
46
|
-
series:
|
|
44
|
+
...n,
|
|
45
|
+
series: i
|
|
47
46
|
}),
|
|
48
|
-
...
|
|
47
|
+
...l(n)
|
|
49
48
|
});
|
|
50
49
|
}
|
|
51
|
-
var
|
|
52
|
-
topLeft
|
|
53
|
-
topRight
|
|
54
|
-
bottomLeft
|
|
55
|
-
bottomRight
|
|
50
|
+
var p = [
|
|
51
|
+
"topLeft",
|
|
52
|
+
"topRight",
|
|
53
|
+
"bottomLeft",
|
|
54
|
+
"bottomRight"
|
|
55
|
+
], m = (e, t, n) => {
|
|
56
|
+
let r = e.endsWith("Left"), i = e.startsWith("top");
|
|
57
|
+
return {
|
|
58
|
+
position: "absolute",
|
|
59
|
+
left: r ? 0 : n.x - t.x,
|
|
60
|
+
top: i ? 0 : n.y - t.y,
|
|
61
|
+
width: r ? n.x - t.x : t.x + t.width - n.x,
|
|
62
|
+
height: i ? n.y - t.y : t.y + t.height - n.y,
|
|
63
|
+
pointerEvents: "none"
|
|
64
|
+
};
|
|
56
65
|
};
|
|
57
|
-
function
|
|
58
|
-
let { points:
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
66
|
+
function h(n) {
|
|
67
|
+
let { points: r, xDomain: o, yDomain: s, xSplit: u, ySplit: d, quadrants: f, xLabel: h, yLabel: g, axisLabels: _, showTicks: v, reverseX: y, showLabels: b, pointSize: x, name: S, draggable: C, onPointClick: w, onPointDrop: T, onQuadrantClick: E, renderTooltip: D, quadrantContent: O } = n, k = {
|
|
68
|
+
xDomain: o,
|
|
69
|
+
yDomain: s,
|
|
70
|
+
xSplit: u,
|
|
71
|
+
ySplit: d,
|
|
72
|
+
reverseX: y
|
|
73
|
+
}, A = i({
|
|
74
|
+
points: r,
|
|
75
|
+
xDomain: o,
|
|
76
|
+
yDomain: s,
|
|
77
|
+
xSplit: u,
|
|
78
|
+
ySplit: d,
|
|
79
|
+
quadrants: f,
|
|
80
|
+
xLabel: h,
|
|
81
|
+
yLabel: g,
|
|
82
|
+
axisLabels: _,
|
|
83
|
+
showTicks: v,
|
|
84
|
+
reverseX: y,
|
|
85
|
+
showLabels: b,
|
|
86
|
+
pointSize: x,
|
|
87
|
+
name: S,
|
|
88
|
+
draggable: C ?? !!T
|
|
89
|
+
}, t({
|
|
90
|
+
...n,
|
|
91
|
+
series: []
|
|
92
|
+
})), j = O ? (e) => {
|
|
93
|
+
let [t, n] = o ?? [0, 10], [r, i] = s ?? [0, 10], a = u ?? (t + n) / 2, l = d ?? (r + i) / 2, f = (a - t) / (n - t || 1), h = (l - r) / (i - r || 1), g = {
|
|
94
|
+
x: e.x + e.width * (y ? 1 - f : f),
|
|
95
|
+
y: e.y + e.height * (1 - h)
|
|
68
96
|
};
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
x: t.x,
|
|
82
|
-
y: t.y,
|
|
83
|
-
label: t.label,
|
|
84
|
-
size: t.size,
|
|
85
|
-
color: t.color ?? E[e(t.x, t.y)].color
|
|
86
|
-
}))
|
|
87
|
-
}];
|
|
88
|
-
}, [
|
|
89
|
-
o,
|
|
90
|
-
E,
|
|
91
|
-
h,
|
|
92
|
-
w,
|
|
93
|
-
T,
|
|
94
|
-
v,
|
|
95
|
-
_,
|
|
96
|
-
g
|
|
97
|
-
]), O = n(() => {
|
|
98
|
-
let e = h ? [w, x] : [b, w], t = h ? [b, w] : [w, x], n = (e, [t, n], [r, i], a) => ({
|
|
99
|
-
type: "rect",
|
|
100
|
-
x0: t,
|
|
101
|
-
x1: n,
|
|
102
|
-
y0: r,
|
|
103
|
-
y1: i,
|
|
104
|
-
color: E[e].color,
|
|
105
|
-
opacity: .07,
|
|
106
|
-
label: E[e].label,
|
|
107
|
-
labelPosition: a
|
|
108
|
-
});
|
|
109
|
-
return [
|
|
110
|
-
n("topLeft", e, [T, C], "top-left"),
|
|
111
|
-
n("topRight", t, [T, C], "top-right"),
|
|
112
|
-
n("bottomLeft", e, [S, T], "bottom-left"),
|
|
113
|
-
n("bottomRight", t, [S, T], "bottom-right"),
|
|
114
|
-
{
|
|
115
|
-
type: "line",
|
|
116
|
-
axis: "x",
|
|
117
|
-
value: w,
|
|
118
|
-
dash: [],
|
|
119
|
-
color: "var(--border-strong-color, var(--border-color, #cbd5e1))"
|
|
120
|
-
},
|
|
121
|
-
{
|
|
122
|
-
type: "line",
|
|
123
|
-
axis: "y",
|
|
124
|
-
value: T,
|
|
125
|
-
dash: [],
|
|
126
|
-
color: "var(--border-strong-color, var(--border-color, #cbd5e1))"
|
|
127
|
-
},
|
|
128
|
-
...i.annotations ?? []
|
|
129
|
-
];
|
|
130
|
-
}, [
|
|
131
|
-
E,
|
|
132
|
-
h,
|
|
133
|
-
b,
|
|
134
|
-
x,
|
|
135
|
-
S,
|
|
136
|
-
C,
|
|
137
|
-
w,
|
|
138
|
-
T,
|
|
139
|
-
i.annotations
|
|
140
|
-
]), k = t({
|
|
141
|
-
...i,
|
|
142
|
-
series: D,
|
|
143
|
-
annotations: O,
|
|
144
|
-
xAxis: {
|
|
145
|
-
min: b,
|
|
146
|
-
max: x,
|
|
147
|
-
title: p,
|
|
148
|
-
reverse: h,
|
|
149
|
-
nice: !1,
|
|
150
|
-
grid: !1,
|
|
151
|
-
tickCount: 4
|
|
152
|
-
},
|
|
153
|
-
yAxis: {
|
|
154
|
-
min: S,
|
|
155
|
-
max: C,
|
|
156
|
-
title: m,
|
|
157
|
-
nice: !1,
|
|
158
|
-
grid: !1,
|
|
159
|
-
tickCount: 4
|
|
160
|
-
},
|
|
161
|
-
legend: i.legend ?? !1,
|
|
162
|
-
interaction: i.interaction ?? { zoom: !1 }
|
|
163
|
-
});
|
|
164
|
-
return /* @__PURE__ */ r(e, {
|
|
165
|
-
options: k,
|
|
166
|
-
...a({
|
|
167
|
-
...i,
|
|
168
|
-
onPointClick: void 0
|
|
97
|
+
return p.map((t) => O[t] ? /* @__PURE__ */ c("div", {
|
|
98
|
+
className: `minerva-chart-quadrant minerva-chart-quadrant-${t}`,
|
|
99
|
+
style: m(t, e, g),
|
|
100
|
+
children: O[t]
|
|
101
|
+
}, t) : null);
|
|
102
|
+
} : void 0;
|
|
103
|
+
return /* @__PURE__ */ c(e, {
|
|
104
|
+
options: A,
|
|
105
|
+
...l({
|
|
106
|
+
...n,
|
|
107
|
+
onPointClick: void 0,
|
|
108
|
+
renderTooltip: void 0
|
|
169
109
|
}),
|
|
170
|
-
|
|
110
|
+
overlay: j,
|
|
111
|
+
onPointClick: w ? (e) => {
|
|
112
|
+
let t = e.items[0]?.index;
|
|
113
|
+
t !== void 0 && r[t] && w(r[t], t);
|
|
114
|
+
} : void 0,
|
|
115
|
+
onPlotClick: E ? (e) => E(a(k, e.x, e.y), e) : void 0,
|
|
116
|
+
onDrop: T ? (e) => {
|
|
117
|
+
let t = e.item.index;
|
|
118
|
+
r[t] && T(r[t], t, {
|
|
119
|
+
x: e.x,
|
|
120
|
+
y: e.y,
|
|
121
|
+
quadrant: a(k, e.x, e.y)
|
|
122
|
+
});
|
|
123
|
+
} : void 0,
|
|
124
|
+
renderTooltip: D ? (e) => {
|
|
171
125
|
let t = e.items[0]?.index;
|
|
172
|
-
t !== void 0 &&
|
|
126
|
+
return t !== void 0 && r[t] ? D(r[t], t) : null;
|
|
173
127
|
} : void 0
|
|
174
128
|
});
|
|
175
129
|
}
|
|
176
130
|
//#endregion
|
|
177
|
-
export {
|
|
131
|
+
export { d as BarChart, u as LineChart, h as QuadrantChart, f as ScatterChart };
|
|
178
132
|
|
|
179
133
|
//# sourceMappingURL=charts.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"charts.js","names":["withType","series","s","type","stack","frameProps","props","LineChart","input","useMemo","area","ChartBase","engineOptions","BarChart","stacked","ScatterChart","DEFAULT_QUADRANT_COLORS","QuadrantChart","x0","x1","xDomain","y0","y1","yDomain","xs","xSplit","ys","ySplit","regions","region","quadrants","corner","cornerOf","right","reverseX","x","y","name","points","p","pointSize","showLabels","annotations","left","rect","xa","xb","ya","yb","position","options","xLabel","yLabel","onPointClick","index","event"],"sources":["../../../../charts/src/react/charts.tsx"],"sourcesContent":["import { useMemo } from \"react\";\nimport type {\n ChartAnnotation,\n ChartSeries,\n ChartSeriesType,\n} from \"../engine/types\";\nimport { ChartBase, engineOptions } from \"./Chart\";\nimport type {\n BarChartProps,\n ChartCommonProps,\n LineChartProps,\n QuadrantChartProps,\n QuadrantRegion,\n ScatterChartProps,\n} from \"./types\";\n\nconst withType = (\n series: readonly ChartSeries[],\n type: ChartSeriesType,\n stack?: string,\n): ChartSeries[] =>\n series.map((s) => ({\n ...s,\n type: s.type ?? type,\n ...(stack !== undefined && (s.type ?? type) === \"bar\"\n ? { stack: s.stack ?? stack }\n : {}),\n }));\n\nconst frameProps = (props: ChartCommonProps) => ({\n height: props.height,\n width: props.width,\n className: props.className,\n style: props.style,\n handleRef: props.ref,\n onHover: props.onHover,\n onPointClick: props.onPointClick,\n onZoom: props.onZoom,\n onRendererChange: props.onRendererChange,\n});\n\n/** Line (or area) chart; handles millions of points on the GPU */\nexport function LineChart(props: LineChartProps) {\n const { series: input, area = false } = props;\n const series = useMemo(\n () => withType(input, area ? \"area\" : \"line\"),\n [input, area],\n );\n return (\n <ChartBase\n options={engineOptions({ ...props, series })}\n {...frameProps(props)}\n />\n );\n}\n\n/** Bar chart: grouped side by side, or stacked */\nexport function BarChart(props: BarChartProps) {\n const { series: input, stacked = false } = props;\n const series = useMemo(\n () => withType(input, \"bar\", stacked ? \"stack\" : undefined),\n [input, stacked],\n );\n return (\n <ChartBase\n options={engineOptions({ ...props, series })}\n {...frameProps(props)}\n />\n );\n}\n\n/** Scatter chart: zooms on both axes, hit testing through a spatial index */\nexport function ScatterChart(props: ScatterChartProps) {\n const { series: input } = props;\n const series = useMemo(() => withType(input, \"scatter\"), [input]);\n return (\n <ChartBase\n options={engineOptions({ ...props, series })}\n {...frameProps(props)}\n />\n );\n}\n\nconst DEFAULT_QUADRANT_COLORS = {\n topLeft: \"var(--danger-color, #ef4444)\",\n topRight: \"var(--primary-color, #4f46e5)\",\n bottomLeft: \"var(--warning-color, #f59e0b)\",\n bottomRight: \"var(--text-secondary-color, #64748b)\",\n} as const;\n\ntype Corner = keyof typeof DEFAULT_QUADRANT_COLORS;\n\n/**\n * Four-quadrant matrix (priority matrix, Eisenhower, BCG, ...): tinted\n * quadrants with titles, dividers, and labelled dots placed without\n * overlapping labels.\n */\nexport function QuadrantChart(props: QuadrantChartProps) {\n const {\n points,\n xDomain = [0, 10],\n yDomain = [0, 10],\n xSplit,\n ySplit,\n quadrants,\n xLabel,\n yLabel,\n reverseX = false,\n showLabels = true,\n pointSize = 12,\n name,\n onPointClick,\n } = props;\n const [x0, x1] = xDomain;\n const [y0, y1] = yDomain;\n const xs = xSplit ?? (x0 + x1) / 2;\n const ys = ySplit ?? (y0 + y1) / 2;\n\n const regions = useMemo(() => {\n const region = (\n corner: Corner,\n ): Required<Pick<QuadrantRegion, \"color\">> & QuadrantRegion => ({\n ...quadrants?.[corner],\n color: quadrants?.[corner]?.color ?? DEFAULT_QUADRANT_COLORS[corner],\n });\n return {\n topLeft: region(\"topLeft\"),\n topRight: region(\"topRight\"),\n bottomLeft: region(\"bottomLeft\"),\n bottomRight: region(\"bottomRight\"),\n };\n }, [quadrants]);\n\n const series = useMemo((): ChartSeries[] => {\n const cornerOf = (x: number, y: number): Corner => {\n const right = reverseX ? x < xs : x >= xs;\n const top = y >= ys;\n return top\n ? right\n ? \"topRight\"\n : \"topLeft\"\n : right\n ? \"bottomRight\"\n : \"bottomLeft\";\n };\n return [\n {\n type: \"scatter\",\n name: name ?? \"\",\n pointSize,\n showLabels,\n opacity: 0.9,\n data: points.map((p) => ({\n x: p.x,\n y: p.y,\n label: p.label,\n size: p.size,\n color: p.color ?? regions[cornerOf(p.x, p.y)].color,\n })),\n },\n ];\n }, [points, regions, reverseX, xs, ys, name, pointSize, showLabels]);\n\n const annotations = useMemo((): ChartAnnotation[] => {\n // visual left / right -> data ranges\n const left: [number, number] = reverseX ? [xs, x1] : [x0, xs];\n const right: [number, number] = reverseX ? [x0, xs] : [xs, x1];\n const rect = (\n corner: Corner,\n [xa, xb]: [number, number],\n [ya, yb]: [number, number],\n position: \"top-left\" | \"top-right\" | \"bottom-left\" | \"bottom-right\",\n ): ChartAnnotation => ({\n type: \"rect\",\n x0: xa,\n x1: xb,\n y0: ya,\n y1: yb,\n color: regions[corner].color,\n opacity: 0.07,\n label: regions[corner].label,\n labelPosition: position,\n });\n return [\n rect(\"topLeft\", left, [ys, y1], \"top-left\"),\n rect(\"topRight\", right, [ys, y1], \"top-right\"),\n rect(\"bottomLeft\", left, [y0, ys], \"bottom-left\"),\n rect(\"bottomRight\", right, [y0, ys], \"bottom-right\"),\n {\n type: \"line\",\n axis: \"x\",\n value: xs,\n dash: [],\n color: \"var(--border-strong-color, var(--border-color, #cbd5e1))\",\n },\n {\n type: \"line\",\n axis: \"y\",\n value: ys,\n dash: [],\n color: \"var(--border-strong-color, var(--border-color, #cbd5e1))\",\n },\n ...(props.annotations ?? []),\n ];\n }, [regions, reverseX, x0, x1, y0, y1, xs, ys, props.annotations]);\n\n const options = engineOptions({\n ...props,\n series,\n annotations,\n xAxis: {\n min: x0,\n max: x1,\n title: xLabel,\n reverse: reverseX,\n nice: false,\n grid: false,\n tickCount: 4,\n },\n yAxis: {\n min: y0,\n max: y1,\n title: yLabel,\n nice: false,\n grid: false,\n tickCount: 4,\n },\n legend: props.legend ?? false,\n interaction: props.interaction ?? { zoom: false },\n });\n\n return (\n <ChartBase\n options={options}\n {...frameProps({ ...props, onPointClick: undefined })}\n onPointClick={\n onPointClick\n ? (event) => {\n const index = event.items[0]?.index;\n if (index !== undefined && points[index])\n onPointClick(points[index], index);\n }\n : undefined\n }\n />\n );\n}\n"],"mappings":";;;;;AAgBA,IAAMA,KACJ,GACA,GACA,MAEAC,EAAO,KAAK,OAAO;CACjB,GAAGC;CACH,MAAMA,EAAE,QAAQC;CAChB,GAAIC,MAAU,KAAA,MAAcF,EAAE,QAAQC,OAAU,QAC5C,EAAE,OAAOD,EAAE,SAASE,EAAM,IAC1B,CAAC;AACP,EAAE,GAEEC,KAAc,OAA6B;CAC/C,QAAQC,EAAM;CACd,OAAOA,EAAM;CACb,WAAWA,EAAM;CACjB,OAAOA,EAAM;CACb,WAAWA,EAAM;CACjB,SAASA,EAAM;CACf,cAAcA,EAAM;CACpB,QAAQA,EAAM;CACd,kBAAkB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,GAAIJ,CAAE,GAAG,WAAW;GAC7CsB,EAAK,cAAcD,GAAM,CAACtB,GAAIK,CAAE,GAAG,aAAa;GAChDkB,EAAK,eAAeX,GAAO,CAACZ,GAAIK,CAAE,GAAG,cAAc;GACnD;IACE,MAAM;IACN,MAAM;IACN,OAAOF;IACP,MAAM,CAAC;IACP,OAAO;GACT;GACA;IACE,MAAM;IACN,MAAM;IACN,OAAOE;IACP,MAAM,CAAC;IACP,OAAO;GACT;GACA,GAAIpB,EAAM,eAAe,CAAC;EAC5B;CACF,GAAG;EAACsB;EAASM;EAAUhB;EAAIC;EAAIE;EAAIC;EAAIE;EAAIE;EAAIpB,EAAM;CAAW,CAAC,GAE3D4C,IAAUtC,EAAc;EAC5B,GAAGN;EACH;EACA;EACA,OAAO;GACL,KAAKY;GACL,KAAKC;GACL,OAAOgC;GACP,SAASjB;GACT,MAAM;GACN,MAAM;GACN,WAAW;EACb;EACA,OAAO;GACL,KAAKb;GACL,KAAKC;GACL,OAAO8B;GACP,MAAM;GACN,MAAM;GACN,WAAW;EACb;EACA,QAAQ9C,EAAM,UAAU;EACxB,aAAaA,EAAM,eAAe,EAAE,MAAM,GAAM;CAClD,CAAC;CAED,OACE,kBAACK,GAAD;EACW;EACT,GAAIN,EAAW;GAAE,GAAGC;GAAO,cAAc,KAAA;EAAU,CAAC;EACpD,cACE+C,KACK,MAAU;GACT,IAAMC,IAAQC,EAAM,MAAM,EAAE,EAAE;GAC9B,AAAID,MAAU,KAAA,KAAahB,EAAOgB,MAChCD,EAAaf,EAAOgB,IAAQA,CAAK;EACrC,IACA,KAAA;CAEP,CAAA;AAEL"}
|
|
1
|
+
{"version":3,"file":"charts.js","names":["frameProps","props","LineChart","input","series","useMemo","lineSeries","area","ChartBase","engineOptions","BarChart","barSeries","stacked","ScatterChart","scatterSeries","CORNERS","cornerStyle","left","corner","top","split","plot","QuadrantChart","geometry","options","quadrantChartOptions","draggable","onPointDrop","overlay","quadrantContent","x0","x1","xDomain","y0","y1","yDomain","xs","xSplit","ys","ySplit","fx","fy","reverseX","onPointClick","index","event","points","onQuadrantClick","quadrantOf","at","renderTooltip"],"sources":["../../../../charts/src/react/charts.tsx"],"sourcesContent":["import { useMemo, type CSSProperties } from \"react\";\nimport {\n barSeries,\n lineSeries,\n quadrantChartOptions,\n quadrantOf,\n scatterSeries,\n type QuadrantCorner,\n} from \"../engine/presets\";\nimport type { ChartRect } from \"../engine/types\";\nimport { ChartBase, engineOptions } from \"./Chart\";\nimport type {\n BarChartProps,\n ChartCommonProps,\n LineChartProps,\n QuadrantChartProps,\n ScatterChartProps,\n} from \"./types\";\n\nconst frameProps = (props: ChartCommonProps) => ({\n height: props.height,\n width: props.width,\n className: props.className,\n style: props.style,\n handleRef: props.ref,\n onHover: props.onHover,\n onPointClick: props.onPointClick,\n onPlotClick: props.onPlotClick,\n onZoom: props.onZoom,\n onRendererChange: props.onRendererChange,\n renderTooltip: props.renderTooltip,\n});\n\n/** Line (or area) chart; handles millions of points on the GPU */\nexport function LineChart(props: LineChartProps) {\n const { series: input, area = false } = props;\n const series = useMemo(() => lineSeries(input, area), [input, area]);\n return (\n <ChartBase\n options={engineOptions({ ...props, series })}\n {...frameProps(props)}\n />\n );\n}\n\n/** Bar chart: grouped side by side, or stacked */\nexport function BarChart(props: BarChartProps) {\n const { series: input, stacked = false } = props;\n const series = useMemo(() => barSeries(input, stacked), [input, stacked]);\n return (\n <ChartBase\n options={engineOptions({ ...props, series })}\n {...frameProps(props)}\n />\n );\n}\n\n/** Scatter chart: zooms on both axes, hit testing through a spatial index */\nexport function ScatterChart(props: ScatterChartProps) {\n const { series: input } = props;\n const series = useMemo(() => scatterSeries(input), [input]);\n return (\n <ChartBase\n options={engineOptions({ ...props, series })}\n {...frameProps(props)}\n />\n );\n}\n\nconst CORNERS: QuadrantCorner[] = [\n \"topLeft\",\n \"topRight\",\n \"bottomLeft\",\n \"bottomRight\",\n];\n\nconst cornerStyle = (\n corner: QuadrantCorner,\n plot: ChartRect,\n split: { x: number; y: number },\n): CSSProperties => {\n const left = corner.endsWith(\"Left\");\n const top = corner.startsWith(\"top\");\n return {\n position: \"absolute\",\n left: left ? 0 : split.x - plot.x,\n top: top ? 0 : split.y - plot.y,\n width: left ? split.x - plot.x : plot.x + plot.width - split.x,\n height: top ? split.y - plot.y : plot.y + plot.height - split.y,\n pointerEvents: \"none\",\n };\n};\n\n/**\n * Four-quadrant matrix (priority matrix, Eisenhower, BCG, ...): tinted\n * quadrants with titles, dividers, and labelled dots placed without\n * overlapping labels. Dots can be dragged to another quadrant.\n */\nexport function QuadrantChart(props: QuadrantChartProps) {\n const {\n points,\n xDomain,\n yDomain,\n xSplit,\n ySplit,\n quadrants,\n xLabel,\n yLabel,\n axisLabels,\n showTicks,\n reverseX,\n showLabels,\n pointSize,\n name,\n draggable,\n onPointClick,\n onPointDrop,\n onQuadrantClick,\n renderTooltip,\n quadrantContent,\n } = props;\n const geometry = { xDomain, yDomain, xSplit, ySplit, reverseX };\n\n const options = quadrantChartOptions(\n {\n points,\n xDomain,\n yDomain,\n xSplit,\n ySplit,\n quadrants,\n xLabel,\n yLabel,\n axisLabels,\n showTicks,\n reverseX,\n showLabels,\n pointSize,\n name,\n draggable: draggable ?? !!onPointDrop,\n },\n engineOptions({ ...props, series: [] }),\n );\n\n const overlay = quadrantContent\n ? (plot: ChartRect) => {\n const [x0, x1] = xDomain ?? [0, 10];\n const [y0, y1] = yDomain ?? [0, 10];\n const xs = xSplit ?? (x0 + x1) / 2;\n const ys = ySplit ?? (y0 + y1) / 2;\n const fx = (xs - x0) / (x1 - x0 || 1);\n const fy = (ys - y0) / (y1 - y0 || 1);\n const split = {\n x: plot.x + plot.width * (reverseX ? 1 - fx : fx),\n y: plot.y + plot.height * (1 - fy),\n };\n return CORNERS.map((corner) =>\n quadrantContent[corner] ? (\n <div\n key={corner}\n className={`minerva-chart-quadrant minerva-chart-quadrant-${corner}`}\n style={cornerStyle(corner, plot, split)}\n >\n {quadrantContent[corner]}\n </div>\n ) : null,\n );\n }\n : undefined;\n\n return (\n <ChartBase\n options={options}\n {...frameProps({\n ...props,\n onPointClick: undefined,\n renderTooltip: undefined,\n })}\n overlay={overlay}\n onPointClick={\n onPointClick\n ? (event) => {\n const index = event.items[0]?.index;\n if (index !== undefined && points[index])\n onPointClick(points[index], index);\n }\n : undefined\n }\n onPlotClick={\n onQuadrantClick\n ? (at) => onQuadrantClick(quadrantOf(geometry, at.x, at.y), at)\n : undefined\n }\n onDrop={\n onPointDrop\n ? (event) => {\n const index = event.item.index;\n if (!points[index]) return;\n onPointDrop(points[index], index, {\n x: event.x,\n y: event.y,\n quadrant: quadrantOf(geometry, event.x, event.y),\n });\n }\n : undefined\n }\n renderTooltip={\n renderTooltip\n ? (event) => {\n const index = event.items[0]?.index;\n return index !== undefined && points[index]\n ? renderTooltip(points[index], index)\n : null;\n }\n : undefined\n }\n />\n );\n}\n"],"mappings":";;;;;;AAmBA,IAAMA,KAAc,OAA6B;CAC/C,QAAQC,EAAM;CACd,OAAOA,EAAM;CACb,WAAWA,EAAM;CACjB,OAAOA,EAAM;CACb,WAAWA,EAAM;CACjB,SAASA,EAAM;CACf,cAAcA,EAAM;CACpB,aAAaA,EAAM;CACnB,QAAQA,EAAM;CACd,kBAAkBA,EAAM;CACxB,eAAeA,EAAM;AACvB;AAGA,SAAgBC,EAAU,GAAuB;CAC/C,IAAM,EAAE,QAAQC,GAAO,UAAO,OAAUF,GAClCG,IAASC,QAAcC,EAAWH,GAAOI,CAAI,GAAG,CAACJ,GAAOI,CAAI,CAAC;CACnE,OACE,kBAACC,GAAD;EACE,SAASC,EAAc;GAAE,GAAGR;GAAO;EAAO,CAAC;EAC3C,GAAID,EAAWC,CAAK;CACrB,CAAA;AAEL;AAGA,SAAgBS,EAAS,GAAsB;CAC7C,IAAM,EAAE,QAAQP,GAAO,aAAU,OAAUF,GACrCG,IAASC,QAAcM,EAAUR,GAAOS,CAAO,GAAG,CAACT,GAAOS,CAAO,CAAC;CACxE,OACE,kBAACJ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AAOD,MAAU,KAAA,KAAaE,EAAOF,KACjCM,EAAcJ,EAAOF,IAAQA,CAAK,IAClC;EACN,IACA,KAAA;CAEP,CAAA;AAEL"}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import { CSSProperties, Ref } from 'react';
|
|
2
|
-
import { ChartAnnotation, ChartAxisOptions, ChartHoverEvent, ChartInstance, ChartLegendOptions, ChartInteractionOptions, ChartPadding, ChartRendererKind, ChartRendererPreference, ChartSeries, ChartTooltipOptions, ChartView } from '../engine/types.cjs';
|
|
1
|
+
import { CSSProperties, ReactNode, Ref } from 'react';
|
|
2
|
+
import { ChartAnnotation, ChartAxisOptions, ChartHoverEvent, ChartInstance, ChartLegendOptions, ChartInteractionOptions, ChartPadding, ChartPlotClickEvent, ChartRendererKind, ChartRendererPreference, ChartSeries, ChartTooltipOptions, ChartView } from '../engine/types.cjs';
|
|
3
|
+
import { QuadrantConfig, QuadrantCorner, QuadrantPoint } from '../engine/presets.cjs';
|
|
4
|
+
export type { QuadrantAxisLabels, QuadrantConfig, QuadrantCorner, QuadrantPoint, QuadrantRegion, QuadrantRegions, } from '../engine/presets.cjs';
|
|
3
5
|
/** Imperative handle of the chart components (`ref`) */
|
|
4
6
|
export interface ChartHandle {
|
|
5
7
|
/** Shows the whole data range */
|
|
@@ -57,6 +59,10 @@ export interface ChartCommonProps {
|
|
|
57
59
|
onHover?: (event: ChartHoverEvent | null) => void;
|
|
58
60
|
/** Called when a point (or bar) is clicked */
|
|
59
61
|
onPointClick?: (event: ChartHoverEvent) => void;
|
|
62
|
+
/** Called when the plot area is clicked where there is no point */
|
|
63
|
+
onPlotClick?: (event: ChartPlotClickEvent) => void;
|
|
64
|
+
/** React content of the tooltip (replaces the default content) */
|
|
65
|
+
renderTooltip?: (event: ChartHoverEvent) => ReactNode;
|
|
60
66
|
/** Called when the user zooms or pans */
|
|
61
67
|
onZoom?: (view: ChartView) => void;
|
|
62
68
|
/** Called with the backend once it is ready (and when it falls back after a GPU loss) */
|
|
@@ -98,71 +104,33 @@ export interface ScatterChartProps extends ChartCommonProps {
|
|
|
98
104
|
/** Series drawn as dots unless they set a `type` */
|
|
99
105
|
series: readonly ChartSeries[];
|
|
100
106
|
}
|
|
101
|
-
/**
|
|
102
|
-
export interface
|
|
103
|
-
/**
|
|
107
|
+
/** Where a dragged QuadrantChart point was dropped */
|
|
108
|
+
export interface QuadrantDropTarget {
|
|
109
|
+
/** Data coordinates of the drop */
|
|
104
110
|
x: number;
|
|
105
|
-
/** Position on the vertical axis */
|
|
106
111
|
y: number;
|
|
107
|
-
/**
|
|
108
|
-
|
|
109
|
-
/** Dot color (any CSS color); the color of its quadrant by default */
|
|
110
|
-
color?: string;
|
|
111
|
-
/** Dot diameter in pixels */
|
|
112
|
-
size?: number;
|
|
113
|
-
}
|
|
114
|
-
/** Title and color of a quadrant */
|
|
115
|
-
export interface QuadrantRegion {
|
|
116
|
-
/** Title drawn in the outer corner of the quadrant */
|
|
117
|
-
label?: string;
|
|
118
|
-
/** Background tint and default dot color (any CSS color) */
|
|
119
|
-
color?: string;
|
|
120
|
-
}
|
|
121
|
-
/** The four quadrants of a QuadrantChart */
|
|
122
|
-
export interface QuadrantRegions {
|
|
123
|
-
topLeft?: QuadrantRegion;
|
|
124
|
-
topRight?: QuadrantRegion;
|
|
125
|
-
bottomLeft?: QuadrantRegion;
|
|
126
|
-
bottomRight?: QuadrantRegion;
|
|
112
|
+
/** Quadrant of the drop, as seen on screen */
|
|
113
|
+
quadrant: QuadrantCorner;
|
|
127
114
|
}
|
|
128
115
|
/** Props of QuadrantChart */
|
|
129
|
-
export interface QuadrantChartProps extends Omit<ChartCommonProps, "onPointClick" | "xAxis" | "yAxis"
|
|
130
|
-
/**
|
|
131
|
-
|
|
132
|
-
/**
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
/**
|
|
138
|
-
* Range of the vertical axis
|
|
139
|
-
* @default [0, 10]
|
|
140
|
-
*/
|
|
141
|
-
yDomain?: [number, number];
|
|
142
|
-
/** X value of the vertical divider (the middle of `xDomain` by default) */
|
|
143
|
-
xSplit?: number;
|
|
144
|
-
/** Y value of the horizontal divider (the middle of `yDomain` by default) */
|
|
145
|
-
ySplit?: number;
|
|
146
|
-
/** Titles and colors of the quadrants */
|
|
147
|
-
quadrants?: QuadrantRegions;
|
|
148
|
-
/** Title of the horizontal axis */
|
|
149
|
-
xLabel?: string;
|
|
150
|
-
/** Title of the vertical axis */
|
|
151
|
-
yLabel?: string;
|
|
152
|
-
/** Reverses the horizontal axis (e.g. "urgent" on the left) */
|
|
153
|
-
reverseX?: boolean;
|
|
116
|
+
export interface QuadrantChartProps extends Omit<ChartCommonProps, "onPointClick" | "onPlotClick" | "renderTooltip" | "xAxis" | "yAxis">, QuadrantConfig {
|
|
117
|
+
/** Called with the clicked point and its index */
|
|
118
|
+
onPointClick?: (point: QuadrantPoint, index: number) => void;
|
|
119
|
+
/** Called when the empty area of a quadrant is clicked */
|
|
120
|
+
onQuadrantClick?: (quadrant: QuadrantCorner, position: {
|
|
121
|
+
x: number;
|
|
122
|
+
y: number;
|
|
123
|
+
}) => void;
|
|
154
124
|
/**
|
|
155
|
-
*
|
|
156
|
-
*
|
|
125
|
+
* Called when a dragged point is released; the dots become draggable
|
|
126
|
+
* when it is set (the chart does not move them: update `points`)
|
|
157
127
|
*/
|
|
158
|
-
|
|
128
|
+
onPointDrop?: (point: QuadrantPoint, index: number, target: QuadrantDropTarget) => void;
|
|
129
|
+
/** React content of the tooltip of a point */
|
|
130
|
+
renderTooltip?: (point: QuadrantPoint, index: number) => ReactNode;
|
|
159
131
|
/**
|
|
160
|
-
*
|
|
161
|
-
*
|
|
132
|
+
* React content placed over each quadrant (e.g. an add button); the
|
|
133
|
+
* content receives pointer events, the rest of the quadrant does not
|
|
162
134
|
*/
|
|
163
|
-
|
|
164
|
-
/** Name of the points in the tooltip */
|
|
165
|
-
name?: string;
|
|
166
|
-
/** Called with the clicked point and its index */
|
|
167
|
-
onPointClick?: (point: QuadrantPoint, index: number) => void;
|
|
135
|
+
quadrantContent?: Partial<Record<QuadrantCorner, ReactNode>>;
|
|
168
136
|
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import { CSSProperties, Ref } from 'react';
|
|
2
|
-
import { ChartAnnotation, ChartAxisOptions, ChartHoverEvent, ChartInstance, ChartLegendOptions, ChartInteractionOptions, ChartPadding, ChartRendererKind, ChartRendererPreference, ChartSeries, ChartTooltipOptions, ChartView } from '../engine/types.js';
|
|
1
|
+
import { CSSProperties, ReactNode, Ref } from 'react';
|
|
2
|
+
import { ChartAnnotation, ChartAxisOptions, ChartHoverEvent, ChartInstance, ChartLegendOptions, ChartInteractionOptions, ChartPadding, ChartPlotClickEvent, ChartRendererKind, ChartRendererPreference, ChartSeries, ChartTooltipOptions, ChartView } from '../engine/types.js';
|
|
3
|
+
import { QuadrantConfig, QuadrantCorner, QuadrantPoint } from '../engine/presets.js';
|
|
4
|
+
export type { QuadrantAxisLabels, QuadrantConfig, QuadrantCorner, QuadrantPoint, QuadrantRegion, QuadrantRegions, } from '../engine/presets.js';
|
|
3
5
|
/** Imperative handle of the chart components (`ref`) */
|
|
4
6
|
export interface ChartHandle {
|
|
5
7
|
/** Shows the whole data range */
|
|
@@ -57,6 +59,10 @@ export interface ChartCommonProps {
|
|
|
57
59
|
onHover?: (event: ChartHoverEvent | null) => void;
|
|
58
60
|
/** Called when a point (or bar) is clicked */
|
|
59
61
|
onPointClick?: (event: ChartHoverEvent) => void;
|
|
62
|
+
/** Called when the plot area is clicked where there is no point */
|
|
63
|
+
onPlotClick?: (event: ChartPlotClickEvent) => void;
|
|
64
|
+
/** React content of the tooltip (replaces the default content) */
|
|
65
|
+
renderTooltip?: (event: ChartHoverEvent) => ReactNode;
|
|
60
66
|
/** Called when the user zooms or pans */
|
|
61
67
|
onZoom?: (view: ChartView) => void;
|
|
62
68
|
/** Called with the backend once it is ready (and when it falls back after a GPU loss) */
|
|
@@ -98,71 +104,33 @@ export interface ScatterChartProps extends ChartCommonProps {
|
|
|
98
104
|
/** Series drawn as dots unless they set a `type` */
|
|
99
105
|
series: readonly ChartSeries[];
|
|
100
106
|
}
|
|
101
|
-
/**
|
|
102
|
-
export interface
|
|
103
|
-
/**
|
|
107
|
+
/** Where a dragged QuadrantChart point was dropped */
|
|
108
|
+
export interface QuadrantDropTarget {
|
|
109
|
+
/** Data coordinates of the drop */
|
|
104
110
|
x: number;
|
|
105
|
-
/** Position on the vertical axis */
|
|
106
111
|
y: number;
|
|
107
|
-
/**
|
|
108
|
-
|
|
109
|
-
/** Dot color (any CSS color); the color of its quadrant by default */
|
|
110
|
-
color?: string;
|
|
111
|
-
/** Dot diameter in pixels */
|
|
112
|
-
size?: number;
|
|
113
|
-
}
|
|
114
|
-
/** Title and color of a quadrant */
|
|
115
|
-
export interface QuadrantRegion {
|
|
116
|
-
/** Title drawn in the outer corner of the quadrant */
|
|
117
|
-
label?: string;
|
|
118
|
-
/** Background tint and default dot color (any CSS color) */
|
|
119
|
-
color?: string;
|
|
120
|
-
}
|
|
121
|
-
/** The four quadrants of a QuadrantChart */
|
|
122
|
-
export interface QuadrantRegions {
|
|
123
|
-
topLeft?: QuadrantRegion;
|
|
124
|
-
topRight?: QuadrantRegion;
|
|
125
|
-
bottomLeft?: QuadrantRegion;
|
|
126
|
-
bottomRight?: QuadrantRegion;
|
|
112
|
+
/** Quadrant of the drop, as seen on screen */
|
|
113
|
+
quadrant: QuadrantCorner;
|
|
127
114
|
}
|
|
128
115
|
/** Props of QuadrantChart */
|
|
129
|
-
export interface QuadrantChartProps extends Omit<ChartCommonProps, "onPointClick" | "xAxis" | "yAxis"
|
|
130
|
-
/**
|
|
131
|
-
|
|
132
|
-
/**
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
/**
|
|
138
|
-
* Range of the vertical axis
|
|
139
|
-
* @default [0, 10]
|
|
140
|
-
*/
|
|
141
|
-
yDomain?: [number, number];
|
|
142
|
-
/** X value of the vertical divider (the middle of `xDomain` by default) */
|
|
143
|
-
xSplit?: number;
|
|
144
|
-
/** Y value of the horizontal divider (the middle of `yDomain` by default) */
|
|
145
|
-
ySplit?: number;
|
|
146
|
-
/** Titles and colors of the quadrants */
|
|
147
|
-
quadrants?: QuadrantRegions;
|
|
148
|
-
/** Title of the horizontal axis */
|
|
149
|
-
xLabel?: string;
|
|
150
|
-
/** Title of the vertical axis */
|
|
151
|
-
yLabel?: string;
|
|
152
|
-
/** Reverses the horizontal axis (e.g. "urgent" on the left) */
|
|
153
|
-
reverseX?: boolean;
|
|
116
|
+
export interface QuadrantChartProps extends Omit<ChartCommonProps, "onPointClick" | "onPlotClick" | "renderTooltip" | "xAxis" | "yAxis">, QuadrantConfig {
|
|
117
|
+
/** Called with the clicked point and its index */
|
|
118
|
+
onPointClick?: (point: QuadrantPoint, index: number) => void;
|
|
119
|
+
/** Called when the empty area of a quadrant is clicked */
|
|
120
|
+
onQuadrantClick?: (quadrant: QuadrantCorner, position: {
|
|
121
|
+
x: number;
|
|
122
|
+
y: number;
|
|
123
|
+
}) => void;
|
|
154
124
|
/**
|
|
155
|
-
*
|
|
156
|
-
*
|
|
125
|
+
* Called when a dragged point is released; the dots become draggable
|
|
126
|
+
* when it is set (the chart does not move them: update `points`)
|
|
157
127
|
*/
|
|
158
|
-
|
|
128
|
+
onPointDrop?: (point: QuadrantPoint, index: number, target: QuadrantDropTarget) => void;
|
|
129
|
+
/** React content of the tooltip of a point */
|
|
130
|
+
renderTooltip?: (point: QuadrantPoint, index: number) => ReactNode;
|
|
159
131
|
/**
|
|
160
|
-
*
|
|
161
|
-
*
|
|
132
|
+
* React content placed over each quadrant (e.g. an add button); the
|
|
133
|
+
* content receives pointer events, the rest of the quadrant does not
|
|
162
134
|
*/
|
|
163
|
-
|
|
164
|
-
/** Name of the points in the tooltip */
|
|
165
|
-
name?: string;
|
|
166
|
-
/** Called with the clicked point and its index */
|
|
167
|
-
onPointClick?: (point: QuadrantPoint, index: number) => void;
|
|
135
|
+
quadrantContent?: Partial<Record<QuadrantCorner, ReactNode>>;
|
|
168
136
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require("./engine/color.cjs");require("./engine/format.cjs");const t=require("./engine/controller.cjs");require("./engine/canvas.cjs");const n=require("./engine/presets.cjs");exports.barSeries=n.barSeries,exports.createChartController=t.createChartController,exports.lineSeries=n.lineSeries,exports.quadrantChartOptions=n.quadrantChartOptions,exports.quadrantOf=n.quadrantOf,exports.scatterSeries=n.scatterSeries,exports.scenePrimitives=t.scenePrimitives,exports.toCss=e.toCss;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { toCss as e } from "./engine/color.js";
|
|
2
|
+
import "./engine/format.js";
|
|
3
|
+
import { createChartController as t, scenePrimitives as n } from "./engine/controller.js";
|
|
4
|
+
import "./engine/canvas.js";
|
|
5
|
+
import { barSeries as r, lineSeries as i, quadrantChartOptions as a, quadrantOf as o, scatterSeries as s } from "./engine/presets.js";
|
|
6
|
+
export { r as barSeries, t as createChartController, i as lineSeries, a as quadrantChartOptions, o as quadrantOf, s as scatterSeries, n as scenePrimitives, e as toCss };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const e=require("./scale.cjs"),t=require("./format.cjs"),n=require("./time.cjs");var r=(r,i,a)=>{let[o,s]=i[0]<=i[1]?i:[i[1],i[0]];if(r.type===`category`){let e=r.categories.length,t=Math.max(0,Math.ceil(o-1e-9)),n=Math.min(e-1,Math.floor(s+1e-9)),i=Math.max(0,n-t+1),c=Math.max(1,Math.ceil(i/Math.max(1,a))),l=[];for(let e=t-t%c;e<=n;e+=c)e>=t&&l.push(e);let u=e=>{let t=Math.round(e);return r.format?r.format(t):r.categories[t]??String(t)};return{values:l,labels:l.map(u),formatValue:u}}if(r.type===`time`){let e=n.timeTicks(o,s,a),t=e.unit===`day`||e.unit===`month`||e.unit===`year`?`day`:e.unit,i=r.format??(e=>n.formatTime(e,t));return{values:e.values,labels:e.values.map(r.format??e.format),formatValue:i}}let c=e.linearTicks(o,s,a),l=e.tickStep(o,s,a),u=r.format??t.tickFormatter(l,Math.max(Math.abs(o),Math.abs(s)));return{values:c,labels:c.map(u),formatValue:r.format??t.formatValue}};exports.axisTicks=r;
|
|
2
|
+
//# sourceMappingURL=axis.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"axis.cjs","names":["timeTicks","formatTime","linearTicks","tickStep","tickFormatter","formatValue","require_scale","require_format","require_time","axisTicks","min","max","range","axis","n","first","last","visible","step","count","values","i","name","v","ticks","unit","full","tick"],"sources":["../../../../../../charts/src/engine/axis.ts"],"sourcesContent":["// Ticks and value labels of an axis for its visible range.\n\nimport { formatValue, tickFormatter } from \"./format\";\nimport type { AxisModel } from \"./model\";\nimport { linearTicks, tickStep } from \"./scale\";\nimport { formatTime, timeTicks, type TimeUnit } from \"./time\";\nimport type { Range } from \"./viewport\";\n\nexport interface AxisTicks {\n values: number[];\n labels: string[];\n /** Full label of any value (tooltips) */\n formatValue: (value: number) => string;\n}\n\n/**\n * @param count approximate number of ticks (numeric / time axes) or the\n * maximum number of labels (category axes)\n */\nexport const axisTicks = (\n axis: AxisModel,\n range: Range,\n count: number,\n): AxisTicks => {\n const [min, max] = range[0] <= range[1] ? range : [range[1], range[0]];\n if (axis.type === \"category\") {\n const n = axis.categories.length;\n const first = Math.max(0, Math.ceil(min - 1e-9));\n const last = Math.min(n - 1, Math.floor(max + 1e-9));\n const visible = Math.max(0, last - first + 1);\n const step = Math.max(1, Math.ceil(visible / Math.max(1, count)));\n const values: number[] = [];\n for (let i = first - (first % step); i <= last; i += step) {\n if (i >= first) values.push(i);\n }\n const name = (v: number) => {\n const i = Math.round(v);\n return axis.format ? axis.format(i) : (axis.categories[i] ?? String(i));\n };\n return { values, labels: values.map(name), formatValue: name };\n }\n if (axis.type === \"time\") {\n const ticks = timeTicks(min, max, count);\n const unit: TimeUnit =\n ticks.unit === \"day\" || ticks.unit === \"month\" || ticks.unit === \"year\"\n ? \"day\"\n : ticks.unit;\n const full = axis.format ?? ((v: number) => formatTime(v, unit));\n return {\n values: ticks.values,\n labels: ticks.values.map(axis.format ?? ticks.format),\n formatValue: full,\n };\n }\n const values = linearTicks(min, max, count);\n const step = tickStep(min, max, count);\n const tick =\n axis.format ?? tickFormatter(step, Math.max(Math.abs(min), Math.abs(max)));\n return {\n values,\n labels: values.map(tick),\n formatValue: axis.format ?? formatValue,\n };\n};\n"],"mappings":"iFAmBA,IAAaS,GACX,EACA,EACA,IACc,CACd,GAAM,CAACC,EAAKC,GAAOC,EAAM,IAAMA,EAAM,GAAKA,EAAQ,CAACA,EAAM,GAAIA,EAAM,EAAE,EACrE,GAAIC,EAAK,OAAS,WAAY,CAC5B,IAAMC,EAAID,EAAK,WAAW,OACpBE,EAAQ,KAAK,IAAI,EAAG,KAAK,KAAKL,EAAM,IAAI,CAAC,EACzCM,EAAO,KAAK,IAAIF,EAAI,EAAG,KAAK,MAAMH,EAAM,IAAI,CAAC,EAC7CM,EAAU,KAAK,IAAI,EAAGD,EAAOD,EAAQ,CAAC,EACtCG,EAAO,KAAK,IAAI,EAAG,KAAK,KAAKD,EAAU,KAAK,IAAI,EAAGE,CAAK,CAAC,CAAC,EAC1DC,EAAmB,CAAC,EAC1B,IAAK,IAAIC,EAAIN,EAASA,EAAQG,EAAOG,GAAKL,EAAM,GAAKE,EAC/CG,GAAKN,GAAOK,EAAO,KAAKC,CAAC,EAE/B,IAAMC,EAAQ,GAAc,CAC1B,IAAMD,EAAI,KAAK,MAAME,CAAC,EACtB,OAAOV,EAAK,OAASA,EAAK,OAAOQ,CAAC,EAAKR,EAAK,WAAWQ,IAAM,OAAOA,CAAC,CACvE,EACA,MAAO,CAAE,SAAQ,OAAQD,EAAO,IAAIE,CAAI,EAAG,YAAaA,CAAK,CAC/D,CACA,GAAIT,EAAK,OAAS,OAAQ,CACxB,IAAMW,EAAQxB,EAAAA,UAAUU,EAAKC,EAAKQ,CAAK,EACjCM,EACJD,EAAM,OAAS,OAASA,EAAM,OAAS,SAAWA,EAAM,OAAS,OAC7D,MACAA,EAAM,KACNE,EAAOb,EAAK,SAAY,GAAcZ,EAAAA,WAAWsB,EAAGE,CAAI,GAC9D,MAAO,CACL,OAAQD,EAAM,OACd,OAAQA,EAAM,OAAO,IAAIX,EAAK,QAAUW,EAAM,MAAM,EACpD,YAAaE,CACf,CACF,CACA,IAAMN,EAASlB,EAAAA,YAAYQ,EAAKC,EAAKQ,CAAK,EACpCD,EAAOf,EAAAA,SAASO,EAAKC,EAAKQ,CAAK,EAC/BQ,EACJd,EAAK,QAAUT,EAAAA,cAAcc,EAAM,KAAK,IAAI,KAAK,IAAIR,CAAG,EAAG,KAAK,IAAIC,CAAG,CAAC,CAAC,EAC3E,MAAO,CACL,SACA,OAAQS,EAAO,IAAIO,CAAI,EACvB,YAAad,EAAK,QAAUR,EAAAA,WAC9B,CACF"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { linearTicks as e, tickStep as t } from "./scale.js";
|
|
2
|
+
import { formatValue as n, tickFormatter as r } from "./format.js";
|
|
3
|
+
import { formatTime as i, timeTicks as a } from "./time.js";
|
|
4
|
+
//#region ../charts/src/engine/axis.ts
|
|
5
|
+
var o = (o, s, c) => {
|
|
6
|
+
let [l, u] = s[0] <= s[1] ? s : [s[1], s[0]];
|
|
7
|
+
if (o.type === "category") {
|
|
8
|
+
let e = o.categories.length, t = Math.max(0, Math.ceil(l - 1e-9)), n = Math.min(e - 1, Math.floor(u + 1e-9)), r = Math.max(0, n - t + 1), i = Math.max(1, Math.ceil(r / Math.max(1, c))), a = [];
|
|
9
|
+
for (let e = t - t % i; e <= n; e += i) e >= t && a.push(e);
|
|
10
|
+
let s = (e) => {
|
|
11
|
+
let t = Math.round(e);
|
|
12
|
+
return o.format ? o.format(t) : o.categories[t] ?? String(t);
|
|
13
|
+
};
|
|
14
|
+
return {
|
|
15
|
+
values: a,
|
|
16
|
+
labels: a.map(s),
|
|
17
|
+
formatValue: s
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
if (o.type === "time") {
|
|
21
|
+
let e = a(l, u, c), t = e.unit === "day" || e.unit === "month" || e.unit === "year" ? "day" : e.unit, n = o.format ?? ((e) => i(e, t));
|
|
22
|
+
return {
|
|
23
|
+
values: e.values,
|
|
24
|
+
labels: e.values.map(o.format ?? e.format),
|
|
25
|
+
formatValue: n
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
let d = e(l, u, c), f = t(l, u, c), p = o.format ?? r(f, Math.max(Math.abs(l), Math.abs(u)));
|
|
29
|
+
return {
|
|
30
|
+
values: d,
|
|
31
|
+
labels: d.map(p),
|
|
32
|
+
formatValue: o.format ?? n
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
//#endregion
|
|
36
|
+
export { o as axisTicks };
|
|
37
|
+
|
|
38
|
+
//# sourceMappingURL=axis.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"axis.js","names":["axisTicks","min","max","range","axis","n","first","last","visible","step","count","values","i","name","v","ticks","timeTicks","unit","full","formatTime","linearTicks","tickStep","tick","tickFormatter","formatValue"],"sources":["../../../../../../charts/src/engine/axis.ts"],"sourcesContent":["// Ticks and value labels of an axis for its visible range.\n\nimport { formatValue, tickFormatter } from \"./format\";\nimport type { AxisModel } from \"./model\";\nimport { linearTicks, tickStep } from \"./scale\";\nimport { formatTime, timeTicks, type TimeUnit } from \"./time\";\nimport type { Range } from \"./viewport\";\n\nexport interface AxisTicks {\n values: number[];\n labels: string[];\n /** Full label of any value (tooltips) */\n formatValue: (value: number) => string;\n}\n\n/**\n * @param count approximate number of ticks (numeric / time axes) or the\n * maximum number of labels (category axes)\n */\nexport const axisTicks = (\n axis: AxisModel,\n range: Range,\n count: number,\n): AxisTicks => {\n const [min, max] = range[0] <= range[1] ? range : [range[1], range[0]];\n if (axis.type === \"category\") {\n const n = axis.categories.length;\n const first = Math.max(0, Math.ceil(min - 1e-9));\n const last = Math.min(n - 1, Math.floor(max + 1e-9));\n const visible = Math.max(0, last - first + 1);\n const step = Math.max(1, Math.ceil(visible / Math.max(1, count)));\n const values: number[] = [];\n for (let i = first - (first % step); i <= last; i += step) {\n if (i >= first) values.push(i);\n }\n const name = (v: number) => {\n const i = Math.round(v);\n return axis.format ? axis.format(i) : (axis.categories[i] ?? String(i));\n };\n return { values, labels: values.map(name), formatValue: name };\n }\n if (axis.type === \"time\") {\n const ticks = timeTicks(min, max, count);\n const unit: TimeUnit =\n ticks.unit === \"day\" || ticks.unit === \"month\" || ticks.unit === \"year\"\n ? \"day\"\n : ticks.unit;\n const full = axis.format ?? ((v: number) => formatTime(v, unit));\n return {\n values: ticks.values,\n labels: ticks.values.map(axis.format ?? ticks.format),\n formatValue: full,\n };\n }\n const values = linearTicks(min, max, count);\n const step = tickStep(min, max, count);\n const tick =\n axis.format ?? tickFormatter(step, Math.max(Math.abs(min), Math.abs(max)));\n return {\n values,\n labels: values.map(tick),\n formatValue: axis.format ?? formatValue,\n };\n};\n"],"mappings":";;;;AAmBA,IAAaA,KACX,GACA,GACA,MACc;CACd,IAAM,CAACC,GAAKC,KAAOC,EAAM,MAAMA,EAAM,KAAKA,IAAQ,CAACA,EAAM,IAAIA,EAAM,EAAE;CACrE,IAAIC,EAAK,SAAS,YAAY;EAC5B,IAAMC,IAAID,EAAK,WAAW,QACpBE,IAAQ,KAAK,IAAI,GAAG,KAAK,KAAKL,IAAM,IAAI,CAAC,GACzCM,IAAO,KAAK,IAAIF,IAAI,GAAG,KAAK,MAAMH,IAAM,IAAI,CAAC,GAC7CM,IAAU,KAAK,IAAI,GAAGD,IAAOD,IAAQ,CAAC,GACtCG,IAAO,KAAK,IAAI,GAAG,KAAK,KAAKD,IAAU,KAAK,IAAI,GAAGE,CAAK,CAAC,CAAC,GAC1DC,IAAmB,CAAC;EAC1B,KAAK,IAAIC,IAAIN,IAASA,IAAQG,GAAOG,KAAKL,GAAM,KAAKE,GACnD,AAAI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