blazeplot 0.1.10 → 0.1.12
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/README.md +46 -6
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +328 -145
- package/dist/index.js.map +1 -1
- package/dist/interaction/index.d.ts +0 -1
- package/dist/interaction/index.d.ts.map +1 -1
- package/dist/plugins/interactions.d.ts +3 -0
- package/dist/plugins/interactions.d.ts.map +1 -0
- package/dist/plugins/interactions.js +143 -0
- package/dist/plugins/interactions.js.map +1 -0
- package/dist/plugins/legend.js +25 -18
- package/dist/plugins/legend.js.map +1 -1
- package/dist/plugins/tooltip.js +12 -8
- package/dist/plugins/tooltip.js.map +1 -1
- package/dist/render/ReglBackend.d.ts.map +1 -1
- package/dist/ui/AxisOverlay.d.ts +2 -1
- package/dist/ui/AxisOverlay.d.ts.map +1 -1
- package/dist/ui/Chart.d.ts +27 -2
- package/dist/ui/Chart.d.ts.map +1 -1
- package/dist/ui/Interactions.d.ts +19 -0
- package/dist/ui/Interactions.d.ts.map +1 -0
- package/dist/ui/Legend.d.ts +5 -0
- package/dist/ui/Legend.d.ts.map +1 -1
- package/dist/ui/Tooltip.d.ts +3 -0
- package/dist/ui/Tooltip.d.ts.map +1 -1
- package/dist/ui/theme.d.ts +41 -0
- package/dist/ui/theme.d.ts.map +1 -0
- package/package.json +5 -1
- package/dist/interaction/InputController.d.ts +0 -23
- package/dist/interaction/InputController.d.ts.map +0 -1
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
export { Camera2D } from './Camera2D.js';
|
|
2
|
-
export { InputController } from './InputController.js';
|
|
3
2
|
export { AxisController } from './AxisController.js';
|
|
4
3
|
export type { PanIntent, ZoomAxis, ZoomIntent, ViewportPolicy } from './types.js';
|
|
5
4
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/interaction/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/interaction/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,YAAY,EAAE,SAAS,EAAE,QAAQ,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interactions.d.ts","sourceRoot":"","sources":["../../src/plugins/interactions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC3D,YAAY,EAAE,yBAAyB,EAAE,MAAM,uBAAuB,CAAC"}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
//#region src/ui/Interactions.ts
|
|
2
|
+
var e = 1;
|
|
3
|
+
function t(e, t) {
|
|
4
|
+
return {
|
|
5
|
+
dx: t === "y" ? 0 : e.dx,
|
|
6
|
+
dy: t === "x" ? 0 : e.dy
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
function n(e) {
|
|
10
|
+
return {
|
|
11
|
+
xMin: e.xMin,
|
|
12
|
+
xMax: e.xMax,
|
|
13
|
+
yMin: e.yMin,
|
|
14
|
+
yMax: e.yMax
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
function r(e, t, n, r) {
|
|
18
|
+
if (n.width <= 0 || n.height <= 0) return null;
|
|
19
|
+
let i = Math.max(0, Math.min(e - n.left, n.width)), a = Math.max(0, Math.min(t - n.top, n.height));
|
|
20
|
+
return [r.xMin + i / n.width * (r.xMax - r.xMin), r.yMax - a / n.height * (r.yMax - r.yMin)];
|
|
21
|
+
}
|
|
22
|
+
function i(e, t, n, r) {
|
|
23
|
+
let i = Math.min(t[0], n[0]), a = Math.max(t[0], n[0]), o = Math.min(t[1], n[1]), s = Math.max(t[1], n[1]);
|
|
24
|
+
return {
|
|
25
|
+
xMin: r === "y" ? e.xMin : i,
|
|
26
|
+
xMax: r === "y" ? e.xMax : a,
|
|
27
|
+
yMin: r === "x" ? e.yMin : o,
|
|
28
|
+
yMax: r === "x" ? e.yMax : s
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
function a(a = {}) {
|
|
32
|
+
return { install(o) {
|
|
33
|
+
let s = a.axis ?? "xy", c = a.minDragDistancePx ?? 6, l = o.canvas, u = o.xAxisElement, d = o.yAxisElement, f = document.createElement("div"), p = `blazeplot-axis-hover-${e++}`, m = document.createElement("style"), h = u.style.pointerEvents, g = d.style.pointerEvents, _ = u.style.cursor, v = d.style.cursor, y = u.style.filter, b = d.style.filter, x = null, S = null;
|
|
34
|
+
f.className = "blazeplot-selection", f.style.position = "absolute", f.style.display = "none", f.style.pointerEvents = "none", f.style.zIndex = "24", f.style.border = `1px solid ${a.selectionStroke ?? "rgba(147, 197, 253, 0.95)"}`, f.style.background = a.selectionFill ?? "rgba(59, 130, 246, 0.18)", o.plotElement.appendChild(f), m.textContent = `.${p} > div { color: ${a.axisHoverColor ?? "#f8fafc"} !important; }`, a.axisInteractions !== !1 && a.axisHover !== !1 && o.rootElement.appendChild(m), a.axisInteractions !== !1 && (u.style.pointerEvents = "auto", d.style.pointerEvents = "auto", u.style.cursor = "ew-resize", d.style.cursor = "ns-resize");
|
|
35
|
+
let C = () => {
|
|
36
|
+
S ??= n(o.getViewport());
|
|
37
|
+
}, w = (e, n) => {
|
|
38
|
+
let r = t(e, n);
|
|
39
|
+
return a.viewportPolicy?.beforePan?.(o.getCamera(), r) ?? r;
|
|
40
|
+
}, T = (e) => a.viewportPolicy?.beforeZoom?.(o.getCamera(), e) ?? e, E = () => {
|
|
41
|
+
f.style.display = "none";
|
|
42
|
+
}, D = (e, t) => {
|
|
43
|
+
if (a.axisHover === !1) return;
|
|
44
|
+
let n = t ? a.axisHoverFilter ?? "brightness(1.18)" : null;
|
|
45
|
+
e.classList.toggle(p, t), e === u ? u.style.filter = n ?? y : e === d && (d.style.filter = n ?? b);
|
|
46
|
+
}, O = () => D(u, !0), k = () => D(u, !1), A = () => D(d, !0), j = () => D(d, !1), M = (e) => {
|
|
47
|
+
let t = l.getBoundingClientRect(), n = Math.max(0, Math.min(e.startX - t.left, t.width)), r = Math.max(0, Math.min(e.startY - t.top, t.height)), i = Math.max(0, Math.min(e.currentX - t.left, t.width)), a = Math.max(0, Math.min(e.currentY - t.top, t.height)), o = s === "y" ? 0 : Math.min(n, i), c = s === "x" ? 0 : Math.min(r, a), u = s === "y" ? t.width : Math.abs(i - n), d = s === "x" ? t.height : Math.abs(a - r);
|
|
48
|
+
f.style.left = `${o}px`, f.style.top = `${c}px`, f.style.width = `${u}px`, f.style.height = `${d}px`, f.style.display = "block";
|
|
49
|
+
}, N = (e, t, n) => {
|
|
50
|
+
C(), e.preventDefault(), n !== l && D(n, !0), n.setPointerCapture(e.pointerId), x = {
|
|
51
|
+
mode: "pan",
|
|
52
|
+
pointerId: e.pointerId,
|
|
53
|
+
axis: t,
|
|
54
|
+
target: n,
|
|
55
|
+
lastX: e.clientX,
|
|
56
|
+
lastY: e.clientY
|
|
57
|
+
};
|
|
58
|
+
}, P = (e) => {
|
|
59
|
+
if (!(x || e.button !== 0)) {
|
|
60
|
+
if (e.shiftKey && a.shiftDragPan !== !1) {
|
|
61
|
+
N(e, s, l);
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
a.boxZoom !== !1 && (C(), e.preventDefault(), l.setPointerCapture(e.pointerId), x = {
|
|
65
|
+
mode: "select",
|
|
66
|
+
pointerId: e.pointerId,
|
|
67
|
+
target: l,
|
|
68
|
+
startX: e.clientX,
|
|
69
|
+
startY: e.clientY,
|
|
70
|
+
currentX: e.clientX,
|
|
71
|
+
currentY: e.clientY
|
|
72
|
+
}, M(x));
|
|
73
|
+
}
|
|
74
|
+
}, F = (e) => {
|
|
75
|
+
x || e.button !== 0 || a.axisInteractions === !1 || N(e, "x", u);
|
|
76
|
+
}, I = (e) => {
|
|
77
|
+
x || e.button !== 0 || a.axisInteractions === !1 || N(e, "y", d);
|
|
78
|
+
}, L = (e) => {
|
|
79
|
+
if (!(!x || e.pointerId !== x.pointerId)) {
|
|
80
|
+
if (e.preventDefault(), x.mode === "pan") {
|
|
81
|
+
let t = l.getBoundingClientRect(), n = w({
|
|
82
|
+
dx: t.width > 0 ? (x.lastX - e.clientX) / t.width : 0,
|
|
83
|
+
dy: t.height > 0 ? (e.clientY - x.lastY) / t.height : 0
|
|
84
|
+
}, x.axis);
|
|
85
|
+
n && o.pan(n), x.lastX = e.clientX, x.lastY = e.clientY;
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
x.currentX = e.clientX, x.currentY = e.clientY, M(x);
|
|
89
|
+
}
|
|
90
|
+
}, R = (e) => {
|
|
91
|
+
if (!x || e.pointerId !== x.pointerId) return;
|
|
92
|
+
e.preventDefault();
|
|
93
|
+
let t = x;
|
|
94
|
+
if (x = null, t.target.hasPointerCapture(e.pointerId) && t.target.releasePointerCapture(e.pointerId), E(), t.mode !== "select") return;
|
|
95
|
+
let n = e.clientX - t.startX, a = e.clientY - t.startY;
|
|
96
|
+
if (Math.hypot(n, a) < c) return;
|
|
97
|
+
let u = o.getViewport(), d = l.getBoundingClientRect(), f = r(t.startX, t.startY, d, u), p = r(e.clientX, e.clientY, d, u);
|
|
98
|
+
if (!f || !p) return;
|
|
99
|
+
let m = i(u, f, p, s);
|
|
100
|
+
m.xMax > m.xMin && m.yMax > m.yMin && o.setViewport(m);
|
|
101
|
+
}, z = (e) => {
|
|
102
|
+
if (!x || e.pointerId !== x.pointerId) return;
|
|
103
|
+
let t = x;
|
|
104
|
+
x = null, t.target.hasPointerCapture(e.pointerId) && t.target.releasePointerCapture(e.pointerId), E();
|
|
105
|
+
}, B = (e, t) => {
|
|
106
|
+
if (a.wheelZoom === !1) return;
|
|
107
|
+
C(), e.preventDefault();
|
|
108
|
+
let n = e.deltaY < 0 ? 1.1 : .9, r = l.getBoundingClientRect(), i = T({
|
|
109
|
+
factor: n,
|
|
110
|
+
cx: r.width > 0 ? (e.clientX - r.left) / r.width : .5,
|
|
111
|
+
cy: r.height > 0 ? 1 - (e.clientY - r.top) / r.height : .5,
|
|
112
|
+
axis: t
|
|
113
|
+
});
|
|
114
|
+
i && o.zoom(i);
|
|
115
|
+
}, V = (e) => {
|
|
116
|
+
B(e, s);
|
|
117
|
+
}, H = (e) => {
|
|
118
|
+
a.axisInteractions !== !1 && B(e, "x");
|
|
119
|
+
}, U = (e) => {
|
|
120
|
+
a.axisInteractions !== !1 && B(e, "y");
|
|
121
|
+
}, W = (e) => {
|
|
122
|
+
if (a.doubleClickReset === !1) return;
|
|
123
|
+
e.preventDefault();
|
|
124
|
+
let t = S ?? n(o.getViewport());
|
|
125
|
+
o.setViewport(t);
|
|
126
|
+
}, G = [
|
|
127
|
+
l,
|
|
128
|
+
u,
|
|
129
|
+
d
|
|
130
|
+
];
|
|
131
|
+
l.addEventListener("pointerdown", P), l.addEventListener("wheel", V, { passive: !1 }), l.addEventListener("dblclick", W), a.axisInteractions !== !1 && (u.addEventListener("pointerdown", F), d.addEventListener("pointerdown", I), u.addEventListener("pointerenter", O), u.addEventListener("pointerleave", k), d.addEventListener("pointerenter", A), d.addEventListener("pointerleave", j), u.addEventListener("wheel", H, { passive: !1 }), d.addEventListener("wheel", U, { passive: !1 }), u.addEventListener("dblclick", W), d.addEventListener("dblclick", W));
|
|
132
|
+
for (let e of G) e.addEventListener("pointermove", L), e.addEventListener("pointerup", R), e.addEventListener("pointercancel", z);
|
|
133
|
+
return () => {
|
|
134
|
+
l.removeEventListener("pointerdown", P), l.removeEventListener("wheel", V), l.removeEventListener("dblclick", W), u.removeEventListener("pointerdown", F), d.removeEventListener("pointerdown", I), u.removeEventListener("pointerenter", O), u.removeEventListener("pointerleave", k), d.removeEventListener("pointerenter", A), d.removeEventListener("pointerleave", j), u.removeEventListener("wheel", H), d.removeEventListener("wheel", U), u.removeEventListener("dblclick", W), d.removeEventListener("dblclick", W);
|
|
135
|
+
for (let e of G) e.removeEventListener("pointermove", L), e.removeEventListener("pointerup", R), e.removeEventListener("pointercancel", z);
|
|
136
|
+
u.style.pointerEvents = h, d.style.pointerEvents = g, u.style.cursor = _, d.style.cursor = v, u.style.filter = y, d.style.filter = b, u.classList.remove(p), d.classList.remove(p), m.remove(), f.remove();
|
|
137
|
+
};
|
|
138
|
+
} };
|
|
139
|
+
}
|
|
140
|
+
//#endregion
|
|
141
|
+
export { a as interactionsPlugin };
|
|
142
|
+
|
|
143
|
+
//# sourceMappingURL=interactions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interactions.js","names":[],"sources":["../../src/ui/Interactions.ts"],"sourcesContent":["import type { Viewport } from \"../core/types.js\";\nimport type { PanIntent, ViewportPolicy, ZoomAxis, ZoomIntent } from \"../interaction/types.js\";\nimport type { Chart, ChartPlugin } from \"./Chart.js\";\n\nexport interface InteractionsPluginOptions {\n readonly axis?: ZoomAxis;\n readonly viewportPolicy?: ViewportPolicy;\n readonly boxZoom?: boolean;\n readonly wheelZoom?: boolean;\n readonly axisInteractions?: boolean;\n readonly axisHover?: boolean;\n readonly axisHoverColor?: string;\n readonly axisHoverFilter?: string;\n readonly shiftDragPan?: boolean;\n readonly doubleClickReset?: boolean;\n readonly minDragDistancePx?: number;\n readonly selectionFill?: string;\n readonly selectionStroke?: string;\n}\n\nlet nextInteractionsPluginId = 1;\n\ntype InteractionTarget = HTMLCanvasElement | HTMLElement;\n\ntype DragState =\n | {\n readonly mode: \"pan\";\n readonly pointerId: number;\n readonly axis: ZoomAxis;\n readonly target: InteractionTarget;\n lastX: number;\n lastY: number;\n }\n | {\n readonly mode: \"select\";\n readonly pointerId: number;\n readonly target: HTMLCanvasElement;\n readonly startX: number;\n readonly startY: number;\n currentX: number;\n currentY: number;\n };\n\nfunction constrainPan(intent: PanIntent, axis: ZoomAxis): PanIntent {\n return {\n dx: axis === \"y\" ? 0 : intent.dx,\n dy: axis === \"x\" ? 0 : intent.dy,\n };\n}\n\nfunction normalizeViewport(v: Viewport): Viewport {\n return { xMin: v.xMin, xMax: v.xMax, yMin: v.yMin, yMax: v.yMax };\n}\n\nfunction clientToDataClamped(\n clientX: number,\n clientY: number,\n rect: DOMRect,\n viewport: Viewport,\n): [number, number] | null {\n if (rect.width <= 0 || rect.height <= 0) return null;\n\n const plotX = Math.max(0, Math.min(clientX - rect.left, rect.width));\n const plotY = Math.max(0, Math.min(clientY - rect.top, rect.height));\n return [\n viewport.xMin + (plotX / rect.width) * (viewport.xMax - viewport.xMin),\n viewport.yMax - (plotY / rect.height) * (viewport.yMax - viewport.yMin),\n ];\n}\n\nfunction applySelectionAxis(\n current: Viewport,\n a: [number, number],\n b: [number, number],\n axis: ZoomAxis,\n): Viewport {\n const xMin = Math.min(a[0], b[0]);\n const xMax = Math.max(a[0], b[0]);\n const yMin = Math.min(a[1], b[1]);\n const yMax = Math.max(a[1], b[1]);\n\n return {\n xMin: axis === \"y\" ? current.xMin : xMin,\n xMax: axis === \"y\" ? current.xMax : xMax,\n yMin: axis === \"x\" ? current.yMin : yMin,\n yMax: axis === \"x\" ? current.yMax : yMax,\n };\n}\n\nexport function interactionsPlugin(options: InteractionsPluginOptions = {}): ChartPlugin {\n return {\n install(chart: Chart) {\n const axis = options.axis ?? \"xy\";\n const minDragDistancePx = options.minDragDistancePx ?? 6;\n const canvas = chart.canvas;\n const xAxis = chart.xAxisElement;\n const yAxis = chart.yAxisElement;\n const selection = document.createElement(\"div\");\n const axisHoverClass = `blazeplot-axis-hover-${nextInteractionsPluginId++}`;\n const axisHoverStyle = document.createElement(\"style\");\n const originalXAxisPointerEvents = xAxis.style.pointerEvents;\n const originalYAxisPointerEvents = yAxis.style.pointerEvents;\n const originalXAxisCursor = xAxis.style.cursor;\n const originalYAxisCursor = yAxis.style.cursor;\n const originalXAxisFilter = xAxis.style.filter;\n const originalYAxisFilter = yAxis.style.filter;\n let drag: DragState | null = null;\n let resetViewport: Viewport | null = null;\n\n selection.className = \"blazeplot-selection\";\n selection.style.position = \"absolute\";\n selection.style.display = \"none\";\n selection.style.pointerEvents = \"none\";\n selection.style.zIndex = \"24\";\n selection.style.border = `1px solid ${options.selectionStroke ?? \"rgba(147, 197, 253, 0.95)\"}`;\n selection.style.background = options.selectionFill ?? \"rgba(59, 130, 246, 0.18)\";\n chart.plotElement.appendChild(selection);\n\n axisHoverStyle.textContent = `.${axisHoverClass} > div { color: ${options.axisHoverColor ?? \"#f8fafc\"} !important; }`;\n if (options.axisInteractions !== false && options.axisHover !== false) {\n chart.rootElement.appendChild(axisHoverStyle);\n }\n\n if (options.axisInteractions !== false) {\n xAxis.style.pointerEvents = \"auto\";\n yAxis.style.pointerEvents = \"auto\";\n xAxis.style.cursor = \"ew-resize\";\n yAxis.style.cursor = \"ns-resize\";\n }\n\n const captureResetViewport = (): void => {\n resetViewport ??= normalizeViewport(chart.getViewport());\n };\n\n const applyPanPolicy = (intent: PanIntent, panAxis: ZoomAxis): PanIntent | null => {\n const constrained = constrainPan(intent, panAxis);\n return options.viewportPolicy?.beforePan?.(chart.getCamera(), constrained) ?? constrained;\n };\n\n const applyZoomPolicy = (intent: ZoomIntent): ZoomIntent | null => {\n return options.viewportPolicy?.beforeZoom?.(chart.getCamera(), intent) ?? intent;\n };\n\n const hideSelection = (): void => {\n selection.style.display = \"none\";\n };\n\n const setAxisHovered = (target: HTMLElement, hovered: boolean): void => {\n if (options.axisHover === false) return;\n const filter = hovered ? options.axisHoverFilter ?? \"brightness(1.18)\" : null;\n target.classList.toggle(axisHoverClass, hovered);\n if (target === xAxis) {\n xAxis.style.filter = filter ?? originalXAxisFilter;\n } else if (target === yAxis) {\n yAxis.style.filter = filter ?? originalYAxisFilter;\n }\n };\n\n const onXAxisPointerEnter = (): void => setAxisHovered(xAxis, true);\n const onXAxisPointerLeave = (): void => setAxisHovered(xAxis, false);\n const onYAxisPointerEnter = (): void => setAxisHovered(yAxis, true);\n const onYAxisPointerLeave = (): void => setAxisHovered(yAxis, false);\n\n const updateSelection = (state: Extract<DragState, { mode: \"select\" }>): void => {\n const rect = canvas.getBoundingClientRect();\n const x0 = Math.max(0, Math.min(state.startX - rect.left, rect.width));\n const y0 = Math.max(0, Math.min(state.startY - rect.top, rect.height));\n const x1 = Math.max(0, Math.min(state.currentX - rect.left, rect.width));\n const y1 = Math.max(0, Math.min(state.currentY - rect.top, rect.height));\n const left = axis === \"y\" ? 0 : Math.min(x0, x1);\n const top = axis === \"x\" ? 0 : Math.min(y0, y1);\n const width = axis === \"y\" ? rect.width : Math.abs(x1 - x0);\n const height = axis === \"x\" ? rect.height : Math.abs(y1 - y0);\n\n selection.style.left = `${left}px`;\n selection.style.top = `${top}px`;\n selection.style.width = `${width}px`;\n selection.style.height = `${height}px`;\n selection.style.display = \"block\";\n };\n\n const beginPan = (event: PointerEvent, panAxis: ZoomAxis, target: InteractionTarget): void => {\n captureResetViewport();\n event.preventDefault();\n if (target !== canvas) setAxisHovered(target, true);\n target.setPointerCapture(event.pointerId);\n drag = {\n mode: \"pan\",\n pointerId: event.pointerId,\n axis: panAxis,\n target,\n lastX: event.clientX,\n lastY: event.clientY,\n };\n };\n\n const onCanvasPointerDown = (event: PointerEvent): void => {\n if (drag || event.button !== 0) return;\n\n if (event.shiftKey && options.shiftDragPan !== false) {\n beginPan(event, axis, canvas);\n return;\n }\n\n if (options.boxZoom === false) return;\n captureResetViewport();\n event.preventDefault();\n canvas.setPointerCapture(event.pointerId);\n drag = {\n mode: \"select\",\n pointerId: event.pointerId,\n target: canvas,\n startX: event.clientX,\n startY: event.clientY,\n currentX: event.clientX,\n currentY: event.clientY,\n };\n updateSelection(drag);\n };\n\n const onXAxisPointerDown = (event: PointerEvent): void => {\n if (drag || event.button !== 0 || options.axisInteractions === false) return;\n beginPan(event, \"x\", xAxis);\n };\n\n const onYAxisPointerDown = (event: PointerEvent): void => {\n if (drag || event.button !== 0 || options.axisInteractions === false) return;\n beginPan(event, \"y\", yAxis);\n };\n\n const onPointerMove = (event: PointerEvent): void => {\n if (!drag || event.pointerId !== drag.pointerId) return;\n event.preventDefault();\n\n if (drag.mode === \"pan\") {\n const rect = canvas.getBoundingClientRect();\n const dx = rect.width > 0 ? (drag.lastX - event.clientX) / rect.width : 0;\n const dy = rect.height > 0 ? (event.clientY - drag.lastY) / rect.height : 0;\n const intent = applyPanPolicy({ dx, dy }, drag.axis);\n if (intent) chart.pan(intent);\n drag.lastX = event.clientX;\n drag.lastY = event.clientY;\n return;\n }\n\n drag.currentX = event.clientX;\n drag.currentY = event.clientY;\n updateSelection(drag);\n };\n\n const onPointerUp = (event: PointerEvent): void => {\n if (!drag || event.pointerId !== drag.pointerId) return;\n event.preventDefault();\n\n const completed = drag;\n drag = null;\n if (completed.target.hasPointerCapture(event.pointerId)) completed.target.releasePointerCapture(event.pointerId);\n hideSelection();\n\n if (completed.mode !== \"select\") return;\n\n const dx = event.clientX - completed.startX;\n const dy = event.clientY - completed.startY;\n if (Math.hypot(dx, dy) < minDragDistancePx) return;\n\n const current = chart.getViewport();\n const rect = canvas.getBoundingClientRect();\n const start = clientToDataClamped(completed.startX, completed.startY, rect, current);\n const end = clientToDataClamped(event.clientX, event.clientY, rect, current);\n if (!start || !end) return;\n\n const next = applySelectionAxis(current, start, end, axis);\n if (next.xMax > next.xMin && next.yMax > next.yMin) chart.setViewport(next);\n };\n\n const onPointerCancel = (event: PointerEvent): void => {\n if (!drag || event.pointerId !== drag.pointerId) return;\n const completed = drag;\n drag = null;\n if (completed.target.hasPointerCapture(event.pointerId)) completed.target.releasePointerCapture(event.pointerId);\n hideSelection();\n };\n\n const wheelOnAxis = (event: WheelEvent, zoomAxis: ZoomAxis): void => {\n if (options.wheelZoom === false) return;\n captureResetViewport();\n event.preventDefault();\n const factor = event.deltaY < 0 ? 1.1 : 0.9;\n const rect = canvas.getBoundingClientRect();\n const cx = rect.width > 0 ? (event.clientX - rect.left) / rect.width : 0.5;\n const cy = rect.height > 0 ? 1 - (event.clientY - rect.top) / rect.height : 0.5;\n const intent = applyZoomPolicy({ factor, cx, cy, axis: zoomAxis });\n if (intent) chart.zoom(intent);\n };\n\n const onCanvasWheel = (event: WheelEvent): void => {\n wheelOnAxis(event, axis);\n };\n\n const onXAxisWheel = (event: WheelEvent): void => {\n if (options.axisInteractions === false) return;\n wheelOnAxis(event, \"x\");\n };\n\n const onYAxisWheel = (event: WheelEvent): void => {\n if (options.axisInteractions === false) return;\n wheelOnAxis(event, \"y\");\n };\n\n const onDoubleClick = (event: MouseEvent): void => {\n if (options.doubleClickReset === false) return;\n event.preventDefault();\n const target = resetViewport ?? normalizeViewport(chart.getViewport());\n chart.setViewport(target);\n };\n\n const pointerTargets = [canvas, xAxis, yAxis];\n canvas.addEventListener(\"pointerdown\", onCanvasPointerDown);\n canvas.addEventListener(\"wheel\", onCanvasWheel, { passive: false });\n canvas.addEventListener(\"dblclick\", onDoubleClick);\n\n if (options.axisInteractions !== false) {\n xAxis.addEventListener(\"pointerdown\", onXAxisPointerDown);\n yAxis.addEventListener(\"pointerdown\", onYAxisPointerDown);\n xAxis.addEventListener(\"pointerenter\", onXAxisPointerEnter);\n xAxis.addEventListener(\"pointerleave\", onXAxisPointerLeave);\n yAxis.addEventListener(\"pointerenter\", onYAxisPointerEnter);\n yAxis.addEventListener(\"pointerleave\", onYAxisPointerLeave);\n xAxis.addEventListener(\"wheel\", onXAxisWheel, { passive: false });\n yAxis.addEventListener(\"wheel\", onYAxisWheel, { passive: false });\n xAxis.addEventListener(\"dblclick\", onDoubleClick);\n yAxis.addEventListener(\"dblclick\", onDoubleClick);\n }\n\n for (const target of pointerTargets) {\n target.addEventListener(\"pointermove\", onPointerMove);\n target.addEventListener(\"pointerup\", onPointerUp);\n target.addEventListener(\"pointercancel\", onPointerCancel);\n }\n\n return () => {\n canvas.removeEventListener(\"pointerdown\", onCanvasPointerDown);\n canvas.removeEventListener(\"wheel\", onCanvasWheel);\n canvas.removeEventListener(\"dblclick\", onDoubleClick);\n xAxis.removeEventListener(\"pointerdown\", onXAxisPointerDown);\n yAxis.removeEventListener(\"pointerdown\", onYAxisPointerDown);\n xAxis.removeEventListener(\"pointerenter\", onXAxisPointerEnter);\n xAxis.removeEventListener(\"pointerleave\", onXAxisPointerLeave);\n yAxis.removeEventListener(\"pointerenter\", onYAxisPointerEnter);\n yAxis.removeEventListener(\"pointerleave\", onYAxisPointerLeave);\n xAxis.removeEventListener(\"wheel\", onXAxisWheel);\n yAxis.removeEventListener(\"wheel\", onYAxisWheel);\n xAxis.removeEventListener(\"dblclick\", onDoubleClick);\n yAxis.removeEventListener(\"dblclick\", onDoubleClick);\n for (const target of pointerTargets) {\n target.removeEventListener(\"pointermove\", onPointerMove);\n target.removeEventListener(\"pointerup\", onPointerUp);\n target.removeEventListener(\"pointercancel\", onPointerCancel);\n }\n xAxis.style.pointerEvents = originalXAxisPointerEvents;\n yAxis.style.pointerEvents = originalYAxisPointerEvents;\n xAxis.style.cursor = originalXAxisCursor;\n yAxis.style.cursor = originalYAxisCursor;\n xAxis.style.filter = originalXAxisFilter;\n yAxis.style.filter = originalYAxisFilter;\n xAxis.classList.remove(axisHoverClass);\n yAxis.classList.remove(axisHoverClass);\n axisHoverStyle.remove();\n selection.remove();\n };\n },\n };\n}\n"],"mappings":";AAoBA,IAAI,IAA2B;AAuB/B,SAAS,EAAa,GAAmB,GAA2B;CAClE,OAAO;EACL,IAAI,MAAS,MAAM,IAAI,EAAO;EAC9B,IAAI,MAAS,MAAM,IAAI,EAAO;CAChC;AACF;AAEA,SAAS,EAAkB,GAAuB;CAChD,OAAO;EAAE,MAAM,EAAE;EAAM,MAAM,EAAE;EAAM,MAAM,EAAE;EAAM,MAAM,EAAE;CAAK;AAClE;AAEA,SAAS,EACP,GACA,GACA,GACA,GACyB;CACzB,IAAI,EAAK,SAAS,KAAK,EAAK,UA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K,IAAM,KAAU,GAGnB,AAFA,EAAO,oBAAoB,eAAe,CAAa,GACvD,EAAO,oBAAoB,aAAa,CAAW,GACnD,EAAO,oBAAoB,iBAAiB,CAAe;GAW7D,AATA,EAAM,MAAM,gBAAgB,GAC5B,EAAM,MAAM,gBAAgB,GAC5B,EAAM,MAAM,SAAS,GACrB,EAAM,MAAM,SAAS,GACrB,EAAM,MAAM,SAAS,GACrB,EAAM,MAAM,SAAS,GACrB,EAAM,UAAU,OAAO,CAAc,GACrC,EAAM,UAAU,OAAO,CAAc,GACrC,EAAe,OAAO,GACtB,EAAU,OAAO;EACnB;CACF,EACF;AACF"}
|
package/dist/plugins/legend.js
CHANGED
|
@@ -5,33 +5,40 @@ function e(e) {
|
|
|
5
5
|
function t(e, t) {
|
|
6
6
|
e.style.top = t.startsWith("top") ? "8px" : "auto", e.style.bottom = t.startsWith("bottom") ? "8px" : "auto", e.style.left = t.endsWith("left") ? "8px" : "auto", e.style.right = t.endsWith("right") ? "8px" : "auto";
|
|
7
7
|
}
|
|
8
|
-
function n(
|
|
8
|
+
function n(e, t) {
|
|
9
|
+
let n = e.borderColor ?? t.theme.legendBorderColor;
|
|
10
|
+
return n === "transparent" ? "0" : `1px solid ${n}`;
|
|
11
|
+
}
|
|
12
|
+
function r(t, n, r, i, a) {
|
|
9
13
|
n.replaceChildren();
|
|
10
|
-
for (let
|
|
14
|
+
for (let o of t) {
|
|
11
15
|
let t = document.createElement("button");
|
|
12
|
-
t.type = "button", t.style.display = "flex", t.style.alignItems = "center", t.style.gap = "6px", t.style.
|
|
13
|
-
let o = document.createElement("span");
|
|
14
|
-
o.style.width = "10px", o.style.height = "10px", o.style.borderRadius = "2px", o.style.background = e(a.color), o.style.flex = "0 0 auto";
|
|
16
|
+
t.type = "button", t.style.display = "flex", t.style.alignItems = "center", t.style.gap = "6px", t.style.border = "0", t.style.margin = "0", t.style.padding = "0", t.style.appearance = "none", t.style.background = "transparent", t.style.color = o.visible ? a.textColor ?? r.theme.legendTextColor : a.mutedTextColor ?? r.theme.legendMutedTextColor, t.style.font = "inherit", t.style.textAlign = "left", t.style.cursor = i ? "pointer" : "default", t.style.opacity = o.visible ? "1" : "0.45";
|
|
15
17
|
let s = document.createElement("span");
|
|
16
|
-
s.textContent =
|
|
17
|
-
|
|
18
|
+
s.textContent = "█", s.style.color = e(o.color), s.style.flex = "0 0 auto";
|
|
19
|
+
let c = document.createElement("span");
|
|
20
|
+
c.textContent = o.name ?? o.id ?? `${o.mode} ${o.index + 1}`, t.append(s, c), i && t.addEventListener("click", () => {
|
|
21
|
+
r.setSeriesVisible(o.series, !o.visible);
|
|
18
22
|
}), n.appendChild(t);
|
|
19
23
|
}
|
|
20
24
|
}
|
|
21
|
-
function
|
|
22
|
-
return { install(
|
|
23
|
-
let
|
|
24
|
-
|
|
25
|
-
let
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
25
|
+
function i(e = {}) {
|
|
26
|
+
return { install(i) {
|
|
27
|
+
let a = document.createElement("div");
|
|
28
|
+
a.className = e.className ?? "blazeplot-legend", a.style.position = "absolute", a.style.zIndex = "20", a.style.pointerEvents = "auto", a.style.padding = "8px 10px", a.style.border = n(e, i), a.style.background = e.backgroundColor ?? i.theme.legendBackgroundColor, a.style.color = e.textColor ?? i.theme.legendTextColor, a.style.font = e.font ?? i.theme.legendFont, a.style.whiteSpace = "pre", a.style.userSelect = "none", t(a, e.position ?? "top-right"), i.rootElement.appendChild(a);
|
|
29
|
+
let o = () => {
|
|
30
|
+
a.style.border = n(e, i), a.style.background = e.backgroundColor ?? i.theme.legendBackgroundColor, a.style.color = e.textColor ?? i.theme.legendTextColor, a.style.font = e.font ?? i.theme.legendFont;
|
|
31
|
+
}, s = () => {
|
|
32
|
+
o();
|
|
33
|
+
let t = i.getSeriesState();
|
|
34
|
+
e.render ? e.render(t, a, i) : r(t, a, i, e.toggleOnClick !== !1, e);
|
|
35
|
+
}, c = i.subscribe("serieschange", s), l = i.subscribe("themechange", s);
|
|
36
|
+
return s(), () => {
|
|
37
|
+
c(), l(), a.remove();
|
|
31
38
|
};
|
|
32
39
|
} };
|
|
33
40
|
}
|
|
34
41
|
//#endregion
|
|
35
|
-
export {
|
|
42
|
+
export { i as legendPlugin };
|
|
36
43
|
|
|
37
44
|
//# sourceMappingURL=legend.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"legend.js","names":[],"sources":["../../src/ui/Legend.ts"],"sourcesContent":["import type { Chart, ChartPlugin, ChartSeriesState } from \"./Chart.js\";\n\nexport interface LegendPluginOptions {\n readonly className?: string;\n readonly position?: \"top-left\" | \"top-right\" | \"bottom-left\" | \"bottom-right\";\n readonly toggleOnClick?: boolean;\n readonly render?: (state: readonly ChartSeriesState[], container: HTMLElement, chart: Chart) => void;\n}\n\nfunction rgba(color: readonly [number, number, number, number]): string {\n return `rgba(${Math.round(color[0] * 255)}, ${Math.round(color[1] * 255)}, ${Math.round(color[2] * 255)}, ${color[3]})`;\n}\n\nfunction applyPosition(el: HTMLElement, position: NonNullable<LegendPluginOptions[\"position\"]>): void {\n el.style.top = position.startsWith(\"top\") ? \"8px\" : \"auto\";\n el.style.bottom = position.startsWith(\"bottom\") ? \"8px\" : \"auto\";\n el.style.left = position.endsWith(\"left\") ? \"8px\" : \"auto\";\n el.style.right = position.endsWith(\"right\") ? \"8px\" : \"auto\";\n}\n\nfunction renderDefaultLegend(\n state: readonly ChartSeriesState[],\n container: HTMLElement,\n chart: Chart,\n toggleOnClick: boolean,\n): void {\n container.replaceChildren();\n\n for (const item of state) {\n const row = document.createElement(\"button\");\n row.type = \"button\";\n row.style.display = \"flex\";\n row.style.alignItems = \"center\";\n row.style.gap = \"6px\";\n row.style.
|
|
1
|
+
{"version":3,"file":"legend.js","names":[],"sources":["../../src/ui/Legend.ts"],"sourcesContent":["import type { Chart, ChartPlugin, ChartSeriesState } from \"./Chart.js\";\n\nexport interface LegendPluginOptions {\n readonly className?: string;\n readonly position?: \"top-left\" | \"top-right\" | \"bottom-left\" | \"bottom-right\";\n readonly toggleOnClick?: boolean;\n readonly backgroundColor?: string;\n readonly borderColor?: string;\n readonly textColor?: string;\n readonly mutedTextColor?: string;\n readonly font?: string;\n readonly render?: (state: readonly ChartSeriesState[], container: HTMLElement, chart: Chart) => void;\n}\n\nfunction rgba(color: readonly [number, number, number, number]): string {\n return `rgba(${Math.round(color[0] * 255)}, ${Math.round(color[1] * 255)}, ${Math.round(color[2] * 255)}, ${color[3]})`;\n}\n\nfunction applyPosition(el: HTMLElement, position: NonNullable<LegendPluginOptions[\"position\"]>): void {\n el.style.top = position.startsWith(\"top\") ? \"8px\" : \"auto\";\n el.style.bottom = position.startsWith(\"bottom\") ? \"8px\" : \"auto\";\n el.style.left = position.endsWith(\"left\") ? \"8px\" : \"auto\";\n el.style.right = position.endsWith(\"right\") ? \"8px\" : \"auto\";\n}\n\nfunction legendBorder(options: LegendPluginOptions, chart: Chart): string {\n const color = options.borderColor ?? chart.theme.legendBorderColor;\n return color === \"transparent\" ? \"0\" : `1px solid ${color}`;\n}\n\nfunction renderDefaultLegend(\n state: readonly ChartSeriesState[],\n container: HTMLElement,\n chart: Chart,\n toggleOnClick: boolean,\n options: LegendPluginOptions,\n): void {\n container.replaceChildren();\n\n for (const item of state) {\n const row = document.createElement(\"button\");\n row.type = \"button\";\n row.style.display = \"flex\";\n row.style.alignItems = \"center\";\n row.style.gap = \"6px\";\n row.style.border = \"0\";\n row.style.margin = \"0\";\n row.style.padding = \"0\";\n row.style.appearance = \"none\";\n row.style.background = \"transparent\";\n row.style.color = item.visible\n ? options.textColor ?? chart.theme.legendTextColor\n : options.mutedTextColor ?? chart.theme.legendMutedTextColor;\n row.style.font = \"inherit\";\n row.style.textAlign = \"left\";\n row.style.cursor = toggleOnClick ? \"pointer\" : \"default\";\n row.style.opacity = item.visible ? \"1\" : \"0.45\";\n\n const swatch = document.createElement(\"span\");\n swatch.textContent = \"\\u2588\";\n swatch.style.color = rgba(item.color);\n swatch.style.flex = \"0 0 auto\";\n\n const label = document.createElement(\"span\");\n label.textContent = item.name ?? item.id ?? `${item.mode} ${item.index + 1}`;\n\n row.append(swatch, label);\n if (toggleOnClick) {\n row.addEventListener(\"click\", () => {\n chart.setSeriesVisible(item.series, !item.visible);\n });\n }\n container.appendChild(row);\n }\n}\n\nexport function legendPlugin(options: LegendPluginOptions = {}): ChartPlugin {\n return {\n install(chart: Chart) {\n const container = document.createElement(\"div\");\n container.className = options.className ?? \"blazeplot-legend\";\n container.style.position = \"absolute\";\n container.style.zIndex = \"20\";\n container.style.pointerEvents = \"auto\";\n container.style.padding = \"8px 10px\";\n container.style.border = legendBorder(options, chart);\n container.style.background = options.backgroundColor ?? chart.theme.legendBackgroundColor;\n container.style.color = options.textColor ?? chart.theme.legendTextColor;\n container.style.font = options.font ?? chart.theme.legendFont;\n container.style.whiteSpace = \"pre\";\n container.style.userSelect = \"none\";\n applyPosition(container, options.position ?? \"top-right\");\n chart.rootElement.appendChild(container);\n\n const applyTheme = (): void => {\n container.style.border = legendBorder(options, chart);\n container.style.background = options.backgroundColor ?? chart.theme.legendBackgroundColor;\n container.style.color = options.textColor ?? chart.theme.legendTextColor;\n container.style.font = options.font ?? chart.theme.legendFont;\n };\n\n const render = (): void => {\n applyTheme();\n const state = chart.getSeriesState();\n if (options.render) {\n options.render(state, container, chart);\n } else {\n renderDefaultLegend(state, container, chart, options.toggleOnClick !== false, options);\n }\n };\n\n const unsubscribeSeries = chart.subscribe(\"serieschange\", render);\n const unsubscribeTheme = chart.subscribe(\"themechange\", render);\n render();\n\n return () => {\n unsubscribeSeries();\n unsubscribeTheme();\n container.remove();\n };\n },\n };\n}\n"],"mappings":";AAcA,SAAS,EAAK,GAA0D;CACtE,OAAO,QAAQ,KAAK,MAAM,EAAM,KAAK,GAAG,EAAE,IAAI,KAAK,MAAM,EAAM,KAAK,GAAG,EAAE,IAAI,KAAK,MAAM,EAAM,KAAK,GAAG,EAAE,IAAI,EAAM,GAAG;A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AEM;GAGX,AAFA,EAAkB,GAClB,EAAiB,GACjB,EAAU,OAAO;EACnB;CACF,EACF;AACF"}
|
package/dist/plugins/tooltip.js
CHANGED
|
@@ -21,26 +21,30 @@ function r(r, i, a) {
|
|
|
21
21
|
function i(e = {}) {
|
|
22
22
|
return { install(t) {
|
|
23
23
|
let i = document.createElement("div");
|
|
24
|
-
i.className = e.className ?? "blazeplot-tooltip", i.style.position = "absolute", i.style.zIndex = "30", i.style.display = "none", i.style.pointerEvents = "none", i.style.background =
|
|
24
|
+
i.className = e.className ?? "blazeplot-tooltip", i.style.position = "absolute", i.style.zIndex = "30", i.style.display = "none", i.style.pointerEvents = "none", i.style.background = e.backgroundColor ?? t.theme.tooltipBackgroundColor, i.style.color = e.textColor ?? t.theme.tooltipTextColor, i.style.font = e.font ?? t.theme.tooltipFont, i.style.padding = "8px 10px", i.style.whiteSpace = "pre", t.rootElement.appendChild(i);
|
|
25
25
|
let a = document.createElement("div");
|
|
26
26
|
a.className = "blazeplot-tooltip-markers", a.style.position = "absolute", a.style.inset = "0", a.style.zIndex = "25", a.style.pointerEvents = "none", t.plotElement.appendChild(a);
|
|
27
|
-
let o = (
|
|
27
|
+
let o = () => {
|
|
28
|
+
i.style.background = e.backgroundColor ?? t.theme.tooltipBackgroundColor, i.style.color = e.textColor ?? t.theme.tooltipTextColor, i.style.font = e.font ?? t.theme.tooltipFont;
|
|
29
|
+
}, s = (t) => {
|
|
28
30
|
if (a.replaceChildren(), !(e.highlight === !1 || !t)) for (let e of t.items) {
|
|
29
31
|
let t = document.createElement("div");
|
|
30
|
-
t.style.position = "absolute", t.style.left = `${e.plotX}px`, t.style.top = `${e.plotY}px`, t.style.width = "10px", t.style.height = "10px", t.style.border = "2px solid #f8fafc", t.style.borderRadius = "999px", t.style.background = n(e.series.style.color), t.style.boxShadow = "0 0 0
|
|
32
|
+
t.style.position = "absolute", t.style.left = `${e.plotX}px`, t.style.top = `${e.plotY}px`, t.style.width = "10px", t.style.height = "10px", t.style.border = "2px solid #f8fafc", t.style.borderRadius = "999px", t.style.background = n(e.series.style.color), t.style.boxShadow = "0 0 0 1px rgba(4, 8, 16, 0.85)", t.style.transform = "translate(-50%, -50%)", a.appendChild(t);
|
|
31
33
|
}
|
|
32
|
-
},
|
|
34
|
+
}, c = (n) => {
|
|
33
35
|
let a = n && (e.mode !== void 0 || e.maxDistancePx !== void 0) ? t.pick(n.clientX, n.clientY, e) : n;
|
|
34
|
-
if (
|
|
36
|
+
if (s(a), !a || a.items.length === 0) {
|
|
35
37
|
i.style.display = "none";
|
|
36
38
|
return;
|
|
37
39
|
}
|
|
38
40
|
e.render ? e.render(a, i, t) : r(a, i, e.formatter);
|
|
39
|
-
let
|
|
41
|
+
let o = t.rootElement.getBoundingClientRect(), c = a.clientX - o.left + (e.offsetX ?? 12), l = a.clientY - o.top + (e.offsetY ?? 12);
|
|
40
42
|
i.style.transform = `translate(${c}px, ${l}px)`, i.style.display = "block";
|
|
43
|
+
}, l = t.subscribe("hover", c), u = t.subscribe("themechange", () => {
|
|
44
|
+
o(), c(t.getHoverState());
|
|
41
45
|
});
|
|
42
|
-
return () => {
|
|
43
|
-
|
|
46
|
+
return o(), () => {
|
|
47
|
+
l(), u(), a.remove(), i.remove();
|
|
44
48
|
};
|
|
45
49
|
} };
|
|
46
50
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tooltip.js","names":[],"sources":["../../src/ui/Tooltip.ts"],"sourcesContent":["import type { Chart, ChartHoverState, ChartPickItem, ChartPickMode, ChartPlugin } from \"./Chart.js\";\n\nexport interface TooltipPluginOptions {\n readonly className?: string;\n readonly mode?: ChartPickMode;\n readonly maxDistancePx?: number;\n readonly offsetX?: number;\n readonly offsetY?: number;\n readonly highlight?: boolean;\n readonly formatter?: (item: ChartPickItem, state: ChartHoverState) => string;\n readonly render?: (state: ChartHoverState, container: HTMLElement, chart: Chart) => void;\n}\n\nfunction labelOf(item: ChartPickItem): string {\n return item.name ?? item.id ?? `${item.mode} ${item.seriesIndex + 1}`;\n}\n\nfunction formatNumber(value: number): string {\n if (!Number.isFinite(value)) return String(value);\n const abs = Math.abs(value);\n if (abs > 0 && (abs < 1e-3 || abs >= 1e6)) return value.toExponential(3);\n return Number(value.toPrecision(6)).toString();\n}\n\nfunction rgba(color: readonly [number, number, number, number]): string {\n return `rgba(${Math.round(color[0] * 255)}, ${Math.round(color[1] * 255)}, ${Math.round(color[2] * 255)}, ${color[3]})`;\n}\n\nfunction renderDefaultTooltip(\n state: ChartHoverState,\n container: HTMLElement,\n formatter: TooltipPluginOptions[\"formatter\"],\n): void {\n const pad = Math.max(1, ...state.items.map((item) => labelOf(item).length));\n let html = \"\";\n for (const item of state.items) {\n const value = formatter ? formatter(item, state) : `(${formatNumber(item.x)}, ${formatNumber(item.y)})`;\n const color = rgba(item.series.style.color);\n if (html) html += \"<br>\";\n html += `<span style=\"color:${color}\">\\u2588</span> ${labelOf(item).padEnd(pad)} ${value}`;\n }\n container.innerHTML = html;\n}\n\nexport function tooltipPlugin(options: TooltipPluginOptions = {}): ChartPlugin {\n return {\n install(chart: Chart) {\n const container = document.createElement(\"div\");\n container.className = options.className ?? \"blazeplot-tooltip\";\n container.style.position = \"absolute\";\n container.style.zIndex = \"30\";\n container.style.display = \"none\";\n container.style.pointerEvents = \"none\";\n container.style.background =
|
|
1
|
+
{"version":3,"file":"tooltip.js","names":[],"sources":["../../src/ui/Tooltip.ts"],"sourcesContent":["import type { Chart, ChartHoverState, ChartPickItem, ChartPickMode, ChartPlugin } from \"./Chart.js\";\n\nexport interface TooltipPluginOptions {\n readonly className?: string;\n readonly mode?: ChartPickMode;\n readonly maxDistancePx?: number;\n readonly offsetX?: number;\n readonly offsetY?: number;\n readonly highlight?: boolean;\n readonly backgroundColor?: string;\n readonly textColor?: string;\n readonly font?: string;\n readonly formatter?: (item: ChartPickItem, state: ChartHoverState) => string;\n readonly render?: (state: ChartHoverState, container: HTMLElement, chart: Chart) => void;\n}\n\nfunction labelOf(item: ChartPickItem): string {\n return item.name ?? item.id ?? `${item.mode} ${item.seriesIndex + 1}`;\n}\n\nfunction formatNumber(value: number): string {\n if (!Number.isFinite(value)) return String(value);\n const abs = Math.abs(value);\n if (abs > 0 && (abs < 1e-3 || abs >= 1e6)) return value.toExponential(3);\n return Number(value.toPrecision(6)).toString();\n}\n\nfunction rgba(color: readonly [number, number, number, number]): string {\n return `rgba(${Math.round(color[0] * 255)}, ${Math.round(color[1] * 255)}, ${Math.round(color[2] * 255)}, ${color[3]})`;\n}\n\nfunction renderDefaultTooltip(\n state: ChartHoverState,\n container: HTMLElement,\n formatter: TooltipPluginOptions[\"formatter\"],\n): void {\n const pad = Math.max(1, ...state.items.map((item) => labelOf(item).length));\n let html = \"\";\n for (const item of state.items) {\n const value = formatter ? formatter(item, state) : `(${formatNumber(item.x)}, ${formatNumber(item.y)})`;\n const color = rgba(item.series.style.color);\n if (html) html += \"<br>\";\n html += `<span style=\"color:${color}\">\\u2588</span> ${labelOf(item).padEnd(pad)} ${value}`;\n }\n container.innerHTML = html;\n}\n\nexport function tooltipPlugin(options: TooltipPluginOptions = {}): ChartPlugin {\n return {\n install(chart: Chart) {\n const container = document.createElement(\"div\");\n container.className = options.className ?? \"blazeplot-tooltip\";\n container.style.position = \"absolute\";\n container.style.zIndex = \"30\";\n container.style.display = \"none\";\n container.style.pointerEvents = \"none\";\n container.style.background = options.backgroundColor ?? chart.theme.tooltipBackgroundColor;\n container.style.color = options.textColor ?? chart.theme.tooltipTextColor;\n container.style.font = options.font ?? chart.theme.tooltipFont;\n container.style.padding = \"8px 10px\";\n container.style.whiteSpace = \"pre\";\n chart.rootElement.appendChild(container);\n\n const markerLayer = document.createElement(\"div\");\n markerLayer.className = \"blazeplot-tooltip-markers\";\n markerLayer.style.position = \"absolute\";\n markerLayer.style.inset = \"0\";\n markerLayer.style.zIndex = \"25\";\n markerLayer.style.pointerEvents = \"none\";\n chart.plotElement.appendChild(markerLayer);\n\n const applyTheme = (): void => {\n container.style.background = options.backgroundColor ?? chart.theme.tooltipBackgroundColor;\n container.style.color = options.textColor ?? chart.theme.tooltipTextColor;\n container.style.font = options.font ?? chart.theme.tooltipFont;\n };\n\n const renderMarkers = (state: ChartHoverState | null): void => {\n markerLayer.replaceChildren();\n if (options.highlight === false || !state) return;\n\n for (const item of state.items) {\n const marker = document.createElement(\"div\");\n marker.style.position = \"absolute\";\n marker.style.left = `${item.plotX}px`;\n marker.style.top = `${item.plotY}px`;\n marker.style.width = \"10px\";\n marker.style.height = \"10px\";\n marker.style.border = \"2px solid #f8fafc\";\n marker.style.borderRadius = \"999px\";\n marker.style.background = rgba(item.series.style.color);\n marker.style.boxShadow = \"0 0 0 1px rgba(4, 8, 16, 0.85)\";\n marker.style.transform = \"translate(-50%, -50%)\";\n markerLayer.appendChild(marker);\n }\n };\n\n const render = (state: ChartHoverState | null): void => {\n const effectiveState = state && (options.mode !== undefined || options.maxDistancePx !== undefined)\n ? chart.pick(state.clientX, state.clientY, options)\n : state;\n\n renderMarkers(effectiveState);\n if (!effectiveState || effectiveState.items.length === 0) {\n container.style.display = \"none\";\n return;\n }\n\n if (options.render) {\n options.render(effectiveState, container, chart);\n } else {\n renderDefaultTooltip(effectiveState, container, options.formatter);\n }\n\n const rootRect = chart.rootElement.getBoundingClientRect();\n const x = effectiveState.clientX - rootRect.left + (options.offsetX ?? 12);\n const y = effectiveState.clientY - rootRect.top + (options.offsetY ?? 12);\n container.style.transform = `translate(${x}px, ${y}px)`;\n container.style.display = \"block\";\n };\n\n const unsubscribeHover = chart.subscribe(\"hover\", render);\n const unsubscribeTheme = chart.subscribe(\"themechange\", () => {\n applyTheme();\n render(chart.getHoverState());\n });\n applyTheme();\n return () => {\n unsubscribeHover();\n unsubscribeTheme();\n markerLayer.remove();\n container.remove();\n };\n },\n };\n}\n"],"mappings":";AAgBA,SAAS,EAAQ,GAA6B;CAC5C,OAAO,EAAK,QAAQ,EAAK,MAAM,GAAG,EAAK,KAAK,GAAG,EAAK,cAAc;AACpE;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,EAAE,MAAM,GAAG,UAAU;IAQrD,IAAI,CAAC,IAAI,EAAE,QAAQ,GAAG,IAAI;IAuC1B,OAAO,CAAC,QAAQ,EAAE,WAAW,GAAG,IAAI;IAMpC,KAAK,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,IAAI;IAIvD,QAAQ,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,IAAI;IAS1D,OAAO,IAAI,IAAI;IAKf,OAAO,CAAC,iBAAiB;IAkCzB,OAAO,CAAC,gBAAgB;IAcxB,OAAO,CAAC,YAAY;IAIpB,OAAO,CAAC,aAAa;IAIrB,OAAO,CAAC,YAAY;IAIpB,OAAO,CAAC,eAAe;CAUxB"}
|
package/dist/ui/AxisOverlay.d.ts
CHANGED
|
@@ -9,12 +9,13 @@ export type AxisOverlayConfig = ChartLayoutConfig;
|
|
|
9
9
|
export declare class AxisOverlay {
|
|
10
10
|
private readonly layout;
|
|
11
11
|
private readonly config;
|
|
12
|
-
private
|
|
12
|
+
private options;
|
|
13
13
|
private xPool;
|
|
14
14
|
private yPool;
|
|
15
15
|
private readonly xTicks;
|
|
16
16
|
private readonly yTicks;
|
|
17
17
|
constructor(layout: ChartLayoutElements, config: AxisOverlayConfig, options?: AxisOverlayOptions);
|
|
18
|
+
setOptions(options: AxisOverlayOptions): void;
|
|
18
19
|
update(camera: Camera2D, axis: AxisController): void;
|
|
19
20
|
dispose(): void;
|
|
20
21
|
private parentForAxis;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AxisOverlay.d.ts","sourceRoot":"","sources":["../../src/ui/AxisOverlay.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,KAAK,EAAE,cAAc,EAA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kBAAkB,GAAG,IAAI;IAY7C,MAAM,CAAC,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,cAAc,GAAG,IAAI;IAoBpD,OAAO,IAAI,IAAI;IAOf,OAAO,CAAC,aAAa;IAOrB,OAAO,CAAC,UAAU;CAqEnB"}
|
package/dist/ui/Chart.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { SeriesConfig, SeriesStyle, SeriesMode, SeriesSample } from '../core/types.js';
|
|
2
2
|
import { SeriesStore } from '../core/SeriesStore.js';
|
|
3
|
-
import {
|
|
3
|
+
import { Camera2D } from '../interaction/Camera2D.js';
|
|
4
|
+
import { PanIntent, ViewportPolicy, ZoomIntent } from '../interaction/types.js';
|
|
4
5
|
import { AxisPosition } from './ChartLayout.js';
|
|
6
|
+
import { ChartTheme, ResolvedChartTheme } from './theme.js';
|
|
5
7
|
export interface AxisConfig {
|
|
6
8
|
readonly visible?: boolean;
|
|
7
9
|
readonly position?: AxisPosition;
|
|
@@ -27,6 +29,7 @@ export interface ChartOptions {
|
|
|
27
29
|
};
|
|
28
30
|
readonly hover?: ChartPickOptions;
|
|
29
31
|
readonly plugins?: readonly ChartPlugin[];
|
|
32
|
+
readonly theme?: ChartTheme;
|
|
30
33
|
}
|
|
31
34
|
export type TypedSeriesConfig = Omit<SeriesConfig, "mode">;
|
|
32
35
|
export interface ChartSeriesState {
|
|
@@ -80,7 +83,6 @@ export declare class Chart {
|
|
|
80
83
|
private camera;
|
|
81
84
|
private axis;
|
|
82
85
|
private renderer;
|
|
83
|
-
private input;
|
|
84
86
|
private rawLineBuffer;
|
|
85
87
|
private rawLineData;
|
|
86
88
|
private minMaxInstanceBuffer;
|
|
@@ -94,12 +96,15 @@ export declare class Chart {
|
|
|
94
96
|
private readonly yTicks;
|
|
95
97
|
private axisOverlay;
|
|
96
98
|
private normalizedAxes;
|
|
99
|
+
private resolvedTheme;
|
|
100
|
+
private _gridVisible;
|
|
97
101
|
private layout;
|
|
98
102
|
private stats;
|
|
99
103
|
private resizeObserver;
|
|
100
104
|
private readonly pluginDisposers;
|
|
101
105
|
private readonly hoverSubscribers;
|
|
102
106
|
private readonly seriesSubscribers;
|
|
107
|
+
private readonly themeSubscribers;
|
|
103
108
|
private currentHover;
|
|
104
109
|
private lastPointerClientX;
|
|
105
110
|
private lastPointerClientY;
|
|
@@ -112,7 +117,20 @@ export declare class Chart {
|
|
|
112
117
|
get canvas(): HTMLCanvasElement;
|
|
113
118
|
get rootElement(): HTMLElement;
|
|
114
119
|
get plotElement(): HTMLElement;
|
|
120
|
+
get xAxisElement(): HTMLElement;
|
|
121
|
+
get yAxisElement(): HTMLElement;
|
|
122
|
+
get theme(): ResolvedChartTheme;
|
|
123
|
+
getCamera(): Camera2D;
|
|
115
124
|
dataToPlot(x: number, y: number): [number, number];
|
|
125
|
+
clientToData(clientX: number, clientY: number): [number, number] | null;
|
|
126
|
+
getViewport(): {
|
|
127
|
+
xMin: number;
|
|
128
|
+
xMax: number;
|
|
129
|
+
yMin: number;
|
|
130
|
+
yMax: number;
|
|
131
|
+
};
|
|
132
|
+
pan(intent: PanIntent): void;
|
|
133
|
+
zoom(intent: ZoomIntent): void;
|
|
116
134
|
addSeries(config: SeriesConfig, style?: Partial<SeriesStyle>): SeriesStore;
|
|
117
135
|
addLine(config: TypedSeriesConfig, style?: Partial<SeriesStyle>): SeriesStore;
|
|
118
136
|
addArea(config: TypedSeriesConfig, style?: Partial<SeriesStyle>): SeriesStore;
|
|
@@ -132,12 +150,18 @@ export declare class Chart {
|
|
|
132
150
|
getHoverState(): ChartHoverState | null;
|
|
133
151
|
subscribe(event: "hover", callback: (state: ChartHoverState | null) => void): () => void;
|
|
134
152
|
subscribe(event: "serieschange", callback: () => void): () => void;
|
|
153
|
+
subscribe(event: "themechange", callback: () => void): () => void;
|
|
154
|
+
setTheme(theme?: ChartTheme): void;
|
|
155
|
+
setGridVisible(visible: boolean): void;
|
|
156
|
+
getGridVisible(): boolean;
|
|
157
|
+
setAxes(axes: ChartOptions["axes"]): void;
|
|
135
158
|
pick(clientX: number, clientY: number, options?: ChartPickOptions): ChartHoverState | null;
|
|
136
159
|
screenshot(options?: ChartScreenshotOptions): Promise<Blob>;
|
|
137
160
|
start(): void;
|
|
138
161
|
stop(): void;
|
|
139
162
|
private render;
|
|
140
163
|
dispose(): void;
|
|
164
|
+
private applyTheme;
|
|
141
165
|
private applyCanvasSize;
|
|
142
166
|
private drawAreaSeries;
|
|
143
167
|
private drawScatterSeries;
|
|
@@ -156,6 +180,7 @@ export declare class Chart {
|
|
|
156
180
|
private refreshHover;
|
|
157
181
|
private emitHover;
|
|
158
182
|
private emitSeriesChange;
|
|
183
|
+
private emitThemeChange;
|
|
159
184
|
private drawDomTextForScreenshot;
|
|
160
185
|
private maxMinMaxSegments;
|
|
161
186
|
private maxBarFallbackBars;
|
package/dist/ui/Chart.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Chart.d.ts","sourceRoot":"","sources":["../../src/ui/Chart.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAW,UAAU,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AACrG,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"Chart.d.ts","sourceRoot":"","sources":["../../src/ui/Chart.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAW,UAAU,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AACrG,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAKrD,OAAO,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAEtD,OAAO,KAAK,EAAE,SAAS,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAGrF,OAAO,KAAK,EAAE,YAAY,EAAwB,MAAM,kBAAkB,CAAC;AAE3E,OAAO,K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B,OAAO,CAAC,iBAAiB;IAgCzB,OAAO,CAAC,gBAAgB;CAOzB"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { ViewportPolicy, ZoomAxis } from '../interaction/types.js';
|
|
2
|
+
import { ChartPlugin } from './Chart.js';
|
|
3
|
+
export interface InteractionsPluginOptions {
|
|
4
|
+
readonly axis?: ZoomAxis;
|
|
5
|
+
readonly viewportPolicy?: ViewportPolicy;
|
|
6
|
+
readonly boxZoom?: boolean;
|
|
7
|
+
readonly wheelZoom?: boolean;
|
|
8
|
+
readonly axisInteractions?: boolean;
|
|
9
|
+
readonly axisHover?: boolean;
|
|
10
|
+
readonly axisHoverColor?: string;
|
|
11
|
+
readonly axisHoverFilter?: string;
|
|
12
|
+
readonly shiftDragPan?: boolean;
|
|
13
|
+
readonly doubleClickReset?: boolean;
|
|
14
|
+
readonly minDragDistancePx?: number;
|
|
15
|
+
readonly selectionFill?: string;
|
|
16
|
+
readonly selectionStroke?: string;
|
|
17
|
+
}
|
|
18
|
+
export declare function interactionsPlugin(options?: InteractionsPluginOptions): ChartPlugin;
|
|
19
|
+
//# sourceMappingURL=Interactions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Interactions.d.ts","sourceRoot":"","sources":["../../src/ui/Interactions.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAa,cAAc,EAAE,QAAQ,EAAc,MAAM,yBAAyB,CAAC;AAC/F,OAAO,KAAK,EAAS,WAAW,EAAE,MAAM,YAAY,CAAC;AAErD,MAAM,WAAW,yBAAyB;IACxC,QAAQ,CAAC,IAAI,CAAC,EAAE,QAAQ,CAAC;IACzB,QAAQ,CAAC,cAAc,CAAC,EAAE,cAAc,CAAC;IACzC,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC;IAC3B,QAAQ,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC;IAC7B,QAAQ,CAAC,gBAAgB,CAAC,EAAE,OAAO,CAAC;IACpC,QAAQ,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC;IAC7B,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC;IACjC,QAAQ,CAAC,eAAe,CAAC,EAAE,MAAM,CAAC;IAClC,QAAQ,CAAC,YAAY,CAAC,EAAE,OAAO,CAAC;IAChC,QAAQ,CAAC,gBAAgB,CAAC,EAAE,OAAO,CAAC;IACpC,QAAQ,CAAC,iBAAiB,CAAC,EAAE,MAAM,CAAC;IACpC,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,eAAe,CAAC,EAAE,MAAM,CAAC;CACnC;AAuED,wBAAgB,kBAAkB,CAAC,OAAO,GAAE,yBAA8B,GAAG,WAAW,CA2RvF"}
|
package/dist/ui/Legend.d.ts
CHANGED
|
@@ -3,6 +3,11 @@ export interface LegendPluginOptions {
|
|
|
3
3
|
readonly className?: string;
|
|
4
4
|
readonly position?: "top-left" | "top-right" | "bottom-left" | "bottom-right";
|
|
5
5
|
readonly toggleOnClick?: boolean;
|
|
6
|
+
readonly backgroundColor?: string;
|
|
7
|
+
readonly borderColor?: string;
|
|
8
|
+
readonly textColor?: string;
|
|
9
|
+
readonly mutedTextColor?: string;
|
|
10
|
+
readonly font?: string;
|
|
6
11
|
readonly render?: (state: readonly ChartSeriesState[], container: HTMLElement, chart: Chart) => void;
|
|
7
12
|
}
|
|
8
13
|
export declare function legendPlugin(options?: LegendPluginOptions): ChartPlugin;
|
package/dist/ui/Legend.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Legend.d.ts","sourceRoot":"","sources":["../../src/ui/Legend.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAEvE,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,QAAQ,CAAC,EAAE,UAAU,GAAG,WAAW,GAAG,aAAa,GAAG,cAAc,CAAC;IAC9E,QAAQ,CAAC,aAAa,CAAC,EAAE,OAAO,CAAC;IACjC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,SAAS,gBAAgB,EAAE,EAAE,SAAS,EAAE,WAAW,EAAE,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;CACtG;
|
|
1
|
+
{"version":3,"file":"Legend.d.ts","sourceRoot":"","sources":["../../src/ui/Legend.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAEvE,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,QAAQ,CAAC,EAAE,UAAU,GAAG,WAAW,GAAG,aAAa,GAAG,cAAc,CAAC;IAC9E,QAAQ,CAAC,aAAa,CAAC,EAAE,OAAO,CAAC;IACjC,QAAQ,CAAC,eAAe,CAAC,EAAE,MAAM,CAAC;IAClC,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC;IACjC,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,SAAS,gBAAgB,EAAE,EAAE,SAAS,EAAE,WAAW,EAAE,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;CACtG;AAgED,wBAAgB,YAAY,CAAC,OAAO,GAAE,mBAAwB,GAAG,WAAW,CA8C3E"}
|
package/dist/ui/Tooltip.d.ts
CHANGED
|
@@ -6,6 +6,9 @@ export interface TooltipPluginOptions {
|
|
|
6
6
|
readonly offsetX?: number;
|
|
7
7
|
readonly offsetY?: number;
|
|
8
8
|
readonly highlight?: boolean;
|
|
9
|
+
readonly backgroundColor?: string;
|
|
10
|
+
readonly textColor?: string;
|
|
11
|
+
readonly font?: string;
|
|
9
12
|
readonly formatter?: (item: ChartPickItem, state: ChartHoverState) => string;
|
|
10
13
|
readonly render?: (state: ChartHoverState, container: HTMLElement, chart: Chart) => void;
|
|
11
14
|
}
|