blazeplot 0.2.0 → 0.2.2

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.
@@ -0,0 +1,3 @@
1
+ export { annotationsPlugin } from '../ui/Annotations.js';
2
+ export type { Annotation, AnnotationBase, AnnotationLabelOptions, AnnotationsPlugin, AnnotationsPluginOptions, BoxAnnotation, LabelAnnotation, PointAnnotation, XLineAnnotation, XRangeAnnotation, YLineAnnotation, YRangeAnnotation } from '../ui/Annotations.js';
3
+ //# sourceMappingURL=annotations.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"annotations.d.ts","sourceRoot":"","sources":["../../src/plugins/annotations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,YAAY,EAAE,UAAU,EAAE,cAAc,EAAE,sBAAsB,EAAE,iBAAiB,EAAE,wBAAwB,EAAE,aAAa,EAAE,eAAe,EAAE,eAAe,EAAE,eAAe,EAAE,gBAAgB,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC"}
@@ -0,0 +1,163 @@
1
+ //#region src/ui/Annotations.ts
2
+ var e = "http://www.w3.org/2000/svg";
3
+ function t(t) {
4
+ return document.createElementNS(e, t);
5
+ }
6
+ function n(e) {
7
+ return e ? typeof e == "string" ? e : e.text : null;
8
+ }
9
+ function r(e) {
10
+ return typeof e == "string" ? { text: e } : e ?? { text: "" };
11
+ }
12
+ function i(e, t, n, r, i, a) {
13
+ let o = Math.max(0, Math.min(e, n)), s = Math.min(i, Math.max(e, n)), c = Math.max(0, Math.min(t, r)), l = Math.min(a, Math.max(t, r));
14
+ return s <= o || l <= c ? null : {
15
+ x: o,
16
+ y: c,
17
+ w: s - o,
18
+ h: l - c
19
+ };
20
+ }
21
+ function a(e, t, n, r) {
22
+ return e >= 0 && e <= n && t >= 0 && t <= r;
23
+ }
24
+ function o(e = {}) {
25
+ let n = [...e.annotations ?? []], r = null, i = null, a = e.defaultColor ?? "rgba(255,255,255,0.85)", o = e.defaultFillColor ?? "rgba(255,255,255,0.12)", c = e.defaultFont ?? "12px system-ui, sans-serif", l = () => {
26
+ r && i && s(r, i, n, a, o, c);
27
+ };
28
+ return {
29
+ install(n) {
30
+ r = n, i = t("svg"), i.classList.add(e.className ?? "blazeplot-annotations"), i.style.position = "absolute", i.style.inset = "0", i.style.width = "100%", i.style.height = "100%", i.style.pointerEvents = "none", i.style.overflow = "hidden", i.style.zIndex = String(e.zIndex ?? 12), n.plotElement.appendChild(i);
31
+ let a = n.subscribe("render", () => l());
32
+ return l(), () => {
33
+ a(), i?.remove(), i = null, r = null;
34
+ };
35
+ },
36
+ add(e) {
37
+ n = [...n, e], l();
38
+ },
39
+ remove(e) {
40
+ let t = n.filter((t) => t.id !== e), r = t.length !== n.length;
41
+ return r && (n = t, l()), r;
42
+ },
43
+ clear() {
44
+ n = [], l();
45
+ },
46
+ setAnnotations(e) {
47
+ n = [...e], l();
48
+ },
49
+ getAnnotations() {
50
+ return n;
51
+ }
52
+ };
53
+ }
54
+ function s(e, t, n, r, i, a) {
55
+ let o = Math.max(1, e.canvas.clientWidth), s = Math.max(1, e.canvas.clientHeight);
56
+ t.setAttribute("viewBox", `0 0 ${o} ${s}`), t.replaceChildren();
57
+ for (let l of n) l.visible !== !1 && c(e, t, l, o, s, r, i, a);
58
+ }
59
+ function c(e, n, r, o, s, c, m, h) {
60
+ let g = e.getViewport(r.yAxis ?? "left"), _ = (e) => (e - g.xMin) / (g.xMax - g.xMin) * o, v = (e) => (g.yMax - e) / (g.yMax - g.yMin) * s, y = t("g");
61
+ switch (r.className && y.classList.add(r.className), r.type) {
62
+ case "x-line": {
63
+ let e = _(r.x);
64
+ if (e < 0 || e > o) return;
65
+ let n = t("line");
66
+ n.setAttribute("x1", String(e)), n.setAttribute("x2", String(e)), n.setAttribute("y1", "0"), n.setAttribute("y2", String(s)), l(n, r.color ?? c, r.width, r.dash), y.appendChild(n), p(y, r.label, e + 4, 6, "start", c, h);
67
+ break;
68
+ }
69
+ case "y-line": {
70
+ let e = v(r.y);
71
+ if (e < 0 || e > s) return;
72
+ let n = t("line");
73
+ n.setAttribute("x1", "0"), n.setAttribute("x2", String(o)), n.setAttribute("y1", String(e)), n.setAttribute("y2", String(e)), l(n, r.color ?? c, r.width, r.dash), y.appendChild(n), p(y, r.label, o - 4, e - 4, "end", c, h);
74
+ break;
75
+ }
76
+ case "x-range": {
77
+ let e = i(_(r.xMin), 0, _(r.xMax), s, o, s);
78
+ if (!e) return;
79
+ u(y, e, r.fillColor ?? m, r.borderColor, r.borderWidth), p(y, r.label, e.x + e.w * .5, 6, "middle", c, h);
80
+ break;
81
+ }
82
+ case "y-range": {
83
+ let e = i(0, v(r.yMax), o, v(r.yMin), o, s);
84
+ if (!e) return;
85
+ u(y, e, r.fillColor ?? m, r.borderColor, r.borderWidth), p(y, r.label, o - 4, e.y + e.h * .5, "end", c, h);
86
+ break;
87
+ }
88
+ case "box": {
89
+ let e = i(_(r.xMin), v(r.yMax), _(r.xMax), v(r.yMin), o, s);
90
+ if (!e) return;
91
+ u(y, e, r.fillColor ?? m, r.borderColor, r.borderWidth), p(y, r.label, e.x + e.w * .5, e.y + 6, "middle", c, h);
92
+ break;
93
+ }
94
+ case "point": {
95
+ let e = _(r.x), t = v(r.y), n = r.radius ?? 5;
96
+ if (!a(e, t, o, s)) return;
97
+ d(y, e, t, n, r), p(y, r.label, e + n + 4, t - n - 2, "start", c, h);
98
+ break;
99
+ }
100
+ case "label": {
101
+ let e = _(r.x), t = v(r.y);
102
+ if (!a(e, t, o, s)) return;
103
+ f(y, r, e, t, c, h);
104
+ break;
105
+ }
106
+ }
107
+ n.appendChild(y);
108
+ }
109
+ function l(e, t, n = 1, r) {
110
+ e.setAttribute("stroke", t), e.setAttribute("stroke-width", String(n)), e.setAttribute("fill", "none"), r && e.setAttribute("stroke-dasharray", r);
111
+ }
112
+ function u(e, n, r, i, a = 0) {
113
+ let o = t("rect");
114
+ o.setAttribute("x", String(n.x)), o.setAttribute("y", String(n.y)), o.setAttribute("width", String(n.w)), o.setAttribute("height", String(n.h)), o.setAttribute("fill", r), i && (o.setAttribute("stroke", i), o.setAttribute("stroke-width", String(a || 1))), e.appendChild(o);
115
+ }
116
+ function d(e, n, r, i, a) {
117
+ let o = a.color ?? "rgba(255,255,255,0.95)", s = a.strokeColor ?? "rgba(0,0,0,0.35)", c = a.strokeWidth ?? 1;
118
+ if (a.shape === "diamond") {
119
+ let a = t("polygon");
120
+ a.setAttribute("points", `${n},${r - i} ${n + i},${r} ${n},${r + i} ${n - i},${r}`), a.setAttribute("fill", o), a.setAttribute("stroke", s), a.setAttribute("stroke-width", String(c)), e.appendChild(a);
121
+ return;
122
+ }
123
+ if (a.shape === "cross") {
124
+ for (let [a, s, u, d] of [[
125
+ n - i,
126
+ r,
127
+ n + i,
128
+ r
129
+ ], [
130
+ n,
131
+ r - i,
132
+ n,
133
+ r + i
134
+ ]]) {
135
+ let n = t("line");
136
+ n.setAttribute("x1", String(a)), n.setAttribute("y1", String(s)), n.setAttribute("x2", String(u)), n.setAttribute("y2", String(d)), l(n, o, c + 1), e.appendChild(n);
137
+ }
138
+ return;
139
+ }
140
+ let u = t("circle");
141
+ u.setAttribute("cx", String(n)), u.setAttribute("cy", String(r)), u.setAttribute("r", String(i)), u.setAttribute("fill", o), u.setAttribute("stroke", s), u.setAttribute("stroke-width", String(c)), e.appendChild(u);
142
+ }
143
+ function f(e, n, r, i, a, o) {
144
+ let s = m(e, n.text, r, i, "start", n.color ?? a, n.font ?? o);
145
+ if (n.backgroundColor) {
146
+ let a = t("rect");
147
+ a.setAttribute("x", String(r - 4)), a.setAttribute("y", String(i - 14)), a.setAttribute("width", String(Math.max(16, n.text.length * 7 + 8))), a.setAttribute("height", "18"), a.setAttribute("rx", "3"), a.setAttribute("fill", n.backgroundColor), e.insertBefore(a, s);
148
+ }
149
+ }
150
+ function p(e, t, i, a, o, s, c) {
151
+ let l = n(t);
152
+ if (!l) return;
153
+ let u = r(t);
154
+ m(e, l, i + (u.offsetX ?? 0), a + (u.offsetY ?? 0), o, u.color ?? s, u.font ?? c);
155
+ }
156
+ function m(e, n, r, i, a, o, s) {
157
+ let c = t("text");
158
+ return c.textContent = n, c.setAttribute("x", String(r)), c.setAttribute("y", String(i)), c.setAttribute("fill", o), c.setAttribute("font", s), c.setAttribute("text-anchor", a), c.setAttribute("dominant-baseline", "hanging"), c.setAttribute("paint-order", "stroke"), c.setAttribute("stroke", "rgba(0,0,0,0.45)"), c.setAttribute("stroke-width", "3"), e.appendChild(c), c;
159
+ }
160
+ //#endregion
161
+ export { o as annotationsPlugin };
162
+
163
+ //# sourceMappingURL=annotations.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"annotations.js","names":[],"sources":["../../src/ui/Annotations.ts"],"sourcesContent":["import type { Chart, ChartPlugin } from \"./Chart.js\";\nimport type { SeriesYAxis } from \"../core/types.js\";\n\nexport interface AnnotationLabelOptions {\n readonly text: string;\n readonly position?: \"start\" | \"center\" | \"end\" | \"top\" | \"bottom\" | \"left\" | \"right\";\n readonly color?: string;\n readonly font?: string;\n readonly offsetX?: number;\n readonly offsetY?: number;\n}\n\nexport interface AnnotationBase {\n readonly id?: string;\n readonly visible?: boolean;\n readonly yAxis?: SeriesYAxis;\n readonly className?: string;\n readonly label?: string | AnnotationLabelOptions;\n}\n\nexport interface XLineAnnotation extends AnnotationBase {\n readonly type: \"x-line\";\n readonly x: number;\n readonly color?: string;\n readonly width?: number;\n readonly dash?: string;\n}\n\nexport interface YLineAnnotation extends AnnotationBase {\n readonly type: \"y-line\";\n readonly y: number;\n readonly color?: string;\n readonly width?: number;\n readonly dash?: string;\n}\n\nexport interface XRangeAnnotation extends AnnotationBase {\n readonly type: \"x-range\";\n readonly xMin: number;\n readonly xMax: number;\n readonly fillColor?: string;\n readonly borderColor?: string;\n readonly borderWidth?: number;\n}\n\nexport interface YRangeAnnotation extends AnnotationBase {\n readonly type: \"y-range\";\n readonly yMin: number;\n readonly yMax: number;\n readonly fillColor?: string;\n readonly borderColor?: string;\n readonly borderWidth?: number;\n}\n\nexport interface BoxAnnotation extends AnnotationBase {\n readonly type: \"box\";\n readonly xMin: number;\n readonly xMax: number;\n readonly yMin: number;\n readonly yMax: number;\n readonly fillColor?: string;\n readonly borderColor?: string;\n readonly borderWidth?: number;\n}\n\nexport interface PointAnnotation extends AnnotationBase {\n readonly type: \"point\";\n readonly x: number;\n readonly y: number;\n readonly radius?: number;\n readonly color?: string;\n readonly strokeColor?: string;\n readonly strokeWidth?: number;\n readonly shape?: \"circle\" | \"diamond\" | \"cross\";\n}\n\nexport interface LabelAnnotation extends AnnotationBase {\n readonly type: \"label\";\n readonly x: number;\n readonly y: number;\n readonly text: string;\n readonly color?: string;\n readonly font?: string;\n readonly backgroundColor?: string;\n}\n\nexport type Annotation =\n | XLineAnnotation\n | YLineAnnotation\n | XRangeAnnotation\n | YRangeAnnotation\n | BoxAnnotation\n | PointAnnotation\n | LabelAnnotation;\n\nexport interface AnnotationsPluginOptions {\n readonly annotations?: readonly Annotation[];\n readonly className?: string;\n readonly defaultColor?: string;\n readonly defaultFillColor?: string;\n readonly defaultFont?: string;\n readonly zIndex?: number;\n}\n\nexport interface AnnotationsPlugin extends ChartPlugin {\n add(annotation: Annotation): void;\n remove(id: string): boolean;\n clear(): void;\n setAnnotations(annotations: readonly Annotation[]): void;\n getAnnotations(): readonly Annotation[];\n}\n\nconst SVG_NS = \"http://www.w3.org/2000/svg\";\n\nfunction svg<K extends keyof SVGElementTagNameMap>(tag: K): SVGElementTagNameMap[K] {\n return document.createElementNS(SVG_NS, tag);\n}\n\nfunction labelText(label: string | AnnotationLabelOptions | undefined): string | null {\n if (!label) return null;\n return typeof label === \"string\" ? label : label.text;\n}\n\nfunction labelOptions(label: string | AnnotationLabelOptions | undefined): AnnotationLabelOptions {\n return typeof label === \"string\" ? { text: label } : label ?? { text: \"\" };\n}\n\nfunction clampRect(x0: number, y0: number, x1: number, y1: number, width: number, height: number): { x: number; y: number; w: number; h: number } | null {\n const left = Math.max(0, Math.min(x0, x1));\n const right = Math.min(width, Math.max(x0, x1));\n const top = Math.max(0, Math.min(y0, y1));\n const bottom = Math.min(height, Math.max(y0, y1));\n if (right <= left || bottom <= top) return null;\n return { x: left, y: top, w: right - left, h: bottom - top };\n}\n\nfunction isInsidePlot(x: number, y: number, width: number, height: number): boolean {\n return x >= 0 && x <= width && y >= 0 && y <= height;\n}\n\nexport function annotationsPlugin(options: AnnotationsPluginOptions = {}): AnnotationsPlugin {\n let annotations = [...(options.annotations ?? [])];\n let chartRef: Chart | null = null;\n let overlay: SVGSVGElement | null = null;\n const color = options.defaultColor ?? \"rgba(255,255,255,0.85)\";\n const fillColor = options.defaultFillColor ?? \"rgba(255,255,255,0.12)\";\n const font = options.defaultFont ?? \"12px system-ui, sans-serif\";\n\n const requestRender = (): void => {\n if (chartRef && overlay) render(chartRef, overlay, annotations, color, fillColor, font);\n };\n\n return {\n install(chart: Chart) {\n chartRef = chart;\n overlay = svg(\"svg\");\n overlay.classList.add(options.className ?? \"blazeplot-annotations\");\n overlay.style.position = \"absolute\";\n overlay.style.inset = \"0\";\n overlay.style.width = \"100%\";\n overlay.style.height = \"100%\";\n overlay.style.pointerEvents = \"none\";\n overlay.style.overflow = \"hidden\";\n overlay.style.zIndex = String(options.zIndex ?? 12);\n chart.plotElement.appendChild(overlay);\n const unsubscribeRender = chart.subscribe(\"render\", () => requestRender());\n requestRender();\n return () => {\n unsubscribeRender();\n overlay?.remove();\n overlay = null;\n chartRef = null;\n };\n },\n add(annotation: Annotation): void {\n annotations = [...annotations, annotation];\n requestRender();\n },\n remove(id: string): boolean {\n const next = annotations.filter((annotation) => annotation.id !== id);\n const changed = next.length !== annotations.length;\n if (changed) {\n annotations = next;\n requestRender();\n }\n return changed;\n },\n clear(): void {\n annotations = [];\n requestRender();\n },\n setAnnotations(next: readonly Annotation[]): void {\n annotations = [...next];\n requestRender();\n },\n getAnnotations(): readonly Annotation[] {\n return annotations;\n },\n };\n}\n\nfunction render(\n chart: Chart,\n overlay: SVGSVGElement,\n annotations: readonly Annotation[],\n defaultColor: string,\n defaultFillColor: string,\n defaultFont: string,\n): void {\n const width = Math.max(1, chart.canvas.clientWidth);\n const height = Math.max(1, chart.canvas.clientHeight);\n overlay.setAttribute(\"viewBox\", `0 0 ${width} ${height}`);\n overlay.replaceChildren();\n\n for (const annotation of annotations) {\n if (annotation.visible === false) continue;\n drawAnnotation(chart, overlay, annotation, width, height, defaultColor, defaultFillColor, defaultFont);\n }\n}\n\nfunction drawAnnotation(\n chart: Chart,\n overlay: SVGSVGElement,\n annotation: Annotation,\n width: number,\n height: number,\n defaultColor: string,\n defaultFillColor: string,\n defaultFont: string,\n): void {\n const viewport = chart.getViewport(annotation.yAxis ?? \"left\");\n const xToPx = (x: number): number => ((x - viewport.xMin) / (viewport.xMax - viewport.xMin)) * width;\n const yToPx = (y: number): number => ((viewport.yMax - y) / (viewport.yMax - viewport.yMin)) * height;\n const group = svg(\"g\");\n if (annotation.className) group.classList.add(annotation.className);\n\n switch (annotation.type) {\n case \"x-line\": {\n const x = xToPx(annotation.x);\n if (x < 0 || x > width) return;\n const line = svg(\"line\");\n line.setAttribute(\"x1\", String(x));\n line.setAttribute(\"x2\", String(x));\n line.setAttribute(\"y1\", \"0\");\n line.setAttribute(\"y2\", String(height));\n styleStroke(line, annotation.color ?? defaultColor, annotation.width, annotation.dash);\n group.appendChild(line);\n appendLabel(group, annotation.label, x + 4, 6, \"start\", defaultColor, defaultFont);\n break;\n }\n case \"y-line\": {\n const y = yToPx(annotation.y);\n if (y < 0 || y > height) return;\n const line = svg(\"line\");\n line.setAttribute(\"x1\", \"0\");\n line.setAttribute(\"x2\", String(width));\n line.setAttribute(\"y1\", String(y));\n line.setAttribute(\"y2\", String(y));\n styleStroke(line, annotation.color ?? defaultColor, annotation.width, annotation.dash);\n group.appendChild(line);\n appendLabel(group, annotation.label, width - 4, y - 4, \"end\", defaultColor, defaultFont);\n break;\n }\n case \"x-range\": {\n const rect = clampRect(xToPx(annotation.xMin), 0, xToPx(annotation.xMax), height, width, height);\n if (!rect) return;\n appendRect(group, rect, annotation.fillColor ?? defaultFillColor, annotation.borderColor, annotation.borderWidth);\n appendLabel(group, annotation.label, rect.x + rect.w * 0.5, 6, \"middle\", defaultColor, defaultFont);\n break;\n }\n case \"y-range\": {\n const rect = clampRect(0, yToPx(annotation.yMax), width, yToPx(annotation.yMin), width, height);\n if (!rect) return;\n appendRect(group, rect, annotation.fillColor ?? defaultFillColor, annotation.borderColor, annotation.borderWidth);\n appendLabel(group, annotation.label, width - 4, rect.y + rect.h * 0.5, \"end\", defaultColor, defaultFont);\n break;\n }\n case \"box\": {\n const rect = clampRect(xToPx(annotation.xMin), yToPx(annotation.yMax), xToPx(annotation.xMax), yToPx(annotation.yMin), width, height);\n if (!rect) return;\n appendRect(group, rect, annotation.fillColor ?? defaultFillColor, annotation.borderColor, annotation.borderWidth);\n appendLabel(group, annotation.label, rect.x + rect.w * 0.5, rect.y + 6, \"middle\", defaultColor, defaultFont);\n break;\n }\n case \"point\": {\n const x = xToPx(annotation.x);\n const y = yToPx(annotation.y);\n const radius = annotation.radius ?? 5;\n if (!isInsidePlot(x, y, width, height)) return;\n appendMarker(group, x, y, radius, annotation);\n appendLabel(group, annotation.label, x + radius + 4, y - radius - 2, \"start\", defaultColor, defaultFont);\n break;\n }\n case \"label\": {\n const x = xToPx(annotation.x);\n const y = yToPx(annotation.y);\n if (!isInsidePlot(x, y, width, height)) return;\n appendStandaloneLabel(group, annotation, x, y, defaultColor, defaultFont);\n break;\n }\n }\n\n overlay.appendChild(group);\n}\n\nfunction styleStroke(el: SVGElement, color: string, width: number = 1, dash?: string): void {\n el.setAttribute(\"stroke\", color);\n el.setAttribute(\"stroke-width\", String(width));\n el.setAttribute(\"fill\", \"none\");\n if (dash) el.setAttribute(\"stroke-dasharray\", dash);\n}\n\nfunction appendRect(group: SVGGElement, rect: { x: number; y: number; w: number; h: number }, fill: string, stroke?: string, strokeWidth: number = 0): void {\n const el = svg(\"rect\");\n el.setAttribute(\"x\", String(rect.x));\n el.setAttribute(\"y\", String(rect.y));\n el.setAttribute(\"width\", String(rect.w));\n el.setAttribute(\"height\", String(rect.h));\n el.setAttribute(\"fill\", fill);\n if (stroke) {\n el.setAttribute(\"stroke\", stroke);\n el.setAttribute(\"stroke-width\", String(strokeWidth || 1));\n }\n group.appendChild(el);\n}\n\nfunction appendMarker(group: SVGGElement, x: number, y: number, radius: number, annotation: PointAnnotation): void {\n const fill = annotation.color ?? \"rgba(255,255,255,0.95)\";\n const stroke = annotation.strokeColor ?? \"rgba(0,0,0,0.35)\";\n const strokeWidth = annotation.strokeWidth ?? 1;\n if (annotation.shape === \"diamond\") {\n const polygon = svg(\"polygon\");\n polygon.setAttribute(\"points\", `${x},${y - radius} ${x + radius},${y} ${x},${y + radius} ${x - radius},${y}`);\n polygon.setAttribute(\"fill\", fill);\n polygon.setAttribute(\"stroke\", stroke);\n polygon.setAttribute(\"stroke-width\", String(strokeWidth));\n group.appendChild(polygon);\n return;\n }\n\n if (annotation.shape === \"cross\") {\n for (const [x1, y1, x2, y2] of [[x - radius, y, x + radius, y], [x, y - radius, x, y + radius]] as const) {\n const line = svg(\"line\");\n line.setAttribute(\"x1\", String(x1));\n line.setAttribute(\"y1\", String(y1));\n line.setAttribute(\"x2\", String(x2));\n line.setAttribute(\"y2\", String(y2));\n styleStroke(line, fill, strokeWidth + 1);\n group.appendChild(line);\n }\n return;\n }\n\n const circle = svg(\"circle\");\n circle.setAttribute(\"cx\", String(x));\n circle.setAttribute(\"cy\", String(y));\n circle.setAttribute(\"r\", String(radius));\n circle.setAttribute(\"fill\", fill);\n circle.setAttribute(\"stroke\", stroke);\n circle.setAttribute(\"stroke-width\", String(strokeWidth));\n group.appendChild(circle);\n}\n\nfunction appendStandaloneLabel(group: SVGGElement, annotation: LabelAnnotation, x: number, y: number, defaultColor: string, defaultFont: string): void {\n const text = appendText(group, annotation.text, x, y, \"start\", annotation.color ?? defaultColor, annotation.font ?? defaultFont);\n if (annotation.backgroundColor) {\n const rect = svg(\"rect\");\n rect.setAttribute(\"x\", String(x - 4));\n rect.setAttribute(\"y\", String(y - 14));\n rect.setAttribute(\"width\", String(Math.max(16, annotation.text.length * 7 + 8)));\n rect.setAttribute(\"height\", \"18\");\n rect.setAttribute(\"rx\", \"3\");\n rect.setAttribute(\"fill\", annotation.backgroundColor);\n group.insertBefore(rect, text);\n }\n}\n\nfunction appendLabel(group: SVGGElement, label: string | AnnotationLabelOptions | undefined, x: number, y: number, anchor: \"start\" | \"middle\" | \"end\", defaultColor: string, defaultFont: string): void {\n const textValue = labelText(label);\n if (!textValue) return;\n const opts = labelOptions(label);\n appendText(group, textValue, x + (opts.offsetX ?? 0), y + (opts.offsetY ?? 0), anchor, opts.color ?? defaultColor, opts.font ?? defaultFont);\n}\n\nfunction appendText(group: SVGGElement, textValue: string, x: number, y: number, anchor: \"start\" | \"middle\" | \"end\", color: string, font: string): SVGTextElement {\n const text = svg(\"text\");\n text.textContent = textValue;\n text.setAttribute(\"x\", String(x));\n text.setAttribute(\"y\", String(y));\n text.setAttribute(\"fill\", color);\n text.setAttribute(\"font\", font);\n text.setAttribute(\"text-anchor\", anchor);\n text.setAttribute(\"dominant-baseline\", \"hanging\");\n text.setAttribute(\"paint-order\", \"stroke\");\n text.setAttribute(\"stroke\", \"rgba(0,0,0,0.45)\");\n text.setAttribute(\"stroke-width\", \"3\");\n group.appendChild(text);\n return text;\n}\n"],"mappings":";AAgHA,IAAM,IAAS;AAEf,SAAS,EAA0C,GAAiC;CAClF,OAAO,SAAS,gBAAgB,GAAQ,CAAG;AAC7C;AAEA,SAAS,EAAU,GAAmE;CAEpF,OADK,IACE,OAAO,KAAU,WAAW,IAAQ,EAAM,OAD9B;AAErB;AAEA,SAAS,EAAa,GAA4E;CAChG,OAAO,OAAO,KAAU,WAAW,EAAE,MAAM,EAAM,IAAI,KAAS,EAAE,MAAM,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;CAChB,IAAM,IAAO,EAAa,CAAK;CAC/B,EAAW,GAAO,GAAW,KAAK,EAAK,WAAW,IAAI,KAAK,EAAK,WAAW,IAAI,GAAQ,EAAK,SAAS,GAAc,EAAK,QAAQ,CAAW;AAC7I;AAEA,SAAS,EAAW,GAAoB,GAAmB,GAAW,GAAW,GAAoC,GAAe,GAA8B;CAChK,IAAM,IAAO,EAAI,MAAM;CAYvB,OAXA,EAAK,cAAc,GACnB,EAAK,aAAa,KAAK,OAAO,CAAC,CAAC,GAChC,EAAK,aAAa,KAAK,OAAO,CAAC,CAAC,GAChC,EAAK,aAAa,QAAQ,CAAK,GAC/B,EAAK,aAAa,QAAQ,CAAI,GAC9B,EAAK,aAAa,eAAe,CAAM,GACvC,EAAK,aAAa,qBAAqB,SAAS,GAChD,EAAK,aAAa,eAAe,QAAQ,GACzC,EAAK,aAAa,UAAU,kBAAkB,GAC9C,EAAK,aAAa,gBAAgB,GAAG,GACrC,EAAM,YAAY,CAAI,GACf;AACT"}
@@ -45,7 +45,7 @@ function o(e = {}) {
45
45
  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%)", o.appendChild(t);
