goro-charts 1.2.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.
@@ -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, r - this.count + 1);
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
- if (e.length !== t.length) throw Error("x and y must have same length");
139
- if (e.length === 0) throw Error("data arrays must not be empty");
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 i = t[e];
144
- i < n && (n = i), i > r && (r = i);
141
+ let n = t[e];
142
+ Number.isNaN(n) || (n < r && (r = n), n > i && (i = n));
145
143
  }
146
- this.applyExtent(n, r);
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
- n.count > 0 && e < n.xLast && console.warn(`[goro-charts] append x=${e} is < last x=${n.xLast}; x values must be monotonically increasing`), n.push(e, t), this.syncFromRing();
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
- for (let r = 0; r < e.length; r++) n.push(e[r], t[r]);
156
- this.syncFromRing();
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
- }, i = class {
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 a(e, t) {
260
+ function o(e, t) {
236
261
  let n = t - e;
237
262
  return n === 0 ? 1 : n;
238
263
  }
239
- function o(e, t) {
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 s(e, t, n) {
244
- let r = o(a(e, t), n), i = Math.ceil(e / r) * r, s = Math.floor(t / r) * r, c = [];
245
- for (let e = i; e <= s + r * .5; e += r) c.push(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 c(e) {
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 l(e, t, n) {
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 u(e, t, n) {
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 d(e, t, n) {
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 f(e, t, n, r) {
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 = s(t.yMin, t.yMax, r.yTicks);
300
+ let o = c(t.yMin, t.yMax, r.yTicks);
276
301
  e.beginPath();
277
302
  for (let r of o) {
278
- let o = u(r, t, n);
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 c = s(t.xMin, t.xMax, r.xTicks);
307
+ let s = c(t.xMin, t.xMax, r.xTicks);
283
308
  e.beginPath();
284
- for (let r of c) {
285
- let o = l(r, t, n);
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 p(e, t, n, r, i = "left") {
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 = s(t.yMin, t.yMax, r.yTicks);
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(c(r), o, u(r, t, n));
320
+ for (let r of a) e.fillText(l(r), o, d(r, t, n));
296
321
  if (i === "left") {
297
- let i = s(t.xMin, t.xMax, r.xTicks);
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(c(r), l(r, t, n), n.y + n.h + 6);
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 m(e, t, n, r, i, a) {
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 h(e, t, n, r) {
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 = d(r, o, n), f = o.bracketLogical(c), p = f + 1 < s ? f + 1 : s - 1, m = o.physOf(f), 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;
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: l(x, o, n),
321
- py: u(S, o, n),
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 g(e, t, n, r, i, a, o) {
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 = h(t, n, r, a.x);
357
+ let s = g(t, n, r, a.x);
333
358
  if (s.length === 0) return;
334
- let l = s[0].px, u = s[0].xVal;
335
- if (e.strokeStyle = i.crosshairColor, e.lineWidth = i.crosshairWidth, e.setLineDash([4, 3]), e.beginPath(), e.moveTo(l, r.y), e.lineTo(l, r.y + r.h), e.stroke(), e.setLineDash([]), s.length === 1) {
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) => c(e), f = `${i.fontSize}px ${i.fontFamily}`, p = `600 ${i.fontSize + 1}px ${i.fontFamily}`, g = i.fontSize + 6;
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 = g + 4, T = 20 + w + 2 + s.length * g, E = l + 14;
349
- E + C > o && (E = Math.max(2, l - C - 14));
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(), m(e, E, D, C, T, 6), e.fill(), e.strokeStyle = "rgba(255,255,255,0.08)", e.lineWidth = .8, e.beginPath(), m(e, E, D, C, T, 6), e.stroke();
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 + g - 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 + g - 4);
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 * g;
358
- e.fillStyle = n.color, e.beginPath(), e.arc(E + 10 + 4, r + g / 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 + g - 4), e.font = p, e.textAlign = "right", e.fillStyle = "rgba(255,255,255,0.90)", e.fillText(d(n.yVal), E + C - 10, r + g - 4);
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 _(e, t, n, r) {
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(), m(e, u, d, c, l, 6), e.fill(), e.strokeStyle = "rgba(255,255,255,0.08)", e.lineWidth = .7, e.beginPath(), m(e, u, d, c, l, 6), e.stroke(), e.textAlign = "left", e.textBaseline = "middle", s) {
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 v(e, t, n, r, i) {
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), x = [], S = new Float64Array(a);
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
- x.push(new Float64Array(S));
423
+ y.push(new Float64Array(S));
399
424
  }
400
- e.lineJoin = "round", a > r.w * 2 ? b(e, x, n, s, o.head, c, f, d, v, h) : y(e, x, n, s, o.head, c, a, f, d, v, h);
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 y(e, t, n, r, i, a, o, s, c, l, u) {
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 b(e, t, n, r, i, a, o, s, c, l) {
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 x = class {
480
+ var S = class {
456
481
  opts;
457
482
  surface;
458
483
  stores;
@@ -501,7 +526,7 @@ var x = class {
501
526
  }, this.autoDraw = this.opts.autoDraw, this.seriesConfigs = this.opts.series.length > 0 ? this.opts.series : [{
502
527
  name: "Series 0",
503
528
  color: this.opts.lineColor
504
- }], this.validateOpts(), this.surface = new i(t), this.stores = this.seriesConfigs.map(() => new r()), this.hasRightAxis = this.seriesConfigs.some((e) => e.yAxis === "right"), this.stackGroupsAll = this.computeAllStackGroups(), this.stackGroupsByAxis = {
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 = {
505
530
  left: this.computeStackGroupsOnAxis("left"),
506
531
  right: this.computeStackGroupsOnAxis("right")
507
532
  }, this.validateStackGroups(), n?.maxPoints != null && n.maxPoints > 0) for (let e of this.stores) e.initRing(n.maxPoints);
@@ -539,7 +564,7 @@ var x = class {
539
564
  count: e.count,
540
565
  last: e.lastValue
541
566
  })).filter((e) => e.count > 0), t;
542
- t = e.length === 0 ? "Chart: no data" : `Chart: ${e.map((e) => `${e.config.name} ${c(e.last)}`).join(", ")}`, this.surface.canvas.setAttribute("aria-label", t);
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);
543
568
  }
544
569
  referenceSeriesIndex() {
545
570
  for (let e = 0; e < this.stores.length; e++) if (this.stores[e].count > 0) return e;
@@ -563,23 +588,44 @@ var x = class {
563
588
  default: return;
564
589
  }
565
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;
566
- this.cursorX = l(a, s, o), this.showCrosshair = !0, this.draw(), this.notifySyncCrosshair();
591
+ this.cursorX = u(a, s, o), this.showCrosshair = !0, this.draw(), this.notifySyncCrosshair();
567
592
  }
568
593
  notifySyncCrosshair() {
569
- let e = d(this.cursorX, this.gridDomainLeft, this.plotRect());
594
+ let e = f(this.cursorX, this.gridDomainLeft, this.plotRect());
570
595
  for (let t of this.syncTargets) t.injectCursor(e);
571
596
  }
572
597
  notifySyncCrosshairLeave() {
573
598
  for (let e of this.syncTargets) e.injectCursorLeave();
574
599
  }
575
- setData(e, t, n) {
576
- this.destroyed || (this.storeAt(e).setData(t, n), this.gridPinned = !1, this.invalidate());
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
+ }
577
609
  }
578
610
  append(e, t, n) {
579
- this.destroyed || (this.storeAt(e).append(t, n), this.invalidate());
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
+ }
580
619
  }
581
620
  appendBatch(e, t, n) {
582
- this.destroyed || (this.storeAt(e).appendBatch(t, n), this.invalidate());
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
+ }
583
629
  }
584
630
  setMaxPoints(e) {
585
631
  if (!this.destroyed) {
@@ -660,10 +706,10 @@ var x = class {
660
706
  });
661
707
  });
662
708
  if (this.onHover || this.liveRegion) {
663
- let e = h(i, this.seriesConfigs, n, this.cursorX);
664
- this.onHover && e.length > 0 && this.onHover(e), this.liveRegion && (this.liveRegion.textContent = e.length > 0 ? e.map((e) => `${e.label}: ${c(e.yVal)}`).join(", ") : "");
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(", ") : "");
665
711
  }
666
- g(this.surface.ctx, i, this.seriesConfigs, n, this.opts, {
712
+ _(this.surface.ctx, i, this.seriesConfigs, n, this.opts, {
667
713
  x: this.cursorX,
668
714
  y: this.cursorY
669
715
  }, e);
@@ -681,7 +727,7 @@ var x = class {
681
727
  renderStatic(e) {
682
728
  let t = this.surface.offscreenCtx(), { cssW: n, cssH: r } = this.surface;
683
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;
684
- this.updateGridDomain(), f(t, this.gridDomainLeft, e, this.opts), p(t, this.gridDomainLeft, e, this.opts), this.hasRightAxis && p(t, this.gridDomainRight, e, this.opts, "right");
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");
685
731
  let { groups: i, stacked: a } = this.detectAllStackGroups();
686
732
  for (let n = 0; n < this.stores.length; n++) {
687
733
  if (a.has(n)) continue;
@@ -712,9 +758,9 @@ var x = class {
712
758
  for (let i = 0; i < r.length; i++) this.renderOne(t, n[i], r[i], r[i].yArr, e);
713
759
  continue;
714
760
  }
715
- v(t, r, i, e, (this.seriesConfigs[n[0]].yAxis ?? "left") === "right" ? this.gridDomainRight : this.gridDomainLeft);
761
+ y(t, r, i, e, (this.seriesConfigs[n[0]].yAxis ?? "left") === "right" ? this.gridDomainRight : this.gridDomainLeft);
716
762
  }
717
- _(t, this.seriesConfigs, e, this.opts);
763
+ v(t, this.seriesConfigs, e, this.opts);
718
764
  }
719
765
  renderOne(e, t, n, r, i) {
720
766
  let a = this.seriesConfigs[t], o = {
@@ -904,7 +950,7 @@ var x = class {
904
950
  this.injectCursorLeave();
905
951
  return;
906
952
  }
907
- this.cursorX = l(e, t, this.plotRect()), this.showCrosshair = !0, this.draw();
953
+ this.cursorX = u(e, t, this.plotRect()), this.showCrosshair = !0, this.draw();
908
954
  }
909
955
  injectCursorLeave() {
910
956
  this.showCrosshair = !1, this.draw();
@@ -925,7 +971,7 @@ var x = class {
925
971
  };
926
972
  //#endregion
927
973
  //#region src/render/line.ts
928
- function S(e, t, n, r) {
974
+ function C(e, t, n, r) {
929
975
  let { xArr: i, yArr: a, count: o, cap: s } = t;
930
976
  if (o === 0) return;
931
977
  e.strokeStyle = r.lineColor, e.lineWidth = r.lineWidth, e.lineJoin = "round", e.lineCap = "round", e.beginPath();
@@ -947,14 +993,14 @@ function S(e, t, n, r) {
947
993
  }
948
994
  //#endregion
949
995
  //#region src/charts/line-chart.ts
950
- var C = class extends x {
996
+ var w = class extends S {
951
997
  renderSeries(e, t, n, r) {
952
- S(e, t, n, r);
998
+ C(e, t, n, r);
953
999
  }
954
1000
  };
955
1001
  //#endregion
956
1002
  //#region src/render/area.ts
957
- function w(e, t, n, r) {
1003
+ function T(e, t, n, r) {
958
1004
  let { xArr: i, yArr: a, count: o, cap: s } = t;
959
1005
  if (o === 0) return;
960
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;
@@ -1003,42 +1049,42 @@ function w(e, t, n, r) {
1003
1049
  }
1004
1050
  //#endregion
1005
1051
  //#region src/charts/area-chart.ts
1006
- var T = class extends x {
1052
+ var E = class extends S {
1007
1053
  renderSeries(e, t, n, r) {
1008
- w(e, t, n, r);
1054
+ T(e, t, n, r);
1009
1055
  }
1010
1056
  };
1011
1057
  //#endregion
1012
1058
  //#region src/render/scatter.ts
1013
- function E(e, t, n) {
1059
+ function D(e, t, n) {
1014
1060
  let r = e + t;
1015
1061
  return r >= n ? r - n : r;
1016
1062
  }
1017
- function D(e, t, n, r) {
1063
+ function O(e, t, n, r) {
1018
1064
  let { xArr: i, yArr: a, count: o, cap: s } = t;
1019
1065
  if (o === 0) return;
1020
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;
1021
1067
  e.fillStyle = r.lineColor, e.beginPath();
1022
1068
  for (let t = 0; t < o; t += h) {
1023
1069
  let t = d + i[_] * u, n = p - a[_] * f;
1024
- e.moveTo(t + g, n), e.arc(t, n, g, 0, Math.PI * 2), _ = E(_, h, s);
1070
+ e.moveTo(t + g, n), e.arc(t, n, g, 0, Math.PI * 2), _ = D(_, h, s);
1025
1071
  }
1026
1072
  e.fill();
1027
1073
  }
1028
1074
  //#endregion
1029
1075
  //#region src/charts/scatter-chart.ts
1030
- var O = class extends x {
1076
+ var k = class extends S {
1031
1077
  renderSeries(e, t, n, r) {
1032
- D(e, t, n, r);
1078
+ O(e, t, n, r);
1033
1079
  }
1034
- }, k = {
1080
+ }, A = {
1035
1081
  gridColor: "rgba(255,255,255,0.08)",
1036
1082
  axisColor: "rgba(255,255,255,0.25)",
1037
1083
  textColor: "rgba(255,255,255,0.5)",
1038
1084
  crosshairColor: "rgba(255,255,255,0.3)",
1039
1085
  pointColor: "#4ea8ff",
1040
1086
  bgColor: "#111"
1041
- }, A = {
1087
+ }, j = {
1042
1088
  gridColor: "rgba(0,0,0,0.08)",
1043
1089
  axisColor: "rgba(0,0,0,0.18)",
1044
1090
  textColor: "rgba(0,0,0,0.55)",
@@ -1047,6 +1093,6 @@ var O = class extends x {
1047
1093
  bgColor: "#fff"
1048
1094
  };
1049
1095
  //#endregion
1050
- export { T as AreaChart, k as DARK, A as LIGHT, C as LineChart, O as ScatterChart };
1096
+ export { E as AreaChart, A as DARK, j as LIGHT, w as LineChart, k as ScatterChart };
1051
1097
 
1052
1098
  //# sourceMappingURL=goro-charts.js.map