@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,607 @@
|
|
|
1
|
+
import { ArcElement as q, PointElement as J, BarElement as K } from "../../chart.js/dist/chart.js";
|
|
2
|
+
import { a4 as g, k as p, i as V, F as Y, Q as B, a as f, v as Q, a0 as Z, d as ee, E as re } from "../../chart.js/dist/chunks/helpers.dataset.js";
|
|
3
|
+
var W = (function() {
|
|
4
|
+
if (typeof window < "u") {
|
|
5
|
+
if (window.devicePixelRatio)
|
|
6
|
+
return window.devicePixelRatio;
|
|
7
|
+
var e = window.screen;
|
|
8
|
+
if (e)
|
|
9
|
+
return (e.deviceXDPI || 1) / (e.logicalXDPI || 1);
|
|
10
|
+
}
|
|
11
|
+
return 1;
|
|
12
|
+
})(), m = {
|
|
13
|
+
// @todo move this in Chart.helpers.toTextLines
|
|
14
|
+
toTextLines: function(e) {
|
|
15
|
+
var t = [], r;
|
|
16
|
+
for (e = [].concat(e); e.length; )
|
|
17
|
+
r = e.pop(), typeof r == "string" ? t.unshift.apply(t, r.split(`
|
|
18
|
+
`)) : Array.isArray(r) ? e.push.apply(e, r) : p(e) || t.unshift("" + r);
|
|
19
|
+
return t;
|
|
20
|
+
},
|
|
21
|
+
// @todo move this in Chart.helpers.canvas.textSize
|
|
22
|
+
// @todo cache calls of measureText if font doesn't change?!
|
|
23
|
+
textSize: function(e, t, r) {
|
|
24
|
+
var a = [].concat(t), i = a.length, n = e.font, o = 0, l;
|
|
25
|
+
for (e.font = r.string, l = 0; l < i; ++l)
|
|
26
|
+
o = Math.max(e.measureText(a[l]).width, o);
|
|
27
|
+
return e.font = n, {
|
|
28
|
+
height: i * r.lineHeight,
|
|
29
|
+
width: o
|
|
30
|
+
};
|
|
31
|
+
},
|
|
32
|
+
/**
|
|
33
|
+
* Returns value bounded by min and max. This is equivalent to max(min, min(value, max)).
|
|
34
|
+
* @todo move this method in Chart.helpers.bound
|
|
35
|
+
* https://doc.qt.io/qt-5/qtglobal.html#qBound
|
|
36
|
+
*/
|
|
37
|
+
bound: function(e, t, r) {
|
|
38
|
+
return Math.max(e, Math.min(t, r));
|
|
39
|
+
},
|
|
40
|
+
/**
|
|
41
|
+
* Returns an array of pair [value, state] where state is:
|
|
42
|
+
* * -1: value is only in a0 (removed)
|
|
43
|
+
* * 1: value is only in a1 (added)
|
|
44
|
+
*/
|
|
45
|
+
arrayDiff: function(e, t) {
|
|
46
|
+
var r = e.slice(), a = [], i, n, o, l;
|
|
47
|
+
for (i = 0, o = t.length; i < o; ++i)
|
|
48
|
+
l = t[i], n = r.indexOf(l), n === -1 ? a.push([l, 1]) : r.splice(n, 1);
|
|
49
|
+
for (i = 0, o = r.length; i < o; ++i)
|
|
50
|
+
a.push([r[i], -1]);
|
|
51
|
+
return a;
|
|
52
|
+
},
|
|
53
|
+
/**
|
|
54
|
+
* https://github.com/chartjs/chartjs-plugin-datalabels/issues/70
|
|
55
|
+
*/
|
|
56
|
+
rasterize: function(e) {
|
|
57
|
+
return Math.round(e * W) / W;
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
function R(e, t) {
|
|
61
|
+
var r = t.x, a = t.y;
|
|
62
|
+
if (r === null)
|
|
63
|
+
return { x: 0, y: -1 };
|
|
64
|
+
if (a === null)
|
|
65
|
+
return { x: 1, y: 0 };
|
|
66
|
+
var i = e.x - r, n = e.y - a, o = Math.sqrt(i * i + n * n);
|
|
67
|
+
return {
|
|
68
|
+
x: o ? i / o : 0,
|
|
69
|
+
y: o ? n / o : -1
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
function ae(e, t, r, a, i) {
|
|
73
|
+
switch (i) {
|
|
74
|
+
case "center":
|
|
75
|
+
r = a = 0;
|
|
76
|
+
break;
|
|
77
|
+
case "bottom":
|
|
78
|
+
r = 0, a = 1;
|
|
79
|
+
break;
|
|
80
|
+
case "right":
|
|
81
|
+
r = 1, a = 0;
|
|
82
|
+
break;
|
|
83
|
+
case "left":
|
|
84
|
+
r = -1, a = 0;
|
|
85
|
+
break;
|
|
86
|
+
case "top":
|
|
87
|
+
r = 0, a = -1;
|
|
88
|
+
break;
|
|
89
|
+
case "start":
|
|
90
|
+
r = -r, a = -a;
|
|
91
|
+
break;
|
|
92
|
+
case "end":
|
|
93
|
+
break;
|
|
94
|
+
default:
|
|
95
|
+
i *= Math.PI / 180, r = Math.cos(i), a = Math.sin(i);
|
|
96
|
+
break;
|
|
97
|
+
}
|
|
98
|
+
return {
|
|
99
|
+
x: e,
|
|
100
|
+
y: t,
|
|
101
|
+
vx: r,
|
|
102
|
+
vy: a
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
var te = 0, j = 1, N = 2, O = 4, F = 8;
|
|
106
|
+
function M(e, t, r) {
|
|
107
|
+
var a = te;
|
|
108
|
+
return e < r.left ? a |= j : e > r.right && (a |= N), t < r.top ? a |= F : t > r.bottom && (a |= O), a;
|
|
109
|
+
}
|
|
110
|
+
function ie(e, t) {
|
|
111
|
+
for (var r = e.x0, a = e.y0, i = e.x1, n = e.y1, o = M(r, a, t), l = M(i, n, t), s, u, v; !(!(o | l) || o & l); )
|
|
112
|
+
s = o || l, s & F ? (u = r + (i - r) * (t.top - a) / (n - a), v = t.top) : s & O ? (u = r + (i - r) * (t.bottom - a) / (n - a), v = t.bottom) : s & N ? (v = a + (n - a) * (t.right - r) / (i - r), u = t.right) : s & j && (v = a + (n - a) * (t.left - r) / (i - r), u = t.left), s === o ? (r = u, a = v, o = M(r, a, t)) : (i = u, n = v, l = M(i, n, t));
|
|
113
|
+
return {
|
|
114
|
+
x0: r,
|
|
115
|
+
x1: i,
|
|
116
|
+
y0: a,
|
|
117
|
+
y1: n
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
function E(e, t) {
|
|
121
|
+
var r = t.anchor, a = e, i, n;
|
|
122
|
+
return t.clamp && (a = ie(a, t.area)), r === "start" ? (i = a.x0, n = a.y0) : r === "end" ? (i = a.x1, n = a.y1) : (i = (a.x0 + a.x1) / 2, n = (a.y0 + a.y1) / 2), ae(i, n, e.vx, e.vy, t.align);
|
|
123
|
+
}
|
|
124
|
+
var P = {
|
|
125
|
+
arc: function(e, t) {
|
|
126
|
+
var r = (e.startAngle + e.endAngle) / 2, a = Math.cos(r), i = Math.sin(r), n = e.innerRadius, o = e.outerRadius;
|
|
127
|
+
return E({
|
|
128
|
+
x0: e.x + a * n,
|
|
129
|
+
y0: e.y + i * n,
|
|
130
|
+
x1: e.x + a * o,
|
|
131
|
+
y1: e.y + i * o,
|
|
132
|
+
vx: a,
|
|
133
|
+
vy: i
|
|
134
|
+
}, t);
|
|
135
|
+
},
|
|
136
|
+
point: function(e, t) {
|
|
137
|
+
var r = R(e, t.origin), a = r.x * e.options.radius, i = r.y * e.options.radius;
|
|
138
|
+
return E({
|
|
139
|
+
x0: e.x - a,
|
|
140
|
+
y0: e.y - i,
|
|
141
|
+
x1: e.x + a,
|
|
142
|
+
y1: e.y + i,
|
|
143
|
+
vx: r.x,
|
|
144
|
+
vy: r.y
|
|
145
|
+
}, t);
|
|
146
|
+
},
|
|
147
|
+
bar: function(e, t) {
|
|
148
|
+
var r = R(e, t.origin), a = e.x, i = e.y, n = 0, o = 0;
|
|
149
|
+
return e.horizontal ? (a = Math.min(e.x, e.base), n = Math.abs(e.base - e.x)) : (i = Math.min(e.y, e.base), o = Math.abs(e.base - e.y)), E({
|
|
150
|
+
x0: a,
|
|
151
|
+
y0: i + o,
|
|
152
|
+
x1: a + n,
|
|
153
|
+
y1: i,
|
|
154
|
+
vx: r.x,
|
|
155
|
+
vy: r.y
|
|
156
|
+
}, t);
|
|
157
|
+
},
|
|
158
|
+
fallback: function(e, t) {
|
|
159
|
+
var r = R(e, t.origin);
|
|
160
|
+
return E({
|
|
161
|
+
x0: e.x,
|
|
162
|
+
y0: e.y,
|
|
163
|
+
x1: e.x + (e.width || 0),
|
|
164
|
+
y1: e.y + (e.height || 0),
|
|
165
|
+
vx: r.x,
|
|
166
|
+
vy: r.y
|
|
167
|
+
}, t);
|
|
168
|
+
}
|
|
169
|
+
}, x = m.rasterize;
|
|
170
|
+
function ne(e) {
|
|
171
|
+
var t = e.borderWidth || 0, r = e.padding, a = e.size.height, i = e.size.width, n = -i / 2, o = -a / 2;
|
|
172
|
+
return {
|
|
173
|
+
frame: {
|
|
174
|
+
x: n - r.left - t,
|
|
175
|
+
y: o - r.top - t,
|
|
176
|
+
w: i + r.width + t * 2,
|
|
177
|
+
h: a + r.height + t * 2
|
|
178
|
+
},
|
|
179
|
+
text: {
|
|
180
|
+
x: n,
|
|
181
|
+
y: o,
|
|
182
|
+
w: i,
|
|
183
|
+
h: a
|
|
184
|
+
}
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
function oe(e, t) {
|
|
188
|
+
var r = t.chart.getDatasetMeta(t.datasetIndex).vScale;
|
|
189
|
+
if (!r)
|
|
190
|
+
return null;
|
|
191
|
+
if (r.xCenter !== void 0 && r.yCenter !== void 0)
|
|
192
|
+
return { x: r.xCenter, y: r.yCenter };
|
|
193
|
+
var a = r.getBasePixel();
|
|
194
|
+
return e.horizontal ? { x: a, y: null } : { x: null, y: a };
|
|
195
|
+
}
|
|
196
|
+
function le(e) {
|
|
197
|
+
return e instanceof q ? P.arc : e instanceof J ? P.point : e instanceof K ? P.bar : P.fallback;
|
|
198
|
+
}
|
|
199
|
+
function se(e, t, r, a, i, n) {
|
|
200
|
+
var o = Math.PI / 2;
|
|
201
|
+
if (n) {
|
|
202
|
+
var l = Math.min(n, i / 2, a / 2), s = t + l, u = r + l, v = t + a - l, d = r + i - l;
|
|
203
|
+
e.moveTo(t, u), s < v && u < d ? (e.arc(s, u, l, -Math.PI, -o), e.arc(v, u, l, -o, 0), e.arc(v, d, l, 0, o), e.arc(s, d, l, o, Math.PI)) : s < v ? (e.moveTo(s, r), e.arc(v, u, l, -o, o), e.arc(s, u, l, o, Math.PI + o)) : u < d ? (e.arc(s, u, l, -Math.PI, 0), e.arc(s, d, l, 0, Math.PI)) : e.arc(s, u, l, -Math.PI, Math.PI), e.closePath(), e.moveTo(t, r);
|
|
204
|
+
} else
|
|
205
|
+
e.rect(t, r, a, i);
|
|
206
|
+
}
|
|
207
|
+
function ue(e, t, r) {
|
|
208
|
+
var a = r.backgroundColor, i = r.borderColor, n = r.borderWidth;
|
|
209
|
+
!a && (!i || !n) || (e.beginPath(), se(
|
|
210
|
+
e,
|
|
211
|
+
x(t.x) + n / 2,
|
|
212
|
+
x(t.y) + n / 2,
|
|
213
|
+
x(t.w) - n,
|
|
214
|
+
x(t.h) - n,
|
|
215
|
+
r.borderRadius
|
|
216
|
+
), e.closePath(), a && (e.fillStyle = a, e.fill()), i && n && (e.strokeStyle = i, e.lineWidth = n, e.lineJoin = "miter", e.stroke()));
|
|
217
|
+
}
|
|
218
|
+
function ve(e, t, r) {
|
|
219
|
+
var a = r.lineHeight, i = e.w, n = e.x, o = e.y + a / 2;
|
|
220
|
+
return t === "center" ? n += i / 2 : (t === "end" || t === "right") && (n += i), {
|
|
221
|
+
h: a,
|
|
222
|
+
w: i,
|
|
223
|
+
x: n,
|
|
224
|
+
y: o
|
|
225
|
+
};
|
|
226
|
+
}
|
|
227
|
+
function de(e, t, r) {
|
|
228
|
+
var a = e.shadowBlur, i = r.stroked, n = x(r.x), o = x(r.y), l = x(r.w);
|
|
229
|
+
i && e.strokeText(t, n, o, l), r.filled && (a && i && (e.shadowBlur = 0), e.fillText(t, n, o, l), a && i && (e.shadowBlur = a));
|
|
230
|
+
}
|
|
231
|
+
function fe(e, t, r, a) {
|
|
232
|
+
var i = a.textAlign, n = a.color, o = !!n, l = a.font, s = t.length, u = a.textStrokeColor, v = a.textStrokeWidth, d = u && v, y;
|
|
233
|
+
if (!(!s || !o && !d))
|
|
234
|
+
for (r = ve(r, i, l), e.font = l.string, e.textAlign = i, e.textBaseline = "middle", e.shadowBlur = a.textShadowBlur, e.shadowColor = a.textShadowColor, o && (e.fillStyle = n), d && (e.lineJoin = "round", e.lineWidth = v, e.strokeStyle = u), y = 0, s = t.length; y < s; ++y)
|
|
235
|
+
de(e, t[y], {
|
|
236
|
+
stroked: d,
|
|
237
|
+
filled: o,
|
|
238
|
+
w: r.w,
|
|
239
|
+
x: r.x,
|
|
240
|
+
y: r.y + r.h * y
|
|
241
|
+
});
|
|
242
|
+
}
|
|
243
|
+
var L = function(e, t, r, a) {
|
|
244
|
+
var i = this;
|
|
245
|
+
i._config = e, i._index = a, i._model = null, i._rects = null, i._ctx = t, i._el = r;
|
|
246
|
+
};
|
|
247
|
+
g(L.prototype, {
|
|
248
|
+
/**
|
|
249
|
+
* @private
|
|
250
|
+
*/
|
|
251
|
+
_modelize: function(e, t, r, a) {
|
|
252
|
+
var i = this, n = i._index, o = Z(f([r.font, {}], a, n)), l = f([r.color, ee.color], a, n);
|
|
253
|
+
return {
|
|
254
|
+
align: f([r.align, "center"], a, n),
|
|
255
|
+
anchor: f([r.anchor, "center"], a, n),
|
|
256
|
+
area: a.chart.chartArea,
|
|
257
|
+
backgroundColor: f([r.backgroundColor, null], a, n),
|
|
258
|
+
borderColor: f([r.borderColor, null], a, n),
|
|
259
|
+
borderRadius: f([r.borderRadius, 0], a, n),
|
|
260
|
+
borderWidth: f([r.borderWidth, 0], a, n),
|
|
261
|
+
clamp: f([r.clamp, !1], a, n),
|
|
262
|
+
clip: f([r.clip, !1], a, n),
|
|
263
|
+
color: l,
|
|
264
|
+
display: e,
|
|
265
|
+
font: o,
|
|
266
|
+
lines: t,
|
|
267
|
+
offset: f([r.offset, 4], a, n),
|
|
268
|
+
opacity: f([r.opacity, 1], a, n),
|
|
269
|
+
origin: oe(i._el, a),
|
|
270
|
+
padding: re(f([r.padding, 4], a, n)),
|
|
271
|
+
positioner: le(i._el),
|
|
272
|
+
rotation: f([r.rotation, 0], a, n) * (Math.PI / 180),
|
|
273
|
+
size: m.textSize(i._ctx, t, o),
|
|
274
|
+
textAlign: f([r.textAlign, "start"], a, n),
|
|
275
|
+
textShadowBlur: f([r.textShadowBlur, 0], a, n),
|
|
276
|
+
textShadowColor: f([r.textShadowColor, l], a, n),
|
|
277
|
+
textStrokeColor: f([r.textStrokeColor, l], a, n),
|
|
278
|
+
textStrokeWidth: f([r.textStrokeWidth, 0], a, n)
|
|
279
|
+
};
|
|
280
|
+
},
|
|
281
|
+
update: function(e) {
|
|
282
|
+
var t = this, r = null, a = null, i = t._index, n = t._config, o, l, s, u = f([n.display, !0], e, i);
|
|
283
|
+
u && (o = e.dataset.data[i], l = Q(B(n.formatter, [o, e]), o), s = p(l) ? [] : m.toTextLines(l), s.length && (r = t._modelize(u, s, n, e), a = ne(r))), t._model = r, t._rects = a;
|
|
284
|
+
},
|
|
285
|
+
geometry: function() {
|
|
286
|
+
return this._rects ? this._rects.frame : {};
|
|
287
|
+
},
|
|
288
|
+
rotation: function() {
|
|
289
|
+
return this._model ? this._model.rotation : 0;
|
|
290
|
+
},
|
|
291
|
+
visible: function() {
|
|
292
|
+
return this._model && this._model.opacity;
|
|
293
|
+
},
|
|
294
|
+
model: function() {
|
|
295
|
+
return this._model;
|
|
296
|
+
},
|
|
297
|
+
draw: function(e, t) {
|
|
298
|
+
var r = this, a = e.ctx, i = r._model, n = r._rects, o;
|
|
299
|
+
this.visible() && (a.save(), i.clip && (o = i.area, a.beginPath(), a.rect(
|
|
300
|
+
o.left,
|
|
301
|
+
o.top,
|
|
302
|
+
o.right - o.left,
|
|
303
|
+
o.bottom - o.top
|
|
304
|
+
), a.clip()), a.globalAlpha = m.bound(0, i.opacity, 1), a.translate(x(t.x), x(t.y)), a.rotate(i.rotation), ue(a, n.frame, i), fe(a, i.lines, n.text, i), a.restore());
|
|
305
|
+
}
|
|
306
|
+
});
|
|
307
|
+
var he = Number.MIN_SAFE_INTEGER || -9007199254740991, ye = Number.MAX_SAFE_INTEGER || 9007199254740991;
|
|
308
|
+
function b(e, t, r) {
|
|
309
|
+
var a = Math.cos(r), i = Math.sin(r), n = t.x, o = t.y;
|
|
310
|
+
return {
|
|
311
|
+
x: n + a * (e.x - n) - i * (e.y - o),
|
|
312
|
+
y: o + i * (e.x - n) + a * (e.y - o)
|
|
313
|
+
};
|
|
314
|
+
}
|
|
315
|
+
function z(e, t) {
|
|
316
|
+
var r = ye, a = he, i = t.origin, n, o, l, s, u;
|
|
317
|
+
for (n = 0; n < e.length; ++n)
|
|
318
|
+
o = e[n], l = o.x - i.x, s = o.y - i.y, u = t.vx * l + t.vy * s, r = Math.min(r, u), a = Math.max(a, u);
|
|
319
|
+
return {
|
|
320
|
+
min: r,
|
|
321
|
+
max: a
|
|
322
|
+
};
|
|
323
|
+
}
|
|
324
|
+
function I(e, t) {
|
|
325
|
+
var r = t.x - e.x, a = t.y - e.y, i = Math.sqrt(r * r + a * a);
|
|
326
|
+
return {
|
|
327
|
+
vx: (t.x - e.x) / i,
|
|
328
|
+
vy: (t.y - e.y) / i,
|
|
329
|
+
origin: e,
|
|
330
|
+
ln: i
|
|
331
|
+
};
|
|
332
|
+
}
|
|
333
|
+
var G = function() {
|
|
334
|
+
this._rotation = 0, this._rect = {
|
|
335
|
+
x: 0,
|
|
336
|
+
y: 0,
|
|
337
|
+
w: 0,
|
|
338
|
+
h: 0
|
|
339
|
+
};
|
|
340
|
+
};
|
|
341
|
+
g(G.prototype, {
|
|
342
|
+
center: function() {
|
|
343
|
+
var e = this._rect;
|
|
344
|
+
return {
|
|
345
|
+
x: e.x + e.w / 2,
|
|
346
|
+
y: e.y + e.h / 2
|
|
347
|
+
};
|
|
348
|
+
},
|
|
349
|
+
update: function(e, t, r) {
|
|
350
|
+
this._rotation = r, this._rect = {
|
|
351
|
+
x: t.x + e.x,
|
|
352
|
+
y: t.y + e.y,
|
|
353
|
+
w: t.w,
|
|
354
|
+
h: t.h
|
|
355
|
+
};
|
|
356
|
+
},
|
|
357
|
+
contains: function(e) {
|
|
358
|
+
var t = this, r = 1, a = t._rect;
|
|
359
|
+
return e = b(e, t.center(), -t._rotation), !(e.x < a.x - r || e.y < a.y - r || e.x > a.x + a.w + r * 2 || e.y > a.y + a.h + r * 2);
|
|
360
|
+
},
|
|
361
|
+
// Separating Axis Theorem
|
|
362
|
+
// https://gamedevelopment.tutsplus.com/tutorials/collision-detection-using-the-separating-axis-theorem--gamedev-169
|
|
363
|
+
intersects: function(e) {
|
|
364
|
+
var t = this._points(), r = e._points(), a = [
|
|
365
|
+
I(t[0], t[1]),
|
|
366
|
+
I(t[0], t[3])
|
|
367
|
+
], i, n, o;
|
|
368
|
+
for (this._rotation !== e._rotation && a.push(
|
|
369
|
+
I(r[0], r[1]),
|
|
370
|
+
I(r[0], r[3])
|
|
371
|
+
), i = 0; i < a.length; ++i)
|
|
372
|
+
if (n = z(t, a[i]), o = z(r, a[i]), n.max < o.min || o.max < n.min)
|
|
373
|
+
return !1;
|
|
374
|
+
return !0;
|
|
375
|
+
},
|
|
376
|
+
/**
|
|
377
|
+
* @private
|
|
378
|
+
*/
|
|
379
|
+
_points: function() {
|
|
380
|
+
var e = this, t = e._rect, r = e._rotation, a = e.center();
|
|
381
|
+
return [
|
|
382
|
+
b({ x: t.x, y: t.y }, a, r),
|
|
383
|
+
b({ x: t.x + t.w, y: t.y }, a, r),
|
|
384
|
+
b({ x: t.x + t.w, y: t.y + t.h }, a, r),
|
|
385
|
+
b({ x: t.x, y: t.y + t.h }, a, r)
|
|
386
|
+
];
|
|
387
|
+
}
|
|
388
|
+
});
|
|
389
|
+
function H(e, t, r) {
|
|
390
|
+
var a = t.positioner(e, t), i = a.vx, n = a.vy;
|
|
391
|
+
if (!i && !n)
|
|
392
|
+
return { x: a.x, y: a.y };
|
|
393
|
+
var o = r.w, l = r.h, s = t.rotation, u = Math.abs(o / 2 * Math.cos(s)) + Math.abs(l / 2 * Math.sin(s)), v = Math.abs(o / 2 * Math.sin(s)) + Math.abs(l / 2 * Math.cos(s)), d = 1 / Math.max(Math.abs(i), Math.abs(n));
|
|
394
|
+
return u *= i * d, v *= n * d, u += t.offset * i, v += t.offset * n, {
|
|
395
|
+
x: a.x + u,
|
|
396
|
+
y: a.y + v
|
|
397
|
+
};
|
|
398
|
+
}
|
|
399
|
+
function xe(e, t) {
|
|
400
|
+
var r, a, i, n;
|
|
401
|
+
for (r = e.length - 1; r >= 0; --r)
|
|
402
|
+
for (i = e[r].$layout, a = r - 1; a >= 0 && i._visible; --a)
|
|
403
|
+
n = e[a].$layout, n._visible && i._box.intersects(n._box) && t(i, n);
|
|
404
|
+
return e;
|
|
405
|
+
}
|
|
406
|
+
function _e(e) {
|
|
407
|
+
var t, r, a, i, n, o, l;
|
|
408
|
+
for (t = 0, r = e.length; t < r; ++t)
|
|
409
|
+
a = e[t], i = a.$layout, i._visible && (l = new Proxy(a._el, { get: (s, u) => s.getProps([u], !0)[u] }), n = a.geometry(), o = H(l, a.model(), n), i._box.update(o, n, a.rotation()));
|
|
410
|
+
return xe(e, function(s, u) {
|
|
411
|
+
var v = s._hidable, d = u._hidable;
|
|
412
|
+
v && d || d ? u._visible = !1 : v && (s._visible = !1);
|
|
413
|
+
});
|
|
414
|
+
}
|
|
415
|
+
var w = {
|
|
416
|
+
prepare: function(e) {
|
|
417
|
+
var t = [], r, a, i, n, o;
|
|
418
|
+
for (r = 0, i = e.length; r < i; ++r)
|
|
419
|
+
for (a = 0, n = e[r].length; a < n; ++a)
|
|
420
|
+
o = e[r][a], t.push(o), o.$layout = {
|
|
421
|
+
_box: new G(),
|
|
422
|
+
_hidable: !1,
|
|
423
|
+
_visible: !0,
|
|
424
|
+
_set: r,
|
|
425
|
+
_idx: o._index
|
|
426
|
+
};
|
|
427
|
+
return t.sort(function(l, s) {
|
|
428
|
+
var u = l.$layout, v = s.$layout;
|
|
429
|
+
return u._idx === v._idx ? v._set - u._set : v._idx - u._idx;
|
|
430
|
+
}), this.update(t), t;
|
|
431
|
+
},
|
|
432
|
+
update: function(e) {
|
|
433
|
+
var t = !1, r, a, i, n, o;
|
|
434
|
+
for (r = 0, a = e.length; r < a; ++r)
|
|
435
|
+
i = e[r], n = i.model(), o = i.$layout, o._hidable = n && n.display === "auto", o._visible = i.visible(), t |= o._hidable;
|
|
436
|
+
t && _e(e);
|
|
437
|
+
},
|
|
438
|
+
lookup: function(e, t) {
|
|
439
|
+
var r, a;
|
|
440
|
+
for (r = e.length - 1; r >= 0; --r)
|
|
441
|
+
if (a = e[r].$layout, a && a._visible && a._box.contains(t))
|
|
442
|
+
return e[r];
|
|
443
|
+
return null;
|
|
444
|
+
},
|
|
445
|
+
draw: function(e, t) {
|
|
446
|
+
var r, a, i, n, o, l;
|
|
447
|
+
for (r = 0, a = t.length; r < a; ++r)
|
|
448
|
+
i = t[r], n = i.$layout, n._visible && (o = i.geometry(), l = H(i._el, i.model(), o), n._box.update(l, o, i.rotation()), i.draw(e, l));
|
|
449
|
+
}
|
|
450
|
+
}, ce = function(e) {
|
|
451
|
+
if (p(e))
|
|
452
|
+
return null;
|
|
453
|
+
var t = e, r, a, i;
|
|
454
|
+
if (V(e))
|
|
455
|
+
if (!p(e.label))
|
|
456
|
+
t = e.label;
|
|
457
|
+
else if (!p(e.r))
|
|
458
|
+
t = e.r;
|
|
459
|
+
else
|
|
460
|
+
for (t = "", r = Object.keys(e), i = 0, a = r.length; i < a; ++i)
|
|
461
|
+
t += (i !== 0 ? ", " : "") + r[i] + ": " + e[r[i]];
|
|
462
|
+
return "" + t;
|
|
463
|
+
}, be = {
|
|
464
|
+
align: "center",
|
|
465
|
+
anchor: "center",
|
|
466
|
+
backgroundColor: null,
|
|
467
|
+
borderColor: null,
|
|
468
|
+
borderRadius: 0,
|
|
469
|
+
borderWidth: 0,
|
|
470
|
+
clamp: !1,
|
|
471
|
+
clip: !1,
|
|
472
|
+
color: void 0,
|
|
473
|
+
display: !0,
|
|
474
|
+
font: {
|
|
475
|
+
family: void 0,
|
|
476
|
+
lineHeight: 1.2,
|
|
477
|
+
size: void 0,
|
|
478
|
+
style: void 0,
|
|
479
|
+
weight: null
|
|
480
|
+
},
|
|
481
|
+
formatter: ce,
|
|
482
|
+
labels: void 0,
|
|
483
|
+
listeners: {},
|
|
484
|
+
offset: 4,
|
|
485
|
+
opacity: 1,
|
|
486
|
+
padding: {
|
|
487
|
+
top: 4,
|
|
488
|
+
right: 4,
|
|
489
|
+
bottom: 4,
|
|
490
|
+
left: 4
|
|
491
|
+
},
|
|
492
|
+
rotation: 0,
|
|
493
|
+
textAlign: "start",
|
|
494
|
+
textStrokeColor: void 0,
|
|
495
|
+
textStrokeWidth: 0,
|
|
496
|
+
textShadowBlur: 0,
|
|
497
|
+
textShadowColor: void 0
|
|
498
|
+
}, h = "$datalabels", U = "$default";
|
|
499
|
+
function pe(e, t) {
|
|
500
|
+
var r = e.datalabels, a = {}, i = [], n, o;
|
|
501
|
+
return r === !1 ? null : (r === !0 && (r = {}), t = g({}, [t, r]), n = t.labels || {}, o = Object.keys(n), delete t.labels, o.length ? o.forEach(function(l) {
|
|
502
|
+
n[l] && i.push(g({}, [
|
|
503
|
+
t,
|
|
504
|
+
n[l],
|
|
505
|
+
{ _key: l }
|
|
506
|
+
]));
|
|
507
|
+
}) : i.push(t), a = i.reduce(function(l, s) {
|
|
508
|
+
return Y(s.listeners || {}, function(u, v) {
|
|
509
|
+
l[v] = l[v] || {}, l[v][s._key || U] = u;
|
|
510
|
+
}), delete s.listeners, l;
|
|
511
|
+
}, {}), {
|
|
512
|
+
labels: i,
|
|
513
|
+
listeners: a
|
|
514
|
+
});
|
|
515
|
+
}
|
|
516
|
+
function A(e, t, r, a) {
|
|
517
|
+
if (t) {
|
|
518
|
+
var i = r.$context, n = r.$groups, o;
|
|
519
|
+
t[n._set] && (o = t[n._set][n._key], o && B(o, [i, a]) === !0 && (e[h]._dirty = !0, r.update(i)));
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
function me(e, t, r, a, i) {
|
|
523
|
+
var n, o;
|
|
524
|
+
!r && !a || (r ? a ? r !== a && (o = n = !0) : o = !0 : n = !0, o && A(e, t.leave, r, i), n && A(e, t.enter, a, i));
|
|
525
|
+
}
|
|
526
|
+
function we(e, t) {
|
|
527
|
+
var r = e[h], a = r._listeners, i, n;
|
|
528
|
+
if (!(!a.enter && !a.leave)) {
|
|
529
|
+
if (t.type === "mousemove")
|
|
530
|
+
n = w.lookup(r._labels, t);
|
|
531
|
+
else if (t.type !== "mouseout")
|
|
532
|
+
return;
|
|
533
|
+
i = r._hovered, r._hovered = n, me(e, a, i, n, t);
|
|
534
|
+
}
|
|
535
|
+
}
|
|
536
|
+
function ge(e, t) {
|
|
537
|
+
var r = e[h], a = r._listeners.click, i = a && w.lookup(r._labels, t);
|
|
538
|
+
i && A(e, a, i, t);
|
|
539
|
+
}
|
|
540
|
+
var Ee = {
|
|
541
|
+
id: "datalabels",
|
|
542
|
+
defaults: be,
|
|
543
|
+
beforeInit: function(e) {
|
|
544
|
+
e[h] = {
|
|
545
|
+
_actives: []
|
|
546
|
+
};
|
|
547
|
+
},
|
|
548
|
+
beforeUpdate: function(e) {
|
|
549
|
+
var t = e[h];
|
|
550
|
+
t._listened = !1, t._listeners = {}, t._datasets = [], t._labels = [];
|
|
551
|
+
},
|
|
552
|
+
afterDatasetUpdate: function(e, t, r) {
|
|
553
|
+
var a = t.index, i = e[h], n = i._datasets[a] = [], o = e.isDatasetVisible(a), l = e.data.datasets[a], s = pe(l, r), u = t.meta.data || [], v = e.ctx, d, y, $, T, S, D, c, _;
|
|
554
|
+
for (v.save(), d = 0, $ = u.length; d < $; ++d)
|
|
555
|
+
if (c = u[d], c[h] = [], o && c && e.getDataVisibility(d) && !c.skip)
|
|
556
|
+
for (y = 0, T = s.labels.length; y < T; ++y)
|
|
557
|
+
S = s.labels[y], D = S._key, _ = new L(S, v, c, d), _.$groups = {
|
|
558
|
+
_set: a,
|
|
559
|
+
_key: D || U
|
|
560
|
+
}, _.$context = {
|
|
561
|
+
active: !1,
|
|
562
|
+
chart: e,
|
|
563
|
+
dataIndex: d,
|
|
564
|
+
dataset: l,
|
|
565
|
+
datasetIndex: a
|
|
566
|
+
}, _.update(_.$context), c[h].push(_), n.push(_);
|
|
567
|
+
v.restore(), g(i._listeners, s.listeners, {
|
|
568
|
+
merger: function(k, C, X) {
|
|
569
|
+
C[k] = C[k] || {}, C[k][t.index] = X[k], i._listened = !0;
|
|
570
|
+
}
|
|
571
|
+
});
|
|
572
|
+
},
|
|
573
|
+
afterUpdate: function(e) {
|
|
574
|
+
e[h]._labels = w.prepare(e[h]._datasets);
|
|
575
|
+
},
|
|
576
|
+
// Draw labels on top of all dataset elements
|
|
577
|
+
// https://github.com/chartjs/chartjs-plugin-datalabels/issues/29
|
|
578
|
+
// https://github.com/chartjs/chartjs-plugin-datalabels/issues/32
|
|
579
|
+
afterDatasetsDraw: function(e) {
|
|
580
|
+
w.draw(e, e[h]._labels);
|
|
581
|
+
},
|
|
582
|
+
beforeEvent: function(e, t) {
|
|
583
|
+
if (e[h]._listened) {
|
|
584
|
+
var r = t.event;
|
|
585
|
+
switch (r.type) {
|
|
586
|
+
case "mousemove":
|
|
587
|
+
case "mouseout":
|
|
588
|
+
we(e, r);
|
|
589
|
+
break;
|
|
590
|
+
case "click":
|
|
591
|
+
ge(e, r);
|
|
592
|
+
break;
|
|
593
|
+
}
|
|
594
|
+
}
|
|
595
|
+
},
|
|
596
|
+
afterEvent: function(e) {
|
|
597
|
+
var t = e[h], r = t._actives, a = t._actives = e.getActiveElements(), i = m.arrayDiff(r, a), n, o, l, s, u, v, d;
|
|
598
|
+
for (n = 0, o = i.length; n < o; ++n)
|
|
599
|
+
if (u = i[n], u[1])
|
|
600
|
+
for (d = u[0].element[h] || [], l = 0, s = d.length; l < s; ++l)
|
|
601
|
+
v = d[l], v.$context.active = u[1] === 1, v.update(v.$context);
|
|
602
|
+
(t._dirty || i.length) && (w.update(t._labels), e.render()), delete t._dirty;
|
|
603
|
+
}
|
|
604
|
+
};
|
|
605
|
+
export {
|
|
606
|
+
Ee as default
|
|
607
|
+
};
|