goro-charts 1.0.0 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +113 -0
- package/README.md +46 -19
- package/dist/charts/chart-base.d.ts +80 -17
- package/dist/data/series-store.d.ts +25 -2
- package/dist/defaults.d.ts +2 -2
- package/dist/goro-charts.js +229 -121
- package/dist/goro-charts.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/types.d.ts +23 -4
- package/package.json +2 -1
package/dist/goro-charts.js
CHANGED
|
@@ -29,8 +29,8 @@ var e = {
|
|
|
29
29
|
yTicks: 6,
|
|
30
30
|
maxPoints: 0,
|
|
31
31
|
autoDraw: !1,
|
|
32
|
-
yMin: 0,
|
|
33
|
-
yMax: 0,
|
|
32
|
+
yMin: void 0,
|
|
33
|
+
yMax: void 0,
|
|
34
34
|
maxDots: 2e3
|
|
35
35
|
}, t = class {
|
|
36
36
|
cap;
|
|
@@ -100,8 +100,8 @@ var e = {
|
|
|
100
100
|
push(e, t) {
|
|
101
101
|
let n;
|
|
102
102
|
this.count < this.cap ? (n = this.head + this.count, n >= this.cap && (n -= this.cap), this.count++) : (n = this.head, this.head = this.head + 1 === this.cap ? 0 : this.head + 1), this.x[n] = e, this.y[n] = t;
|
|
103
|
-
let r = this.seq
|
|
104
|
-
this.ext.push(t, r,
|
|
103
|
+
let r = this.seq++, i = r - this.count + 1;
|
|
104
|
+
Number.isNaN(t) || this.ext.push(t, r, i);
|
|
105
105
|
}
|
|
106
106
|
clear() {
|
|
107
107
|
this.head = 0, this.count = 0, this.seq = 0, this.ext.clear();
|
|
@@ -134,26 +134,35 @@ var e = {
|
|
|
134
134
|
if (e < 1) throw Error("maxPoints must be >= 1");
|
|
135
135
|
this.ring = new n(e), this.bindRing();
|
|
136
136
|
}
|
|
137
|
-
setData(e, t) {
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
this.ring = null, this.xArr = e, this.yArr = t, this.head = 0, this.count = e.length, this.cap = e.length, this.xMin = e[0], this.xMax = e[e.length - 1];
|
|
141
|
-
let n = Infinity, r = -Infinity;
|
|
137
|
+
setData(e, t, n = "copy") {
|
|
138
|
+
this.validateSnapshot(e, t), this.ring = null, this.xArr = n === "copy" ? new Float64Array(e) : e, this.yArr = n === "copy" ? new Float64Array(t) : t, this.head = 0, this.count = e.length, this.cap = e.length, this.xMin = e[0], this.xMax = e[e.length - 1];
|
|
139
|
+
let r = Infinity, i = -Infinity;
|
|
142
140
|
for (let e = 0; e < t.length; e++) {
|
|
143
|
-
let
|
|
144
|
-
|
|
141
|
+
let n = t[e];
|
|
142
|
+
Number.isNaN(n) || (n < r && (r = n), n > i && (i = n));
|
|
145
143
|
}
|
|
146
|
-
this.applyExtent(
|
|
144
|
+
r === Infinity && (r = 0, i = 0), this.applyExtent(r, i);
|
|
147
145
|
}
|
|
148
146
|
append(e, t) {
|
|
149
147
|
let n = this.requireRing("append");
|
|
150
|
-
|
|
148
|
+
if (!Number.isFinite(e)) throw Error(`append x=${e} is not finite`);
|
|
149
|
+
if (n.count > 0 && e < n.xLast) throw Error(`append x=${e} is < last x=${n.xLast}; x must be monotonically increasing`);
|
|
150
|
+
if (!i(t)) throw Error(`append y=${t} is not finite`);
|
|
151
|
+
n.push(e, t), this.syncFromRing();
|
|
151
152
|
}
|
|
152
153
|
appendBatch(e, t) {
|
|
153
154
|
let n = this.requireRing("appendBatch");
|
|
154
155
|
if (e.length !== t.length) throw Error("xs and ys must have same length");
|
|
155
|
-
|
|
156
|
-
|
|
156
|
+
let r = e.length;
|
|
157
|
+
if (r !== 0) {
|
|
158
|
+
for (let n = 0; n < r; n++) {
|
|
159
|
+
if (!Number.isFinite(e[n])) throw Error(`xs[${n}]=${e[n]} is not finite`);
|
|
160
|
+
if (n > 0 && e[n] < e[n - 1]) throw Error(`xs not monotonically increasing at batch index ${n}: xs[${n}]=${e[n]} < xs[${n - 1}]=${e[n - 1]}`);
|
|
161
|
+
if (!i(t[n])) throw Error(`ys[${n}]=${t[n]} is not finite`);
|
|
162
|
+
}
|
|
163
|
+
for (let i = 0; i < r; i++) n.push(e[i], t[i]);
|
|
164
|
+
this.syncFromRing();
|
|
165
|
+
}
|
|
157
166
|
}
|
|
158
167
|
setMaxPoints(e) {
|
|
159
168
|
if (e < 1) throw Error("maxPoints must be >= 1");
|
|
@@ -179,6 +188,16 @@ var e = {
|
|
|
179
188
|
}
|
|
180
189
|
return n;
|
|
181
190
|
}
|
|
191
|
+
validateSnapshot(e, t) {
|
|
192
|
+
if (e.length !== t.length) throw Error(`x and y length mismatch: x.length=${e.length}, y.length=${t.length}`);
|
|
193
|
+
if (e.length === 0) throw Error("data arrays must not be empty");
|
|
194
|
+
if (!Number.isFinite(e[0])) throw Error(`x[0]=${e[0]} is not finite`);
|
|
195
|
+
for (let t = 1; t < e.length; t++) {
|
|
196
|
+
if (!Number.isFinite(e[t])) throw Error(`x[${t}]=${e[t]} is not finite`);
|
|
197
|
+
if (e[t] < e[t - 1]) throw Error(`x not monotonically increasing at index ${t}: x[${t}]=${e[t]} < x[${t - 1}]=${e[t - 1]}`);
|
|
198
|
+
}
|
|
199
|
+
for (let e = 0; e < t.length; e++) if (!i(t[e])) throw Error(`y[${e}]=${t[e]} is not finite`);
|
|
200
|
+
}
|
|
182
201
|
requireRing(e) {
|
|
183
202
|
if (!this.ring) throw Error(`${e}() requires the chart to be created with { maxPoints }`);
|
|
184
203
|
return this.ring;
|
|
@@ -194,7 +213,13 @@ var e = {
|
|
|
194
213
|
applyExtent(e, t) {
|
|
195
214
|
t - e === 0 ? (this.yMin = e - 1, this.yMax = t + 1) : (this.yMin = e, this.yMax = t);
|
|
196
215
|
}
|
|
197
|
-
}
|
|
216
|
+
};
|
|
217
|
+
function i(e) {
|
|
218
|
+
return Number.isFinite(e) || Number.isNaN(e);
|
|
219
|
+
}
|
|
220
|
+
//#endregion
|
|
221
|
+
//#region src/render/surface.ts
|
|
222
|
+
var a = class {
|
|
198
223
|
canvas;
|
|
199
224
|
ctx;
|
|
200
225
|
dpr;
|
|
@@ -232,93 +257,93 @@ var e = {
|
|
|
232
257
|
};
|
|
233
258
|
//#endregion
|
|
234
259
|
//#region src/math/ticks.ts
|
|
235
|
-
function
|
|
260
|
+
function o(e, t) {
|
|
236
261
|
let n = t - e;
|
|
237
262
|
return n === 0 ? 1 : n;
|
|
238
263
|
}
|
|
239
|
-
function
|
|
264
|
+
function s(e, t) {
|
|
240
265
|
let n = Math.floor(Math.log10(e / t)), r = e / t / 10 ** n, i;
|
|
241
266
|
return i = r <= 1.5 ? 1 : r <= 3.5 ? 2 : r <= 7.5 ? 5 : 10, i * 10 ** n;
|
|
242
267
|
}
|
|
243
|
-
function
|
|
244
|
-
let r = o(
|
|
245
|
-
for (let e = i; e <=
|
|
268
|
+
function c(e, t, n) {
|
|
269
|
+
let r = s(o(e, t), n), i = Math.ceil(e / r) * r, a = Math.floor(t / r) * r, c = [];
|
|
270
|
+
for (let e = i; e <= a + r * .5; e += r) c.push(e);
|
|
246
271
|
return c;
|
|
247
272
|
}
|
|
248
273
|
//#endregion
|
|
249
274
|
//#region src/math/format.ts
|
|
250
|
-
function
|
|
275
|
+
function l(e) {
|
|
251
276
|
if (Number.isInteger(e)) return e.toFixed(0);
|
|
252
277
|
let t = Math.abs(e);
|
|
253
278
|
return (t >= 1e6 || t <= 1e-4 && t > 0) && isFinite(e) ? e.toExponential(2) : t >= 1 ? e.toFixed(2) : e.toPrecision(3);
|
|
254
279
|
}
|
|
255
280
|
//#endregion
|
|
256
281
|
//#region src/math/scale.ts
|
|
257
|
-
function
|
|
282
|
+
function u(e, t, n) {
|
|
258
283
|
let r = t.xMax - t.xMin;
|
|
259
284
|
return r <= 0 ? n.x : n.x + (e - t.xMin) / r * n.w;
|
|
260
285
|
}
|
|
261
|
-
function
|
|
286
|
+
function d(e, t, n) {
|
|
262
287
|
let r = t.yMax - t.yMin;
|
|
263
288
|
return r <= 0 ? n.y : n.y + (1 - (e - t.yMin) / r) * n.h;
|
|
264
289
|
}
|
|
265
|
-
function
|
|
290
|
+
function f(e, t, n) {
|
|
266
291
|
let r = t.xMax - t.xMin;
|
|
267
292
|
return r <= 0 ? t.xMin : t.xMin + (e - n.x) / n.w * r;
|
|
268
293
|
}
|
|
269
294
|
//#endregion
|
|
270
295
|
//#region src/render/axes.ts
|
|
271
|
-
function
|
|
296
|
+
function p(e, t, n, r) {
|
|
272
297
|
e.setLineDash([6, 4]);
|
|
273
298
|
let i = n.y + n.h, a = n.x + n.w;
|
|
274
299
|
e.strokeStyle = r.gridColor, e.lineWidth = .5;
|
|
275
|
-
let o =
|
|
300
|
+
let o = c(t.yMin, t.yMax, r.yTicks);
|
|
276
301
|
e.beginPath();
|
|
277
302
|
for (let r of o) {
|
|
278
|
-
let o =
|
|
303
|
+
let o = d(r, t, n);
|
|
279
304
|
o <= n.y || o >= i || (e.moveTo(n.x, o), e.lineTo(a, o));
|
|
280
305
|
}
|
|
281
306
|
e.stroke();
|
|
282
|
-
let
|
|
307
|
+
let s = c(t.xMin, t.xMax, r.xTicks);
|
|
283
308
|
e.beginPath();
|
|
284
|
-
for (let r of
|
|
285
|
-
let o =
|
|
309
|
+
for (let r of s) {
|
|
310
|
+
let o = u(r, t, n);
|
|
286
311
|
o <= n.x || o >= a || (e.moveTo(o, n.y), e.lineTo(o, i));
|
|
287
312
|
}
|
|
288
313
|
e.stroke(), e.strokeStyle = r.axisColor, e.lineWidth = .8, e.strokeRect(n.x, n.y, n.w, n.h), e.setLineDash([]);
|
|
289
314
|
}
|
|
290
|
-
function
|
|
315
|
+
function m(e, t, n, r, i = "left") {
|
|
291
316
|
e.font = `${r.fontSize}px ${r.fontFamily}`, e.fillStyle = r.textColor;
|
|
292
|
-
let a =
|
|
317
|
+
let a = c(t.yMin, t.yMax, r.yTicks);
|
|
293
318
|
e.textAlign = i === "right" ? "left" : "right", e.textBaseline = "middle";
|
|
294
319
|
let o = i === "right" ? n.x + n.w + 6 : n.x - 6;
|
|
295
|
-
for (let r of a) e.fillText(
|
|
320
|
+
for (let r of a) e.fillText(l(r), o, d(r, t, n));
|
|
296
321
|
if (i === "left") {
|
|
297
|
-
let i =
|
|
322
|
+
let i = c(t.xMin, t.xMax, r.xTicks);
|
|
298
323
|
e.textAlign = "center", e.textBaseline = "top";
|
|
299
|
-
for (let r of i) e.fillText(
|
|
324
|
+
for (let r of i) e.fillText(l(r), u(r, t, n), n.y + n.h + 6);
|
|
300
325
|
}
|
|
301
326
|
}
|
|
302
327
|
//#endregion
|
|
303
328
|
//#region src/render/shape.ts
|
|
304
|
-
function
|
|
329
|
+
function h(e, t, n, r, i, a) {
|
|
305
330
|
if (r <= 0 || i <= 0) return;
|
|
306
331
|
let o = Math.min(a, r / 2, i / 2);
|
|
307
332
|
e.moveTo(t + o, n), e.arcTo(t + r, n, t + r, n + i, o), e.arcTo(t + r, n + i, t, n + i, o), e.arcTo(t, n + i, t, n, o), e.arcTo(t, n, t + r, n, o), e.closePath();
|
|
308
333
|
}
|
|
309
334
|
//#endregion
|
|
310
335
|
//#region src/render/crosshair.ts
|
|
311
|
-
function
|
|
336
|
+
function g(e, t, n, r) {
|
|
312
337
|
let i = [];
|
|
313
338
|
for (let a = 0; a < e.length; a++) {
|
|
314
339
|
let o = e[a], s = o.count;
|
|
315
340
|
if (s === 0) continue;
|
|
316
|
-
let c =
|
|
341
|
+
let c = f(r, o, n), l = o.bracketLogical(c), p = l + 1 < s ? l + 1 : s - 1, m = o.physOf(l), h = o.physOf(p), g = o.xArr[m], _ = o.xArr[h], v = o.yArr[m], y = o.yArr[h], b = _ > g ? (c - g) / (_ - g) : 0;
|
|
317
342
|
b < 0 ? b = 0 : b > 1 && (b = 1);
|
|
318
343
|
let x = g + (_ - g) * b, S = v + (y - v) * b;
|
|
319
344
|
i.push({
|
|
320
|
-
px:
|
|
321
|
-
py:
|
|
345
|
+
px: u(x, o, n),
|
|
346
|
+
py: d(S, o, n),
|
|
322
347
|
xVal: x,
|
|
323
348
|
yVal: S,
|
|
324
349
|
color: t[a].color,
|
|
@@ -327,17 +352,17 @@ function h(e, t, n, r) {
|
|
|
327
352
|
}
|
|
328
353
|
return i;
|
|
329
354
|
}
|
|
330
|
-
function
|
|
355
|
+
function _(e, t, n, r, i, a, o) {
|
|
331
356
|
if (a.x < r.x || a.x > r.x + r.w || a.y < r.y || a.y > r.y + r.h) return;
|
|
332
|
-
let s =
|
|
357
|
+
let s = g(t, n, r, a.x);
|
|
333
358
|
if (s.length === 0) return;
|
|
334
|
-
let
|
|
335
|
-
if (e.strokeStyle = i.crosshairColor, e.lineWidth = i.crosshairWidth, e.setLineDash([4, 3]), e.beginPath(), e.moveTo(
|
|
359
|
+
let c = s[0].px, u = s[0].xVal;
|
|
360
|
+
if (e.strokeStyle = i.crosshairColor, e.lineWidth = i.crosshairWidth, e.setLineDash([4, 3]), e.beginPath(), e.moveTo(c, r.y), e.lineTo(c, r.y + r.h), e.stroke(), e.setLineDash([]), s.length === 1) {
|
|
336
361
|
let t = s[0];
|
|
337
362
|
e.strokeStyle = i.crosshairColor, e.lineWidth = i.crosshairWidth, e.setLineDash([4, 3]), e.beginPath(), e.moveTo(r.x, t.py), e.lineTo(r.x + r.w, t.py), e.stroke(), e.setLineDash([]);
|
|
338
363
|
}
|
|
339
364
|
for (let t of s) e.fillStyle = "rgba(0,0,0,0.65)", e.beginPath(), e.arc(t.px, t.py, i.pointRadius + 1.5, 0, Math.PI * 2), e.fill(), e.fillStyle = t.color, e.beginPath(), e.arc(t.px, t.py, i.pointRadius, 0, Math.PI * 2), e.fill();
|
|
340
|
-
let d = (e) =>
|
|
365
|
+
let d = (e) => l(e), f = `${i.fontSize}px ${i.fontFamily}`, p = `600 ${i.fontSize + 1}px ${i.fontFamily}`, m = i.fontSize + 6;
|
|
341
366
|
e.font = f;
|
|
342
367
|
let _ = Math.max(...s.map((t) => e.measureText(t.label).width));
|
|
343
368
|
e.font = p;
|
|
@@ -345,23 +370,23 @@ function g(e, t, n, r, i, a, o) {
|
|
|
345
370
|
e.font = f;
|
|
346
371
|
let y = e.measureText("x").width;
|
|
347
372
|
e.font = p;
|
|
348
|
-
let b = e.measureText(d(u)).width, x = Math.max(0, _, y), S = Math.max(v, b), C = 36 + x + 8 + S, w =
|
|
349
|
-
E + C > o && (E = Math.max(2,
|
|
373
|
+
let b = e.measureText(d(u)).width, x = Math.max(0, _, y), S = Math.max(v, b), C = 36 + x + 8 + S, w = m + 4, T = 20 + w + 2 + s.length * m, E = c + 14;
|
|
374
|
+
E + C > o && (E = Math.max(2, c - C - 14));
|
|
350
375
|
let D = a.y - T - 10;
|
|
351
|
-
D < 2 && (D = a.y + 10), D + T > r.y + r.h && (D = Math.max(2, a.y - T - 10)), e.fillStyle = "rgba(10,12,14,0.70)", e.beginPath(),
|
|
376
|
+
D < 2 && (D = a.y + 10), D + T > r.y + r.h && (D = Math.max(2, a.y - T - 10)), e.fillStyle = "rgba(10,12,14,0.70)", e.beginPath(), h(e, E, D, C, T, 6), e.fill(), e.strokeStyle = "rgba(255,255,255,0.08)", e.lineWidth = .8, e.beginPath(), h(e, E, D, C, T, 6), e.stroke();
|
|
352
377
|
let O = D + 10;
|
|
353
|
-
e.fillStyle = i.textColor, e.globalAlpha = .5, e.font = f, e.fillText("x", E + 10 + 8 + 8, O +
|
|
378
|
+
e.fillStyle = i.textColor, e.globalAlpha = .5, e.font = f, e.fillText("x", E + 10 + 8 + 8, O + m - 4), e.globalAlpha = 1, e.font = p, e.textAlign = "right", e.fillStyle = "rgba(255,255,255,0.85)", e.fillText(d(u), E + C - 10, O + m - 4);
|
|
354
379
|
let k = D + 10 + w + 1;
|
|
355
380
|
e.strokeStyle = "rgba(255,255,255,0.07)", e.lineWidth = 1, e.beginPath(), e.moveTo(E + 10, k), e.lineTo(E + C - 10, k), e.stroke();
|
|
356
381
|
for (let t = 0; t < s.length; t++) {
|
|
357
|
-
let n = s[t], r = D + 10 + w + 2 + t *
|
|
358
|
-
e.fillStyle = n.color, e.beginPath(), e.arc(E + 10 + 4, r +
|
|
382
|
+
let n = s[t], r = D + 10 + w + 2 + t * m;
|
|
383
|
+
e.fillStyle = n.color, e.beginPath(), e.arc(E + 10 + 4, r + m / 2, 4, 0, Math.PI * 2), e.fill(), e.font = f, e.textAlign = "left", e.fillStyle = "rgba(255,255,255,0.55)", e.fillText(n.label, E + 10 + 8 + 8, r + m - 4), e.font = p, e.textAlign = "right", e.fillStyle = "rgba(255,255,255,0.90)", e.fillText(d(n.yVal), E + C - 10, r + m - 4);
|
|
359
384
|
}
|
|
360
385
|
e.textAlign = "left", e.globalAlpha = 1;
|
|
361
386
|
}
|
|
362
387
|
//#endregion
|
|
363
388
|
//#region src/render/legend.ts
|
|
364
|
-
function
|
|
389
|
+
function v(e, t, n, r) {
|
|
365
390
|
if (t.length < 2) return;
|
|
366
391
|
e.font = `${r.fontSize}px ${r.fontFamily}`;
|
|
367
392
|
let i = t.map((t) => ({
|
|
@@ -370,7 +395,7 @@ function _(e, t, n, r) {
|
|
|
370
395
|
})), a = i.reduce((e, t) => e + t.width + (e > 0 ? 16 : 0), 0), o = Math.max(...i.map((e) => e.width)), s = a <= n.w - 16, c, l;
|
|
371
396
|
s ? (c = a + 20, l = r.fontSize + 14) : (c = o + 20, l = i.length * (r.fontSize + 6) + 14);
|
|
372
397
|
let u = n.x + n.w - c - 8, d = n.y + 8;
|
|
373
|
-
if (e.fillStyle = "rgba(10,12,14,0.70)", e.beginPath(),
|
|
398
|
+
if (e.fillStyle = "rgba(10,12,14,0.70)", e.beginPath(), h(e, u, d, c, l, 6), e.fill(), e.strokeStyle = "rgba(255,255,255,0.08)", e.lineWidth = .7, e.beginPath(), h(e, u, d, c, l, 6), e.stroke(), e.textAlign = "left", e.textBaseline = "middle", s) {
|
|
374
399
|
let t = u + 10;
|
|
375
400
|
for (let n = 0; n < i.length; n++) {
|
|
376
401
|
n > 0 && (t += 16);
|
|
@@ -388,18 +413,18 @@ function _(e, t, n, r) {
|
|
|
388
413
|
}
|
|
389
414
|
//#endregion
|
|
390
415
|
//#region src/render/stacked-band.ts
|
|
391
|
-
function
|
|
416
|
+
function y(e, t, n, r, i) {
|
|
392
417
|
let a = t[0].count;
|
|
393
418
|
if (a === 0) return;
|
|
394
|
-
let o = t[0], { xArr: s, cap: c } = o, l = i.xMax - i.xMin, u = i.yMax - i.yMin, d = l > 0 ? r.w / l : 0, f = r.x - i.xMin * d, p = u > 0 ? r.h / u : 0, m = r.y + r.h + i.yMin * p, h = r.y + r.h, g = r.y, _ = (e) => e < g ? g : e > h ? h : e, v = (e) => _(m - e * p),
|
|
419
|
+
let o = t[0], { xArr: s, cap: c } = o, l = i.xMax - i.xMin, u = i.yMax - i.yMin, d = l > 0 ? r.w / l : 0, f = r.x - i.xMin * d, p = u > 0 ? r.h / u : 0, m = r.y + r.h + i.yMin * p, h = r.y + r.h, g = r.y, _ = (e) => e < g ? g : e > h ? h : e, v = (e) => _(m - e * p), y = [], S = new Float64Array(a);
|
|
395
420
|
for (let e = 0; e < t.length; e++) {
|
|
396
421
|
let n = t[e], r = n.head, i = n.cap - n.head;
|
|
397
422
|
for (let e = 0; e < a; e++) S[e] += n.yArr[r], --i === 0 ? (r = 0, i = n.cap) : r++;
|
|
398
|
-
|
|
423
|
+
y.push(new Float64Array(S));
|
|
399
424
|
}
|
|
400
|
-
e.lineJoin = "round", a > r.w * 2 ?
|
|
425
|
+
e.lineJoin = "round", a > r.w * 2 ? x(e, y, n, s, o.head, c, f, d, v, h) : b(e, y, n, s, o.head, c, a, f, d, v, h);
|
|
401
426
|
}
|
|
402
|
-
function
|
|
427
|
+
function b(e, t, n, r, i, a, o, s, c, l, u) {
|
|
403
428
|
let d = new Float64Array(o), f = i, p = a - i;
|
|
404
429
|
for (let e = 0; e < o; e++) d[e] = s + r[f] * c, --p === 0 ? (f = 0, p = a) : f++;
|
|
405
430
|
for (let r = 0; r < t.length; r++) {
|
|
@@ -416,7 +441,7 @@ function y(e, t, n, r, i, a, o, s, c, l, u) {
|
|
|
416
441
|
e.stroke();
|
|
417
442
|
}
|
|
418
443
|
}
|
|
419
|
-
function
|
|
444
|
+
function x(e, t, n, r, i, a, o, s, c, l) {
|
|
420
445
|
let u = t[0].length, d = new Int32Array(u);
|
|
421
446
|
{
|
|
422
447
|
let e = i, t = a - i;
|
|
@@ -452,7 +477,7 @@ function b(e, t, n, r, i, a, o, s, c, l) {
|
|
|
452
477
|
}
|
|
453
478
|
//#endregion
|
|
454
479
|
//#region src/charts/chart-base.ts
|
|
455
|
-
var
|
|
480
|
+
var S = class {
|
|
456
481
|
opts;
|
|
457
482
|
surface;
|
|
458
483
|
stores;
|
|
@@ -473,10 +498,12 @@ var x = class {
|
|
|
473
498
|
hasRightAxis = !1;
|
|
474
499
|
stackGroupsAll;
|
|
475
500
|
stackGroupsByAxis;
|
|
501
|
+
stackWarned = /* @__PURE__ */ new Set();
|
|
476
502
|
dirty = !1;
|
|
477
503
|
cursorX = -1;
|
|
478
504
|
cursorY = -1;
|
|
479
505
|
showCrosshair = !1;
|
|
506
|
+
cursorLogical = -1;
|
|
480
507
|
autoDraw;
|
|
481
508
|
rafScheduled = 0;
|
|
482
509
|
suspendCount = 0;
|
|
@@ -484,6 +511,10 @@ var x = class {
|
|
|
484
511
|
resizeObserver = null;
|
|
485
512
|
destroyed = !1;
|
|
486
513
|
liveRegion = null;
|
|
514
|
+
reducedMotionMql = null;
|
|
515
|
+
handleReducedMotionChange = () => {
|
|
516
|
+
this.draw();
|
|
517
|
+
};
|
|
487
518
|
handleResize = () => this.onResize();
|
|
488
519
|
handleMouseMove = (e) => this.onMouseMove(e);
|
|
489
520
|
handleMouseLeave = () => this.onMouseLeave();
|
|
@@ -495,16 +526,16 @@ var x = class {
|
|
|
495
526
|
}, this.autoDraw = this.opts.autoDraw, this.seriesConfigs = this.opts.series.length > 0 ? this.opts.series : [{
|
|
496
527
|
name: "Series 0",
|
|
497
528
|
color: this.opts.lineColor
|
|
498
|
-
}], this.validateOpts(), this.surface = new
|
|
529
|
+
}], this.validateOpts(), this.surface = new a(t), this.stores = this.seriesConfigs.map(() => new r()), this.hasRightAxis = this.seriesConfigs.some((e) => e.yAxis === "right"), this.stackGroupsAll = this.computeAllStackGroups(), this.stackGroupsByAxis = {
|
|
499
530
|
left: this.computeStackGroupsOnAxis("left"),
|
|
500
531
|
right: this.computeStackGroupsOnAxis("right")
|
|
501
|
-
}, n?.maxPoints != null && n.maxPoints > 0) for (let e of this.stores) e.initRing(n.maxPoints);
|
|
502
|
-
(this.opts.yMin !== 0 || this.opts.yMax !== 0) && (this.gridDomainLeft.yMin = this.opts.yMin, this.gridDomainLeft.yMax = this.opts.yMax, this.gridDomainRight.yMin = this.opts.yMin, this.gridDomainRight.yMax = this.opts.yMax, this.gridPinned = !0), this.dirty = !0, this.attachEvents(), this.applySystemTheme(), this.ensureLiveRegion();
|
|
532
|
+
}, this.validateStackGroups(), n?.maxPoints != null && n.maxPoints > 0) for (let e of this.stores) e.initRing(n.maxPoints);
|
|
533
|
+
(this.opts.yMin !== void 0 || this.opts.yMax !== void 0) && (this.opts.yMin !== void 0 && (this.gridDomainLeft.yMin = this.opts.yMin), this.opts.yMax !== void 0 && (this.gridDomainLeft.yMax = this.opts.yMax), this.opts.yMin !== void 0 && (this.gridDomainRight.yMin = this.opts.yMin), this.opts.yMax !== void 0 && (this.gridDomainRight.yMax = this.opts.yMax), this.gridPinned = !0), this.dirty = !0, this.attachEvents(), this.applySystemTheme(), this.ensureLiveRegion();
|
|
503
534
|
}
|
|
504
535
|
validateOpts() {
|
|
505
536
|
this.opts.maxPoints < 0 && (console.warn(`[goro-charts] maxPoints must be >= 0, got ${this.opts.maxPoints}. Using 0.`), this.opts.maxPoints = 0), this.opts.fontSize < 6 && console.warn(`[goro-charts] fontSize ${this.opts.fontSize} is very small. Minimum recommended: 6.`);
|
|
506
537
|
let e = this.opts.padding;
|
|
507
|
-
e.some((e) => e < 0) && (console.warn(`[goro-charts] padding values must be >= 0, got [${e}]. Clamping to 0.`), this.opts.padding = e.map((e) => Math.max(0, e))), this.opts.yMin
|
|
538
|
+
e.some((e) => e < 0) && (console.warn(`[goro-charts] padding values must be >= 0, got [${e}]. Clamping to 0.`), this.opts.padding = e.map((e) => Math.max(0, e))), this.opts.yMin !== void 0 && this.opts.yMax !== void 0 && this.opts.yMin >= this.opts.yMax && (console.warn(`[goro-charts] yMin (${this.opts.yMin}) must be < yMax (${this.opts.yMax}). Swapping.`), [this.opts.yMin, this.opts.yMax] = [this.opts.yMax, this.opts.yMin]);
|
|
508
539
|
for (let e = 0; e < this.seriesConfigs.length; e++) {
|
|
509
540
|
let t = this.seriesConfigs[e];
|
|
510
541
|
(!t.name || t.name.trim() === "") && (console.warn(`[goro-charts] series[${e}] name is empty. Using "Series ${e}".`), this.seriesConfigs[e] = {
|
|
@@ -518,7 +549,8 @@ var x = class {
|
|
|
518
549
|
}
|
|
519
550
|
applySystemTheme() {
|
|
520
551
|
try {
|
|
521
|
-
|
|
552
|
+
let e = window.matchMedia("(prefers-reduced-motion: reduce)");
|
|
553
|
+
this.reducedMotionMql = e, e.addEventListener("change", this.handleReducedMotionChange), window.matchMedia("(prefers-contrast: more)").matches && (this.opts.gridColor === "rgba(255,255,255,0.08)" && (this.opts.gridColor = "rgba(255,255,255,0.25)"), this.opts.textColor === "rgba(255,255,255,0.5)" && (this.opts.textColor = "rgba(255,255,255,0.8)")), window.matchMedia("(forced-colors: active)").matches && (this.opts.textColor = "CanvasText", this.opts.bgColor = "Canvas", this.opts.gridColor = "GrayText", this.opts.axisColor = "GrayText", this.opts.crosshairColor = "GrayText");
|
|
522
554
|
} catch {}
|
|
523
555
|
}
|
|
524
556
|
ensureLiveRegion() {
|
|
@@ -532,38 +564,68 @@ var x = class {
|
|
|
532
564
|
count: e.count,
|
|
533
565
|
last: e.lastValue
|
|
534
566
|
})).filter((e) => e.count > 0), t;
|
|
535
|
-
t = e.length === 0 ? "Chart: no data" : `Chart: ${e.map((e) => `${e.config.name} ${
|
|
567
|
+
t = e.length === 0 ? "Chart: no data" : `Chart: ${e.map((e) => `${e.config.name} ${l(e.last)}`).join(", ")}`, this.surface.canvas.setAttribute("aria-label", t);
|
|
568
|
+
}
|
|
569
|
+
referenceSeriesIndex() {
|
|
570
|
+
for (let e = 0; e < this.stores.length; e++) if (this.stores[e].count > 0) return e;
|
|
571
|
+
return -1;
|
|
536
572
|
}
|
|
537
573
|
onKeyDown(e) {
|
|
538
574
|
if (document.activeElement !== this.surface.canvas) return;
|
|
539
|
-
let t = e.shiftKey ? 10 : 1, n = this.
|
|
575
|
+
let t = e.shiftKey ? 10 : 1, n = this.referenceSeriesIndex();
|
|
576
|
+
if (n < 0) return;
|
|
577
|
+
let r = this.stores[n].count;
|
|
540
578
|
switch (e.key) {
|
|
541
579
|
case "ArrowLeft":
|
|
542
|
-
e.preventDefault(), this.
|
|
580
|
+
e.preventDefault(), this.cursorLogical < 0 || this.cursorLogical >= r ? this.cursorLogical = r - 1 : this.cursorLogical = Math.max(0, this.cursorLogical - t);
|
|
543
581
|
break;
|
|
544
582
|
case "ArrowRight":
|
|
545
|
-
e.preventDefault(), this.
|
|
583
|
+
e.preventDefault(), this.cursorLogical < 0 || this.cursorLogical >= r ? this.cursorLogical = 0 : this.cursorLogical = Math.min(r - 1, this.cursorLogical + t);
|
|
546
584
|
break;
|
|
547
585
|
case "Escape":
|
|
548
586
|
e.preventDefault(), this.showCrosshair = !1, this.draw(), this.notifySyncCrosshairLeave();
|
|
549
|
-
|
|
587
|
+
return;
|
|
588
|
+
default: return;
|
|
550
589
|
}
|
|
590
|
+
let i = this.stores[n], a = i.xArr[i.physOf(this.cursorLogical)], o = this.plotRect(), s = (this.seriesConfigs[n].yAxis ?? "left") === "right" ? this.gridDomainRight : this.gridDomainLeft;
|
|
591
|
+
this.cursorX = u(a, s, o), this.showCrosshair = !0, this.draw(), this.notifySyncCrosshair();
|
|
551
592
|
}
|
|
552
593
|
notifySyncCrosshair() {
|
|
553
|
-
let e = this.
|
|
594
|
+
let e = f(this.cursorX, this.gridDomainLeft, this.plotRect());
|
|
554
595
|
for (let t of this.syncTargets) t.injectCursor(e);
|
|
555
596
|
}
|
|
556
597
|
notifySyncCrosshairLeave() {
|
|
557
598
|
for (let e of this.syncTargets) e.injectCursorLeave();
|
|
558
599
|
}
|
|
559
|
-
setData(e, t, n) {
|
|
560
|
-
|
|
600
|
+
setData(e, t, n, r) {
|
|
601
|
+
if (!this.destroyed) {
|
|
602
|
+
try {
|
|
603
|
+
this.storeAt(e).setData(t, n, r);
|
|
604
|
+
} catch (t) {
|
|
605
|
+
throw Error(`series ${e}: ${t.message}`, { cause: t });
|
|
606
|
+
}
|
|
607
|
+
this.gridPinned = !1, this.invalidate();
|
|
608
|
+
}
|
|
561
609
|
}
|
|
562
610
|
append(e, t, n) {
|
|
563
|
-
|
|
611
|
+
if (!this.destroyed) {
|
|
612
|
+
try {
|
|
613
|
+
this.storeAt(e).append(t, n);
|
|
614
|
+
} catch (t) {
|
|
615
|
+
throw Error(`series ${e}: ${t.message}`, { cause: t });
|
|
616
|
+
}
|
|
617
|
+
this.invalidate();
|
|
618
|
+
}
|
|
564
619
|
}
|
|
565
620
|
appendBatch(e, t, n) {
|
|
566
|
-
|
|
621
|
+
if (!this.destroyed) {
|
|
622
|
+
try {
|
|
623
|
+
this.storeAt(e).appendBatch(t, n);
|
|
624
|
+
} catch (t) {
|
|
625
|
+
throw Error(`series ${e}: ${t.message}`, { cause: t });
|
|
626
|
+
}
|
|
627
|
+
this.invalidate();
|
|
628
|
+
}
|
|
567
629
|
}
|
|
568
630
|
setMaxPoints(e) {
|
|
569
631
|
if (!this.destroyed) {
|
|
@@ -574,15 +636,20 @@ var x = class {
|
|
|
574
636
|
clear() {
|
|
575
637
|
if (!this.destroyed) {
|
|
576
638
|
for (let e of this.stores) e.clear();
|
|
577
|
-
this.gridPinned = !1, this.invalidate();
|
|
639
|
+
this.gridPinned = !1, this.stackWarned.clear(), this.invalidate();
|
|
578
640
|
}
|
|
579
641
|
}
|
|
580
642
|
get seriesCount() {
|
|
581
643
|
return this.destroyed ? 0 : this.stores.length;
|
|
582
644
|
}
|
|
583
|
-
get
|
|
645
|
+
get windowPointCount() {
|
|
584
646
|
return this.destroyed ? 0 : this.stores.reduce((e, t) => e + t.count, 0);
|
|
585
647
|
}
|
|
648
|
+
get drawnPointCount() {
|
|
649
|
+
if (this.destroyed) return 0;
|
|
650
|
+
let e = this.plotRect().w;
|
|
651
|
+
return e <= 0 ? this.windowPointCount : this.stores.reduce((t, n) => n.count === 0 ? t : t + (n.count > e * 2 ? Math.min(n.count, Math.ceil(e * 2)) : n.count), 0);
|
|
652
|
+
}
|
|
586
653
|
pointCount(e) {
|
|
587
654
|
return this.destroyed ? 0 : this.stores[e].count;
|
|
588
655
|
}
|
|
@@ -607,6 +674,9 @@ var x = class {
|
|
|
607
674
|
sync(e) {
|
|
608
675
|
this.destroyed || (this.syncTargets.add(e), e.syncTargets.add(this));
|
|
609
676
|
}
|
|
677
|
+
unsync(e) {
|
|
678
|
+
this.destroyed || (this.syncTargets.delete(e), e.syncTargets.delete(this));
|
|
679
|
+
}
|
|
610
680
|
onHover;
|
|
611
681
|
draw() {
|
|
612
682
|
if (this.destroyed || !this.dirty && !this.showCrosshair) return;
|
|
@@ -618,8 +688,10 @@ var x = class {
|
|
|
618
688
|
let { groups: t } = this.detectAllStackGroups(), r = /* @__PURE__ */ new Map();
|
|
619
689
|
for (let [, e] of t) {
|
|
620
690
|
if (e.length < 2) continue;
|
|
621
|
-
let t = this.accumulateStackGroup(e);
|
|
622
|
-
if (t
|
|
691
|
+
let { posCum: t, negCum: n } = this.accumulateStackGroup(e);
|
|
692
|
+
if (!t && !n) continue;
|
|
693
|
+
let i = t && n ? t.map((e, t) => e + n[t]) : t ?? n;
|
|
694
|
+
for (let t of e) r.set(t, new Float64Array(i));
|
|
623
695
|
}
|
|
624
696
|
let i = this.stores.map((e, t) => {
|
|
625
697
|
let n = this.seriesConfigs[t], i = (n.yAxis ?? "left") === "right" ? this.gridDomainRight : this.gridDomainLeft, a = i.yMin, o = i.yMax;
|
|
@@ -634,10 +706,10 @@ var x = class {
|
|
|
634
706
|
});
|
|
635
707
|
});
|
|
636
708
|
if (this.onHover || this.liveRegion) {
|
|
637
|
-
let e =
|
|
638
|
-
this.onHover && e.length > 0 && this.onHover(e), this.liveRegion && (this.liveRegion.textContent = e.length > 0 ? e.map((e) => `${e.label}: ${
|
|
709
|
+
let e = g(i, this.seriesConfigs, n, this.cursorX);
|
|
710
|
+
this.onHover && e.length > 0 && this.onHover(e), this.liveRegion && (this.liveRegion.textContent = e.length > 0 ? e.map((e) => `${e.label}: ${l(e.yVal)}`).join(", ") : "");
|
|
639
711
|
}
|
|
640
|
-
|
|
712
|
+
_(this.surface.ctx, i, this.seriesConfigs, n, this.opts, {
|
|
641
713
|
x: this.cursorX,
|
|
642
714
|
y: this.cursorY
|
|
643
715
|
}, e);
|
|
@@ -646,12 +718,16 @@ var x = class {
|
|
|
646
718
|
}
|
|
647
719
|
}
|
|
648
720
|
destroy() {
|
|
649
|
-
|
|
721
|
+
if (!this.destroyed) {
|
|
722
|
+
this.destroyed = !0, this.rafScheduled &&= (cancelAnimationFrame(this.rafScheduled), 0), this.resizeObserver?.disconnect(), this.resizeObserver = null, this.reducedMotionMql?.removeEventListener("change", this.handleReducedMotionChange), this.reducedMotionMql = null, this.surface.canvas.removeEventListener("mousemove", this.handleMouseMove), this.surface.canvas.removeEventListener("mouseleave", this.handleMouseLeave), this.surface.canvas.removeEventListener("keydown", this.handleKeyDown), this.liveRegion?.remove(), this.liveRegion = null;
|
|
723
|
+
for (let e of this.syncTargets) e.syncTargets.delete(this);
|
|
724
|
+
this.syncTargets.clear(), this.surface.dispose(), this.stores = [];
|
|
725
|
+
}
|
|
650
726
|
}
|
|
651
727
|
renderStatic(e) {
|
|
652
728
|
let t = this.surface.offscreenCtx(), { cssW: n, cssH: r } = this.surface;
|
|
653
729
|
if (t.clearRect(0, 0, n, r), t.fillStyle = this.opts.bgColor, t.fillRect(0, 0, n, r), this.stores.every((e) => e.count === 0)) return;
|
|
654
|
-
this.updateGridDomain(),
|
|
730
|
+
this.updateGridDomain(), p(t, this.gridDomainLeft, e, this.opts), m(t, this.gridDomainLeft, e, this.opts), this.hasRightAxis && m(t, this.gridDomainRight, e, this.opts, "right");
|
|
655
731
|
let { groups: i, stacked: a } = this.detectAllStackGroups();
|
|
656
732
|
for (let n = 0; n < this.stores.length; n++) {
|
|
657
733
|
if (a.has(n)) continue;
|
|
@@ -682,9 +758,9 @@ var x = class {
|
|
|
682
758
|
for (let i = 0; i < r.length; i++) this.renderOne(t, n[i], r[i], r[i].yArr, e);
|
|
683
759
|
continue;
|
|
684
760
|
}
|
|
685
|
-
|
|
761
|
+
y(t, r, i, e, (this.seriesConfigs[n[0]].yAxis ?? "left") === "right" ? this.gridDomainRight : this.gridDomainLeft);
|
|
686
762
|
}
|
|
687
|
-
|
|
763
|
+
v(t, this.seriesConfigs, e, this.opts);
|
|
688
764
|
}
|
|
689
765
|
renderOne(e, t, n, r, i) {
|
|
690
766
|
let a = this.seriesConfigs[t], o = {
|
|
@@ -743,20 +819,45 @@ var x = class {
|
|
|
743
819
|
stacked: t
|
|
744
820
|
};
|
|
745
821
|
}
|
|
822
|
+
validateStackGroups() {
|
|
823
|
+
for (let e = 0; e < this.stores.length; e++) {
|
|
824
|
+
let t = this.seriesConfigs[e].stack;
|
|
825
|
+
if (t) for (let n = e + 1; n < this.stores.length; n++) {
|
|
826
|
+
if (this.seriesConfigs[n].stack !== t) continue;
|
|
827
|
+
let r = this.seriesConfigs[e].yAxis ?? "left", i = this.seriesConfigs[n].yAxis ?? "left";
|
|
828
|
+
r !== i && console.warn(`[goro-charts] stack group "${t}" mixes axis ${r} (series ${e}) and ${i} (series ${n}). All series in a stack group must share the same yAxis.`);
|
|
829
|
+
}
|
|
830
|
+
}
|
|
831
|
+
}
|
|
746
832
|
accumulateStackGroup(e) {
|
|
747
833
|
let t = this.stores[e[0]].count;
|
|
748
|
-
if (t === 0) return
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
834
|
+
if (t === 0) return {
|
|
835
|
+
posCum: null,
|
|
836
|
+
negCum: null
|
|
837
|
+
};
|
|
838
|
+
for (let n of e) if (this.stores[n].count !== t && this.stores[n].count > 0) {
|
|
839
|
+
let r = `len:${e.join(",")}:${n}:${this.stores[n].count}:${t}`;
|
|
840
|
+
this.stackWarned.has(r) || (this.stackWarned.add(r), console.warn(`[goro-charts] stack accumulation skipped series ${n}: count=${this.stores[n].count} doesn't match group length ${t}.`));
|
|
753
841
|
}
|
|
754
|
-
|
|
842
|
+
let n = new Float64Array(t), r = new Float64Array(t), i = !1, a = !1;
|
|
843
|
+
for (let o of e) {
|
|
844
|
+
let e = this.stores[o];
|
|
845
|
+
if (e.count !== t) continue;
|
|
846
|
+
let s = e.head, c = e.cap - e.head;
|
|
847
|
+
for (let o = 0; o < t; o++) {
|
|
848
|
+
let t = e.yArr[s];
|
|
849
|
+
t > 0 ? (n[o] += t, i = !0) : t < 0 && (r[o] += t, a = !0), --c === 0 ? (s = 0, c = e.cap) : s++;
|
|
850
|
+
}
|
|
851
|
+
}
|
|
852
|
+
return {
|
|
853
|
+
posCum: i ? n : null,
|
|
854
|
+
negCum: a ? r : null
|
|
855
|
+
};
|
|
755
856
|
}
|
|
756
857
|
updateGridDomain() {
|
|
757
858
|
if (this.stores.every((e) => e.count === 0)) return;
|
|
758
|
-
let e = this.opts.yMin, t = this.opts.yMax, n = e !== 0 || t !== 0, r = this.stores.some((e) => e.isRing), i = () => {
|
|
759
|
-
n && (e !== 0 && (this.gridDomainLeft.yMin = e, this.gridDomainRight.yMin = e), t !== 0 && (this.gridDomainLeft.yMax = t, this.gridDomainRight.yMax = t));
|
|
859
|
+
let e = this.opts.yMin, t = this.opts.yMax, n = e !== void 0 || t !== void 0, r = this.stores.some((e) => e.isRing), i = () => {
|
|
860
|
+
n && (e !== void 0 && (this.gridDomainLeft.yMin = e, this.gridDomainRight.yMin = e), t !== void 0 && (this.gridDomainLeft.yMax = t, this.gridDomainRight.yMax = t));
|
|
760
861
|
};
|
|
761
862
|
if (r && !n) {
|
|
762
863
|
this.initDomain(this.gridDomainLeft, "left", .05), this.hasRightAxis && this.initDomain(this.gridDomainRight, "right", .05), this.refreshXDomain(), this.gridPinned = !0;
|
|
@@ -773,15 +874,17 @@ var x = class {
|
|
|
773
874
|
let { groups: r, stacked: i } = this.detectStackGroupsOnAxis(t);
|
|
774
875
|
for (let [, t] of r) {
|
|
775
876
|
if (t.length < 2) continue;
|
|
776
|
-
let n = this.accumulateStackGroup(t);
|
|
777
|
-
if (!n) continue;
|
|
778
|
-
let
|
|
877
|
+
let { posCum: n, negCum: r } = this.accumulateStackGroup(t);
|
|
878
|
+
if (!n && !r) continue;
|
|
879
|
+
let i = Infinity, a = -Infinity;
|
|
779
880
|
for (let n of t) {
|
|
780
881
|
let t = this.stores[n];
|
|
781
882
|
t.xMin < e.xMin && (e.xMin = t.xMin), t.xMax > e.xMax && (e.xMax = t.xMax);
|
|
782
883
|
}
|
|
783
|
-
|
|
784
|
-
|
|
884
|
+
let o = (e) => {
|
|
885
|
+
for (let t = 0; t < e.length; t++) e[t] < i && (i = e[t]), e[t] > a && (a = e[t]);
|
|
886
|
+
};
|
|
887
|
+
n && o(n), r && o(r), i < e.yMin && (e.yMin = i), a > e.yMax && (e.yMax = a);
|
|
785
888
|
}
|
|
786
889
|
for (let n = 0; n < this.stores.length; n++) {
|
|
787
890
|
if (i.has(n)) continue;
|
|
@@ -797,11 +900,12 @@ var x = class {
|
|
|
797
900
|
let n = e.yMax - e.yMin || 1, { groups: r, stacked: i } = this.detectStackGroupsOnAxis(t), a = !1;
|
|
798
901
|
for (let [, t] of r) {
|
|
799
902
|
if (t.length < 2) continue;
|
|
800
|
-
let r = this.accumulateStackGroup(t);
|
|
801
|
-
if (!r) continue;
|
|
802
|
-
let
|
|
803
|
-
|
|
804
|
-
|
|
903
|
+
let { posCum: r, negCum: i } = this.accumulateStackGroup(t);
|
|
904
|
+
if (!r && !i) continue;
|
|
905
|
+
let o = Infinity, s = -Infinity, c = (e) => {
|
|
906
|
+
for (let t = 0; t < e.length; t++) e[t] < o && (o = e[t]), e[t] > s && (s = e[t]);
|
|
907
|
+
};
|
|
908
|
+
r && c(r), i && c(i), o < e.yMin && (e.yMin = o - n * .1, a = !0), s > e.yMax && (e.yMax = s + n * .1, a = !0);
|
|
805
909
|
}
|
|
806
910
|
for (let r = 0; r < this.stores.length; r++) {
|
|
807
911
|
if (i.has(r)) continue;
|
|
@@ -841,8 +945,12 @@ var x = class {
|
|
|
841
945
|
return t;
|
|
842
946
|
}
|
|
843
947
|
injectCursor(e) {
|
|
844
|
-
let t = this.
|
|
845
|
-
|
|
948
|
+
let t = this.gridDomainLeft;
|
|
949
|
+
if (e < t.xMin || e > t.xMax) {
|
|
950
|
+
this.injectCursorLeave();
|
|
951
|
+
return;
|
|
952
|
+
}
|
|
953
|
+
this.cursorX = u(e, t, this.plotRect()), this.showCrosshair = !0, this.draw();
|
|
846
954
|
}
|
|
847
955
|
injectCursorLeave() {
|
|
848
956
|
this.showCrosshair = !1, this.draw();
|
|
@@ -863,7 +971,7 @@ var x = class {
|
|
|
863
971
|
};
|
|
864
972
|
//#endregion
|
|
865
973
|
//#region src/render/line.ts
|
|
866
|
-
function
|
|
974
|
+
function C(e, t, n, r) {
|
|
867
975
|
let { xArr: i, yArr: a, count: o, cap: s } = t;
|
|
868
976
|
if (o === 0) return;
|
|
869
977
|
e.strokeStyle = r.lineColor, e.lineWidth = r.lineWidth, e.lineJoin = "round", e.lineCap = "round", e.beginPath();
|
|
@@ -885,14 +993,14 @@ function S(e, t, n, r) {
|
|
|
885
993
|
}
|
|
886
994
|
//#endregion
|
|
887
995
|
//#region src/charts/line-chart.ts
|
|
888
|
-
var
|
|
996
|
+
var w = class extends S {
|
|
889
997
|
renderSeries(e, t, n, r) {
|
|
890
|
-
|
|
998
|
+
C(e, t, n, r);
|
|
891
999
|
}
|
|
892
1000
|
};
|
|
893
1001
|
//#endregion
|
|
894
1002
|
//#region src/render/area.ts
|
|
895
|
-
function
|
|
1003
|
+
function T(e, t, n, r) {
|
|
896
1004
|
let { xArr: i, yArr: a, count: o, cap: s } = t;
|
|
897
1005
|
if (o === 0) return;
|
|
898
1006
|
let c = t.xMax - t.xMin, l = t.yMax - t.yMin, u = c > 0 ? n.w / c : 0, d = n.x - t.xMin * u, f = l > 0 ? n.h / l : 0, p = n.y + n.h + t.yMin * f, m = n.y + n.h, h = t.head, g = s - t.head;
|
|
@@ -941,42 +1049,42 @@ function w(e, t, n, r) {
|
|
|
941
1049
|
}
|
|
942
1050
|
//#endregion
|
|
943
1051
|
//#region src/charts/area-chart.ts
|
|
944
|
-
var
|
|
1052
|
+
var E = class extends S {
|
|
945
1053
|
renderSeries(e, t, n, r) {
|
|
946
|
-
|
|
1054
|
+
T(e, t, n, r);
|
|
947
1055
|
}
|
|
948
1056
|
};
|
|
949
1057
|
//#endregion
|
|
950
1058
|
//#region src/render/scatter.ts
|
|
951
|
-
function
|
|
1059
|
+
function D(e, t, n) {
|
|
952
1060
|
let r = e + t;
|
|
953
1061
|
return r >= n ? r - n : r;
|
|
954
1062
|
}
|
|
955
|
-
function
|
|
1063
|
+
function O(e, t, n, r) {
|
|
956
1064
|
let { xArr: i, yArr: a, count: o, cap: s } = t;
|
|
957
1065
|
if (o === 0) return;
|
|
958
1066
|
let c = t.xMax - t.xMin, l = t.yMax - t.yMin, u = c > 0 ? n.w / c : 0, d = n.x - t.xMin * u, f = l > 0 ? n.h / l : 0, p = n.y + n.h + t.yMin * f, m = r.maxDots, h = o > m ? Math.max(1, Math.floor(o / m)) : 1, g = r.pointRadius, _ = t.head;
|
|
959
1067
|
e.fillStyle = r.lineColor, e.beginPath();
|
|
960
1068
|
for (let t = 0; t < o; t += h) {
|
|
961
1069
|
let t = d + i[_] * u, n = p - a[_] * f;
|
|
962
|
-
e.moveTo(t + g, n), e.arc(t, n, g, 0, Math.PI * 2), _ =
|
|
1070
|
+
e.moveTo(t + g, n), e.arc(t, n, g, 0, Math.PI * 2), _ = D(_, h, s);
|
|
963
1071
|
}
|
|
964
1072
|
e.fill();
|
|
965
1073
|
}
|
|
966
1074
|
//#endregion
|
|
967
1075
|
//#region src/charts/scatter-chart.ts
|
|
968
|
-
var
|
|
1076
|
+
var k = class extends S {
|
|
969
1077
|
renderSeries(e, t, n, r) {
|
|
970
|
-
|
|
1078
|
+
O(e, t, n, r);
|
|
971
1079
|
}
|
|
972
|
-
},
|
|
1080
|
+
}, A = {
|
|
973
1081
|
gridColor: "rgba(255,255,255,0.08)",
|
|
974
1082
|
axisColor: "rgba(255,255,255,0.25)",
|
|
975
1083
|
textColor: "rgba(255,255,255,0.5)",
|
|
976
1084
|
crosshairColor: "rgba(255,255,255,0.3)",
|
|
977
1085
|
pointColor: "#4ea8ff",
|
|
978
1086
|
bgColor: "#111"
|
|
979
|
-
},
|
|
1087
|
+
}, j = {
|
|
980
1088
|
gridColor: "rgba(0,0,0,0.08)",
|
|
981
1089
|
axisColor: "rgba(0,0,0,0.18)",
|
|
982
1090
|
textColor: "rgba(0,0,0,0.55)",
|
|
@@ -985,6 +1093,6 @@ var O = class extends x {
|
|
|
985
1093
|
bgColor: "#fff"
|
|
986
1094
|
};
|
|
987
1095
|
//#endregion
|
|
988
|
-
export {
|
|
1096
|
+
export { E as AreaChart, A as DARK, j as LIGHT, w as LineChart, k as ScatterChart };
|
|
989
1097
|
|
|
990
1098
|
//# sourceMappingURL=goro-charts.js.map
|