46
46
  }
47
47
  }, f = (n) => {
48
- let o = n && (e.mode !== void 0 || e.maxDistancePx !== void 0) ? t.pick(n.clientX, n.clientY, e) : n;
48
+ let o = n !== null && (e.mode !== void 0 && e.mode !== n.mode || e.group !== void 0 && e.group !== n.group || e.maxDistancePx !== void 0 && e.maxDistancePx !== n.maxDistancePx) ? t.pick(n.clientX, n.clientY, e) : n;
49
49
  if (d(o), !o || o.items.length === 0) {
50
50
  i.style.display = "none", l();
51
51
  return;
@@ -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 backgroundColor?: string;\n readonly textColor?: string;\n readonly font?: string;\n readonly zIndex?: number;\n readonly lockWidth?: 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\nfunction clamp(value: number, min: number, max: number): number {\n return Math.min(max, Math.max(min, value));\n}\n\nfunction placeTooltip(\n container: HTMLElement,\n state: ChartHoverState,\n options: TooltipPluginOptions,\n): void {\n const offsetX = options.offsetX ?? 12;\n const offsetY = options.offsetY ?? 12;\n const tooltipRect = container.getBoundingClientRect();\n const margin = 4;\n const doc = container.ownerDocument;\n const viewportWidth = Math.max(1, globalThis.innerWidth || doc.documentElement.clientWidth);\n const viewportHeight = Math.max(1, globalThis.innerHeight || doc.documentElement.clientHeight);\n\n const viewportX = clamp(\n state.clientX + offsetX,\n margin,\n Math.max(margin, viewportWidth - tooltipRect.width - margin),\n );\n const viewportY = clamp(\n state.clientY + offsetY,\n margin,\n Math.max(margin, viewportHeight - tooltipRect.height - margin),\n );\n container.style.transform = `translate(${viewportX}px, ${viewportY}px)`;\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 = \"fixed\";\n container.style.left = \"0\";\n container.style.top = \"0\";\n container.style.zIndex = String(options.zIndex ?? 10_000);\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 const tooltipParent = chart.rootElement.ownerDocument.body ?? chart.rootElement;\n tooltipParent.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 let lockedTooltipWidth = 0;\n\n const lockTooltipWidth = (): void => {\n if (options.lockWidth === false) return;\n const width = Math.ceil(container.getBoundingClientRect().width);\n if (width <= lockedTooltipWidth) return;\n lockedTooltipWidth = width;\n container.style.minWidth = `${lockedTooltipWidth}px`;\n };\n\n const resetTooltipWidth = (): void => {\n lockedTooltipWidth = 0;\n container.style.minWidth = \"\";\n };\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 resetTooltipWidth();\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 container.style.display = \"block\";\n lockTooltipWidth();\n placeTooltip(container, effectiveState, options);\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":";AAkBA,SAAS,EAAQ,GAA6B;CAC5C,OAAO,EAAK,QAAQ,EAAK,MAAM,GAAG,EAAK,KAAK,GAAG,EAAK,cAAc;AACpE;AAEA,SAAS,EAAa,GAAuB;CAC3C,IAAI,CAAC,OAAO,SAAS,CAAK,GAAG,OAAO,OAAO,C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CAAC;EAC9B,CAAC;EAED,OADA,EAAW,SACE;GAIX,AAHA,EAAiB,GACjB,EAAiB,GACjB,EAAY,OAAO,GACnB,EAAU,OAAO;EACnB;CACF,EACF;AACF"}
1
+ {"version":3,"file":"tooltip.js","names":[],"sources":["../../src/ui/Tooltip.ts"],"sourcesContent":["import type { Chart, ChartHoverState, ChartPickGroup, ChartPickItem, ChartPickMode, ChartPlugin } from \"./Chart.js\";\n\nexport interface TooltipPluginOptions {\n readonly className?: string;\n readonly mode?: ChartPickMode;\n readonly group?: ChartPickGroup;\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 zIndex?: number;\n readonly lockWidth?: 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\nfunction clamp(value: number, min: number, max: number): number {\n return Math.min(max, Math.max(min, value));\n}\n\nfunction placeTooltip(\n container: HTMLElement,\n state: ChartHoverState,\n options: TooltipPluginOptions,\n): void {\n const offsetX = options.offsetX ?? 12;\n const offsetY = options.offsetY ?? 12;\n const tooltipRect = container.getBoundingClientRect();\n const margin = 4;\n const doc = container.ownerDocument;\n const viewportWidth = Math.max(1, globalThis.innerWidth || doc.documentElement.clientWidth);\n const viewportHeight = Math.max(1, globalThis.innerHeight || doc.documentElement.clientHeight);\n\n const viewportX = clamp(\n state.clientX + offsetX,\n margin,\n Math.max(margin, viewportWidth - tooltipRect.width - margin),\n );\n const viewportY = clamp(\n state.clientY + offsetY,\n margin,\n Math.max(margin, viewportHeight - tooltipRect.height - margin),\n );\n container.style.transform = `translate(${viewportX}px, ${viewportY}px)`;\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 = \"fixed\";\n container.style.left = \"0\";\n container.style.top = \"0\";\n container.style.zIndex = String(options.zIndex ?? 10_000);\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 const tooltipParent = chart.rootElement.ownerDocument.body ?? chart.rootElement;\n tooltipParent.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 let lockedTooltipWidth = 0;\n\n const lockTooltipWidth = (): void => {\n if (options.lockWidth === false) return;\n const width = Math.ceil(container.getBoundingClientRect().width);\n if (width <= lockedTooltipWidth) return;\n lockedTooltipWidth = width;\n container.style.minWidth = `${lockedTooltipWidth}px`;\n };\n\n const resetTooltipWidth = (): void => {\n lockedTooltipWidth = 0;\n container.style.minWidth = \"\";\n };\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 shouldRepick = state !== null && (\n (options.mode !== undefined && options.mode !== state.mode) ||\n (options.group !== undefined && options.group !== state.group) ||\n (options.maxDistancePx !== undefined && options.maxDistancePx !== state.maxDistancePx)\n );\n const effectiveState = shouldRepick ? chart.pick(state.clientX, state.clientY, options) : state;\n\n renderMarkers(effectiveState);\n if (!effectiveState || effectiveState.items.length === 0) {\n container.style.display = \"none\";\n resetTooltipWidth();\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 container.style.display = \"block\";\n lockTooltipWidth();\n placeTooltip(container, effectiveState, options);\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":";AAmBA,SAAS,EAAQ,GAA6B;CAC5C,OAAO,EAAK,QAAQ,EAAK,MAAM,GAAG,EAAK,KAAK,GAAG,EAAK,cAAc;AACpE;AAEA,SAAS,EAAa,GAAuB;CAC3C,IAAI,CAAC,OAAO,SAAS,CAAK,GAAG,OAAO,OAAO,CAAK;CAChD,IAAM,IAAM,KAAK,IAAI,CAAK;CAE1B,OADI,IAAM,MAAM,IAAM,QAAQ,KAAO,OAAa,EAAM,cAAc,CAAC,IAChE,OAAO,EAAM,YAAY,CAAC,CAAC,EAAE,SAAS;AAC/C;AAEA,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;AACvH;AAEA,SAAS,EACP,GACA,GACA,GACM;CACN,IAAM,IAAM,KAAK,IAAI,GAAG,GAAG,EAAM,MAAM,KAAK,MAAS,EAAQ,CAAI,EAAE,MAAM,CAAC,GACtE,IAAO;CACX,KAAK,IAAM,KAAQ,EAAM,OAAO;EAC9B,IAAM,IAAQ,IAAY,EAAU,GAAM,CAAK,IAAI,IAAI,EAAa,EAAK,CAAC,EAAE,IAAI,EAAa,EAAK,CAAC,EAAE,IAC/F,IAAQ,EAAK,EAAK,OAAO,MAAM,KAAK;EAE1C,AADI,MAAM,KAAQ,SAClB,KAAQ,sBAAsB,EAAM,kBAAkB,EAAQ,CAAI,EAAE,OAAO,CAAG,EAAE,IAAI;CACtF;CACA,EAAU,YAAY;AACxB;AAEA,SAAS,EAAM,GAAe,GAAa,GAAqB;CAC9D,OAAO,KAAK,IAAI,GAAK,KAAK,IAAI,GAAK,CAAK,CAAC;AAC3C;AAEA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AO,IAAI;GAG1F,IADA,EAAc,CAAc,GACxB,CAAC,KAAkB,EAAe,MAAM,WAAW,GAAG;IAExD,AADA,EAAU,MAAM,UAAU,QAC1B,EAAkB;IAClB;GACF;GAUA,AARI,EAAQ,SACV,EAAQ,OAAO,GAAgB,GAAW,CAAK,IAE/C,EAAqB,GAAgB,GAAW,EAAQ,SAAS,GAGnE,EAAU,MAAM,UAAU,SAC1B,EAAiB,GACjB,EAAa,GAAW,GAAgB,CAAO;EACjD,GAEM,IAAmB,EAAM,UAAU,SAAS,CAAM,GAClD,IAAmB,EAAM,UAAU,qBAAqB;GAE5D,AADA,EAAW,GACX,EAAO,EAAM,cAAc,CAAC;EAC9B,CAAC;EAED,OADA,EAAW,SACE;GAIX,AAHA,EAAiB,GACjB,EAAiB,GACjB,EAAY,OAAO,GACnB,EAAU,OAAO;EACnB;CACF,EACF;AACF"}
@@ -15,6 +15,7 @@ export declare class ReglBackend implements GpuBackend {
15
15
  dispose(resource: GpuResource): void;
16
16
  clear(r: number, g: number, b: number, a: number): void;
17
17
  viewport(x: number, y: number, w: number, h: number): void;
18
+ getContext(): WebGL2RenderingContext;
18
19
  destroy(): void;
19
20
  private createDrawCommand;
20
21
  private resolveAttribute;
@@ -1 +1 @@
1
- {"version":3,"file":"ReglBackend.d.ts","sourceRoot":"","sources":["../../src/render/ReglBackend.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,UAAU,EAAE,WAAW,EAAE,UAAU,EAAE,QAAQ,EAA+B,MAAM,YAAY,CAAC;AA8BpI,qBAAa,WAAY,YAAW,UAAU;IAC5C,OAAO,CAAC,EAAE,CAAyB;IACnC,OAAO,CAAC,IAAI,CAAO;IACnB,OAAO,CAAC,SAAS,CAAkB;IACnC,OAAO,CAAC,aAAa,CAAa;IAClC,OAAO,CAAC,YAAY,CAAuC;IAC3D,OAAO,CAAC,UAAU,CAA+D;IACjF,QAAQ,CAAC,YAAY,EAAE,UAAU,CA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CAA+D;IACjF,QAAQ,CAAC,YAAY,EAAE,UAAU,CAAC,cAAc,CAAC,CAAC;gBAEtC,MAAM,EAAE,iBAAiB;IAiCrC,YAAY,CAAC,IAAI,EAAE,UAAU,GAAG,SAAS;IASzC,YAAY,CAAC,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE,YAAY,GAAG,WAAW,EAAE,MAAM,GAAE,MAAU,GAAG,IAAI;IAS3F,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,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,UAAU,IAAI,sBAAsB;IAIpC,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"}
@@ -25,6 +25,7 @@ export declare class Renderer {
25
25
  updateFloatBuffer(buffer: GpuBuffer, data: Float32Array, floatCount?: number): void;
26
26
  viewport(x: number, y: number, width: number, height: number): void;
27
27
  setXOrigin(origin: number): void;
28
+ getWebGLContext(): WebGL2RenderingContext | null;
28
29
  drawLines(positions: GpuBuffer, count: number, style: SeriesStyle, camera: Camera2D): void;
29
30
  drawLineStrip(positions: GpuBuffer, count: number, style: SeriesStyle, camera: Camera2D): void;
30
31
  drawClipLineStrip(positions: GpuBuffer, count: number, style: Seri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Resource): void;
10
10
  clear(r: number, g: number, b: number, a: number): void;
11
11
  viewport(x: number, y: number, w: number, h: number): void;
12
+ getContext?(): WebGL2RenderingContext | null;
12
13
  destroy(): void;
13
14
  }
14
15
  export interface GpuCapabilities {
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/render/types.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,cAAc,EAAE,OAAO,MAAM,CAAC;AAC5C,OAAO,CAAC,MAAM,eAAe,EAAE,OAAO,MAAM,CAAC;AAE7C,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,YAAY,EAAE,eAAe,CAAC;IACvC,YAAY,CAAC,IAAI,EAAE,UAAU,GAAG,SAAS,CAAC;IAC1C,YAAY,CAAC,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE,YAAY,GAAG,WAAW,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACzF,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,UAAU,CAAC;IACtD,IAAI,CAAC,IAAI,EAAE,QAAQ,GAAG,IAAI,CAAC;IAC3B,OAAO,CAAC,QAAQ,EAAE,WAAW,GAAG,IAAI,CAAC;IACrC,KAAK,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACxD,QAAQ,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3D,OAAO,IAAI,IAAI,CAAC;CACjB;AAED,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC;CAC9B;AAED,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,KAAK,EAAE,QAAQ,GAAG,SAAS,GAAG,QAAQ,CAAC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C,QAAQ,CAAC,EAAE,SAAS,CAAC;CAC/B"}
@@ -0,0 +1,94 @@
1
+ import { ChartPlugin } from './Chart.js';
2
+ import { SeriesYAxis } from '../core/types.js';
3
+ export interface AnnotationLabelOptions {
4
+ readonly text: string;
5
+ readonly position?: "start" | "center" | "end" | "top" | "bottom" | "left" | "right";
6
+ readonly color?: string;
7
+ readonly font?: string;
8
+ readonly offsetX?: number;
9
+ readonly offsetY?: number;
10
+ }
11
+ export interface AnnotationBase {
12
+ readonly id?: string;
13
+ readonly visible?: boolean;
14
+ readonly yAxis?: SeriesYAxis;
15
+ readonly className?: string;
16
+ readonly label?: string | AnnotationLabelOptions;
17
+ }
18
+ export interface XLineAnnotation extends AnnotationBase {
19
+ readonly type: "x-line";
20
+ readonly x: number;
21
+ readonly color?: string;
22
+ readonly width?: number;
23
+ readonly dash?: string;
24
+ }
25
+ export interface YLineAnnotation extends AnnotationBase {
26
+ readonly type: "y-line";
27
+ readonly y: number;
28
+ readonly color?: string;
29
+ readonly width?: number;
30
+ readonly dash?: string;
31
+ }
32
+ export interface XRangeAnnotation extends AnnotationBase {
33
+ readonly type: "x-range";
34
+ readonly xMin: number;
35
+ readonly xMax: number;
36
+ readonly fillColor?: string;
37
+ readonly borderColor?: string;
38
+ readonly borderWidth?: number;
39
+ }
40
+ export interface YRangeAnnotation extends AnnotationBase {
41
+ readonly type: "y-range";
42
+ readonly yMin: number;
43
+ readonly yMax: number;
44
+ readonly fillColor?: string;
45
+ readonly borderColor?: string;
46
+ readonly borderWidth?: number;
47
+ }
48
+ export interface BoxAnnotation extends AnnotationBase {
49
+ readonly type: "box";
50
+ readonly xMin: number;
51
+ readonly xMax: number;
52
+ readonly yMin: number;
53
+ readonly yMax: number;
54
+ readonly fillColor?: string;
55
+ readonly borderColor?: string;
56
+ readonly borderWidth?: number;
57
+ }
58
+ export interface PointAnnotation extends AnnotationBase {
59
+ readonly type: "point";
60
+ readonly x: number;
61
+ readonly y: number;
62
+ readonly radius?: number;
63
+ readonly color?: string;
64
+ readonly strokeColor?: string;
65
+ readonly strokeWidth?: number;
66
+ readonly shape?: "circle" | "diamond" | "cross";
67
+ }
68
+ export interface LabelAnnotation extends AnnotationBase {
69
+ readonly type: "label";
70
+ readonly x: number;
71
+ readonly y: number;
72
+ readonly text: string;
73
+ readonly color?: string;
74
+ readonly font?: string;
75
+ readonly backgroundColor?: string;
76
+ }
77
+ export type Annotation = XLineAnnotation | YLineAnnotation | XRangeAnnotation | YRangeAnnotation | BoxAnnotation | PointAnnotation | LabelAnnotation;
78
+ export interface AnnotationsPluginOptions {
79
+ readonly annotations?: readonly Annotation[];
80
+ readonly className?: string;
81
+ readonly defaultColor?: string;
82
+ readonly defaultFillColor?: string;
83
+ readonly defaultFont?: string;
84
+ readonly zIndex?: number;
85
+ }
86
+ export interface AnnotationsPlugin extends ChartPlugin {
87
+ add(annotation: Annotation): void;
88
+ remove(id: string): boolean;
89
+ clear(): void;
90
+ setAnnotations(annotations: readonly Annotation[]): void;
91
+ getAnnotations(): readonly Annotation[];
92
+ }
93
+ export declare function annotationsPlugin(options?: AnnotationsPluginOptions): AnnotationsPlugin;
94
+ //# sourceMappingURL=Annotations.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Annotations.d.ts","sourceRoot":"","sources":["../../src/ui/Annotations.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAS,WAAW,EAAE,MAAM,YAAY,CAAC;AACrD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAEpD,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,GAAG,QAAQ,GAAG,KAAK,GAAG,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,OAAO,CAAC;IACrF,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CA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Overlay {
12
12
  private options;
13
13
  private xPool;
14
14
  private yPool;
15
+ private y2Pool;
15
16
  private readonly xTicks;
16
17
  private readonly yTicks;
18
+ private readonly y2Ticks;
17
19
  constructor(layout: ChartLayoutElements, config: AxisOverlayConfig, options?: AxisOverlayOptions);
18
20
  setOptions(options: AxisOverlayOptions): void;
19
- update(camera: Camera2D, axis: AxisController): void;
21
+ update(camera: Camera2D, axis: AxisController, rightCamera?: Camera2D, rightAxis?: AxisController): void;
20
22
  dispose(): void;
21
23
  private parentForAxis;
22
24
  private updateAxis;
@@ -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,EAAE,MAAM,kCAAkC,CAAC;AACvE,OAAO,KAAK,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAE/E,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,MAAM,iBAAiB,GAAG,iBAAiB,CAAC;AAElD,qBAAa,WAAW;IAOpB,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,OAAO;IARjB,OAAO,CAAC,KAAK,CAAwB;IACrC,OAAO,CAAC,KAAK,CAAwB;IACrC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAgB;IACvC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAgB;gBAGpB,MAAM,EAAE,mBAAmB,EAC3B,MAAM,EAAE,iBAAiB,EAClC,OAAO,GAAE,kBAAuB;IAG1C,UAAU,CAAC,OAAO,EAAE,kBAAkB,GAAG,IAAI;IAY7C,MAAM,CAA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ASf,OAAO,CAAC,aAAa;IAUrB,OAAO,CAAC,UAAU;CAuEnB"}
@@ -1,4 +1,4 @@
1
- import { SeriesConfig, SeriesStyle, SeriesMode, SeriesSample, Viewport } from '../core/types.js';
1
+ import { SeriesConfig, SeriesStyle, SeriesMode, SeriesSample, SeriesYAxis, Viewport } from '../core/types.js';
2
2
  import { SeriesStore } from '../core/SeriesStore.js';
3
3
  import { Camera2D } from '../interaction/Camera2D.js';
4
4
  import { PanIntent, ViewportPolicy, ZoomIntent } from '../interaction/types.js';
@@ -9,8 +9,10 @@ export interface AxisConfig {
9
9
  readonly position?: AxisPosition;
10
10
  }
11
11
  export type ChartPickMode = "nearest-x" | "nearest-point";
12
+ export type ChartPickGroup = "x" | "none";
12
13
  export interface ChartPickOptions {
13
14
  readonly mode?: ChartPickMode;
15
+ readonly group?: ChartPickGroup;
14
16
  readonly maxDistancePx?: number;
15
17
  }
16
18
  export interface ChartPluginHandle {
@@ -26,6 +28,7 @@ export interface ChartOptions {
26
28
  readonly axes?: boolean | {
27
29
  x?: boolean | AxisConfig;
28
30
  y?: boolean | AxisConfig;
31
+ y2?: boolean | AxisConfig;
29
32
  };
30
33
  readonly hover?: ChartPickOptions;
31
34
  readonly plugins?: readonly ChartPlugin[];
@@ -40,6 +43,7 @@ export interface ChartSeriesState {
40
43
  readonly mode: SeriesMode;
41
44
  readonly visible: boolean;
42
45
  readonly color: readonly [number, number, number, number];
46
+ readonly yAxis: SeriesYAxis;
43
47
  }
44
48
  export interface ChartPickItem extends SeriesSample {
45
49
  readonly series: SeriesStore;
@@ -61,6 +65,8 @@ export interface ChartHoverState {
61
65
  readonly dataY: number;
62
66
  readonly anchorX: number;
63
67
  readonly mode: ChartPickMode;
68
+ readonly group: ChartPickGroup;
69
+ readonly maxDistancePx: number;
64
70
  readonly items: readonly ChartPickItem[];
65
71
  }
66
72
  export interface ChartScreenshotOptions {
@@ -81,7 +87,9 @@ export declare class Chart {
81
87
  private readonly options;
82
88
  private series;
83
89
  private camera;
90
+ private rightCamera;
84
91
  private axis;
92
+ private rightAxis;
85
93
  private renderer;
86
94
  private rawLineBuffer;
87
95
  private rawLineData;
@@ -105,6 +113,7 @@ export declare class Chart {
105
113
  private readonly hoverSubscribers;
106
114
  private readonly seriesSubscribers;
107
115
  private readonly themeSubscribers;
116
+ private readonly renderSubscribers;
108
117
  private currentHover;
109
118
  private lastPointerClientX;
110
119
  private lastPointerClientY;
@@ -120,11 +129,13 @@ export declare class Chart {
120
129
  get plotElement(): HTMLElement;
121
130
  get xAxisElement(): HTMLElement;
122
131
  get yAxisElement(): HTMLElement;
132
+ get y2AxisElement(): HTMLElement;
123
133
  get theme(): ResolvedChartTheme;
124
- getCamera(): Camera2D;
125
- dataToPlot(x: number, y: number): [number, number];
126
- clientToData(clientX: number, clientY: number): [number, number] | null;
127
- getViewport(): Viewport;
134
+ getWebGLContext(): WebGL2RenderingContext | null;
135
+ getCamera(yAxis?: SeriesYAxis): Camera2D;
136
+ dataToPlot(x: number, y: number, yAxis?: SeriesYAxis): [number, number];
137
+ clientToData(clientX: number, clientY: number, yAxis?: SeriesYAxis): [number, number] | null;
138
+ getViewport(yAxis?: SeriesYAxis): Viewport;
128
139
  pan(intent: PanIntent): void;
129
140
  zoom(intent: ZoomIntent): void;
130
141
  addSeries(config: SeriesConfig, style?: Partial<SeriesStyle>): SeriesStore;
@@ -133,6 +144,7 @@ export declare class Chart {
133
144
  addScatter(config: TypedSeriesConfig, style?: Partial<SeriesStyle>): SeriesStore;
134
145
  addBar(config: TypedSeriesConfig, style?: Partial<SeriesStyle>): SeriesStore;
135
146
  addOhlc(config: TypedSeriesConfig, style?: Partial<SeriesStyle>): SeriesStore;
147
+ addCandlestick(config: TypedSeriesConfig, style?: Partial<SeriesStyle>): SeriesStore;
136
148
  removeSeries(series: SeriesStore): boolean;
137
149
  setSeriesVisible(series: SeriesStore, visible: boolean): boolean;
138
150
  getSeriesState(): ChartSeriesState[];
@@ -142,12 +154,17 @@ export declare class Chart {
142
154
  yMin?: number;
143
155
  yMax?: number;
144
156
  }): void;
157
+ setYViewport(yAxis: SeriesYAxis, v: {
158
+ yMin?: number;
159
+ yMax?: number;
160
+ }): void;
145
161
  resize(dpr?: number): boolean;
146
162
  getFrameStats(target?: ChartFrameStats): ChartFrameStats;
147
163
  getHoverState(): ChartHoverState | null;
148
164
  subscribe(event: "hover", callback: (state: ChartHoverState | null) => void): () => void;
149
165
  subscribe(event: "serieschange", callback: () => void): () => void;
150
166
  subscribe(event: "themechange", callback: () => void): () => void;
167
+ subscribe(event: "render", callback: (chart: Chart) => void): () => void;
151
168
  setTheme(theme?: ChartTheme): void;
152
169
  setGridVisible(visible: boolean): void;
153
170
  getGridVisible(): boolean;
@@ -160,10 +177,13 @@ export declare class Chart {
160
177
  dispose(): void;
161
178
  private applyTheme;
162
179
  private applyCanvasSize;
180
+ private cameraForSeries;
181
+ private syncRightCameraX;
163
182
  private drawSeries;
164
183
  private drawLineSeries;
165
184
  private drawAreaSeries;
166
185
  private drawOhlcSeries;
186
+ private drawCandlestickSeries;
167
187
  private drawScatterSeries;
168
188
  private drawBarSeries;
169
189
  private uploadRawLineData;
@@ -175,16 +195,20 @@ export declare class Chart {
175
195
  private writeBarTriangles;
176
196
  private writeBarBucketTriangles;
177
197
  private barBucketBounds;
198
+ private writeCandlestickWicks;
199
+ private drawCandlestickBodies;
178
200
  private writeBarTriangle;
179
201
  private drawBarTriangles;
180
202
  private recordDraw;
181
- private findNearestXAnchor;
182
- private findNearestPointAnchor;
203
+ private findNearestXCandidate;
204
+ private findNearestPointCandidate;
183
205
  private collectPickItems;
206
+ private createPickItem;
184
207
  private refreshHover;
185
208
  private emitHover;
186
209
  private emitSeriesChange;
187
210
  private emitThemeChange;
211
+ private emitRender;
188
212
  private drawDomTextForScreenshot;
189
213
  private maxMinMaxSegments;
190
214
  private maxBarTriangleBars;