@tellaro/tql 1.3.8 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +44 -41
- package/dist/node_modules/@kurkle/color/dist/color.esm.js +442 -0
- package/dist/node_modules/chart.js/dist/chart.js +6149 -0
- package/dist/node_modules/chart.js/dist/chunks/helpers.dataset.js +1685 -0
- package/dist/node_modules/chartjs-adapter-luxon/dist/chartjs-adapter-luxon.esm.js +56 -0
- package/dist/node_modules/chartjs-plugin-annotation/dist/chartjs-plugin-annotation.esm.js +1655 -0
- package/dist/node_modules/chartjs-plugin-datalabels/dist/chartjs-plugin-datalabels.esm.js +607 -0
- package/dist/node_modules/luxon/build/es6/luxon.js +5524 -0
- package/dist/src/builder.d.ts +62 -0
- package/dist/src/builder.js +56 -0
- package/dist/src/chart/colors.d.ts +23 -0
- package/dist/src/chart/colors.js +101 -0
- package/dist/src/chart/formatters.d.ts +17 -0
- package/dist/src/chart/formatters.js +49 -0
- package/dist/src/chart/index.d.ts +9 -0
- package/dist/src/chart/index.js +31 -0
- package/dist/src/chart/mappers.d.ts +849 -0
- package/dist/src/chart/mappers.js +613 -0
- package/dist/src/completionProvider.js +294 -165
- package/dist/src/index.d.ts +2 -1
- package/dist/src/parser.d.ts +10 -0
- package/dist/src/parser.js +41 -9
- package/dist/src/tokenizer.js +124 -103
- package/dist/src/types.d.ts +27 -3
- package/dist/src/validator.js +10 -9
- package/dist/tql.css +1 -1
- package/dist/vue/TqlChart.vue.d.ts +2 -0
- package/dist/vue/TqlChart.vue.js +7 -0
- package/dist/vue/TqlChart.vue2.js +212 -0
- package/dist/vue/index.d.ts +1 -0
- package/dist/vue/index.js +12 -10
- package/dist/vue/useTqlInput.js +80 -80
- package/package.json +39 -3
|
@@ -0,0 +1,1655 @@
|
|
|
1
|
+
import { Chart as se, Element as j, DoughnutController as St, Animations as Mt } from "../../chart.js/dist/chart.js";
|
|
2
|
+
import { i as E, b as L, t as S, aF as ye, h as w, E as Q, P as m, Y as Ct, $ as Pt, a7 as R, b4 as Ue, aw as kt, ay as At, v as V, g as Fe, Q as me, b5 as z, H as U, b6 as ke, T as Ke, U as Dt, x as Ae, a0 as ae, D as De, d as vt } from "../../chart.js/dist/chunks/helpers.dataset.js";
|
|
3
|
+
const ve = {
|
|
4
|
+
modes: {
|
|
5
|
+
/**
|
|
6
|
+
* Point mode returns all elements that hit test based on the event position
|
|
7
|
+
* @param {AnnotationElement[]} visibleElements - annotation elements which are visible
|
|
8
|
+
* @param {ChartEvent} event - the event we are find things at
|
|
9
|
+
* @return {AnnotationElement[]} - elements that are found
|
|
10
|
+
*/
|
|
11
|
+
point(t, e) {
|
|
12
|
+
return F(t, e, { intersect: !0 });
|
|
13
|
+
},
|
|
14
|
+
/**
|
|
15
|
+
* Nearest mode returns the element closest to the event position
|
|
16
|
+
* @param {AnnotationElement[]} visibleElements - annotation elements which are visible
|
|
17
|
+
* @param {ChartEvent} event - the event we are find things at
|
|
18
|
+
* @param {Object} options - interaction options to use
|
|
19
|
+
* @return {AnnotationElement[]} - elements that are found (only 1 element)
|
|
20
|
+
*/
|
|
21
|
+
nearest(t, e, n) {
|
|
22
|
+
return It(t, e, n);
|
|
23
|
+
},
|
|
24
|
+
/**
|
|
25
|
+
* x mode returns the elements that hit-test at the current x coordinate
|
|
26
|
+
* @param {AnnotationElement[]} visibleElements - annotation elements which are visible
|
|
27
|
+
* @param {ChartEvent} event - the event we are find things at
|
|
28
|
+
* @param {Object} options - interaction options to use
|
|
29
|
+
* @return {AnnotationElement[]} - elements that are found
|
|
30
|
+
*/
|
|
31
|
+
x(t, e, n) {
|
|
32
|
+
return F(t, e, { intersect: n.intersect, axis: "x" });
|
|
33
|
+
},
|
|
34
|
+
/**
|
|
35
|
+
* y mode returns the elements that hit-test at the current y coordinate
|
|
36
|
+
* @param {AnnotationElement[]} visibleElements - annotation elements which are visible
|
|
37
|
+
* @param {ChartEvent} event - the event we are find things at
|
|
38
|
+
* @param {Object} options - interaction options to use
|
|
39
|
+
* @return {AnnotationElement[]} - elements that are found
|
|
40
|
+
*/
|
|
41
|
+
y(t, e, n) {
|
|
42
|
+
return F(t, e, { intersect: n.intersect, axis: "y" });
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
function pe(t, e, n) {
|
|
47
|
+
return (ve.modes[n.mode] || ve.modes.nearest)(t, e, n);
|
|
48
|
+
}
|
|
49
|
+
function Tt(t, e, n) {
|
|
50
|
+
return n !== "x" && n !== "y" ? t.inRange(e.x, e.y, "x", !0) || t.inRange(e.x, e.y, "y", !0) : t.inRange(e.x, e.y, n, !0);
|
|
51
|
+
}
|
|
52
|
+
function jt(t, e, n) {
|
|
53
|
+
return n === "x" ? { x: t.x, y: e.y } : n === "y" ? { x: e.x, y: t.y } : e;
|
|
54
|
+
}
|
|
55
|
+
function F(t, e, n) {
|
|
56
|
+
return t.filter((o) => n.intersect ? o.inRange(e.x, e.y) : Tt(o, e, n.axis));
|
|
57
|
+
}
|
|
58
|
+
function It(t, e, n) {
|
|
59
|
+
let o = Number.POSITIVE_INFINITY;
|
|
60
|
+
return F(t, e, n).reduce((r, i) => {
|
|
61
|
+
const s = i.getCenterPoint(), a = jt(e, s, n.axis), d = ye(e, a);
|
|
62
|
+
return d < o ? (r = [i], o = d) : d === o && r.push(i), r;
|
|
63
|
+
}, []).sort((r, i) => r._index - i._index).slice(0, 1);
|
|
64
|
+
}
|
|
65
|
+
function I(t, e, n) {
|
|
66
|
+
const o = Math.cos(n), r = Math.sin(n), i = e.x, s = e.y;
|
|
67
|
+
return {
|
|
68
|
+
x: i + o * (t.x - i) - r * (t.y - s),
|
|
69
|
+
y: s + r * (t.x - i) + o * (t.y - s)
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
const Ot = (t, e) => e > t || t.length > e.length && t.slice(0, e.length) === e, v = 1e-3, G = (t, e, n) => Math.min(n, Math.max(e, t)), Qe = (t, e) => t.value >= t.start - e && t.value <= t.end + e;
|
|
73
|
+
function Rt(t, e, n) {
|
|
74
|
+
for (const o of Object.keys(t))
|
|
75
|
+
t[o] = G(t[o], e, n);
|
|
76
|
+
return t;
|
|
77
|
+
}
|
|
78
|
+
function Et(t, e, n, o) {
|
|
79
|
+
return !t || !e || n <= 0 ? !1 : Math.pow(t.x - e.x, 2) + Math.pow(t.y - e.y, 2) <= Math.pow(n + o, 2);
|
|
80
|
+
}
|
|
81
|
+
function Ge(t, { x: e, y: n, x2: o, y2: r }, i, { borderWidth: s, hitTolerance: a }) {
|
|
82
|
+
const d = (s + a) / 2, l = t.x >= e - d - v && t.x <= o + d + v, c = t.y >= n - d - v && t.y <= r + d + v;
|
|
83
|
+
return i === "x" ? l : (i === "y" || l) && c;
|
|
84
|
+
}
|
|
85
|
+
function Ze(t, { rect: e, center: n }, o, { rotation: r, borderWidth: i, hitTolerance: s }) {
|
|
86
|
+
const a = I(t, n, S(-r));
|
|
87
|
+
return Ge(a, e, o, { borderWidth: i, hitTolerance: s });
|
|
88
|
+
}
|
|
89
|
+
function O(t, e) {
|
|
90
|
+
const { centerX: n, centerY: o } = t.getProps(["centerX", "centerY"], e);
|
|
91
|
+
return { x: n, y: o };
|
|
92
|
+
}
|
|
93
|
+
function Lt(t, e, n, o = !0) {
|
|
94
|
+
const r = n.split(".");
|
|
95
|
+
let i = 0;
|
|
96
|
+
for (const s of e.split(".")) {
|
|
97
|
+
const a = r[i++];
|
|
98
|
+
if (parseInt(s, 10) < parseInt(a, 10))
|
|
99
|
+
break;
|
|
100
|
+
if (Ot(a, s)) {
|
|
101
|
+
if (o)
|
|
102
|
+
throw new Error(`${t} v${n} is not supported. v${e} or newer is required.`);
|
|
103
|
+
return !1;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
return !0;
|
|
107
|
+
}
|
|
108
|
+
const et = (t) => typeof t == "string" && t.endsWith("%"), tt = (t) => parseFloat(t) / 100, nt = (t) => G(tt(t), 0, 1), H = (t, e) => ({ x: t, y: e, x2: t, y2: e, width: 0, height: 0 }), Yt = {
|
|
109
|
+
box: (t) => H(t.centerX, t.centerY),
|
|
110
|
+
doughnutLabel: (t) => H(t.centerX, t.centerY),
|
|
111
|
+
ellipse: (t) => ({ centerX: t.centerX, centerY: t.centerX, radius: 0, width: 0, height: 0 }),
|
|
112
|
+
label: (t) => H(t.centerX, t.centerY),
|
|
113
|
+
line: (t) => H(t.x, t.y),
|
|
114
|
+
point: (t) => ({ centerX: t.centerX, centerY: t.centerY, radius: 0, width: 0, height: 0 }),
|
|
115
|
+
polygon: (t) => H(t.centerX, t.centerY)
|
|
116
|
+
};
|
|
117
|
+
function we(t, e) {
|
|
118
|
+
return e === "start" ? 0 : e === "end" ? t : et(e) ? nt(e) * t : t / 2;
|
|
119
|
+
}
|
|
120
|
+
function A(t, e, n = !0) {
|
|
121
|
+
return typeof e == "number" ? e : et(e) ? (n ? nt(e) : tt(e)) * t : t;
|
|
122
|
+
}
|
|
123
|
+
function Wt(t, e) {
|
|
124
|
+
const { x: n, width: o } = t, r = e.textAlign;
|
|
125
|
+
return r === "center" ? n + o / 2 : r === "end" || r === "right" ? n + o : n;
|
|
126
|
+
}
|
|
127
|
+
function ot(t, e, { borderWidth: n, position: o, xAdjust: r, yAdjust: i }, s) {
|
|
128
|
+
const a = E(s), d = e.width + (a ? s.width : 0) + n, l = e.height + (a ? s.height : 0) + n, c = xe(o), u = Te(t.x, d, r, c.x), f = Te(t.y, l, i, c.y);
|
|
129
|
+
return {
|
|
130
|
+
x: u,
|
|
131
|
+
y: f,
|
|
132
|
+
x2: u + d,
|
|
133
|
+
y2: f + l,
|
|
134
|
+
width: d,
|
|
135
|
+
height: l,
|
|
136
|
+
centerX: u + d / 2,
|
|
137
|
+
centerY: f + l / 2
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
function xe(t, e = "center") {
|
|
141
|
+
return E(t) ? {
|
|
142
|
+
x: V(t.x, e),
|
|
143
|
+
y: V(t.y, e)
|
|
144
|
+
} : (t = V(t, e), {
|
|
145
|
+
x: t,
|
|
146
|
+
y: t
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
const rt = (t, e) => t && t.autoFit && e < 1;
|
|
150
|
+
function it(t, e) {
|
|
151
|
+
const n = t.font, o = L(n) ? n : [n];
|
|
152
|
+
return rt(t, e) ? o.map(function(r) {
|
|
153
|
+
const i = ae(r);
|
|
154
|
+
return i.size = Math.floor(r.size * e), i.lineHeight = r.lineHeight, ae(i);
|
|
155
|
+
}) : o.map((r) => ae(r));
|
|
156
|
+
}
|
|
157
|
+
function st(t) {
|
|
158
|
+
return t && (w(t.xValue) || w(t.yValue));
|
|
159
|
+
}
|
|
160
|
+
function Te(t, e, n = 0, o) {
|
|
161
|
+
return t - we(e, o) + n;
|
|
162
|
+
}
|
|
163
|
+
function W(t, e, n) {
|
|
164
|
+
const o = n.init;
|
|
165
|
+
if (o) {
|
|
166
|
+
if (o === !0)
|
|
167
|
+
return dt(e, n);
|
|
168
|
+
} else return;
|
|
169
|
+
return _t(t, e, n);
|
|
170
|
+
}
|
|
171
|
+
function at(t, e, n) {
|
|
172
|
+
let o = !1;
|
|
173
|
+
return e.forEach((r) => {
|
|
174
|
+
R(t[r]) ? (o = !0, n[r] = t[r]) : w(n[r]) && delete n[r];
|
|
175
|
+
}), o;
|
|
176
|
+
}
|
|
177
|
+
function dt(t, e) {
|
|
178
|
+
const n = e.type || "line";
|
|
179
|
+
return Yt[n](t);
|
|
180
|
+
}
|
|
181
|
+
function _t(t, e, n) {
|
|
182
|
+
const o = me(n.init, [{ chart: t, properties: e, options: n }]);
|
|
183
|
+
if (o === !0)
|
|
184
|
+
return dt(e, n);
|
|
185
|
+
if (E(o))
|
|
186
|
+
return o;
|
|
187
|
+
}
|
|
188
|
+
const de = /* @__PURE__ */ new Map(), Xt = (t) => isNaN(t) || t <= 0, zt = (t) => t.reduce(function(e, n) {
|
|
189
|
+
return e += n.string, e;
|
|
190
|
+
}, "");
|
|
191
|
+
function Z(t) {
|
|
192
|
+
if (t && typeof t == "object") {
|
|
193
|
+
const e = t.toString();
|
|
194
|
+
return e === "[object HTMLImageElement]" || e === "[object HTMLCanvasElement]";
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
function ee(t, { x: e, y: n }, o) {
|
|
198
|
+
o && (t.translate(e, n), t.rotate(S(o)), t.translate(-e, -n));
|
|
199
|
+
}
|
|
200
|
+
function x(t, e) {
|
|
201
|
+
if (e && e.borderWidth)
|
|
202
|
+
return t.lineCap = e.borderCapStyle || "butt", t.setLineDash(e.borderDash), t.lineDashOffset = e.borderDashOffset, t.lineJoin = e.borderJoinStyle || "miter", t.lineWidth = e.borderWidth, t.strokeStyle = e.borderColor, !0;
|
|
203
|
+
}
|
|
204
|
+
function _(t, e) {
|
|
205
|
+
t.shadowColor = e.backgroundShadowColor, t.shadowBlur = e.shadowBlur, t.shadowOffsetX = e.shadowOffsetX, t.shadowOffsetY = e.shadowOffsetY;
|
|
206
|
+
}
|
|
207
|
+
function te(t, e) {
|
|
208
|
+
const n = e.content;
|
|
209
|
+
if (Z(n))
|
|
210
|
+
return {
|
|
211
|
+
width: A(n.width, e.width),
|
|
212
|
+
height: A(n.height, e.height)
|
|
213
|
+
};
|
|
214
|
+
const o = it(e), r = e.textStrokeWidth, i = L(n) ? n : [n], s = i.join() + zt(o) + r + (t._measureText ? "-spriting" : "");
|
|
215
|
+
return de.has(s) || de.set(s, Vt(t, i, o, r)), de.get(s);
|
|
216
|
+
}
|
|
217
|
+
function lt(t, e, n) {
|
|
218
|
+
const { x: o, y: r, width: i, height: s } = e;
|
|
219
|
+
t.save(), _(t, n);
|
|
220
|
+
const a = x(t, n);
|
|
221
|
+
t.fillStyle = n.backgroundColor, t.beginPath(), kt(t, {
|
|
222
|
+
x: o,
|
|
223
|
+
y: r,
|
|
224
|
+
w: i,
|
|
225
|
+
h: s,
|
|
226
|
+
radius: Rt(At(n.borderRadius), 0, Math.min(i, s) / 2)
|
|
227
|
+
}), t.closePath(), t.fill(), a && (t.shadowColor = n.borderShadowColor, t.stroke()), t.restore();
|
|
228
|
+
}
|
|
229
|
+
function ct(t, e, n, o) {
|
|
230
|
+
const r = n.content;
|
|
231
|
+
if (Z(r)) {
|
|
232
|
+
t.save(), t.globalAlpha = qt(n.opacity, r.style.opacity), t.drawImage(r, e.x, e.y, e.width, e.height), t.restore();
|
|
233
|
+
return;
|
|
234
|
+
}
|
|
235
|
+
const i = L(r) ? r : [r], s = it(n, o), a = n.color, d = L(a) ? a : [a], l = Wt(e, n), c = e.y + n.textStrokeWidth / 2;
|
|
236
|
+
t.save(), t.textBaseline = "middle", t.textAlign = n.textAlign, Ht(t, n) && $t(t, { x: l, y: c }, i, s), Jt(t, { x: l, y: c }, i, { fonts: s, colors: d }), t.restore();
|
|
237
|
+
}
|
|
238
|
+
function Ht(t, e) {
|
|
239
|
+
if (e.textStrokeWidth > 0)
|
|
240
|
+
return t.lineJoin = "round", t.miterLimit = 2, t.lineWidth = e.textStrokeWidth, t.strokeStyle = e.textStrokeColor, !0;
|
|
241
|
+
}
|
|
242
|
+
function Bt(t, e, n, o) {
|
|
243
|
+
const { radius: r, options: i } = e, s = i.pointStyle, a = i.rotation;
|
|
244
|
+
let d = (a || 0) * Ue;
|
|
245
|
+
if (Z(s)) {
|
|
246
|
+
t.save(), t.translate(n, o), t.rotate(d), t.drawImage(s, -s.width / 2, -s.height / 2, s.width, s.height), t.restore();
|
|
247
|
+
return;
|
|
248
|
+
}
|
|
249
|
+
Xt(r) || Nt(t, { x: n, y: o, radius: r, rotation: a, style: s, rad: d });
|
|
250
|
+
}
|
|
251
|
+
function Nt(t, { x: e, y: n, radius: o, rotation: r, style: i, rad: s }) {
|
|
252
|
+
let a, d, l, c;
|
|
253
|
+
switch (t.beginPath(), i) {
|
|
254
|
+
// Default includes circle
|
|
255
|
+
default:
|
|
256
|
+
t.arc(e, n, o, 0, Ke), t.closePath();
|
|
257
|
+
break;
|
|
258
|
+
case "triangle":
|
|
259
|
+
t.moveTo(e + Math.sin(s) * o, n - Math.cos(s) * o), s += ke, t.lineTo(e + Math.sin(s) * o, n - Math.cos(s) * o), s += ke, t.lineTo(e + Math.sin(s) * o, n - Math.cos(s) * o), t.closePath();
|
|
260
|
+
break;
|
|
261
|
+
case "rectRounded":
|
|
262
|
+
c = o * 0.516, l = o - c, a = Math.cos(s + z) * l, d = Math.sin(s + z) * l, t.arc(e - a, n - d, c, s - m, s - U), t.arc(e + d, n - a, c, s - U, s), t.arc(e + a, n + d, c, s, s + U), t.arc(e - d, n + a, c, s + U, s + m), t.closePath();
|
|
263
|
+
break;
|
|
264
|
+
case "rect":
|
|
265
|
+
if (!r) {
|
|
266
|
+
l = Math.SQRT1_2 * o, t.rect(e - l, n - l, 2 * l, 2 * l);
|
|
267
|
+
break;
|
|
268
|
+
}
|
|
269
|
+
s += z;
|
|
270
|
+
/* falls through */
|
|
271
|
+
case "rectRot":
|
|
272
|
+
a = Math.cos(s) * o, d = Math.sin(s) * o, t.moveTo(e - a, n - d), t.lineTo(e + d, n - a), t.lineTo(e + a, n + d), t.lineTo(e - d, n + a), t.closePath();
|
|
273
|
+
break;
|
|
274
|
+
case "crossRot":
|
|
275
|
+
s += z;
|
|
276
|
+
/* falls through */
|
|
277
|
+
case "cross":
|
|
278
|
+
a = Math.cos(s) * o, d = Math.sin(s) * o, t.moveTo(e - a, n - d), t.lineTo(e + a, n + d), t.moveTo(e + d, n - a), t.lineTo(e - d, n + a);
|
|
279
|
+
break;
|
|
280
|
+
case "star":
|
|
281
|
+
a = Math.cos(s) * o, d = Math.sin(s) * o, t.moveTo(e - a, n - d), t.lineTo(e + a, n + d), t.moveTo(e + d, n - a), t.lineTo(e - d, n + a), s += z, a = Math.cos(s) * o, d = Math.sin(s) * o, t.moveTo(e - a, n - d), t.lineTo(e + a, n + d), t.moveTo(e + d, n - a), t.lineTo(e - d, n + a);
|
|
282
|
+
break;
|
|
283
|
+
case "line":
|
|
284
|
+
a = Math.cos(s) * o, d = Math.sin(s) * o, t.moveTo(e - a, n - d), t.lineTo(e + a, n + d);
|
|
285
|
+
break;
|
|
286
|
+
case "dash":
|
|
287
|
+
t.moveTo(e, n), t.lineTo(e + Math.cos(s) * o, n + Math.sin(s) * o);
|
|
288
|
+
break;
|
|
289
|
+
}
|
|
290
|
+
t.fill();
|
|
291
|
+
}
|
|
292
|
+
function Vt(t, e, n, o) {
|
|
293
|
+
t.save();
|
|
294
|
+
const r = e.length;
|
|
295
|
+
let i = 0, s = o;
|
|
296
|
+
for (let a = 0; a < r; a++) {
|
|
297
|
+
const d = n[Math.min(a, n.length - 1)];
|
|
298
|
+
t.font = d.string;
|
|
299
|
+
const l = e[a];
|
|
300
|
+
i = Math.max(i, t.measureText(l).width + o), s += d.lineHeight;
|
|
301
|
+
}
|
|
302
|
+
return t.restore(), { width: i, height: s };
|
|
303
|
+
}
|
|
304
|
+
function $t(t, { x: e, y: n }, o, r) {
|
|
305
|
+
t.beginPath();
|
|
306
|
+
let i = 0;
|
|
307
|
+
o.forEach(function(s, a) {
|
|
308
|
+
const d = r[Math.min(a, r.length - 1)], l = d.lineHeight;
|
|
309
|
+
t.font = d.string, t.strokeText(s, e, n + l / 2 + i), i += l;
|
|
310
|
+
}), t.stroke();
|
|
311
|
+
}
|
|
312
|
+
function Jt(t, { x: e, y: n }, o, { fonts: r, colors: i }) {
|
|
313
|
+
let s = 0;
|
|
314
|
+
o.forEach(function(a, d) {
|
|
315
|
+
const l = i[Math.min(d, i.length - 1)], c = r[Math.min(d, r.length - 1)], u = c.lineHeight;
|
|
316
|
+
t.beginPath(), t.font = c.string, t.fillStyle = l, t.fillText(a, e, n + u / 2 + s), s += u, t.fill();
|
|
317
|
+
});
|
|
318
|
+
}
|
|
319
|
+
function qt(t, e) {
|
|
320
|
+
const n = Ae(t) ? t : e;
|
|
321
|
+
return Ae(n) ? G(n, 0, 1) : 1;
|
|
322
|
+
}
|
|
323
|
+
const ut = ["left", "bottom", "top", "right"];
|
|
324
|
+
function Ut(t, e) {
|
|
325
|
+
const { pointX: n, pointY: o, options: r } = e, i = r.callout, s = i && i.display && Zt(e, i);
|
|
326
|
+
if (!s || tn(e, i, s))
|
|
327
|
+
return;
|
|
328
|
+
if (t.save(), t.beginPath(), !x(t, i))
|
|
329
|
+
return t.restore();
|
|
330
|
+
const { separatorStart: d, separatorEnd: l } = Ft(e, s), { sideStart: c, sideEnd: u } = Qt(e, s, d);
|
|
331
|
+
(i.margin > 0 || r.borderWidth === 0) && (t.moveTo(d.x, d.y), t.lineTo(l.x, l.y)), t.moveTo(c.x, c.y), t.lineTo(u.x, u.y);
|
|
332
|
+
const f = I({ x: n, y: o }, e.getCenterPoint(), S(-e.rotation));
|
|
333
|
+
t.lineTo(f.x, f.y), t.stroke(), t.restore();
|
|
334
|
+
}
|
|
335
|
+
function Ft(t, e) {
|
|
336
|
+
const { x: n, y: o, x2: r, y2: i } = t, s = Kt(t, e);
|
|
337
|
+
let a, d;
|
|
338
|
+
return e === "left" || e === "right" ? (a = { x: n + s, y: o }, d = { x: a.x, y: i }) : (a = { x: n, y: o + s }, d = { x: r, y: a.y }), { separatorStart: a, separatorEnd: d };
|
|
339
|
+
}
|
|
340
|
+
function Kt(t, e) {
|
|
341
|
+
const { width: n, height: o, options: r } = t, i = r.callout.margin + r.borderWidth / 2;
|
|
342
|
+
return e === "right" ? n + i : e === "bottom" ? o + i : -i;
|
|
343
|
+
}
|
|
344
|
+
function Qt(t, e, n) {
|
|
345
|
+
const { y: o, width: r, height: i, options: s } = t, a = s.callout.start, d = Gt(e, s.callout);
|
|
346
|
+
let l, c;
|
|
347
|
+
return e === "left" || e === "right" ? (l = { x: n.x, y: o + A(i, a) }, c = { x: l.x + d, y: l.y }) : (l = { x: n.x + A(r, a), y: n.y }, c = { x: l.x, y: l.y + d }), { sideStart: l, sideEnd: c };
|
|
348
|
+
}
|
|
349
|
+
function Gt(t, e) {
|
|
350
|
+
const n = e.side;
|
|
351
|
+
return t === "left" || t === "top" ? -n : n;
|
|
352
|
+
}
|
|
353
|
+
function Zt(t, e) {
|
|
354
|
+
const n = e.position;
|
|
355
|
+
return ut.includes(n) ? n : en(t, e);
|
|
356
|
+
}
|
|
357
|
+
function en(t, e) {
|
|
358
|
+
const { x: n, y: o, x2: r, y2: i, width: s, height: a, pointX: d, pointY: l, centerX: c, centerY: u, rotation: f } = t, h = { x: c, y: u }, g = e.start, p = A(s, g), M = A(a, g), b = [n, n + p, n + p, r], y = [o + M, i, o, i], C = [];
|
|
359
|
+
for (let D = 0; D < 4; D++) {
|
|
360
|
+
const ie = I({ x: b[D], y: y[D] }, h, S(f));
|
|
361
|
+
C.push({
|
|
362
|
+
position: ut[D],
|
|
363
|
+
distance: ye(ie, { x: d, y: l })
|
|
364
|
+
});
|
|
365
|
+
}
|
|
366
|
+
return C.sort((D, ie) => D.distance - ie.distance)[0].position;
|
|
367
|
+
}
|
|
368
|
+
function tn(t, e, n) {
|
|
369
|
+
const { pointX: o, pointY: r } = t, i = e.margin;
|
|
370
|
+
let s = o, a = r;
|
|
371
|
+
return n === "left" ? s += i : n === "right" ? s -= i : n === "top" ? a += i : n === "bottom" && (a -= i), t.inRange(s, a);
|
|
372
|
+
}
|
|
373
|
+
const je = {
|
|
374
|
+
xScaleID: { min: "xMin", max: "xMax", start: "left", end: "right", startProp: "x", endProp: "x2" },
|
|
375
|
+
yScaleID: { min: "yMin", max: "yMax", start: "bottom", end: "top", startProp: "y", endProp: "y2" }
|
|
376
|
+
};
|
|
377
|
+
function Y(t, e, n) {
|
|
378
|
+
return e = typeof e == "number" ? e : t.parse(e), Fe(e) ? t.getPixelForValue(e) : n;
|
|
379
|
+
}
|
|
380
|
+
function T(t, e, n) {
|
|
381
|
+
const o = e[n];
|
|
382
|
+
if (o || n === "scaleID")
|
|
383
|
+
return o;
|
|
384
|
+
const r = n.charAt(0), i = Object.values(t).filter((s) => s.axis && s.axis === r);
|
|
385
|
+
return i.length ? i[0].id : r;
|
|
386
|
+
}
|
|
387
|
+
function ft(t, e) {
|
|
388
|
+
if (t) {
|
|
389
|
+
const n = t.options.reverse, o = Y(t, e.min, n ? e.end : e.start), r = Y(t, e.max, n ? e.start : e.end);
|
|
390
|
+
return {
|
|
391
|
+
start: o,
|
|
392
|
+
end: r
|
|
393
|
+
};
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
function ht(t, e) {
|
|
397
|
+
const { chartArea: n, scales: o } = t, r = o[T(o, e, "xScaleID")], i = o[T(o, e, "yScaleID")];
|
|
398
|
+
let s = n.width / 2, a = n.height / 2;
|
|
399
|
+
return r && (s = Y(r, e.xValue, r.left + r.width / 2)), i && (a = Y(i, e.yValue, i.top + i.height / 2)), { x: s, y: a };
|
|
400
|
+
}
|
|
401
|
+
function Se(t, e) {
|
|
402
|
+
const n = t.scales, o = n[T(n, e, "xScaleID")], r = n[T(n, e, "yScaleID")];
|
|
403
|
+
if (!o && !r)
|
|
404
|
+
return {};
|
|
405
|
+
let { left: i, right: s } = o || t.chartArea, { top: a, bottom: d } = r || t.chartArea;
|
|
406
|
+
const l = Ie(o, { min: e.xMin, max: e.xMax, start: i, end: s });
|
|
407
|
+
i = l.start, s = l.end;
|
|
408
|
+
const c = Ie(r, { min: e.yMin, max: e.yMax, start: d, end: a });
|
|
409
|
+
return a = c.start, d = c.end, {
|
|
410
|
+
x: i,
|
|
411
|
+
y: a,
|
|
412
|
+
x2: s,
|
|
413
|
+
y2: d,
|
|
414
|
+
width: s - i,
|
|
415
|
+
height: d - a,
|
|
416
|
+
centerX: i + (s - i) / 2,
|
|
417
|
+
centerY: a + (d - a) / 2
|
|
418
|
+
};
|
|
419
|
+
}
|
|
420
|
+
function gt(t, e) {
|
|
421
|
+
if (!st(e)) {
|
|
422
|
+
const n = Se(t, e);
|
|
423
|
+
let o = e.radius;
|
|
424
|
+
(!o || isNaN(o)) && (o = Math.min(n.width, n.height) / 2, e.radius = o);
|
|
425
|
+
const r = o * 2, i = n.centerX + e.xAdjust, s = n.centerY + e.yAdjust;
|
|
426
|
+
return {
|
|
427
|
+
x: i - o,
|
|
428
|
+
y: s - o,
|
|
429
|
+
x2: i + o,
|
|
430
|
+
y2: s + o,
|
|
431
|
+
centerX: i,
|
|
432
|
+
centerY: s,
|
|
433
|
+
width: r,
|
|
434
|
+
height: r,
|
|
435
|
+
radius: o
|
|
436
|
+
};
|
|
437
|
+
}
|
|
438
|
+
return on(t, e);
|
|
439
|
+
}
|
|
440
|
+
function nn(t, e) {
|
|
441
|
+
const { scales: n, chartArea: o } = t, r = n[e.scaleID], i = { x: o.left, y: o.top, x2: o.right, y2: o.bottom };
|
|
442
|
+
return r ? rn(r, i, e) : sn(n, i, e), i;
|
|
443
|
+
}
|
|
444
|
+
function bt(t, e) {
|
|
445
|
+
const n = Se(t, e);
|
|
446
|
+
return n.initProperties = W(t, n, e), n.elements = [{
|
|
447
|
+
type: "label",
|
|
448
|
+
optionScope: "label",
|
|
449
|
+
properties: ln(t, n, e),
|
|
450
|
+
initProperties: n.initProperties
|
|
451
|
+
}], n;
|
|
452
|
+
}
|
|
453
|
+
function on(t, e) {
|
|
454
|
+
const n = ht(t, e), o = e.radius * 2;
|
|
455
|
+
return {
|
|
456
|
+
x: n.x - e.radius + e.xAdjust,
|
|
457
|
+
y: n.y - e.radius + e.yAdjust,
|
|
458
|
+
x2: n.x + e.radius + e.xAdjust,
|
|
459
|
+
y2: n.y + e.radius + e.yAdjust,
|
|
460
|
+
centerX: n.x + e.xAdjust,
|
|
461
|
+
centerY: n.y + e.yAdjust,
|
|
462
|
+
radius: e.radius,
|
|
463
|
+
width: o,
|
|
464
|
+
height: o
|
|
465
|
+
};
|
|
466
|
+
}
|
|
467
|
+
function Ie(t, e) {
|
|
468
|
+
const n = ft(t, e) || e;
|
|
469
|
+
return {
|
|
470
|
+
start: Math.min(n.start, n.end),
|
|
471
|
+
end: Math.max(n.start, n.end)
|
|
472
|
+
};
|
|
473
|
+
}
|
|
474
|
+
function rn(t, e, n) {
|
|
475
|
+
const o = Y(t, n.value, NaN), r = Y(t, n.endValue, o);
|
|
476
|
+
t.isHorizontal() ? (e.x = o, e.x2 = r) : (e.y = o, e.y2 = r);
|
|
477
|
+
}
|
|
478
|
+
function sn(t, e, n) {
|
|
479
|
+
for (const o of Object.keys(je)) {
|
|
480
|
+
const r = t[T(t, n, o)];
|
|
481
|
+
if (r) {
|
|
482
|
+
const { min: i, max: s, start: a, end: d, startProp: l, endProp: c } = je[o], u = ft(r, { min: n[i], max: n[s], start: r[a], end: r[d] });
|
|
483
|
+
e[l] = u.start, e[c] = u.end;
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
function an({ properties: t, options: e }, n, o, r) {
|
|
488
|
+
const { x: i, x2: s, width: a } = t;
|
|
489
|
+
return yt({ start: i, end: s, borderWidth: e.borderWidth }, {
|
|
490
|
+
position: o.x,
|
|
491
|
+
padding: { start: r.left, end: r.right },
|
|
492
|
+
adjust: e.label.xAdjust,
|
|
493
|
+
size: n.width
|
|
494
|
+
});
|
|
495
|
+
}
|
|
496
|
+
function dn({ properties: t, options: e }, n, o, r) {
|
|
497
|
+
const { y: i, y2: s, height: a } = t;
|
|
498
|
+
return yt({ start: i, end: s, borderWidth: e.borderWidth }, {
|
|
499
|
+
position: o.y,
|
|
500
|
+
padding: { start: r.top, end: r.bottom },
|
|
501
|
+
adjust: e.label.yAdjust,
|
|
502
|
+
size: n.height
|
|
503
|
+
});
|
|
504
|
+
}
|
|
505
|
+
function yt(t, e) {
|
|
506
|
+
const { start: n, end: o, borderWidth: r } = t, { position: i, padding: { start: s, end: a }, adjust: d } = e, l = o - r - n - s - a - e.size;
|
|
507
|
+
return n + r / 2 + d + we(l, i);
|
|
508
|
+
}
|
|
509
|
+
function ln(t, e, n) {
|
|
510
|
+
const o = n.label;
|
|
511
|
+
o.backgroundColor = "transparent", o.callout.display = !1;
|
|
512
|
+
const r = xe(o.position), i = Q(o.padding), s = te(t.ctx, o), a = an({ properties: e, options: n }, s, r, i), d = dn({ properties: e, options: n }, s, r, i), l = s.width + i.width, c = s.height + i.height;
|
|
513
|
+
return {
|
|
514
|
+
x: a,
|
|
515
|
+
y: d,
|
|
516
|
+
x2: a + l,
|
|
517
|
+
y2: d + c,
|
|
518
|
+
width: l,
|
|
519
|
+
height: c,
|
|
520
|
+
centerX: a + l / 2,
|
|
521
|
+
centerY: d + c / 2,
|
|
522
|
+
rotation: o.rotation
|
|
523
|
+
};
|
|
524
|
+
}
|
|
525
|
+
const le = ["enter", "leave"], Me = le.concat("click");
|
|
526
|
+
function cn(t, e, n) {
|
|
527
|
+
e.listened = at(n, Me, e.listeners), e.moveListened = !1, le.forEach((o) => {
|
|
528
|
+
R(n[o]) && (e.moveListened = !0);
|
|
529
|
+
}), (!e.listened || !e.moveListened) && e.annotations.forEach((o) => {
|
|
530
|
+
!e.listened && R(o.click) && (e.listened = !0), e.moveListened || le.forEach((r) => {
|
|
531
|
+
R(o[r]) && (e.listened = !0, e.moveListened = !0);
|
|
532
|
+
});
|
|
533
|
+
});
|
|
534
|
+
}
|
|
535
|
+
function un(t, e, n) {
|
|
536
|
+
if (t.listened)
|
|
537
|
+
switch (e.type) {
|
|
538
|
+
case "mousemove":
|
|
539
|
+
case "mouseout":
|
|
540
|
+
return fn(t, e, n);
|
|
541
|
+
case "click":
|
|
542
|
+
return hn(t, e, n);
|
|
543
|
+
}
|
|
544
|
+
}
|
|
545
|
+
function fn(t, e, n) {
|
|
546
|
+
if (!t.moveListened)
|
|
547
|
+
return;
|
|
548
|
+
let o;
|
|
549
|
+
e.type === "mousemove" ? o = pe(t.visibleElements, e, n.interaction) : o = [];
|
|
550
|
+
const r = t.hovered;
|
|
551
|
+
t.hovered = o;
|
|
552
|
+
const i = { state: t, event: e };
|
|
553
|
+
let s = Oe(i, "leave", r, o);
|
|
554
|
+
return Oe(i, "enter", o, r) || s;
|
|
555
|
+
}
|
|
556
|
+
function Oe({ state: t, event: e }, n, o, r) {
|
|
557
|
+
let i;
|
|
558
|
+
for (const s of o)
|
|
559
|
+
r.indexOf(s) < 0 && (i = mt(s.options[n] || t.listeners[n], s, e) || i);
|
|
560
|
+
return i;
|
|
561
|
+
}
|
|
562
|
+
function hn(t, e, n) {
|
|
563
|
+
const o = t.listeners, r = pe(t.visibleElements, e, n.interaction);
|
|
564
|
+
let i;
|
|
565
|
+
for (const s of r)
|
|
566
|
+
i = mt(s.options.click || o.click, s, e) || i;
|
|
567
|
+
return i;
|
|
568
|
+
}
|
|
569
|
+
function mt(t, e, n) {
|
|
570
|
+
return me(t, [e.$context, n]) === !0;
|
|
571
|
+
}
|
|
572
|
+
const K = ["afterDraw", "beforeDraw"];
|
|
573
|
+
function gn(t, e, n) {
|
|
574
|
+
const o = e.visibleElements;
|
|
575
|
+
e.hooked = at(n, K, e.hooks), e.hooked || o.forEach((r) => {
|
|
576
|
+
e.hooked || K.forEach((i) => {
|
|
577
|
+
R(r.options[i]) && (e.hooked = !0);
|
|
578
|
+
});
|
|
579
|
+
});
|
|
580
|
+
}
|
|
581
|
+
function Re(t, e, n) {
|
|
582
|
+
if (t.hooked) {
|
|
583
|
+
const o = e.options[n] || t.hooks[n];
|
|
584
|
+
return me(o, [e.$context]);
|
|
585
|
+
}
|
|
586
|
+
}
|
|
587
|
+
function bn(t, e, n) {
|
|
588
|
+
const o = xn(t.scales, e, n);
|
|
589
|
+
let r = Ee(e, o, "min", "suggestedMin");
|
|
590
|
+
r = Ee(e, o, "max", "suggestedMax") || r, r && R(e.handleTickRangeOptions) && e.handleTickRangeOptions();
|
|
591
|
+
}
|
|
592
|
+
function yn(t, e) {
|
|
593
|
+
for (const n of t)
|
|
594
|
+
pn(n, e);
|
|
595
|
+
}
|
|
596
|
+
function Ee(t, e, n, o) {
|
|
597
|
+
if (Fe(e[n]) && !mn(t.options, n, o)) {
|
|
598
|
+
const r = t[n] !== e[n];
|
|
599
|
+
return t[n] = e[n], r;
|
|
600
|
+
}
|
|
601
|
+
}
|
|
602
|
+
function mn(t, e, n) {
|
|
603
|
+
return w(t[e]) || w(t[n]);
|
|
604
|
+
}
|
|
605
|
+
function pn(t, e) {
|
|
606
|
+
for (const n of ["scaleID", "xScaleID", "yScaleID"]) {
|
|
607
|
+
const o = T(e, t, n);
|
|
608
|
+
o && !e[o] && wn(t, n) && console.warn(`No scale found with id '${o}' for annotation '${t.id}'`);
|
|
609
|
+
}
|
|
610
|
+
}
|
|
611
|
+
function wn(t, e) {
|
|
612
|
+
if (e === "scaleID")
|
|
613
|
+
return !0;
|
|
614
|
+
const n = e.charAt(0);
|
|
615
|
+
for (const o of ["Min", "Max", "Value"])
|
|
616
|
+
if (w(t[n + o]))
|
|
617
|
+
return !0;
|
|
618
|
+
return !1;
|
|
619
|
+
}
|
|
620
|
+
function xn(t, e, n) {
|
|
621
|
+
const o = e.axis, r = e.id, i = o + "ScaleID", s = {
|
|
622
|
+
min: V(e.min, Number.NEGATIVE_INFINITY),
|
|
623
|
+
max: V(e.max, Number.POSITIVE_INFINITY)
|
|
624
|
+
};
|
|
625
|
+
for (const a of n)
|
|
626
|
+
a.scaleID === r ? Le(a, e, ["value", "endValue"], s) : T(t, a, i) === r && Le(a, e, [o + "Min", o + "Max", o + "Value"], s);
|
|
627
|
+
return s;
|
|
628
|
+
}
|
|
629
|
+
function Le(t, e, n, o) {
|
|
630
|
+
for (const r of n) {
|
|
631
|
+
const i = t[r];
|
|
632
|
+
if (w(i)) {
|
|
633
|
+
const s = e.parse(i);
|
|
634
|
+
o.min = Math.min(o.min, s), o.max = Math.max(o.max, s);
|
|
635
|
+
}
|
|
636
|
+
}
|
|
637
|
+
}
|
|
638
|
+
class X extends j {
|
|
639
|
+
inRange(e, n, o, r) {
|
|
640
|
+
const { x: i, y: s } = I({ x: e, y: n }, this.getCenterPoint(r), S(-this.options.rotation));
|
|
641
|
+
return Ge({ x: i, y: s }, this.getProps(["x", "y", "x2", "y2"], r), o, this.options);
|
|
642
|
+
}
|
|
643
|
+
getCenterPoint(e) {
|
|
644
|
+
return O(this, e);
|
|
645
|
+
}
|
|
646
|
+
draw(e) {
|
|
647
|
+
e.save(), ee(e, this.getCenterPoint(), this.options.rotation), lt(e, this, this.options), e.restore();
|
|
648
|
+
}
|
|
649
|
+
get label() {
|
|
650
|
+
return this.elements && this.elements[0];
|
|
651
|
+
}
|
|
652
|
+
resolveElementProperties(e, n) {
|
|
653
|
+
return bt(e, n);
|
|
654
|
+
}
|
|
655
|
+
}
|
|
656
|
+
X.id = "boxAnnotation";
|
|
657
|
+
X.defaults = {
|
|
658
|
+
adjustScaleRange: !0,
|
|
659
|
+
backgroundShadowColor: "transparent",
|
|
660
|
+
borderCapStyle: "butt",
|
|
661
|
+
borderDash: [],
|
|
662
|
+
borderDashOffset: 0,
|
|
663
|
+
borderJoinStyle: "miter",
|
|
664
|
+
borderRadius: 0,
|
|
665
|
+
borderShadowColor: "transparent",
|
|
666
|
+
borderWidth: 1,
|
|
667
|
+
display: !0,
|
|
668
|
+
init: void 0,
|
|
669
|
+
hitTolerance: 0,
|
|
670
|
+
label: {
|
|
671
|
+
backgroundColor: "transparent",
|
|
672
|
+
borderWidth: 0,
|
|
673
|
+
callout: {
|
|
674
|
+
display: !1
|
|
675
|
+
},
|
|
676
|
+
color: "black",
|
|
677
|
+
content: null,
|
|
678
|
+
display: !1,
|
|
679
|
+
drawTime: void 0,
|
|
680
|
+
font: {
|
|
681
|
+
family: void 0,
|
|
682
|
+
lineHeight: void 0,
|
|
683
|
+
size: void 0,
|
|
684
|
+
style: void 0,
|
|
685
|
+
weight: "bold"
|
|
686
|
+
},
|
|
687
|
+
height: void 0,
|
|
688
|
+
hitTolerance: void 0,
|
|
689
|
+
opacity: void 0,
|
|
690
|
+
padding: 6,
|
|
691
|
+
position: "center",
|
|
692
|
+
rotation: void 0,
|
|
693
|
+
textAlign: "start",
|
|
694
|
+
textStrokeColor: void 0,
|
|
695
|
+
textStrokeWidth: 0,
|
|
696
|
+
width: void 0,
|
|
697
|
+
xAdjust: 0,
|
|
698
|
+
yAdjust: 0,
|
|
699
|
+
z: void 0
|
|
700
|
+
},
|
|
701
|
+
rotation: 0,
|
|
702
|
+
shadowBlur: 0,
|
|
703
|
+
shadowOffsetX: 0,
|
|
704
|
+
shadowOffsetY: 0,
|
|
705
|
+
xMax: void 0,
|
|
706
|
+
xMin: void 0,
|
|
707
|
+
xScaleID: void 0,
|
|
708
|
+
yMax: void 0,
|
|
709
|
+
yMin: void 0,
|
|
710
|
+
yScaleID: void 0,
|
|
711
|
+
z: 0
|
|
712
|
+
};
|
|
713
|
+
X.defaultRoutes = {
|
|
714
|
+
borderColor: "color",
|
|
715
|
+
backgroundColor: "color"
|
|
716
|
+
};
|
|
717
|
+
X.descriptors = {
|
|
718
|
+
label: {
|
|
719
|
+
_fallback: !0
|
|
720
|
+
}
|
|
721
|
+
};
|
|
722
|
+
class ne extends j {
|
|
723
|
+
inRange(e, n, o, r) {
|
|
724
|
+
return Ze(
|
|
725
|
+
{ x: e, y: n },
|
|
726
|
+
{ rect: this.getProps(["x", "y", "x2", "y2"], r), center: this.getCenterPoint(r) },
|
|
727
|
+
o,
|
|
728
|
+
{ rotation: this.rotation, borderWidth: 0, hitTolerance: this.options.hitTolerance }
|
|
729
|
+
);
|
|
730
|
+
}
|
|
731
|
+
getCenterPoint(e) {
|
|
732
|
+
return O(this, e);
|
|
733
|
+
}
|
|
734
|
+
draw(e) {
|
|
735
|
+
const n = this.options;
|
|
736
|
+
!n.display || !n.content || (An(e, this), e.save(), ee(e, this.getCenterPoint(), this.rotation), ct(e, this, n, this._fitRatio), e.restore());
|
|
737
|
+
}
|
|
738
|
+
resolveElementProperties(e, n) {
|
|
739
|
+
const o = Sn(e, n);
|
|
740
|
+
if (!o)
|
|
741
|
+
return {};
|
|
742
|
+
const { controllerMeta: r, point: i, radius: s } = Cn(e, n, o);
|
|
743
|
+
let a = te(e.ctx, n);
|
|
744
|
+
const d = Pn(a, s);
|
|
745
|
+
rt(n, d) && (a = { width: a.width * d, height: a.height * d });
|
|
746
|
+
const { position: l, xAdjust: c, yAdjust: u } = n, f = ot(i, a, { borderWidth: 0, position: l, xAdjust: c, yAdjust: u });
|
|
747
|
+
return {
|
|
748
|
+
initProperties: W(e, f, n),
|
|
749
|
+
...f,
|
|
750
|
+
...r,
|
|
751
|
+
rotation: n.rotation,
|
|
752
|
+
_fitRatio: d
|
|
753
|
+
};
|
|
754
|
+
}
|
|
755
|
+
}
|
|
756
|
+
ne.id = "doughnutLabelAnnotation";
|
|
757
|
+
ne.defaults = {
|
|
758
|
+
autoFit: !0,
|
|
759
|
+
autoHide: !0,
|
|
760
|
+
backgroundColor: "transparent",
|
|
761
|
+
backgroundShadowColor: "transparent",
|
|
762
|
+
borderColor: "transparent",
|
|
763
|
+
borderDash: [],
|
|
764
|
+
borderDashOffset: 0,
|
|
765
|
+
borderJoinStyle: "miter",
|
|
766
|
+
borderShadowColor: "transparent",
|
|
767
|
+
borderWidth: 0,
|
|
768
|
+
color: "black",
|
|
769
|
+
content: null,
|
|
770
|
+
display: !0,
|
|
771
|
+
font: {
|
|
772
|
+
family: void 0,
|
|
773
|
+
lineHeight: void 0,
|
|
774
|
+
size: void 0,
|
|
775
|
+
style: void 0,
|
|
776
|
+
weight: void 0
|
|
777
|
+
},
|
|
778
|
+
height: void 0,
|
|
779
|
+
hitTolerance: 0,
|
|
780
|
+
init: void 0,
|
|
781
|
+
opacity: void 0,
|
|
782
|
+
position: "center",
|
|
783
|
+
rotation: 0,
|
|
784
|
+
shadowBlur: 0,
|
|
785
|
+
shadowOffsetX: 0,
|
|
786
|
+
shadowOffsetY: 0,
|
|
787
|
+
spacing: 1,
|
|
788
|
+
textAlign: "center",
|
|
789
|
+
textStrokeColor: void 0,
|
|
790
|
+
textStrokeWidth: 0,
|
|
791
|
+
width: void 0,
|
|
792
|
+
xAdjust: 0,
|
|
793
|
+
yAdjust: 0
|
|
794
|
+
};
|
|
795
|
+
ne.defaultRoutes = {};
|
|
796
|
+
function Sn(t, e) {
|
|
797
|
+
return t.getSortedVisibleDatasetMetas().reduce(function(n, o) {
|
|
798
|
+
const r = o.controller;
|
|
799
|
+
return r instanceof St && Mn(t, e, o.data) && (!n || r.innerRadius < n.controller.innerRadius) && r.options.circumference >= 90 ? o : n;
|
|
800
|
+
}, void 0);
|
|
801
|
+
}
|
|
802
|
+
function Mn(t, e, n) {
|
|
803
|
+
if (!e.autoHide)
|
|
804
|
+
return !0;
|
|
805
|
+
for (let o = 0; o < n.length; o++)
|
|
806
|
+
if (!n[o].hidden && t.getDataVisibility(o))
|
|
807
|
+
return !0;
|
|
808
|
+
}
|
|
809
|
+
function Cn({ chartArea: t }, e, n) {
|
|
810
|
+
const { left: o, top: r, right: i, bottom: s } = t, { innerRadius: a, offsetX: d, offsetY: l } = n.controller, c = (o + i) / 2 + d, u = (r + s) / 2 + l, f = {
|
|
811
|
+
left: Math.max(c - a, o),
|
|
812
|
+
right: Math.min(c + a, i),
|
|
813
|
+
top: Math.max(u - a, r),
|
|
814
|
+
bottom: Math.min(u + a, s)
|
|
815
|
+
}, h = {
|
|
816
|
+
x: (f.left + f.right) / 2,
|
|
817
|
+
y: (f.top + f.bottom) / 2
|
|
818
|
+
}, g = e.spacing + e.borderWidth / 2, p = a - g, M = h.y > u, b = M ? r + g : s - g, y = kn(b, c, u, p);
|
|
819
|
+
return {
|
|
820
|
+
controllerMeta: {
|
|
821
|
+
_centerX: c,
|
|
822
|
+
_centerY: u,
|
|
823
|
+
_radius: p,
|
|
824
|
+
_counterclockwise: M,
|
|
825
|
+
...y
|
|
826
|
+
},
|
|
827
|
+
point: h,
|
|
828
|
+
radius: Math.min(a, Math.min(f.right - f.left, f.bottom - f.top) / 2)
|
|
829
|
+
};
|
|
830
|
+
}
|
|
831
|
+
function Pn({ width: t, height: e }, n) {
|
|
832
|
+
const o = Math.sqrt(Math.pow(t, 2) + Math.pow(e, 2));
|
|
833
|
+
return n * 2 / o;
|
|
834
|
+
}
|
|
835
|
+
function kn(t, e, n, o) {
|
|
836
|
+
const r = Math.pow(n - t, 2), i = Math.pow(o, 2), s = e * -2, a = Math.pow(e, 2) + r - i, d = Math.pow(s, 2) - 4 * a;
|
|
837
|
+
if (d <= 0)
|
|
838
|
+
return {
|
|
839
|
+
_startAngle: 0,
|
|
840
|
+
_endAngle: Ke
|
|
841
|
+
};
|
|
842
|
+
const l = (-s - Math.sqrt(d)) / 2, c = (-s + Math.sqrt(d)) / 2;
|
|
843
|
+
return {
|
|
844
|
+
_startAngle: De({ x: e, y: n }, { x: l, y: t }).angle,
|
|
845
|
+
_endAngle: De({ x: e, y: n }, { x: c, y: t }).angle
|
|
846
|
+
};
|
|
847
|
+
}
|
|
848
|
+
function An(t, e) {
|
|
849
|
+
const { _centerX: n, _centerY: o, _radius: r, _startAngle: i, _endAngle: s, _counterclockwise: a, options: d } = e;
|
|
850
|
+
t.save();
|
|
851
|
+
const l = x(t, d);
|
|
852
|
+
t.fillStyle = d.backgroundColor, t.beginPath(), t.arc(n, o, r, i, s, a), t.closePath(), t.fill(), l && t.stroke(), t.restore();
|
|
853
|
+
}
|
|
854
|
+
class $ extends j {
|
|
855
|
+
inRange(e, n, o, r) {
|
|
856
|
+
return Ze(
|
|
857
|
+
{ x: e, y: n },
|
|
858
|
+
{ rect: this.getProps(["x", "y", "x2", "y2"], r), center: this.getCenterPoint(r) },
|
|
859
|
+
o,
|
|
860
|
+
{ rotation: this.rotation, borderWidth: this.options.borderWidth, hitTolerance: this.options.hitTolerance }
|
|
861
|
+
);
|
|
862
|
+
}
|
|
863
|
+
getCenterPoint(e) {
|
|
864
|
+
return O(this, e);
|
|
865
|
+
}
|
|
866
|
+
draw(e) {
|
|
867
|
+
const n = this.options, o = !w(this._visible) || this._visible;
|
|
868
|
+
!n.display || !n.content || !o || (e.save(), ee(e, this.getCenterPoint(), this.rotation), Ut(e, this), lt(e, this, n), ct(e, Dn(this), n), e.restore());
|
|
869
|
+
}
|
|
870
|
+
resolveElementProperties(e, n) {
|
|
871
|
+
let o;
|
|
872
|
+
if (st(n))
|
|
873
|
+
o = ht(e, n);
|
|
874
|
+
else {
|
|
875
|
+
const { centerX: a, centerY: d } = Se(e, n);
|
|
876
|
+
o = { x: a, y: d };
|
|
877
|
+
}
|
|
878
|
+
const r = Q(n.padding), i = te(e.ctx, n), s = ot(o, i, n, r);
|
|
879
|
+
return {
|
|
880
|
+
initProperties: W(e, s, n),
|
|
881
|
+
pointX: o.x,
|
|
882
|
+
pointY: o.y,
|
|
883
|
+
...s,
|
|
884
|
+
rotation: n.rotation
|
|
885
|
+
};
|
|
886
|
+
}
|
|
887
|
+
}
|
|
888
|
+
$.id = "labelAnnotation";
|
|
889
|
+
$.defaults = {
|
|
890
|
+
adjustScaleRange: !0,
|
|
891
|
+
backgroundColor: "transparent",
|
|
892
|
+
backgroundShadowColor: "transparent",
|
|
893
|
+
borderCapStyle: "butt",
|
|
894
|
+
borderDash: [],
|
|
895
|
+
borderDashOffset: 0,
|
|
896
|
+
borderJoinStyle: "miter",
|
|
897
|
+
borderRadius: 0,
|
|
898
|
+
borderShadowColor: "transparent",
|
|
899
|
+
borderWidth: 0,
|
|
900
|
+
callout: {
|
|
901
|
+
borderCapStyle: "butt",
|
|
902
|
+
borderColor: void 0,
|
|
903
|
+
borderDash: [],
|
|
904
|
+
borderDashOffset: 0,
|
|
905
|
+
borderJoinStyle: "miter",
|
|
906
|
+
borderWidth: 1,
|
|
907
|
+
display: !1,
|
|
908
|
+
margin: 5,
|
|
909
|
+
position: "auto",
|
|
910
|
+
side: 5,
|
|
911
|
+
start: "50%"
|
|
912
|
+
},
|
|
913
|
+
color: "black",
|
|
914
|
+
content: null,
|
|
915
|
+
display: !0,
|
|
916
|
+
font: {
|
|
917
|
+
family: void 0,
|
|
918
|
+
lineHeight: void 0,
|
|
919
|
+
size: void 0,
|
|
920
|
+
style: void 0,
|
|
921
|
+
weight: void 0
|
|
922
|
+
},
|
|
923
|
+
height: void 0,
|
|
924
|
+
hitTolerance: 0,
|
|
925
|
+
init: void 0,
|
|
926
|
+
opacity: void 0,
|
|
927
|
+
padding: 6,
|
|
928
|
+
position: "center",
|
|
929
|
+
rotation: 0,
|
|
930
|
+
shadowBlur: 0,
|
|
931
|
+
shadowOffsetX: 0,
|
|
932
|
+
shadowOffsetY: 0,
|
|
933
|
+
textAlign: "center",
|
|
934
|
+
textStrokeColor: void 0,
|
|
935
|
+
textStrokeWidth: 0,
|
|
936
|
+
width: void 0,
|
|
937
|
+
xAdjust: 0,
|
|
938
|
+
xMax: void 0,
|
|
939
|
+
xMin: void 0,
|
|
940
|
+
xScaleID: void 0,
|
|
941
|
+
xValue: void 0,
|
|
942
|
+
yAdjust: 0,
|
|
943
|
+
yMax: void 0,
|
|
944
|
+
yMin: void 0,
|
|
945
|
+
yScaleID: void 0,
|
|
946
|
+
yValue: void 0,
|
|
947
|
+
z: 0
|
|
948
|
+
};
|
|
949
|
+
$.defaultRoutes = {
|
|
950
|
+
borderColor: "color"
|
|
951
|
+
};
|
|
952
|
+
function Dn({ x: t, y: e, width: n, height: o, options: r }) {
|
|
953
|
+
const i = r.borderWidth / 2, s = Q(r.padding);
|
|
954
|
+
return {
|
|
955
|
+
x: t + s.left + i,
|
|
956
|
+
y: e + s.top + i,
|
|
957
|
+
width: n - s.left - s.right - r.borderWidth,
|
|
958
|
+
height: o - s.top - s.bottom - r.borderWidth
|
|
959
|
+
};
|
|
960
|
+
}
|
|
961
|
+
const Ce = (t, e, n) => ({ x: t.x + n * (e.x - t.x), y: t.y + n * (e.y - t.y) }), ce = (t, e, n) => Ce(e, n, Math.abs((t - e.y) / (n.y - e.y))).x, Ye = (t, e, n) => Ce(e, n, Math.abs((t - e.x) / (n.x - e.x))).y, N = (t) => t * t, vn = (t, e, { x: n, y: o, x2: r, y2: i }, s) => s === "y" ? { start: Math.min(o, i), end: Math.max(o, i), value: e } : { start: Math.min(n, r), end: Math.max(n, r), value: t }, We = (t, e, n, o) => (1 - o) * (1 - o) * t + 2 * (1 - o) * o * e + o * o * n, ue = (t, e, n, o) => ({ x: We(t.x, e.x, n.x, o), y: We(t.y, e.y, n.y, o) }), _e = (t, e, n, o) => 2 * (1 - o) * (e - t) + 2 * o * (n - e), Xe = (t, e, n, o) => -Math.atan2(_e(t.x, e.x, n.x, o), _e(t.y, e.y, n.y, o)) + 0.5 * m;
|
|
962
|
+
class J extends j {
|
|
963
|
+
inRange(e, n, o, r) {
|
|
964
|
+
const i = (this.options.borderWidth + this.options.hitTolerance) / 2;
|
|
965
|
+
if (o !== "x" && o !== "y") {
|
|
966
|
+
const s = { mouseX: e, mouseY: n }, { path: a, ctx: d } = this;
|
|
967
|
+
if (a) {
|
|
968
|
+
x(d, this.options), d.lineWidth += this.options.hitTolerance;
|
|
969
|
+
const { chart: c } = this.$context, u = e * c.currentDevicePixelRatio, f = n * c.currentDevicePixelRatio, h = d.isPointInStroke(a, u, f) || fe(this, s, r);
|
|
970
|
+
return d.restore(), h;
|
|
971
|
+
}
|
|
972
|
+
const l = N(i);
|
|
973
|
+
return On(this, s, l, r) || fe(this, s, r);
|
|
974
|
+
}
|
|
975
|
+
return Tn(this, { mouseX: e, mouseY: n }, o, { hitSize: i, useFinalPosition: r });
|
|
976
|
+
}
|
|
977
|
+
getCenterPoint(e) {
|
|
978
|
+
return O(this, e);
|
|
979
|
+
}
|
|
980
|
+
draw(e) {
|
|
981
|
+
const { x: n, y: o, x2: r, y2: i, cp: s, options: a } = this;
|
|
982
|
+
if (e.save(), !x(e, a))
|
|
983
|
+
return e.restore();
|
|
984
|
+
_(e, a);
|
|
985
|
+
const d = Math.sqrt(Math.pow(r - n, 2) + Math.pow(i - o, 2));
|
|
986
|
+
if (a.curve && s)
|
|
987
|
+
return zn(e, this, s, d), e.restore();
|
|
988
|
+
const { startOpts: l, endOpts: c, startAdjust: u, endAdjust: f } = pt(this), h = Math.atan2(i - o, r - n);
|
|
989
|
+
e.translate(n, o), e.rotate(h), e.beginPath(), e.moveTo(0 + u, 0), e.lineTo(d - f, 0), e.shadowColor = a.borderShadowColor, e.stroke(), he(e, 0, u, l), he(e, d, -f, c), e.restore();
|
|
990
|
+
}
|
|
991
|
+
get label() {
|
|
992
|
+
return this.elements && this.elements[0];
|
|
993
|
+
}
|
|
994
|
+
resolveElementProperties(e, n) {
|
|
995
|
+
const o = nn(e, n), { x: r, y: i, x2: s, y2: a } = o, d = jn(o, e.chartArea), l = d ? In({ x: r, y: i }, { x: s, y: a }, e.chartArea) : { x: r, y: i, x2: s, y2: a, width: Math.abs(s - r), height: Math.abs(a - i) };
|
|
996
|
+
if (l.centerX = (s + r) / 2, l.centerY = (a + i) / 2, l.initProperties = W(e, l, n), n.curve) {
|
|
997
|
+
const u = { x: l.x, y: l.y }, f = { x: l.x2, y: l.y2 };
|
|
998
|
+
l.cp = Xn(l, n, ye(u, f));
|
|
999
|
+
}
|
|
1000
|
+
const c = Rn(e, l, n.label);
|
|
1001
|
+
return c._visible = d, l.elements = [{
|
|
1002
|
+
type: "label",
|
|
1003
|
+
optionScope: "label",
|
|
1004
|
+
properties: c,
|
|
1005
|
+
initProperties: l.initProperties
|
|
1006
|
+
}], l;
|
|
1007
|
+
}
|
|
1008
|
+
}
|
|
1009
|
+
J.id = "lineAnnotation";
|
|
1010
|
+
const ze = {
|
|
1011
|
+
backgroundColor: void 0,
|
|
1012
|
+
backgroundShadowColor: void 0,
|
|
1013
|
+
borderColor: void 0,
|
|
1014
|
+
borderDash: void 0,
|
|
1015
|
+
borderDashOffset: void 0,
|
|
1016
|
+
borderShadowColor: void 0,
|
|
1017
|
+
borderWidth: void 0,
|
|
1018
|
+
display: void 0,
|
|
1019
|
+
fill: void 0,
|
|
1020
|
+
length: void 0,
|
|
1021
|
+
shadowBlur: void 0,
|
|
1022
|
+
shadowOffsetX: void 0,
|
|
1023
|
+
shadowOffsetY: void 0,
|
|
1024
|
+
width: void 0
|
|
1025
|
+
};
|
|
1026
|
+
J.defaults = {
|
|
1027
|
+
adjustScaleRange: !0,
|
|
1028
|
+
arrowHeads: {
|
|
1029
|
+
display: !1,
|
|
1030
|
+
end: Object.assign({}, ze),
|
|
1031
|
+
fill: !1,
|
|
1032
|
+
length: 12,
|
|
1033
|
+
start: Object.assign({}, ze),
|
|
1034
|
+
width: 6
|
|
1035
|
+
},
|
|
1036
|
+
borderDash: [],
|
|
1037
|
+
borderDashOffset: 0,
|
|
1038
|
+
borderShadowColor: "transparent",
|
|
1039
|
+
borderWidth: 2,
|
|
1040
|
+
curve: !1,
|
|
1041
|
+
controlPoint: {
|
|
1042
|
+
y: "-50%"
|
|
1043
|
+
},
|
|
1044
|
+
display: !0,
|
|
1045
|
+
endValue: void 0,
|
|
1046
|
+
init: void 0,
|
|
1047
|
+
hitTolerance: 0,
|
|
1048
|
+
label: {
|
|
1049
|
+
backgroundColor: "rgba(0,0,0,0.8)",
|
|
1050
|
+
backgroundShadowColor: "transparent",
|
|
1051
|
+
borderCapStyle: "butt",
|
|
1052
|
+
borderColor: "black",
|
|
1053
|
+
borderDash: [],
|
|
1054
|
+
borderDashOffset: 0,
|
|
1055
|
+
borderJoinStyle: "miter",
|
|
1056
|
+
borderRadius: 6,
|
|
1057
|
+
borderShadowColor: "transparent",
|
|
1058
|
+
borderWidth: 0,
|
|
1059
|
+
callout: Object.assign({}, $.defaults.callout),
|
|
1060
|
+
color: "#fff",
|
|
1061
|
+
content: null,
|
|
1062
|
+
display: !1,
|
|
1063
|
+
drawTime: void 0,
|
|
1064
|
+
font: {
|
|
1065
|
+
family: void 0,
|
|
1066
|
+
lineHeight: void 0,
|
|
1067
|
+
size: void 0,
|
|
1068
|
+
style: void 0,
|
|
1069
|
+
weight: "bold"
|
|
1070
|
+
},
|
|
1071
|
+
height: void 0,
|
|
1072
|
+
hitTolerance: void 0,
|
|
1073
|
+
opacity: void 0,
|
|
1074
|
+
padding: 6,
|
|
1075
|
+
position: "center",
|
|
1076
|
+
rotation: 0,
|
|
1077
|
+
shadowBlur: 0,
|
|
1078
|
+
shadowOffsetX: 0,
|
|
1079
|
+
shadowOffsetY: 0,
|
|
1080
|
+
textAlign: "center",
|
|
1081
|
+
textStrokeColor: void 0,
|
|
1082
|
+
textStrokeWidth: 0,
|
|
1083
|
+
width: void 0,
|
|
1084
|
+
xAdjust: 0,
|
|
1085
|
+
yAdjust: 0,
|
|
1086
|
+
z: void 0
|
|
1087
|
+
},
|
|
1088
|
+
scaleID: void 0,
|
|
1089
|
+
shadowBlur: 0,
|
|
1090
|
+
shadowOffsetX: 0,
|
|
1091
|
+
shadowOffsetY: 0,
|
|
1092
|
+
value: void 0,
|
|
1093
|
+
xMax: void 0,
|
|
1094
|
+
xMin: void 0,
|
|
1095
|
+
xScaleID: void 0,
|
|
1096
|
+
yMax: void 0,
|
|
1097
|
+
yMin: void 0,
|
|
1098
|
+
yScaleID: void 0,
|
|
1099
|
+
z: 0
|
|
1100
|
+
};
|
|
1101
|
+
J.descriptors = {
|
|
1102
|
+
arrowHeads: {
|
|
1103
|
+
start: {
|
|
1104
|
+
_fallback: !0
|
|
1105
|
+
},
|
|
1106
|
+
end: {
|
|
1107
|
+
_fallback: !0
|
|
1108
|
+
},
|
|
1109
|
+
_fallback: !0
|
|
1110
|
+
}
|
|
1111
|
+
};
|
|
1112
|
+
J.defaultRoutes = {
|
|
1113
|
+
borderColor: "color"
|
|
1114
|
+
};
|
|
1115
|
+
function Tn(t, { mouseX: e, mouseY: n }, o, { hitSize: r, useFinalPosition: i }) {
|
|
1116
|
+
const s = vn(e, n, t.getProps(["x", "y", "x2", "y2"], i), o);
|
|
1117
|
+
return Qe(s, r) || fe(t, { mouseX: e, mouseY: n }, i, o);
|
|
1118
|
+
}
|
|
1119
|
+
function jn({ x: t, y: e, x2: n, y2: o }, { top: r, right: i, bottom: s, left: a }) {
|
|
1120
|
+
return !(t < a && n < a || t > i && n > i || e < r && o < r || e > s && o > s);
|
|
1121
|
+
}
|
|
1122
|
+
function He({ x: t, y: e }, n, { top: o, right: r, bottom: i, left: s }) {
|
|
1123
|
+
return t < s && (e = Ye(s, { x: t, y: e }, n), t = s), t > r && (e = Ye(r, { x: t, y: e }, n), t = r), e < o && (t = ce(o, { x: t, y: e }, n), e = o), e > i && (t = ce(i, { x: t, y: e }, n), e = i), { x: t, y: e };
|
|
1124
|
+
}
|
|
1125
|
+
function In(t, e, n) {
|
|
1126
|
+
const { x: o, y: r } = He(t, e, n), { x: i, y: s } = He(e, t, n);
|
|
1127
|
+
return { x: o, y: r, x2: i, y2: s, width: Math.abs(i - o), height: Math.abs(s - r) };
|
|
1128
|
+
}
|
|
1129
|
+
function On(t, { mouseX: e, mouseY: n }, o = v, r) {
|
|
1130
|
+
const { x: i, y: s, x2: a, y2: d } = t.getProps(["x", "y", "x2", "y2"], r), l = a - i, c = d - s, u = N(l) + N(c), f = u === 0 ? -1 : ((e - i) * l + (n - s) * c) / u;
|
|
1131
|
+
let h, g;
|
|
1132
|
+
return f < 0 ? (h = i, g = s) : f > 1 ? (h = a, g = d) : (h = i + f * l, g = s + f * c), N(e - h) + N(n - g) <= o;
|
|
1133
|
+
}
|
|
1134
|
+
function fe(t, { mouseX: e, mouseY: n }, o, r) {
|
|
1135
|
+
const i = t.label;
|
|
1136
|
+
return i.options.display && i.inRange(e, n, r, o);
|
|
1137
|
+
}
|
|
1138
|
+
function Rn(t, e, n) {
|
|
1139
|
+
const o = n.borderWidth, r = Q(n.padding), i = te(t.ctx, n), s = i.width + r.width + o, a = i.height + r.height + o;
|
|
1140
|
+
return Ln(e, n, { width: s, height: a, padding: r }, t.chartArea);
|
|
1141
|
+
}
|
|
1142
|
+
function En(t) {
|
|
1143
|
+
const { x: e, y: n, x2: o, y2: r } = t, i = Math.atan2(r - n, o - e);
|
|
1144
|
+
return i > m / 2 ? i - m : i < m / -2 ? i + m : i;
|
|
1145
|
+
}
|
|
1146
|
+
function Ln(t, e, n, o) {
|
|
1147
|
+
const { width: r, height: i, padding: s } = n, { xAdjust: a, yAdjust: d } = e, l = { x: t.x, y: t.y }, c = { x: t.x2, y: t.y2 }, u = e.rotation === "auto" ? En(t) : S(e.rotation), f = Yn(r, i, u), h = Wn(t, e, { labelSize: f, padding: s }, o), g = t.cp ? ue(l, t.cp, c, h) : Ce(l, c, h), p = { size: f.w, min: o.left, max: o.right, padding: s.left }, M = { size: f.h, min: o.top, max: o.bottom, padding: s.top }, b = Ne(g.x, p) + a, y = Ne(g.y, M) + d;
|
|
1148
|
+
return {
|
|
1149
|
+
x: b - r / 2,
|
|
1150
|
+
y: y - i / 2,
|
|
1151
|
+
x2: b + r / 2,
|
|
1152
|
+
y2: y + i / 2,
|
|
1153
|
+
centerX: b,
|
|
1154
|
+
centerY: y,
|
|
1155
|
+
pointX: g.x,
|
|
1156
|
+
pointY: g.y,
|
|
1157
|
+
width: r,
|
|
1158
|
+
height: i,
|
|
1159
|
+
rotation: Dt(u)
|
|
1160
|
+
};
|
|
1161
|
+
}
|
|
1162
|
+
function Yn(t, e, n) {
|
|
1163
|
+
const o = Math.cos(n), r = Math.sin(n);
|
|
1164
|
+
return {
|
|
1165
|
+
w: Math.abs(t * o) + Math.abs(e * r),
|
|
1166
|
+
h: Math.abs(t * r) + Math.abs(e * o)
|
|
1167
|
+
};
|
|
1168
|
+
}
|
|
1169
|
+
function Wn(t, e, n, o) {
|
|
1170
|
+
let r;
|
|
1171
|
+
const i = _n(t, o);
|
|
1172
|
+
return e.position === "start" ? r = Be({ w: t.x2 - t.x, h: t.y2 - t.y }, n, e, i) : e.position === "end" ? r = 1 - Be({ w: t.x - t.x2, h: t.y - t.y2 }, n, e, i) : r = we(1, e.position), r;
|
|
1173
|
+
}
|
|
1174
|
+
function Be(t, e, n, o) {
|
|
1175
|
+
const { labelSize: r, padding: i } = e, s = t.w * o.dx, a = t.h * o.dy, d = s > 0 && (r.w / 2 + i.left - o.x) / s, l = a > 0 && (r.h / 2 + i.top - o.y) / a;
|
|
1176
|
+
return G(Math.max(d, l), 0, 0.25);
|
|
1177
|
+
}
|
|
1178
|
+
function _n(t, e) {
|
|
1179
|
+
const { x: n, x2: o, y: r, y2: i } = t, s = Math.min(r, i) - e.top, a = Math.min(n, o) - e.left, d = e.bottom - Math.max(r, i), l = e.right - Math.max(n, o);
|
|
1180
|
+
return {
|
|
1181
|
+
x: Math.min(a, l),
|
|
1182
|
+
y: Math.min(s, d),
|
|
1183
|
+
dx: a <= l ? 1 : -1,
|
|
1184
|
+
dy: s <= d ? 1 : -1
|
|
1185
|
+
};
|
|
1186
|
+
}
|
|
1187
|
+
function Ne(t, e) {
|
|
1188
|
+
const { size: n, min: o, max: r, padding: i } = e, s = n / 2;
|
|
1189
|
+
return n > r - o ? (r + o) / 2 : (o >= t - i - s && (t = o + i + s), r <= t + i + s && (t = r - i - s), t);
|
|
1190
|
+
}
|
|
1191
|
+
function pt(t) {
|
|
1192
|
+
const e = t.options, n = e.arrowHeads && e.arrowHeads.start, o = e.arrowHeads && e.arrowHeads.end;
|
|
1193
|
+
return {
|
|
1194
|
+
startOpts: n,
|
|
1195
|
+
endOpts: o,
|
|
1196
|
+
startAdjust: Ve(t, n),
|
|
1197
|
+
endAdjust: Ve(t, o)
|
|
1198
|
+
};
|
|
1199
|
+
}
|
|
1200
|
+
function Ve(t, e) {
|
|
1201
|
+
if (!e || !e.display)
|
|
1202
|
+
return 0;
|
|
1203
|
+
const { length: n, width: o } = e, r = t.options.borderWidth / 2, i = { x: n, y: o + r };
|
|
1204
|
+
return Math.abs(ce(0, i, { x: 0, y: r }));
|
|
1205
|
+
}
|
|
1206
|
+
function he(t, e, n, o) {
|
|
1207
|
+
if (!o || !o.display)
|
|
1208
|
+
return;
|
|
1209
|
+
const { length: r, width: i, fill: s, backgroundColor: a, borderColor: d } = o, l = Math.abs(e - r) + n;
|
|
1210
|
+
t.beginPath(), _(t, o), x(t, o), t.moveTo(l, -i), t.lineTo(e + n, 0), t.lineTo(l, i), s === !0 ? (t.fillStyle = a || d, t.closePath(), t.fill(), t.shadowColor = "transparent") : t.shadowColor = o.borderShadowColor, t.stroke();
|
|
1211
|
+
}
|
|
1212
|
+
function Xn(t, e, n) {
|
|
1213
|
+
const { x: o, y: r, x2: i, y2: s, centerX: a, centerY: d } = t, l = Math.atan2(s - r, i - o), c = xe(e.controlPoint, 0), u = {
|
|
1214
|
+
x: a + A(n, c.x, !1),
|
|
1215
|
+
y: d + A(n, c.y, !1)
|
|
1216
|
+
};
|
|
1217
|
+
return I(u, { x: a, y: d }, l);
|
|
1218
|
+
}
|
|
1219
|
+
function $e(t, { x: e, y: n }, { angle: o, adjust: r }, i) {
|
|
1220
|
+
!i || !i.display || (t.save(), t.translate(e, n), t.rotate(o), he(t, 0, -r, i), t.restore());
|
|
1221
|
+
}
|
|
1222
|
+
function zn(t, e, n, o) {
|
|
1223
|
+
const { x: r, y: i, x2: s, y2: a, options: d } = e, { startOpts: l, endOpts: c, startAdjust: u, endAdjust: f } = pt(e), h = { x: r, y: i }, g = { x: s, y: a }, p = Xe(h, n, g, 0), M = Xe(h, n, g, 1) - m, b = ue(h, n, g, u / o), y = ue(h, n, g, 1 - f / o), C = new Path2D();
|
|
1224
|
+
t.beginPath(), C.moveTo(b.x, b.y), C.quadraticCurveTo(n.x, n.y, y.x, y.y), t.shadowColor = d.borderShadowColor, t.stroke(C), e.path = C, e.ctx = t, $e(t, b, { angle: p, adjust: u }, l), $e(t, y, { angle: M, adjust: f }, c);
|
|
1225
|
+
}
|
|
1226
|
+
class q extends j {
|
|
1227
|
+
inRange(e, n, o, r) {
|
|
1228
|
+
const i = this.options.rotation, s = (this.options.borderWidth + this.options.hitTolerance) / 2;
|
|
1229
|
+
if (o !== "x" && o !== "y")
|
|
1230
|
+
return Hn({ x: e, y: n }, this.getProps(["width", "height", "centerX", "centerY"], r), i, s);
|
|
1231
|
+
const { x: a, y: d, x2: l, y2: c } = this.getProps(["x", "y", "x2", "y2"], r), u = o === "y" ? { start: d, end: c } : { start: a, end: l }, f = I({ x: e, y: n }, this.getCenterPoint(r), S(-i));
|
|
1232
|
+
return f[o] >= u.start - s - v && f[o] <= u.end + s + v;
|
|
1233
|
+
}
|
|
1234
|
+
getCenterPoint(e) {
|
|
1235
|
+
return O(this, e);
|
|
1236
|
+
}
|
|
1237
|
+
draw(e) {
|
|
1238
|
+
const { width: n, height: o, centerX: r, centerY: i, options: s } = this;
|
|
1239
|
+
e.save(), ee(e, this.getCenterPoint(), s.rotation), _(e, this.options), e.beginPath(), e.fillStyle = s.backgroundColor;
|
|
1240
|
+
const a = x(e, s);
|
|
1241
|
+
e.ellipse(r, i, o / 2, n / 2, m / 2, 0, 2 * m), e.fill(), a && (e.shadowColor = s.borderShadowColor, e.stroke()), e.restore();
|
|
1242
|
+
}
|
|
1243
|
+
get label() {
|
|
1244
|
+
return this.elements && this.elements[0];
|
|
1245
|
+
}
|
|
1246
|
+
resolveElementProperties(e, n) {
|
|
1247
|
+
return bt(e, n);
|
|
1248
|
+
}
|
|
1249
|
+
}
|
|
1250
|
+
q.id = "ellipseAnnotation";
|
|
1251
|
+
q.defaults = {
|
|
1252
|
+
adjustScaleRange: !0,
|
|
1253
|
+
backgroundShadowColor: "transparent",
|
|
1254
|
+
borderDash: [],
|
|
1255
|
+
borderDashOffset: 0,
|
|
1256
|
+
borderShadowColor: "transparent",
|
|
1257
|
+
borderWidth: 1,
|
|
1258
|
+
display: !0,
|
|
1259
|
+
hitTolerance: 0,
|
|
1260
|
+
init: void 0,
|
|
1261
|
+
label: Object.assign({}, X.defaults.label),
|
|
1262
|
+
rotation: 0,
|
|
1263
|
+
shadowBlur: 0,
|
|
1264
|
+
shadowOffsetX: 0,
|
|
1265
|
+
shadowOffsetY: 0,
|
|
1266
|
+
xMax: void 0,
|
|
1267
|
+
xMin: void 0,
|
|
1268
|
+
xScaleID: void 0,
|
|
1269
|
+
yMax: void 0,
|
|
1270
|
+
yMin: void 0,
|
|
1271
|
+
yScaleID: void 0,
|
|
1272
|
+
z: 0
|
|
1273
|
+
};
|
|
1274
|
+
q.defaultRoutes = {
|
|
1275
|
+
borderColor: "color",
|
|
1276
|
+
backgroundColor: "color"
|
|
1277
|
+
};
|
|
1278
|
+
q.descriptors = {
|
|
1279
|
+
label: {
|
|
1280
|
+
_fallback: !0
|
|
1281
|
+
}
|
|
1282
|
+
};
|
|
1283
|
+
function Hn(t, e, n, o) {
|
|
1284
|
+
const { width: r, height: i, centerX: s, centerY: a } = e, d = r / 2, l = i / 2;
|
|
1285
|
+
if (d <= 0 || l <= 0)
|
|
1286
|
+
return !1;
|
|
1287
|
+
const c = S(n || 0), u = Math.cos(c), f = Math.sin(c), h = Math.pow(u * (t.x - s) + f * (t.y - a), 2), g = Math.pow(f * (t.x - s) - u * (t.y - a), 2);
|
|
1288
|
+
return h / Math.pow(d + o, 2) + g / Math.pow(l + o, 2) <= 1.0001;
|
|
1289
|
+
}
|
|
1290
|
+
class oe extends j {
|
|
1291
|
+
inRange(e, n, o, r) {
|
|
1292
|
+
const { x: i, y: s, x2: a, y2: d, width: l } = this.getProps(["x", "y", "x2", "y2", "width"], r), c = (this.options.borderWidth + this.options.hitTolerance) / 2;
|
|
1293
|
+
return o !== "x" && o !== "y" ? Et({ x: e, y: n }, this.getCenterPoint(r), l / 2, c) : Qe(o === "y" ? { start: s, end: d, value: n } : { start: i, end: a, value: e }, c);
|
|
1294
|
+
}
|
|
1295
|
+
getCenterPoint(e) {
|
|
1296
|
+
return O(this, e);
|
|
1297
|
+
}
|
|
1298
|
+
draw(e) {
|
|
1299
|
+
const n = this.options, o = n.borderWidth;
|
|
1300
|
+
if (n.radius < 0.1)
|
|
1301
|
+
return;
|
|
1302
|
+
e.save(), e.fillStyle = n.backgroundColor, _(e, n);
|
|
1303
|
+
const r = x(e, n);
|
|
1304
|
+
Bt(e, this, this.centerX, this.centerY), r && !Z(n.pointStyle) && (e.shadowColor = n.borderShadowColor, e.stroke()), e.restore(), n.borderWidth = o;
|
|
1305
|
+
}
|
|
1306
|
+
resolveElementProperties(e, n) {
|
|
1307
|
+
const o = gt(e, n);
|
|
1308
|
+
return o.initProperties = W(e, o, n), o;
|
|
1309
|
+
}
|
|
1310
|
+
}
|
|
1311
|
+
oe.id = "pointAnnotation";
|
|
1312
|
+
oe.defaults = {
|
|
1313
|
+
adjustScaleRange: !0,
|
|
1314
|
+
backgroundShadowColor: "transparent",
|
|
1315
|
+
borderDash: [],
|
|
1316
|
+
borderDashOffset: 0,
|
|
1317
|
+
borderShadowColor: "transparent",
|
|
1318
|
+
borderWidth: 1,
|
|
1319
|
+
display: !0,
|
|
1320
|
+
hitTolerance: 0,
|
|
1321
|
+
init: void 0,
|
|
1322
|
+
pointStyle: "circle",
|
|
1323
|
+
radius: 10,
|
|
1324
|
+
rotation: 0,
|
|
1325
|
+
shadowBlur: 0,
|
|
1326
|
+
shadowOffsetX: 0,
|
|
1327
|
+
shadowOffsetY: 0,
|
|
1328
|
+
xAdjust: 0,
|
|
1329
|
+
xMax: void 0,
|
|
1330
|
+
xMin: void 0,
|
|
1331
|
+
xScaleID: void 0,
|
|
1332
|
+
xValue: void 0,
|
|
1333
|
+
yAdjust: 0,
|
|
1334
|
+
yMax: void 0,
|
|
1335
|
+
yMin: void 0,
|
|
1336
|
+
yScaleID: void 0,
|
|
1337
|
+
yValue: void 0,
|
|
1338
|
+
z: 0
|
|
1339
|
+
};
|
|
1340
|
+
oe.defaultRoutes = {
|
|
1341
|
+
borderColor: "color",
|
|
1342
|
+
backgroundColor: "color"
|
|
1343
|
+
};
|
|
1344
|
+
class re extends j {
|
|
1345
|
+
inRange(e, n, o, r) {
|
|
1346
|
+
if (o !== "x" && o !== "y")
|
|
1347
|
+
return this.options.radius >= 0.1 && this.elements.length > 1 && Nn(this.elements, e, n, r);
|
|
1348
|
+
const i = I({ x: e, y: n }, this.getCenterPoint(r), S(-this.options.rotation)), s = this.elements.map((l) => o === "y" ? l.bY : l.bX), a = Math.min(...s), d = Math.max(...s);
|
|
1349
|
+
return i[o] >= a && i[o] <= d;
|
|
1350
|
+
}
|
|
1351
|
+
getCenterPoint(e) {
|
|
1352
|
+
return O(this, e);
|
|
1353
|
+
}
|
|
1354
|
+
draw(e) {
|
|
1355
|
+
const { elements: n, options: o } = this;
|
|
1356
|
+
e.save(), e.beginPath(), e.fillStyle = o.backgroundColor, _(e, o);
|
|
1357
|
+
const r = x(e, o);
|
|
1358
|
+
let i = !0;
|
|
1359
|
+
for (const s of n)
|
|
1360
|
+
i ? (e.moveTo(s.x, s.y), i = !1) : e.lineTo(s.x, s.y);
|
|
1361
|
+
e.closePath(), e.fill(), r && (e.shadowColor = o.borderShadowColor, e.stroke()), e.restore();
|
|
1362
|
+
}
|
|
1363
|
+
resolveElementProperties(e, n) {
|
|
1364
|
+
const o = gt(e, n), { sides: r, rotation: i } = n, s = [], a = 2 * m / r;
|
|
1365
|
+
let d = i * Ue;
|
|
1366
|
+
for (let l = 0; l < r; l++, d += a) {
|
|
1367
|
+
const c = Bn(o, n, d);
|
|
1368
|
+
c.initProperties = W(e, o, n), s.push(c);
|
|
1369
|
+
}
|
|
1370
|
+
return o.elements = s, o;
|
|
1371
|
+
}
|
|
1372
|
+
}
|
|
1373
|
+
re.id = "polygonAnnotation";
|
|
1374
|
+
re.defaults = {
|
|
1375
|
+
adjustScaleRange: !0,
|
|
1376
|
+
backgroundShadowColor: "transparent",
|
|
1377
|
+
borderCapStyle: "butt",
|
|
1378
|
+
borderDash: [],
|
|
1379
|
+
borderDashOffset: 0,
|
|
1380
|
+
borderJoinStyle: "miter",
|
|
1381
|
+
borderShadowColor: "transparent",
|
|
1382
|
+
borderWidth: 1,
|
|
1383
|
+
display: !0,
|
|
1384
|
+
hitTolerance: 0,
|
|
1385
|
+
init: void 0,
|
|
1386
|
+
point: {
|
|
1387
|
+
radius: 0
|
|
1388
|
+
},
|
|
1389
|
+
radius: 10,
|
|
1390
|
+
rotation: 0,
|
|
1391
|
+
shadowBlur: 0,
|
|
1392
|
+
shadowOffsetX: 0,
|
|
1393
|
+
shadowOffsetY: 0,
|
|
1394
|
+
sides: 3,
|
|
1395
|
+
xAdjust: 0,
|
|
1396
|
+
xMax: void 0,
|
|
1397
|
+
xMin: void 0,
|
|
1398
|
+
xScaleID: void 0,
|
|
1399
|
+
xValue: void 0,
|
|
1400
|
+
yAdjust: 0,
|
|
1401
|
+
yMax: void 0,
|
|
1402
|
+
yMin: void 0,
|
|
1403
|
+
yScaleID: void 0,
|
|
1404
|
+
yValue: void 0,
|
|
1405
|
+
z: 0
|
|
1406
|
+
};
|
|
1407
|
+
re.defaultRoutes = {
|
|
1408
|
+
borderColor: "color",
|
|
1409
|
+
backgroundColor: "color"
|
|
1410
|
+
};
|
|
1411
|
+
function Bn({ centerX: t, centerY: e }, { radius: n, borderWidth: o, hitTolerance: r }, i) {
|
|
1412
|
+
const s = (o + r) / 2, a = Math.sin(i), d = Math.cos(i), l = { x: t + a * n, y: e - d * n };
|
|
1413
|
+
return {
|
|
1414
|
+
type: "point",
|
|
1415
|
+
optionScope: "point",
|
|
1416
|
+
properties: {
|
|
1417
|
+
x: l.x,
|
|
1418
|
+
y: l.y,
|
|
1419
|
+
centerX: l.x,
|
|
1420
|
+
centerY: l.y,
|
|
1421
|
+
bX: t + a * (n + s),
|
|
1422
|
+
bY: e - d * (n + s)
|
|
1423
|
+
}
|
|
1424
|
+
};
|
|
1425
|
+
}
|
|
1426
|
+
function Nn(t, e, n, o) {
|
|
1427
|
+
let r = !1, i = t[t.length - 1].getProps(["bX", "bY"], o);
|
|
1428
|
+
for (const s of t) {
|
|
1429
|
+
const a = s.getProps(["bX", "bY"], o);
|
|
1430
|
+
a.bY > n != i.bY > n && e < (i.bX - a.bX) * (n - a.bY) / (i.bY - a.bY) + a.bX && (r = !r), i = a;
|
|
1431
|
+
}
|
|
1432
|
+
return r;
|
|
1433
|
+
}
|
|
1434
|
+
const k = {
|
|
1435
|
+
box: X,
|
|
1436
|
+
doughnutLabel: ne,
|
|
1437
|
+
ellipse: q,
|
|
1438
|
+
label: $,
|
|
1439
|
+
line: J,
|
|
1440
|
+
point: oe,
|
|
1441
|
+
polygon: re
|
|
1442
|
+
};
|
|
1443
|
+
Object.keys(k).forEach((t) => {
|
|
1444
|
+
vt.describe(`elements.${k[t].id}`, {
|
|
1445
|
+
_fallback: "plugins.annotation.common"
|
|
1446
|
+
});
|
|
1447
|
+
});
|
|
1448
|
+
const Vn = {
|
|
1449
|
+
update: Object.assign
|
|
1450
|
+
}, $n = Me.concat(K), Je = (t, e) => E(e) ? be(t, e) : t, ge = (t) => t === "color" || t === "font";
|
|
1451
|
+
function Pe(t = "line") {
|
|
1452
|
+
return k[t] ? t : (console.warn(`Unknown annotation type: '${t}', defaulting to 'line'`), "line");
|
|
1453
|
+
}
|
|
1454
|
+
function Jn(t, e, n, o) {
|
|
1455
|
+
const r = Un(t, n.animations, o), i = e.annotations, s = Qn(e.elements, i);
|
|
1456
|
+
for (let a = 0; a < i.length; a++) {
|
|
1457
|
+
const d = i[a], l = wt(s, a, d.type), c = d.setContext(Kn(t, l, s, d)), u = l.resolveElementProperties(t, c);
|
|
1458
|
+
u.skip = qn(u), "elements" in u && (Fn(l, u.elements, c, r), delete u.elements), w(l.x) || Object.assign(l, u), Object.assign(l, u.initProperties), u.options = xt(c), r.update(l, u);
|
|
1459
|
+
}
|
|
1460
|
+
}
|
|
1461
|
+
function qn(t) {
|
|
1462
|
+
return isNaN(t.x) || isNaN(t.y);
|
|
1463
|
+
}
|
|
1464
|
+
function Un(t, e, n) {
|
|
1465
|
+
return n === "reset" || n === "none" || n === "resize" ? Vn : new Mt(t, e);
|
|
1466
|
+
}
|
|
1467
|
+
function Fn(t, e, n, o) {
|
|
1468
|
+
const r = t.elements || (t.elements = []);
|
|
1469
|
+
r.length = e.length;
|
|
1470
|
+
for (let i = 0; i < e.length; i++) {
|
|
1471
|
+
const s = e[i], a = s.properties, d = wt(r, i, s.type, s.initProperties), l = n[s.optionScope].override(s);
|
|
1472
|
+
a.options = xt(l), o.update(d, a);
|
|
1473
|
+
}
|
|
1474
|
+
}
|
|
1475
|
+
function wt(t, e, n, o) {
|
|
1476
|
+
const r = k[Pe(n)];
|
|
1477
|
+
let i = t[e];
|
|
1478
|
+
return (!i || !(i instanceof r)) && (i = t[e] = new r(), Object.assign(i, o)), i;
|
|
1479
|
+
}
|
|
1480
|
+
function xt(t) {
|
|
1481
|
+
const e = k[Pe(t.type)], n = {};
|
|
1482
|
+
n.id = t.id, n.type = t.type, n.drawTime = t.drawTime, Object.assign(
|
|
1483
|
+
n,
|
|
1484
|
+
be(t, e.defaults),
|
|
1485
|
+
be(t, e.defaultRoutes)
|
|
1486
|
+
);
|
|
1487
|
+
for (const o of $n)
|
|
1488
|
+
n[o] = t[o];
|
|
1489
|
+
return n;
|
|
1490
|
+
}
|
|
1491
|
+
function be(t, e) {
|
|
1492
|
+
const n = {};
|
|
1493
|
+
for (const o of Object.keys(e)) {
|
|
1494
|
+
const r = e[o], i = t[o];
|
|
1495
|
+
ge(o) && L(i) ? n[o] = i.map((s) => Je(s, r)) : n[o] = Je(i, r);
|
|
1496
|
+
}
|
|
1497
|
+
return n;
|
|
1498
|
+
}
|
|
1499
|
+
function Kn(t, e, n, o) {
|
|
1500
|
+
return e.$context || (e.$context = Object.assign(Object.create(t.getContext()), {
|
|
1501
|
+
element: e,
|
|
1502
|
+
get elements() {
|
|
1503
|
+
return n.filter((r) => r && r.options);
|
|
1504
|
+
},
|
|
1505
|
+
id: o.id,
|
|
1506
|
+
type: "annotation"
|
|
1507
|
+
}));
|
|
1508
|
+
}
|
|
1509
|
+
function Qn(t, e) {
|
|
1510
|
+
const n = e.length, o = t.length;
|
|
1511
|
+
if (o < n) {
|
|
1512
|
+
const r = n - o;
|
|
1513
|
+
t.splice(o, 0, ...new Array(r));
|
|
1514
|
+
} else o > n && t.splice(n, o - n);
|
|
1515
|
+
return t;
|
|
1516
|
+
}
|
|
1517
|
+
var Gn = "3.1.0";
|
|
1518
|
+
const P = /* @__PURE__ */ new Map(), qe = (t) => t.type !== "doughnutLabel", Zn = Me.concat(K);
|
|
1519
|
+
var ro = {
|
|
1520
|
+
id: "annotation",
|
|
1521
|
+
version: Gn,
|
|
1522
|
+
beforeRegister() {
|
|
1523
|
+
Lt("chart.js", "4.0", se.version);
|
|
1524
|
+
},
|
|
1525
|
+
afterRegister() {
|
|
1526
|
+
se.register(k);
|
|
1527
|
+
},
|
|
1528
|
+
afterUnregister() {
|
|
1529
|
+
se.unregister(k);
|
|
1530
|
+
},
|
|
1531
|
+
beforeInit(t) {
|
|
1532
|
+
P.set(t, {
|
|
1533
|
+
annotations: [],
|
|
1534
|
+
elements: [],
|
|
1535
|
+
visibleElements: [],
|
|
1536
|
+
listeners: {},
|
|
1537
|
+
listened: !1,
|
|
1538
|
+
moveListened: !1,
|
|
1539
|
+
hooks: {},
|
|
1540
|
+
hooked: !1,
|
|
1541
|
+
hovered: []
|
|
1542
|
+
});
|
|
1543
|
+
},
|
|
1544
|
+
beforeUpdate(t, e, n) {
|
|
1545
|
+
const o = P.get(t), r = o.annotations = [];
|
|
1546
|
+
let i = n.annotations;
|
|
1547
|
+
E(i) ? Object.keys(i).forEach((s) => {
|
|
1548
|
+
const a = i[s];
|
|
1549
|
+
E(a) && (a.id = s, r.push(a));
|
|
1550
|
+
}) : L(i) && r.push(...i), yn(r.filter(qe), t.scales);
|
|
1551
|
+
},
|
|
1552
|
+
afterDataLimits(t, e) {
|
|
1553
|
+
const n = P.get(t);
|
|
1554
|
+
bn(t, e.scale, n.annotations.filter(qe).filter((o) => o.display && o.adjustScaleRange));
|
|
1555
|
+
},
|
|
1556
|
+
afterUpdate(t, e, n) {
|
|
1557
|
+
const o = P.get(t);
|
|
1558
|
+
cn(t, o, n), Jn(t, o, n, e.mode), o.visibleElements = o.elements.filter((r) => !r.skip && r.options.display), gn(t, o, n);
|
|
1559
|
+
},
|
|
1560
|
+
beforeDatasetsDraw(t, e, n) {
|
|
1561
|
+
B(t, "beforeDatasetsDraw", n.clip);
|
|
1562
|
+
},
|
|
1563
|
+
afterDatasetsDraw(t, e, n) {
|
|
1564
|
+
B(t, "afterDatasetsDraw", n.clip);
|
|
1565
|
+
},
|
|
1566
|
+
beforeDatasetDraw(t, e, n) {
|
|
1567
|
+
B(t, e.index, n.clip);
|
|
1568
|
+
},
|
|
1569
|
+
beforeDraw(t, e, n) {
|
|
1570
|
+
B(t, "beforeDraw", n.clip);
|
|
1571
|
+
},
|
|
1572
|
+
afterDraw(t, e, n) {
|
|
1573
|
+
B(t, "afterDraw", n.clip);
|
|
1574
|
+
},
|
|
1575
|
+
beforeEvent(t, e, n) {
|
|
1576
|
+
const o = P.get(t);
|
|
1577
|
+
un(o, e.event, n) && (e.changed = !0);
|
|
1578
|
+
},
|
|
1579
|
+
afterDestroy(t) {
|
|
1580
|
+
P.delete(t);
|
|
1581
|
+
},
|
|
1582
|
+
getAnnotations(t) {
|
|
1583
|
+
const e = P.get(t);
|
|
1584
|
+
return e ? e.elements : [];
|
|
1585
|
+
},
|
|
1586
|
+
// only for testing
|
|
1587
|
+
_getAnnotationElementsAtEventForMode(t, e, n) {
|
|
1588
|
+
return pe(t, e, n);
|
|
1589
|
+
},
|
|
1590
|
+
defaults: {
|
|
1591
|
+
animations: {
|
|
1592
|
+
numbers: {
|
|
1593
|
+
properties: ["x", "y", "x2", "y2", "width", "height", "centerX", "centerY", "pointX", "pointY", "radius"],
|
|
1594
|
+
type: "number"
|
|
1595
|
+
},
|
|
1596
|
+
colors: {
|
|
1597
|
+
properties: ["backgroundColor", "borderColor"],
|
|
1598
|
+
type: "color"
|
|
1599
|
+
}
|
|
1600
|
+
},
|
|
1601
|
+
clip: !0,
|
|
1602
|
+
interaction: {
|
|
1603
|
+
mode: void 0,
|
|
1604
|
+
axis: void 0,
|
|
1605
|
+
intersect: void 0
|
|
1606
|
+
},
|
|
1607
|
+
common: {
|
|
1608
|
+
drawTime: "afterDatasetsDraw",
|
|
1609
|
+
init: !1,
|
|
1610
|
+
label: {}
|
|
1611
|
+
}
|
|
1612
|
+
},
|
|
1613
|
+
descriptors: {
|
|
1614
|
+
_indexable: !1,
|
|
1615
|
+
_scriptable: (t) => !Zn.includes(t) && t !== "init",
|
|
1616
|
+
annotations: {
|
|
1617
|
+
_allKeys: !1,
|
|
1618
|
+
_fallback: (t, e) => `elements.${k[Pe(e.type)].id}`
|
|
1619
|
+
},
|
|
1620
|
+
interaction: {
|
|
1621
|
+
_fallback: !0
|
|
1622
|
+
},
|
|
1623
|
+
common: {
|
|
1624
|
+
label: {
|
|
1625
|
+
_indexable: ge,
|
|
1626
|
+
_fallback: !0
|
|
1627
|
+
},
|
|
1628
|
+
_indexable: ge
|
|
1629
|
+
}
|
|
1630
|
+
},
|
|
1631
|
+
additionalOptionScopes: [""]
|
|
1632
|
+
};
|
|
1633
|
+
function B(t, e, n) {
|
|
1634
|
+
const { ctx: o, chartArea: r } = t, i = P.get(t);
|
|
1635
|
+
n && Ct(o, r);
|
|
1636
|
+
const s = eo(i.visibleElements, e).sort((a, d) => a.element.options.z - d.element.options.z);
|
|
1637
|
+
for (const a of s)
|
|
1638
|
+
to(o, r, i, a);
|
|
1639
|
+
n && Pt(o);
|
|
1640
|
+
}
|
|
1641
|
+
function eo(t, e) {
|
|
1642
|
+
const n = [];
|
|
1643
|
+
for (const o of t)
|
|
1644
|
+
if (o.options.drawTime === e && n.push({ element: o, main: !0 }), o.elements && o.elements.length)
|
|
1645
|
+
for (const r of o.elements)
|
|
1646
|
+
r.options.display && r.options.drawTime === e && n.push({ element: r });
|
|
1647
|
+
return n;
|
|
1648
|
+
}
|
|
1649
|
+
function to(t, e, n, o) {
|
|
1650
|
+
const r = o.element;
|
|
1651
|
+
o.main ? (Re(n, r, "beforeDraw"), r.draw(t, e), Re(n, r, "afterDraw")) : r.draw(t, e);
|
|
1652
|
+
}
|
|
1653
|
+
export {
|
|
1654
|
+
ro as default
|
|
1655
|
+
};
|