@cfasim-ui/charts 0.3.18 → 0.4.1

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 CHANGED
@@ -1,38 +1,30 @@
1
- import { Fragment as e, computed as t, createBlock as n, createCommentVNode as r, createElementBlock as i, createElementVNode as a, createTextVNode as o, createVNode as s, defineComponent as c, guardReactiveProps as l, normalizeClass as u, normalizeProps as ee, normalizeStyle as d, onMounted as te, onUnmounted as ne, openBlock as f, ref as p, renderList as m, renderSlot as h, toDisplayString as g, toRaw as _, unref as v, useId as y, watch as re, withCtx as b, withModifiers as x } from "vue";
2
- import { DropdownMenuContent as S, DropdownMenuItem as C, DropdownMenuPortal as ie, DropdownMenuRoot as w, DropdownMenuTrigger as T, PopoverAnchor as E, PopoverContent as D, PopoverPortal as O, PopoverRoot as ae } from "reka-ui";
3
- import { geoAlbersUsa as oe, geoPath as k } from "d3-geo";
4
- import { zoom as A } from "d3-zoom";
5
- import { select as se } from "d3-selection";
6
- import { feature as j, merge as M, mesh as N } from "topojson-client";
1
+ import { Fragment as e, computed as t, createBlock as n, createCommentVNode as r, createElementBlock as i, createElementVNode as a, createTextVNode as o, createVNode as s, defineComponent as c, guardReactiveProps as l, mergeProps as u, normalizeClass as d, normalizeProps as f, normalizeStyle as p, onMounted as ee, onUnmounted as m, openBlock as h, ref as g, renderList as _, renderSlot as v, toDisplayString as y, toHandlers as te, toRaw as b, unref as x, useId as S, watch as ne, withCtx as C } from "vue";
2
+ import { DropdownMenuContent as w, DropdownMenuItem as T, DropdownMenuPortal as re, DropdownMenuRoot as E, DropdownMenuTrigger as D, PopoverAnchor as O, PopoverContent as k, PopoverPortal as A, PopoverRoot as j } from "reka-ui";
3
+ import { geoAlbersUsa as M, geoPath as N } from "d3-geo";
4
+ import { zoom as P } from "d3-zoom";
5
+ import { select as F } from "d3-selection";
6
+ import { feature as I, merge as L, mesh as ie } from "topojson-client";
7
7
  //#region src/ChartMenu/ChartMenu.vue?vue&type=script&setup=true&lang.ts
8
- var P = { class: "chart-menu-trigger-area" }, ce = ["aria-label"], F = /* @__PURE__ */ c({
8
+ var R = { class: "chart-menu-trigger-area" }, ae = ["aria-label"], z = /* @__PURE__ */ c({
9
9
  __name: "ChartMenu",
10
- props: { items: {} },
10
+ props: {
11
+ items: {},
12
+ forceDropdown: {
13
+ type: Boolean,
14
+ default: !1
15
+ }
16
+ },
11
17
  setup(t) {
12
- return (r, c) => (f(), i("div", P, [t.items.length === 1 ? (f(), i("button", {
13
- key: 0,
14
- class: "chart-menu-button chart-menu-single",
15
- "aria-label": t.items[0].label,
16
- onClick: c[0] ||= (...e) => t.items[0].action && t.items[0].action(...e)
17
- }, [...c[1] ||= [a("svg", {
18
- width: "14",
19
- height: "14",
20
- viewBox: "0 0 14 14",
21
- fill: "none",
22
- stroke: "currentColor",
23
- "stroke-width": "1.5",
24
- "stroke-linecap": "round",
25
- "stroke-linejoin": "round",
26
- "aria-hidden": "true"
27
- }, [a("path", { d: "M7 1v8M3 6l4 4 4-4M2 13h10" })], -1)]], 8, ce)) : (f(), n(v(w), {
18
+ let r = t, c = () => r.forceDropdown || r.items.length > 1;
19
+ return (r, l) => (h(), i("div", R, [c() ? (h(), n(x(E), {
28
20
  key: 1,
29
21
  modal: !1
30
22
  }, {
31
- default: b(() => [s(v(T), {
23
+ default: C(() => [s(x(D), {
32
24
  class: "chart-menu-button",
33
25
  "aria-label": "Chart options"
34
26
  }, {
35
- default: b(() => [...c[2] ||= [a("svg", {
27
+ default: C(() => [...l[2] ||= [a("svg", {
36
28
  width: "16",
37
29
  height: "16",
38
30
  viewBox: "0 0 16 16",
@@ -56,18 +48,18 @@ var P = { class: "chart-menu-trigger-area" }, ce = ["aria-label"], F = /* @__PUR
56
48
  })
57
49
  ], -1)]]),
58
50
  _: 1
59
- }), s(v(ie), null, {
60
- default: b(() => [s(v(S), {
51
+ }), s(x(re), null, {
52
+ default: C(() => [s(x(w), {
61
53
  class: "chart-menu-content",
62
54
  "side-offset": 4,
63
55
  align: "end"
64
56
  }, {
65
- default: b(() => [(f(!0), i(e, null, m(t.items, (e) => (f(), n(v(C), {
57
+ default: C(() => [(h(!0), i(e, null, _(t.items, (e) => (h(), n(x(T), {
66
58
  key: e.label,
67
59
  class: "chart-menu-item",
68
60
  onSelect: e.action
69
61
  }, {
70
- default: b(() => [o(g(e.label), 1)]),
62
+ default: C(() => [o(y(e.label), 1)]),
71
63
  _: 2
72
64
  }, 1032, ["onSelect"]))), 128))]),
73
65
  _: 1
@@ -75,26 +67,195 @@ var P = { class: "chart-menu-trigger-area" }, ce = ["aria-label"], F = /* @__PUR
75
67
  _: 1
76
68
  })]),
77
69
  _: 1
78
- }))]));
70
+ })) : (h(), i("button", {
71
+ key: 0,
72
+ class: "chart-menu-button chart-menu-single",
73
+ "aria-label": t.items[0].label,
74
+ onClick: l[0] ||= (...e) => t.items[0].action && t.items[0].action(...e)
75
+ }, [...l[1] ||= [a("svg", {
76
+ width: "14",
77
+ height: "14",
78
+ viewBox: "0 0 14 14",
79
+ fill: "none",
80
+ stroke: "currentColor",
81
+ "stroke-width": "1.5",
82
+ "stroke-linecap": "round",
83
+ "stroke-linejoin": "round",
84
+ "aria-hidden": "true"
85
+ }, [a("path", { d: "M7 1v8M3 6l4 4 4-4M2 13h10" })], -1)]], 8, ae))]));
79
86
  }
80
- }), I = (e, t) => {
87
+ }), B = (e, t) => {
81
88
  let n = e.__vccOpts || e;
82
89
  for (let [e, r] of t) n[e] = r;
83
90
  return n;
84
- }, le = /* @__PURE__ */ I(F, [["__scopeId", "data-v-fe2f6904"]]);
91
+ }, oe = /* @__PURE__ */ B(z, [["__scopeId", "data-v-b3c563e8"]]);
92
+ //#endregion
93
+ //#region src/_shared/axes.ts
94
+ function V(e) {
95
+ return Math.round(e) + .5;
96
+ }
97
+ function H(e, t) {
98
+ let n = e / t, r = 10 ** Math.floor(Math.log10(n)), i = n / r, a;
99
+ return a = i <= 1.5 ? 1 : i <= 3 ? 2 : i <= 7 ? 5 : 10, a * r;
100
+ }
101
+ function se(e, t, n) {
102
+ if (!(n > 0) || !isFinite(n)) return [];
103
+ let r = [], i = Math.ceil(e / n) * n;
104
+ for (let e = 0, a = i; a <= t + 1e-9 && e < 1e3; e++, a = i + e * n) r.push(a);
105
+ return r;
106
+ }
107
+ var U = new Intl.NumberFormat();
108
+ function W(e) {
109
+ return Math.abs(e) >= 1e3 ? U.format(e) : Number.isInteger(e) ? e.toString() : e.toFixed(1);
110
+ }
111
+ //#endregion
112
+ //#region src/_shared/computeTicks.ts
113
+ function ce(e) {
114
+ let { min: t, max: n, ticks: r } = e;
115
+ if (t === n) return [];
116
+ let i = e.displayOffset ?? 0;
117
+ if (Array.isArray(r)) return r.map((e) => e - i).filter((e) => e >= t && e <= n);
118
+ if (typeof r == "number") return se(t + i, n + i, r).map((e) => e - i);
119
+ let a = Math.max(3, Math.floor(e.targetTickCount ?? 3)), o = H(n - t, a);
120
+ return se(t + i, n + i, o).map((e) => e - i);
121
+ }
122
+ //#endregion
123
+ //#region src/_shared/useChartSize.ts
124
+ function G(e = {}) {
125
+ let t = g(null), n = g(0), r = null, i = null;
126
+ return ee(() => {
127
+ t.value && (n.value = t.value.clientWidth, r = new ResizeObserver((t) => {
128
+ let r = t[0];
129
+ if (!r) return;
130
+ let a = e.debounce?.();
131
+ a ? (i && clearTimeout(i), i = setTimeout(() => {
132
+ n.value = r.contentRect.width;
133
+ }, a)) : n.value = r.contentRect.width;
134
+ }), r.observe(t.value));
135
+ }), m(() => {
136
+ r?.disconnect(), i && clearTimeout(i);
137
+ }), {
138
+ containerRef: t,
139
+ measuredWidth: n
140
+ };
141
+ }
142
+ function K(e) {
143
+ let n = t(() => ({
144
+ top: (e.title() ? 30 : 10) + (e.hasInlineLegend() ? 20 : 0),
145
+ right: 10,
146
+ bottom: e.xLabel() ? 46 : 30,
147
+ left: e.yLabel() ? 66 : 50
148
+ }));
149
+ return {
150
+ padding: n,
151
+ innerW: t(() => e.width() - n.value.left - n.value.right),
152
+ innerH: t(() => e.height() - n.value.top - n.value.bottom)
153
+ };
154
+ }
155
+ //#endregion
156
+ //#region src/tooltip-position.ts
157
+ var q = 16, J = 8;
158
+ function le(e, t, n, r, i, a) {
159
+ if (i === "none") return {
160
+ left: e + q,
161
+ top: t
162
+ };
163
+ let o = i === "chart" && a ? {
164
+ left: a.left,
165
+ right: a.right,
166
+ top: a.top,
167
+ bottom: a.bottom
168
+ } : {
169
+ left: 0,
170
+ right: window.innerWidth,
171
+ top: 0,
172
+ bottom: window.innerHeight
173
+ }, s = e + q + n > o.right - J ? e - q - n : e + q, c = r / 2;
174
+ return {
175
+ left: s,
176
+ top: Math.min(Math.max(t, o.top + J + c), o.bottom - J - c)
177
+ };
178
+ }
179
+ //#endregion
180
+ //#region src/_shared/useChartTooltip.ts
181
+ function ue(e) {
182
+ let t = e.touchYOffset ?? 50, n = g(null), r = g(!1), i = g(null), a = g(null), o = g(null);
183
+ function s(e) {
184
+ return "touches" in e ? e.touches[0] ?? null : e;
185
+ }
186
+ function c(t) {
187
+ let r = s(t);
188
+ if (!r) return;
189
+ let i = e.pointerToIndex(r.clientX, r.clientY);
190
+ i !== null && (n.value = i, a.value = {
191
+ clientX: r.clientX,
192
+ clientY: r.clientY
193
+ }, e.onHover?.({ index: i }));
194
+ }
195
+ ne([a, n], () => {
196
+ if (n.value === null || !a.value) {
197
+ o.value = null;
198
+ return;
199
+ }
200
+ let s = i.value, c = e.containerRef.value;
201
+ if (!s || !c) return;
202
+ let l = c.getBoundingClientRect(), u = r.value ? t : 0, d = e.clamp?.() ?? "chart", { left: f, top: p } = le(a.value.clientX, a.value.clientY - u, s.offsetWidth, s.offsetHeight, d, l);
203
+ o.value = {
204
+ left: f - l.left,
205
+ top: p - l.top
206
+ };
207
+ }, { flush: "post" });
208
+ function l(t) {
209
+ e.enabled() && c(t);
210
+ }
211
+ function u() {
212
+ e.enabled() && e.trigger?.() !== "click" && (n.value = null, e.onHover?.(null));
213
+ }
214
+ function d(t) {
215
+ if (!e.enabled() || e.trigger?.() !== "click") return;
216
+ let r = s(t);
217
+ if (!r) return;
218
+ let i = e.pointerToIndex(r.clientX, r.clientY);
219
+ i !== null && (n.value = n.value === i ? null : i, e.onHover?.(n.value === null ? null : { index: i }));
220
+ }
221
+ function f(t) {
222
+ e.enabled() && (t.preventDefault(), r.value = !0, c(t));
223
+ }
224
+ function p(t) {
225
+ e.enabled() && (t.preventDefault(), c(t));
226
+ }
227
+ function ee() {
228
+ e.enabled() && (r.value = !1, n.value = null, e.onHover?.(null));
229
+ }
230
+ return {
231
+ hoverIndex: n,
232
+ isTouching: r,
233
+ pointer: a,
234
+ tooltipRef: i,
235
+ tooltipPos: o,
236
+ handlers: {
237
+ mousemove: l,
238
+ mouseleave: u,
239
+ click: d,
240
+ touchstart: f,
241
+ touchmove: p,
242
+ touchend: ee
243
+ }
244
+ };
245
+ }
85
246
  //#endregion
86
247
  //#region src/ChartMenu/download.ts
87
- function L(e, t) {
248
+ function Y(e, t) {
88
249
  let n = URL.createObjectURL(e), r = document.createElement("a");
89
250
  r.href = n, r.download = t, r.click(), URL.revokeObjectURL(n);
90
251
  }
91
- function ue(e, t) {
252
+ function de(e, t) {
92
253
  let n = e.cloneNode(!0);
93
254
  n.setAttribute("xmlns", "http://www.w3.org/2000/svg");
94
255
  let r = new XMLSerializer().serializeToString(n);
95
- L(new Blob([r], { type: "image/svg+xml" }), `${t}.svg`);
256
+ Y(new Blob([r], { type: "image/svg+xml" }), `${t}.svg`);
96
257
  }
97
- function de(e, t) {
258
+ function X(e, t) {
98
259
  let n = e.cloneNode(!0);
99
260
  n.setAttribute("xmlns", "http://www.w3.org/2000/svg");
100
261
  let r = new XMLSerializer().serializeToString(n), i = new Blob([r], { type: "image/svg+xml;charset=utf-8" }), a = URL.createObjectURL(i), o = new Image(), s = e.width.baseVal.value || e.clientWidth, c = e.height.baseVal.value || e.clientHeight;
@@ -103,103 +264,143 @@ function de(e, t) {
103
264
  e.width = s * 2, e.height = c * 2;
104
265
  let n = e.getContext("2d");
105
266
  n.scale(2, 2), n.drawImage(o, 0, 0, s, c), e.toBlob((e) => {
106
- e && L(e, `${t}.png`);
267
+ e && Y(e, `${t}.png`);
107
268
  }), URL.revokeObjectURL(a);
108
269
  }, o.src = a;
109
270
  }
110
271
  function fe(e, t) {
111
- L(new Blob([e], { type: "text/csv" }), `${t}.csv`);
272
+ Y(new Blob([e], { type: "text/csv" }), `${t}.csv`);
112
273
  }
113
274
  //#endregion
114
- //#region src/tooltip-position.ts
115
- var R = 16, z = 8;
116
- function pe(e, t, n, r, i, a) {
117
- if (i === "none") return {
118
- left: e + R,
119
- top: t
120
- };
121
- let o = i === "chart" && a ? {
122
- left: a.left,
123
- right: a.right,
124
- top: a.top,
125
- bottom: a.bottom
126
- } : {
127
- left: 0,
128
- right: window.innerWidth,
129
- top: 0,
130
- bottom: window.innerHeight
131
- }, s = e + R + n > o.right - z ? e - R - n : e + R, c = r / 2;
275
+ //#region src/_shared/useChartMenu.ts
276
+ function pe(e) {
277
+ let n = g(null);
278
+ function r() {
279
+ let t = e.filename();
280
+ if (t) return t;
281
+ let n = e.legacyMenuLabel();
282
+ return typeof n == "string" ? n : "chart";
283
+ }
132
284
  return {
133
- left: s,
134
- top: Math.min(Math.max(t, o.top + z + c), o.bottom - z - c)
285
+ svgRef: n,
286
+ items: t(() => {
287
+ let t = r(), i = [{
288
+ label: "Save as SVG",
289
+ action: () => {
290
+ n.value && de(n.value, t);
291
+ }
292
+ }, {
293
+ label: "Save as PNG",
294
+ action: () => {
295
+ n.value && X(n.value, t);
296
+ }
297
+ }];
298
+ return e.downloadLink() || i.push({
299
+ label: "Download CSV",
300
+ action: () => fe(e.getCsv(), t)
301
+ }), i;
302
+ }),
303
+ downloadLinkText: t(() => {
304
+ let t = e.downloadLink();
305
+ return t ? typeof t == "string" ? t : "Download data (CSV)" : null;
306
+ }),
307
+ csvHref: t(() => e.downloadLink() ? `data:text/csv;charset=utf-8,${encodeURIComponent(e.getCsv())}` : null),
308
+ resolvedFilename: r
135
309
  };
136
310
  }
137
311
  //#endregion
312
+ //#region src/_shared/seriesCsv.ts
313
+ function me(e) {
314
+ if (e.length === 0) return "";
315
+ let t = 0;
316
+ for (let n of e) n.data.length > t && (t = n.data.length);
317
+ let n = e.every((t) => t.x === e[0].x) ? e[0].x : void 0, r = n ? "x" : "index", i = [(e.length === 1 ? [r, "value"] : [r, ...e.map((e, t) => `series_${t}`)]).join(",")];
318
+ for (let r = 0; r < t; r++) {
319
+ let t = [n ? String(n[r]) : r.toString()];
320
+ for (let n of e) t.push(r < n.data.length ? String(n.data[r]) : "");
321
+ i.push(t.join(","));
322
+ }
323
+ return i.join("\n");
324
+ }
325
+ function Z(e, t, n = "category") {
326
+ if (t.length === 0 || e.length === 0) return "";
327
+ let r = [(t.length === 1 ? [n, t[0].label || "value"] : [n, ...t.map((e, t) => e.label || `series_${t}`)]).join(",")];
328
+ for (let n = 0; n < e.length; n++) {
329
+ let i = [Q(e[n])];
330
+ for (let e of t) i.push(n < e.data.length ? String(e.data[n]) : "");
331
+ r.push(i.join(","));
332
+ }
333
+ return r.join("\n");
334
+ }
335
+ function Q(e) {
336
+ return e.includes(",") || e.includes("\"") || e.includes("\n") ? `"${e.replace(/"/g, "\"\"")}"` : e;
337
+ }
338
+ //#endregion
138
339
  //#region src/LineChart/LineChart.vue?vue&type=script&setup=true&lang.ts
139
- var B = ["width", "height"], me = ["x"], he = { key: 1 }, V = [
340
+ var he = ["width", "height"], ge = ["x"], _e = { key: 1 }, ve = [
140
341
  "x1",
141
342
  "y1",
142
343
  "x2",
143
344
  "y2",
144
345
  "stroke",
145
346
  "stroke-dasharray"
146
- ], H = [
347
+ ], ye = [
147
348
  "cx",
148
349
  "cy",
149
350
  "fill",
150
351
  "fill-opacity",
151
352
  "stroke"
152
- ], ge = ["x", "y"], _e = [
353
+ ], be = ["x", "y"], xe = [
153
354
  "x1",
154
355
  "y1",
155
356
  "x2",
156
357
  "y2"
157
- ], ve = [
358
+ ], $ = [
158
359
  "x1",
159
360
  "y1",
160
361
  "x2",
161
362
  "y2"
162
- ], ye = [
363
+ ], Se = [
163
364
  "x1",
164
365
  "y1",
165
366
  "x2",
166
367
  "y2"
167
- ], be = [
368
+ ], Ce = [
168
369
  "x1",
169
370
  "y1",
170
371
  "x2",
171
372
  "y2"
172
- ], xe = ["x", "y"], Se = ["transform"], U = [
373
+ ], we = ["x", "y"], Te = ["transform"], Ee = [
173
374
  "x",
174
375
  "y",
175
376
  "text-anchor"
176
- ], W = ["x", "y"], Ce = [
377
+ ], De = ["x", "y"], Oe = [
177
378
  "d",
178
379
  "fill",
179
380
  "fill-opacity"
180
- ], we = [
381
+ ], ke = [
181
382
  "d",
182
383
  "stroke",
183
384
  "stroke-width",
184
385
  "stroke-opacity",
185
386
  "stroke-dasharray"
186
- ], Te = [
387
+ ], Ae = [
187
388
  "cx",
188
389
  "cy",
189
390
  "r",
190
391
  "fill",
191
392
  "fill-opacity",
192
393
  "stroke"
193
- ], Ee = [
394
+ ], je = [
194
395
  "d",
195
396
  "fill",
196
397
  "fill-opacity"
197
- ], De = [
398
+ ], Me = [
198
399
  "d",
199
400
  "stroke",
200
401
  "stroke-width",
201
402
  "stroke-dasharray"
202
- ], Oe = [
403
+ ], Ne = [
203
404
  "x1",
204
405
  "y1",
205
406
  "x2",
@@ -207,7 +408,7 @@ var B = ["width", "height"], me = ["x"], he = { key: 1 }, V = [
207
408
  "stroke",
208
409
  "stroke-width",
209
410
  "stroke-dasharray"
210
- ], G = [
411
+ ], Pe = [
211
412
  "x1",
212
413
  "y1",
213
414
  "x2",
@@ -215,44 +416,44 @@ var B = ["width", "height"], me = ["x"], he = { key: 1 }, V = [
215
416
  "stroke",
216
417
  "stroke-width",
217
418
  "stroke-dasharray"
218
- ], ke = [
419
+ ], Fe = [
219
420
  "x1",
220
421
  "y1",
221
422
  "x2",
222
423
  "y2"
223
- ], Ae = [
424
+ ], Ie = [
224
425
  "x1",
225
426
  "y1",
226
427
  "x2",
227
428
  "y2"
228
- ], je = [
429
+ ], Le = [
229
430
  "x1",
230
431
  "y1",
231
432
  "x2",
232
433
  "y2"
233
- ], Me = [
434
+ ], Re = [
234
435
  "cx",
235
436
  "cy",
236
437
  "fill"
237
- ], Ne = [
438
+ ], ze = [
238
439
  "x",
239
440
  "y",
240
441
  "width",
241
442
  "height"
242
- ], Pe = [
443
+ ], Be = [
243
444
  "cx",
244
445
  "cy",
245
446
  "fill",
246
447
  "fill-opacity",
247
448
  "stroke"
248
- ], Fe = [
449
+ ], Ve = [
249
450
  "x",
250
451
  "y",
251
452
  "fill"
252
- ], Ie = ["x", "y"], Le = { class: "line-chart-tooltip" }, Re = {
453
+ ], He = ["x", "y"], Ue = { class: "line-chart-tooltip" }, We = {
253
454
  key: 0,
254
455
  class: "line-chart-tooltip-label"
255
- }, ze = ["href", "download"], K = 20, q = 36, Be = 12, Ve = 7, He = 16, Ue = 50, J = /* @__PURE__ */ I(/* @__PURE__ */ c({
456
+ }, Ge = ["href", "download"], Ke = 36, qe = 12, Je = 7, Ye = 16, Xe = /* @__PURE__ */ B(/* @__PURE__ */ c({
256
457
  __name: "LineChart",
257
458
  props: {
258
459
  y: {},
@@ -273,6 +474,7 @@ var B = ["width", "height"], me = ["x"], he = { key: 1 }, V = [
273
474
  yTicks: {},
274
475
  xTickFormat: {},
275
476
  yTickFormat: {},
477
+ tooltipValueFormat: {},
276
478
  xLabels: {},
277
479
  debounce: {},
278
480
  menu: {
@@ -290,55 +492,49 @@ var B = ["width", "height"], me = ["x"], he = { key: 1 }, V = [
290
492
  },
291
493
  emits: ["hover"],
292
494
  setup(s, { emit: c }) {
293
- let u = s, _ = c, v = p(null), y = p(null), b = p(0), S = null, C = null;
294
- te(() => {
295
- v.value && (b.value = v.value.clientWidth, S = new ResizeObserver((e) => {
296
- let t = e[0];
297
- t && (u.debounce ? (C && clearTimeout(C), C = setTimeout(() => {
298
- b.value = t.contentRect.width;
299
- }, u.debounce)) : b.value = t.contentRect.width);
300
- }), S.observe(v.value));
301
- }), ne(() => {
302
- S?.disconnect(), C && clearTimeout(C);
303
- });
304
- let ie = t(() => u.width ?? (b.value || 400)), w = t(() => u.height ?? 200), T = t(() => k.value.some((e) => e.legend) || u.areaSections?.some((e) => e.legend === "inline" && (e.label || e.description))), E = t(() => ({
305
- top: (u.title ? 30 : 10) + (T.value ? K : 0),
306
- right: 10,
307
- bottom: u.xLabel ? 46 : 30,
308
- left: u.yLabel ? 66 : 50
309
- })), D = t(() => ie.value - E.value.left - E.value.right), O = t(() => w.value - E.value.top - E.value.bottom), ae = [];
310
- function oe(e) {
495
+ let d = s, ee = c, { containerRef: m, measuredWidth: g } = G({ debounce: () => d.debounce }), b = t(() => d.width ?? (g.value || 400)), S = t(() => d.height ?? 200), ne = t(() => O.value.some((e) => e.legend) || d.areaSections?.some((e) => e.legend === "inline" && (e.label || e.description)) || !1), { padding: C, innerW: w, innerH: T } = K({
496
+ title: () => d.title,
497
+ xLabel: () => d.xLabel,
498
+ yLabel: () => d.yLabel,
499
+ hasInlineLegend: () => ne.value,
500
+ width: () => b.value,
501
+ height: () => S.value
502
+ }), re = [];
503
+ function E(e) {
311
504
  return {
312
505
  ...e,
313
- data: e.y ?? e.data ?? ae
506
+ data: e.y ?? e.data ?? re
314
507
  };
315
508
  }
316
- let k = t(() => {
317
- if (u.series && u.series.length > 0) return u.series.map(oe);
318
- let e = u.y ?? u.data;
509
+ function D(e) {
510
+ return d.tooltipValueFormat ? d.tooltipValueFormat(e) : d.yTickFormat ? d.yTickFormat(e) : W(e);
511
+ }
512
+ let O = t(() => {
513
+ if (d.series && d.series.length > 0) return d.series.map(E);
514
+ let e = d.y ?? d.data;
319
515
  return e ? [{
320
516
  data: e,
321
- x: u.x
517
+ x: d.x
322
518
  }] : [];
323
- }), A = t(() => u.areas ?? []), se = t(() => {
519
+ }), k = t(() => d.areas ?? []), A = t(() => {
324
520
  let e = 0;
325
- for (let t of k.value) t.data.length > e && (e = t.data.length);
326
- for (let t of A.value) t.upper.length > e && (e = t.upper.length), t.lower.length > e && (e = t.lower.length);
521
+ for (let t of O.value) t.data.length > e && (e = t.data.length);
522
+ for (let t of k.value) t.upper.length > e && (e = t.upper.length), t.lower.length > e && (e = t.lower.length);
327
523
  return e;
328
- }), j = t(() => k.value.some((e) => e.x != null) || A.value.some((e) => e.x != null));
524
+ }), j = t(() => O.value.some((e) => e.x != null) || k.value.some((e) => e.x != null));
329
525
  function M(e, t) {
330
526
  return e.x ? Number(e.x[t]) : t;
331
527
  }
332
528
  function N(e, t) {
333
529
  return e.x ? Number(e.x[t]) : t;
334
530
  }
335
- let P = t(() => j.value ? 0 : u.xMin ?? 0), ce = t(() => {
531
+ let P = t(() => j.value ? 0 : d.xMin ?? 0), F = t(() => {
336
532
  let e = Infinity, t = -Infinity;
337
- for (let n of k.value) for (let r = 0; r < n.data.length; r++) {
533
+ for (let n of O.value) for (let r = 0; r < n.data.length; r++) {
338
534
  let i = M(n, r);
339
535
  isFinite(i) && (i < e && (e = i), i > t && (t = i));
340
536
  }
341
- for (let n of A.value) {
537
+ for (let n of k.value) {
342
538
  let r = Math.max(n.upper.length, n.lower.length);
343
539
  for (let i = 0; i < r; i++) {
344
540
  let r = N(n, i);
@@ -353,18 +549,18 @@ var B = ["width", "height"], me = ["x"], he = { key: 1 }, V = [
353
549
  max: 0
354
550
  };
355
551
  });
356
- function F(e) {
357
- let { min: t, max: n } = ce.value, r = n - t || 1;
358
- return E.value.left + (e - t) / r * D.value;
552
+ function I(e) {
553
+ let { min: t, max: n } = F.value, r = n - t || 1;
554
+ return C.value.left + (e - t) / r * w.value;
359
555
  }
360
- let I = t(() => {
556
+ let L = t(() => {
361
557
  let e = Infinity, t = -Infinity;
362
- for (let n of k.value) for (let r of n.data) isFinite(r) && (r < e && (e = r), r > t && (t = r));
363
- for (let n of A.value) {
558
+ for (let n of O.value) for (let r of n.data) isFinite(r) && (r < e && (e = r), r > t && (t = r));
559
+ for (let n of k.value) {
364
560
  for (let r of n.upper) isFinite(r) && (r < e && (e = r), r > t && (t = r));
365
561
  for (let r of n.lower) isFinite(r) && (r < e && (e = r), r > t && (t = r));
366
562
  }
367
- return isFinite(e) ? (u.yMin != null && u.yMin < e && (e = u.yMin), {
563
+ return isFinite(e) ? (d.yMin != null && d.yMin < e && (e = d.yMin), {
368
564
  min: e,
369
565
  max: t,
370
566
  range: t - e || 1
@@ -374,75 +570,75 @@ var B = ["width", "height"], me = ["x"], he = { key: 1 }, V = [
374
570
  range: 1
375
571
  };
376
572
  });
377
- function L(e) {
573
+ function ie(e) {
378
574
  let t = e.data;
379
575
  if (t.length === 0) return "";
380
- let { min: n, range: r } = I.value, i = O.value / r, a = E.value.top + O.value, o = "", s = !1;
576
+ let { min: n, range: r } = L.value, i = T.value / r, a = C.value.top + T.value, o = "", s = !1;
381
577
  for (let r = 0; r < t.length; r++) {
382
578
  let c = M(e, r);
383
579
  if (!isFinite(t[r]) || !isFinite(c)) {
384
580
  s = !1;
385
581
  continue;
386
582
  }
387
- let l = F(c), u = a - (t[r] - n) * i;
583
+ let l = I(c), u = a - (t[r] - n) * i;
388
584
  o += s ? `L${l},${u}` : `M${l},${u}`, s = !0;
389
585
  }
390
586
  return o;
391
587
  }
392
588
  function R(e) {
393
- let t = e.data, { min: n, range: r } = I.value, i = O.value / r, a = E.value.top + O.value, o = [];
589
+ let t = e.data, { min: n, range: r } = L.value, i = T.value / r, a = C.value.top + T.value, o = [];
394
590
  for (let r = 0; r < t.length; r++) {
395
591
  let s = M(e, r);
396
592
  !isFinite(t[r]) || !isFinite(s) || o.push({
397
- x: F(s),
593
+ x: I(s),
398
594
  y: a - (t[r] - n) * i
399
595
  });
400
596
  }
401
597
  return o;
402
598
  }
403
- function z(e) {
599
+ function ae(e) {
404
600
  let t = Math.min(e.upper.length, e.lower.length);
405
601
  if (t === 0) return "";
406
- let { min: n, range: r } = I.value, i = O.value / r, a = E.value.top + O.value, o = (e) => a - (e - n) * i, s = [], c = [];
602
+ let { min: n, range: r } = L.value, i = T.value / r, a = C.value.top + T.value, o = (e) => a - (e - n) * i, s = [], c = [];
407
603
  for (let n = 0; n < t; n++) isFinite(e.upper[n]) && isFinite(e.lower[n]) && isFinite(N(e, n)) ? c.push(n) : c.length && (s.push(c), c = []);
408
604
  c.length && s.push(c);
409
605
  let l = "";
410
606
  for (let t of s) {
411
- l += `M${F(N(e, t[0]))},${o(e.upper[t[0]])}`;
412
- for (let n = 1; n < t.length; n++) l += `L${F(N(e, t[n]))},${o(e.upper[t[n]])}`;
413
- for (let n = t.length - 1; n >= 0; n--) l += `L${F(N(e, t[n]))},${o(e.lower[t[n]])}`;
607
+ l += `M${I(N(e, t[0]))},${o(e.upper[t[0]])}`;
608
+ for (let n = 1; n < t.length; n++) l += `L${I(N(e, t[n]))},${o(e.upper[t[n]])}`;
609
+ for (let n = t.length - 1; n >= 0; n--) l += `L${I(N(e, t[n]))},${o(e.lower[t[n]])}`;
414
610
  l += "Z";
415
611
  }
416
612
  return l;
417
613
  }
418
- function J(e, t) {
419
- let n = t === "start" ? e.startIndex : e.endIndex, r = e.seriesIndex != null && k.value[e.seriesIndex] || k.value[0];
420
- return F(r ? M(r, n) : n);
614
+ function z(e, t) {
615
+ let n = t === "start" ? e.startIndex : e.endIndex, r = e.seriesIndex != null && O.value[e.seriesIndex] || O.value[0];
616
+ return I(r ? M(r, n) : n);
421
617
  }
422
- function We(e, t = !0) {
423
- let n = E.value.top + O.value;
618
+ function B(e, t = !0) {
619
+ let n = C.value.top + T.value;
424
620
  if (e.seriesIndex == null) {
425
- let t = J(e, "start"), r = J(e, "end");
426
- return t > r ? "" : `M${t},${E.value.top}L${r},${E.value.top}L${r},${n}L${t},${n}Z`;
621
+ let t = z(e, "start"), r = z(e, "end");
622
+ return t > r ? "" : `M${t},${C.value.top}L${r},${C.value.top}L${r},${n}L${t},${n}Z`;
427
623
  }
428
- let r = k.value[e.seriesIndex];
624
+ let r = O.value[e.seriesIndex];
429
625
  if (!r) return "";
430
- let { min: i, range: a } = I.value, o = O.value / a, s = (e) => n - (e - i) * o, c = Math.max(0, e.startIndex), l = Math.min(r.data.length - 1, e.endIndex);
626
+ let { min: i, range: a } = L.value, o = T.value / a, s = (e) => n - (e - i) * o, c = Math.max(0, e.startIndex), l = Math.min(r.data.length - 1, e.endIndex);
431
627
  if (c > l) return "";
432
- let u = `M${F(M(r, c))},${s(r.data[c])}`;
433
- for (let e = c + 1; e <= l; e++) isFinite(r.data[e]) && (u += `L${F(M(r, e))},${s(r.data[e])}`);
434
- return t && (u += `L${F(M(r, l))},${n}`, u += `L${F(M(r, c))},${n}`, u += "Z"), u;
628
+ let u = `M${I(M(r, c))},${s(r.data[c])}`;
629
+ for (let e = c + 1; e <= l; e++) isFinite(r.data[e]) && (u += `L${I(M(r, e))},${s(r.data[e])}`);
630
+ return t && (u += `L${I(M(r, l))},${n}`, u += `L${I(M(r, c))},${n}`, u += "Z"), u;
435
631
  }
436
- let Ge = t(() => {
437
- let e = u.areaSections;
632
+ let H = t(() => {
633
+ let e = d.areaSections;
438
634
  if (!e?.length) return {
439
635
  labels: [],
440
636
  extraHeight: 0
441
637
  };
442
- let t = [], n = E.value.left + D.value;
638
+ let t = [], n = C.value.left + w.value;
443
639
  for (let r of e) {
444
640
  if (!r.label && !r.description || r.legend === "inline" || r.legend === !1) continue;
445
- let e = r.label ?? "", i = r.description ?? "", a = Math.max(e.length, i.length) * Ve, o = J(r, "start") + a / 2 + 2, s = n - a / 2 - 8, c = Math.min(o, s), l = r.color ?? (r.seriesIndex == null ? "#999" : k.value[r.seriesIndex]?.color ?? "currentColor");
641
+ let e = r.label ?? "", i = r.description ?? "", a = Math.max(e.length, i.length) * Je, o = z(r, "start") + a / 2 + 2, s = n - a / 2 - 8, c = Math.min(o, s), l = r.color ?? (r.seriesIndex == null ? "#999" : O.value[r.seriesIndex]?.color ?? "currentColor");
446
642
  t.push({
447
643
  cx: c,
448
644
  labelText: e,
@@ -457,7 +653,7 @@ var B = ["width", "height"], me = ["x"], he = { key: 1 }, V = [
457
653
  let r = [];
458
654
  for (let e of t) {
459
655
  let t = e.cx - e.textWidth / 2, n = 0;
460
- for (; n < r.length && !(t >= r[n] + He);) n++;
656
+ for (; n < r.length && !(t >= r[n] + Ye);) n++;
461
657
  e.row = n;
462
658
  let i = e.cx + e.textWidth / 2;
463
659
  r[n] = Math.max(r[n] ?? -Infinity, i);
@@ -467,20 +663,20 @@ var B = ["width", "height"], me = ["x"], he = { key: 1 }, V = [
467
663
  extraHeight: 0
468
664
  } : {
469
665
  labels: t,
470
- extraHeight: (Math.max(...t.map((e) => e.row)) + 1) * q + Be
666
+ extraHeight: (Math.max(...t.map((e) => e.row)) + 1) * Ke + qe
471
667
  };
472
- }), Ke = t(() => {
668
+ }), se = t(() => {
473
669
  let e = [];
474
- for (let t of k.value) t.legend && e.push({
670
+ for (let t of O.value) t.legend && e.push({
475
671
  label: t.legend,
476
672
  color: t.color ?? "currentColor",
477
673
  type: "series",
478
674
  dashed: t.dashed
479
675
  });
480
- let t = u.areaSections;
676
+ let t = d.areaSections;
481
677
  if (t) for (let n of t) {
482
678
  if (n.legend !== "inline" || !n.label && !n.description) continue;
483
- let t = [n.label, n.description].filter(Boolean).join(" "), r = n.color ?? (n.seriesIndex == null ? "#999" : k.value[n.seriesIndex]?.color ?? "currentColor");
679
+ let t = [n.label, n.description].filter(Boolean).join(" "), r = n.color ?? (n.seriesIndex == null ? "#999" : O.value[n.seriesIndex]?.color ?? "currentColor");
484
680
  e.push({
485
681
  label: t,
486
682
  color: r,
@@ -489,61 +685,41 @@ var B = ["width", "height"], me = ["x"], he = { key: 1 }, V = [
489
685
  });
490
686
  }
491
687
  return e;
492
- }), qe = t(() => w.value + Ge.value.extraHeight), Je = t(() => E.value.top + O.value + E.value.bottom + Be);
493
- function Ye(e, t) {
494
- let n = e / t, r = 10 ** Math.floor(Math.log10(n)), i = n / r, a;
495
- return a = i <= 1.5 ? 1 : i <= 3 ? 2 : i <= 7 ? 5 : 10, a * r;
496
- }
497
- function Y(e) {
498
- return Math.round(e) + .5;
499
- }
500
- let Xe = new Intl.NumberFormat();
501
- function X(e) {
502
- return Math.abs(e) >= 1e3 ? Xe.format(e) : Number.isInteger(e) ? e.toString() : e.toFixed(1);
503
- }
504
- function Ze(e, t, n) {
505
- if (!(n > 0) || !isFinite(n)) return [];
506
- let r = [], i = Math.ceil(e / n) * n;
507
- for (let e = 0, a = i; a <= t + 1e-9 && e < 1e3; e++, a = i + e * n) r.push(a);
508
- return r;
509
- }
510
- let Qe = t(() => {
511
- let { min: e, max: t } = I.value, n = (t) => Y(E.value.top + O.value - (t - e) / I.value.range * O.value), r = (e) => u.yTickFormat ? u.yTickFormat(e) : X(e);
512
- if (e === t) return [{
688
+ }), U = t(() => S.value + H.value.extraHeight), q = t(() => C.value.top + T.value + C.value.bottom + qe), J = t(() => {
689
+ let { min: e, max: t } = L.value, n = (t) => V(C.value.top + T.value - (t - e) / L.value.range * T.value), r = (e) => d.yTickFormat ? d.yTickFormat(e) : W(e);
690
+ return e === t ? [{
513
691
  value: r(e),
514
- y: Y(E.value.top + O.value / 2)
515
- }];
516
- let i;
517
- if (Array.isArray(u.yTicks)) i = u.yTicks.filter((n) => n >= e && n <= t);
518
- else if (typeof u.yTicks == "number") i = Ze(e, t, u.yTicks);
519
- else {
520
- let n = Math.max(3, Math.floor(O.value / 50));
521
- i = Ze(e, t, Ye(t - e, n));
522
- }
523
- return i.map((e) => ({
692
+ y: V(C.value.top + T.value / 2)
693
+ }] : ce({
694
+ min: e,
695
+ max: t,
696
+ ticks: d.yTicks,
697
+ targetTickCount: T.value / 50
698
+ }).map((e) => ({
524
699
  value: r(e),
525
700
  y: n(e)
526
701
  }));
527
- }), $e = t(() => {
528
- let { min: e, max: t } = ce.value;
702
+ }), le = t(() => {
703
+ let { min: e, max: t } = F.value;
529
704
  if (e === t) return [];
530
- let n = P.value, r = se.value, i = (e, t) => {
705
+ let n = P.value, r = A.value, i = (e, t) => {
531
706
  let r = e + n;
532
- return u.xTickFormat ? u.xTickFormat(r, t) : !j.value && u.xLabels && Number.isInteger(e) && e >= 0 && e < u.xLabels.length ? u.xLabels[e] : X(r);
707
+ return d.xTickFormat ? d.xTickFormat(r, t) : !j.value && d.xLabels && Number.isInteger(e) && e >= 0 && e < d.xLabels.length ? d.xLabels[e] : W(r);
533
708
  }, a;
534
- if (Array.isArray(u.xTicks)) a = u.xTicks.map((e) => e - n).filter((n) => n >= e && n <= t);
535
- else if (typeof u.xTicks == "number") a = Ze(e + n, t + n, u.xTicks).map((e) => e - n);
536
- else if (!j.value && u.xLabels && u.xLabels.length === r) {
537
- let e = Math.max(3, Math.floor(D.value / 80)), t = Math.max(1, Math.round((r - 1) / e));
709
+ if (d.xTicks == null && !j.value && d.xLabels && d.xLabels.length === r) {
710
+ let e = Math.max(3, Math.floor(w.value / 80)), t = Math.max(1, Math.round((r - 1) / e));
538
711
  a = [];
539
712
  for (let e = 0; e < r; e += t) a.push(e);
540
- } else {
541
- let r = Math.max(3, Math.floor(D.value / 80)), i = Ye(t - e, r);
542
- a = Ze(e + n, t + n, i).map((e) => e - n);
543
- }
544
- let o = E.value.left, s = E.value.left + D.value;
713
+ } else a = ce({
714
+ min: e,
715
+ max: t,
716
+ ticks: d.xTicks,
717
+ targetTickCount: w.value / 80,
718
+ displayOffset: n
719
+ });
720
+ let o = C.value.left, s = C.value.left + w.value;
545
721
  return a.map((e, t) => {
546
- let n = Y(F(e)), r = "middle";
722
+ let n = V(I(e)), r = "middle";
547
723
  return n - o <= 1 ? r = "start" : s - n <= 1 && (r = "end"), {
548
724
  value: i(e, t),
549
725
  x: n,
@@ -551,30 +727,14 @@ var B = ["width", "height"], me = ["x"], he = { key: 1 }, V = [
551
727
  };
552
728
  });
553
729
  });
554
- function et() {
555
- return u.filename ? u.filename : typeof u.menu == "string" ? u.menu : "chart";
556
- }
557
- function tt() {
558
- return y.value;
559
- }
560
- function nt() {
561
- if (typeof u.csv == "function") return u.csv();
562
- if (typeof u.csv == "string") return u.csv;
563
- let e = k.value;
564
- if (e.length === 0) return "";
565
- let t = se.value, n = e.every((t) => t.x === e[0].x) ? e[0].x : void 0, r = n ? "x" : "index", i = [(e.length === 1 ? [r, "value"] : [r, ...e.map((e, t) => `series_${t}`)]).join(",")];
566
- for (let r = 0; r < t; r++) {
567
- let t = [n ? String(n[r]) : r.toString()];
568
- for (let n of e) t.push(r < n.data.length ? String(n.data[r]) : "");
569
- i.push(t.join(","));
570
- }
571
- return i.join("\n");
730
+ function Y() {
731
+ return typeof d.csv == "function" ? d.csv() : typeof d.csv == "string" ? d.csv : me(O.value);
572
732
  }
573
- let Z = p(null), rt = p(!1), it = p(null), Q = p(null), $ = p(null), at = t(() => !!u.tooltipData || !!u.tooltipTrigger), ot = t(() => {
574
- let e = Z.value, t = k.value[0];
733
+ let de = t(() => !!d.tooltipData || !!d.tooltipTrigger), X = t(() => {
734
+ let e = Qe.value, t = O.value[0];
575
735
  return e === null || !t ? null : M(t, e);
576
- }), st = t(() => ot.value === null ? 0 : F(ot.value));
577
- function ct(e, t) {
736
+ }), fe = t(() => X.value === null ? 0 : I(X.value));
737
+ function Z(e, t) {
578
738
  let n = e.data.length;
579
739
  if (n === 0) return null;
580
740
  let r = 0, i = Infinity;
@@ -586,249 +746,196 @@ var B = ["width", "height"], me = ["x"], he = { key: 1 }, V = [
586
746
  }
587
747
  return i === Infinity ? null : r;
588
748
  }
589
- let lt = t(() => {
590
- let e = ot.value;
749
+ let Q = t(() => {
750
+ let e = X.value;
591
751
  if (e === null) return [];
592
- let { min: t, range: n } = I.value, r = O.value / n, i = E.value.top + O.value, a = [];
593
- for (let n of k.value) {
594
- let o = ct(n, e);
752
+ let { min: t, range: n } = L.value, r = T.value / n, i = C.value.top + T.value, a = [];
753
+ for (let n of O.value) {
754
+ let o = Z(n, e);
595
755
  if (o === null) continue;
596
756
  let s = n.data[o];
597
757
  isFinite(s) && a.push({
598
- x: F(M(n, o)),
758
+ x: I(M(n, o)),
599
759
  y: i - (s - t) * r,
600
760
  color: n.color ?? "currentColor"
601
761
  });
602
762
  }
603
763
  return a;
604
- }), ut = t(() => {
605
- let e = Z.value, t = ot.value;
764
+ }), Xe = t(() => {
765
+ let e = Qe.value, t = X.value;
606
766
  if (e === null || t === null) return null;
607
767
  let n = t + P.value, r;
608
- return r = u.xTickFormat ? u.xTickFormat(n, e) : j.value ? X(n) : u.xLabels?.[e], {
768
+ return r = d.xTickFormat ? d.xTickFormat(n, e) : j.value ? W(n) : d.xLabels?.[e], {
609
769
  index: e,
610
770
  xLabel: r,
611
- values: k.value.map((e, n) => {
612
- let r = ct(e, t);
771
+ values: O.value.map((e, n) => {
772
+ let r = Z(e, t);
613
773
  return {
614
774
  value: r === null ? NaN : Number(e.data[r]),
615
775
  color: e.color ?? "currentColor",
616
776
  seriesIndex: n
617
777
  };
618
778
  }),
619
- data: u.tooltipData?.[e] ?? null
779
+ data: d.tooltipData?.[e] ?? null
620
780
  };
621
781
  });
622
- function dt(e) {
623
- return "touches" in e ? e.touches[0] ?? null : e;
624
- }
625
- function ft(e) {
626
- let t = v.value?.getBoundingClientRect();
782
+ function Ze(e) {
783
+ let t = m.value?.getBoundingClientRect();
627
784
  if (!t) return null;
628
- let n = k.value[0];
785
+ let n = O.value[0];
629
786
  if (!n || n.data.length === 0) return null;
630
- let { min: r, max: i } = ce.value, a = i - r || 1;
631
- return ct(n, r + (e - t.left - E.value.left) / D.value * a);
632
- }
633
- function pt(e) {
634
- let t = dt(e);
635
- if (!t) return;
636
- let n = ft(t.clientX);
637
- n !== null && (Z.value = n, Q.value = {
638
- clientX: t.clientX,
639
- clientY: t.clientY
640
- }, _("hover", { index: n }));
641
- }
642
- re([Q, Z], () => {
643
- if (Z.value === null || !Q.value) {
644
- $.value = null;
645
- return;
646
- }
647
- let e = it.value, t = v.value;
648
- if (!e || !t) return;
649
- let n = t.getBoundingClientRect(), r = rt.value ? Ue : 0, { left: i, top: a } = pe(Q.value.clientX, Q.value.clientY - r, e.offsetWidth, e.offsetHeight, u.tooltipClamp, n);
650
- $.value = {
651
- left: i - n.left,
652
- top: a - n.top
653
- };
654
- }, { flush: "post" });
655
- function mt(e) {
656
- pt(e);
657
- }
658
- function ht() {
659
- u.tooltipTrigger !== "click" && (Z.value = null, _("hover", null));
787
+ let { min: r, max: i } = F.value, a = i - r || 1;
788
+ return Z(n, r + (e - t.left - C.value.left) / w.value * a);
660
789
  }
661
- function gt(e) {
662
- if (u.tooltipTrigger !== "click") return;
663
- let t = dt(e);
664
- if (!t) return;
665
- let n = ft(t.clientX);
666
- n !== null && (Z.value = Z.value === n ? null : n, _("hover", Z.value === null ? null : { index: n }));
667
- }
668
- function _t(e) {
669
- rt.value = !0, pt(e);
670
- }
671
- function vt(e) {
672
- pt(e);
673
- }
674
- function yt() {
675
- rt.value = !1, Z.value = null, _("hover", null);
676
- }
677
- let bt = t(() => u.downloadLink ? typeof u.downloadLink == "string" ? u.downloadLink : "Download data (CSV)" : null), xt = t(() => u.downloadLink ? `data:text/csv;charset=utf-8,${encodeURIComponent(nt())}` : null), St = t(() => {
678
- let e = et(), t = [{
679
- label: "Save as SVG",
680
- action: () => {
681
- let t = tt();
682
- t && ue(t, e);
683
- }
684
- }, {
685
- label: "Save as PNG",
686
- action: () => {
687
- let t = tt();
688
- t && de(t, e);
689
- }
690
- }];
691
- return u.downloadLink || t.push({
692
- label: "Download CSV",
693
- action: () => fe(nt(), e)
694
- }), t;
790
+ let { hoverIndex: Qe, tooltipRef: $e, tooltipPos: et, handlers: tt } = ue({
791
+ enabled: () => de.value,
792
+ trigger: () => d.tooltipTrigger,
793
+ clamp: () => d.tooltipClamp,
794
+ pointerToIndex: Ze,
795
+ containerRef: m,
796
+ onHover: (e) => ee("hover", e)
797
+ }), { svgRef: nt, items: rt, downloadLinkText: it, csvHref: at, resolvedFilename: ot } = pe({
798
+ filename: () => d.filename,
799
+ legacyMenuLabel: () => d.menu,
800
+ getCsv: Y,
801
+ downloadLink: () => d.downloadLink
695
802
  });
696
- return (t, c) => (f(), i("div", {
803
+ return (t, c) => (h(), i("div", {
697
804
  ref_key: "containerRef",
698
- ref: v,
805
+ ref: m,
699
806
  class: "line-chart-wrapper"
700
807
  }, [
701
- s.menu ? (f(), n(le, {
808
+ s.menu ? (h(), n(oe, {
702
809
  key: 0,
703
- items: St.value
810
+ items: x(rt)
704
811
  }, null, 8, ["items"])) : r("", !0),
705
- (f(), i("svg", {
812
+ (h(), i("svg", {
706
813
  ref_key: "svgRef",
707
- ref: y,
708
- width: ie.value,
709
- height: qe.value
814
+ ref: nt,
815
+ width: b.value,
816
+ height: U.value
710
817
  }, [
711
- s.title ? (f(), i("text", {
818
+ s.title ? (h(), i("text", {
712
819
  key: 0,
713
- x: ie.value / 2,
820
+ x: b.value / 2,
714
821
  y: 18,
715
822
  "text-anchor": "middle",
716
823
  "font-size": "14",
717
824
  "font-weight": "600",
718
825
  fill: "currentColor"
719
- }, g(s.title), 9, me)) : r("", !0),
720
- Ke.value.length > 0 ? (f(), i("g", he, [(f(!0), i(e, null, m(Ke.value, (t, n) => (f(), i(e, { key: "ileg" + n }, [t.type === "series" ? (f(), i("line", {
826
+ }, y(s.title), 9, ge)) : r("", !0),
827
+ se.value.length > 0 ? (h(), i("g", _e, [(h(!0), i(e, null, _(se.value, (t, n) => (h(), i(e, { key: "ileg" + n }, [t.type === "series" ? (h(), i("line", {
721
828
  key: 0,
722
- x1: E.value.left + n * 120,
723
- y1: E.value.top - K / 2,
724
- x2: E.value.left + n * 120 + 12,
725
- y2: E.value.top - K / 2,
829
+ x1: x(C).left + n * 120,
830
+ y1: x(C).top - x(20) / 2,
831
+ x2: x(C).left + n * 120 + 12,
832
+ y2: x(C).top - x(20) / 2,
726
833
  stroke: t.color,
727
834
  "stroke-width": "2",
728
835
  "stroke-dasharray": t.dashed ? "4 2" : void 0
729
- }, null, 8, V)) : (f(), i("circle", {
836
+ }, null, 8, ve)) : (h(), i("circle", {
730
837
  key: 1,
731
- cx: E.value.left + n * 120 + 4,
732
- cy: E.value.top - K / 2,
838
+ cx: x(C).left + n * 120 + 4,
839
+ cy: x(C).top - x(20) / 2,
733
840
  r: "4",
734
841
  fill: t.color,
735
842
  "fill-opacity": t.fillOpacity,
736
843
  stroke: t.color,
737
844
  "stroke-width": "1.5"
738
- }, null, 8, H)), a("text", {
739
- x: E.value.left + n * 120 + 18,
740
- y: E.value.top - K / 2 + 4,
845
+ }, null, 8, ye)), a("text", {
846
+ x: x(C).left + n * 120 + 18,
847
+ y: x(C).top - x(20) / 2 + 4,
741
848
  "font-size": "11",
742
849
  fill: "currentColor"
743
- }, g(t.label), 9, ge)], 64))), 128))])) : r("", !0),
850
+ }, y(t.label), 9, be)], 64))), 128))])) : r("", !0),
744
851
  a("line", {
745
- x1: Y(E.value.left),
746
- y1: Y(E.value.top),
747
- x2: Y(E.value.left),
748
- y2: Y(E.value.top + O.value),
852
+ x1: x(V)(x(C).left),
853
+ y1: x(V)(x(C).top),
854
+ x2: x(V)(x(C).left),
855
+ y2: x(V)(x(C).top + x(T)),
749
856
  stroke: "currentColor",
750
857
  "stroke-opacity": "0.3"
751
- }, null, 8, _e),
858
+ }, null, 8, xe),
752
859
  a("line", {
753
- x1: Y(E.value.left),
754
- y1: Y(E.value.top + O.value),
755
- x2: Y(E.value.left + D.value),
756
- y2: Y(E.value.top + O.value),
860
+ x1: x(V)(x(C).left),
861
+ y1: x(V)(x(C).top + x(T)),
862
+ x2: x(V)(x(C).left + x(w)),
863
+ y2: x(V)(x(C).top + x(T)),
757
864
  stroke: "currentColor",
758
865
  "stroke-opacity": "0.3"
759
- }, null, 8, ve),
760
- s.yGrid ? (f(!0), i(e, { key: 2 }, m(Qe.value, (e, t) => (f(), i("line", {
866
+ }, null, 8, $),
867
+ s.yGrid ? (h(!0), i(e, { key: 2 }, _(J.value, (e, t) => (h(), i("line", {
761
868
  key: "yg" + t,
762
- x1: E.value.left,
869
+ x1: x(C).left,
763
870
  y1: e.y,
764
- x2: E.value.left + D.value,
871
+ x2: x(C).left + x(w),
765
872
  y2: e.y,
766
873
  stroke: "currentColor",
767
874
  "stroke-opacity": "0.1"
768
- }, null, 8, ye))), 128)) : r("", !0),
769
- s.xGrid ? (f(!0), i(e, { key: 3 }, m($e.value, (e, t) => (f(), i("line", {
875
+ }, null, 8, Se))), 128)) : r("", !0),
876
+ s.xGrid ? (h(!0), i(e, { key: 3 }, _(le.value, (e, t) => (h(), i("line", {
770
877
  key: "xg" + t,
771
878
  x1: e.x,
772
- y1: E.value.top,
879
+ y1: x(C).top,
773
880
  x2: e.x,
774
- y2: E.value.top + O.value,
881
+ y2: x(C).top + x(T),
775
882
  stroke: "currentColor",
776
883
  "stroke-opacity": "0.1"
777
- }, null, 8, be))), 128)) : r("", !0),
778
- (f(!0), i(e, null, m(Qe.value, (e, t) => (f(), i("text", {
884
+ }, null, 8, Ce))), 128)) : r("", !0),
885
+ (h(!0), i(e, null, _(J.value, (e, t) => (h(), i("text", {
779
886
  key: "y" + t,
780
887
  "data-testid": "y-tick",
781
- x: E.value.left - 6,
888
+ x: x(C).left - 6,
782
889
  y: e.y,
783
890
  "text-anchor": "end",
784
891
  "dominant-baseline": "middle",
785
892
  "font-size": "10",
786
893
  fill: "currentColor",
787
894
  "fill-opacity": "0.6"
788
- }, g(e.value), 9, xe))), 128)),
789
- s.yLabel ? (f(), i("text", {
895
+ }, y(e.value), 9, we))), 128)),
896
+ s.yLabel ? (h(), i("text", {
790
897
  key: 4,
791
898
  x: 0,
792
899
  y: 0,
793
- transform: `translate(14, ${E.value.top + O.value / 2}) rotate(-90)`,
900
+ transform: `translate(14, ${x(C).top + x(T) / 2}) rotate(-90)`,
794
901
  "text-anchor": "middle",
795
902
  "font-size": "13",
796
903
  fill: "currentColor"
797
- }, g(s.yLabel), 9, Se)) : r("", !0),
798
- (f(!0), i(e, null, m($e.value, (e, t) => (f(), i("text", {
904
+ }, y(s.yLabel), 9, Te)) : r("", !0),
905
+ (h(!0), i(e, null, _(le.value, (e, t) => (h(), i("text", {
799
906
  key: "x" + t,
800
907
  "data-testid": "x-tick",
801
908
  x: e.x,
802
- y: E.value.top + O.value + 16,
909
+ y: x(C).top + x(T) + 16,
803
910
  "text-anchor": e.anchor,
804
911
  "font-size": "10",
805
912
  fill: "currentColor",
806
913
  "fill-opacity": "0.6"
807
- }, g(e.value), 9, U))), 128)),
808
- s.xLabel ? (f(), i("text", {
914
+ }, y(e.value), 9, Ee))), 128)),
915
+ s.xLabel ? (h(), i("text", {
809
916
  key: 5,
810
- x: E.value.left + D.value / 2,
811
- y: w.value - 4,
917
+ x: x(C).left + x(w) / 2,
918
+ y: S.value - 4,
812
919
  "text-anchor": "middle",
813
920
  "font-size": "13",
814
921
  fill: "currentColor"
815
- }, g(s.xLabel), 9, W)) : r("", !0),
816
- (f(!0), i(e, null, m(A.value, (e, t) => (f(), i("path", {
922
+ }, y(s.xLabel), 9, De)) : r("", !0),
923
+ (h(!0), i(e, null, _(k.value, (e, t) => (h(), i("path", {
817
924
  key: "area" + t,
818
- d: z(e),
925
+ d: ae(e),
819
926
  fill: e.color ?? "currentColor",
820
927
  "fill-opacity": e.opacity ?? .2,
821
928
  stroke: "none"
822
- }, null, 8, Ce))), 128)),
823
- (f(!0), i(e, null, m(k.value, (t, n) => (f(), i(e, { key: n }, [t.line === !1 ? r("", !0) : (f(), i("path", {
929
+ }, null, 8, Oe))), 128)),
930
+ (h(!0), i(e, null, _(O.value, (t, n) => (h(), i(e, { key: n }, [t.line === !1 ? r("", !0) : (h(), i("path", {
824
931
  key: 0,
825
- d: L(t),
932
+ d: ie(t),
826
933
  fill: "none",
827
934
  stroke: t.color ?? "currentColor",
828
935
  "stroke-width": t.strokeWidth ?? 1.5,
829
936
  "stroke-opacity": t.lineOpacity ?? t.opacity ?? s.lineOpacity,
830
937
  "stroke-dasharray": t.dashed ? "6 3" : void 0
831
- }, null, 8, we)), t.dots ? (f(!0), i(e, { key: 1 }, m(R(t), (e, n) => (f(), i("circle", {
938
+ }, null, 8, ke)), t.dots ? (h(!0), i(e, { key: 1 }, _(R(t), (e, n) => (h(), i("circle", {
832
939
  key: n,
833
940
  cx: e.x,
834
941
  cy: e.y,
@@ -836,68 +943,68 @@ var B = ["width", "height"], me = ["x"], he = { key: 1 }, V = [
836
943
  fill: t.dotFill ?? t.color ?? "currentColor",
837
944
  "fill-opacity": t.dotOpacity ?? t.opacity ?? s.lineOpacity,
838
945
  stroke: t.dotStroke ?? "none"
839
- }, null, 8, Te))), 128)) : r("", !0)], 64))), 128)),
840
- (f(!0), i(e, null, m(s.areaSections ?? [], (t, n) => (f(), i(e, { key: "areasec" + n }, [
946
+ }, null, 8, Ae))), 128)) : r("", !0)], 64))), 128)),
947
+ (h(!0), i(e, null, _(s.areaSections ?? [], (t, n) => (h(), i(e, { key: "areasec" + n }, [
841
948
  a("path", {
842
- d: We(t),
843
- fill: t.color ?? (t.seriesIndex == null ? "#999" : k.value[t.seriesIndex]?.color ?? "currentColor"),
949
+ d: B(t),
950
+ fill: t.color ?? (t.seriesIndex == null ? "#999" : O.value[t.seriesIndex]?.color ?? "currentColor"),
844
951
  "fill-opacity": t.opacity ?? .15,
845
952
  stroke: "none"
846
- }, null, 8, Ee),
847
- t.seriesIndex == null ? r("", !0) : (f(), i("path", {
953
+ }, null, 8, je),
954
+ t.seriesIndex == null ? r("", !0) : (h(), i("path", {
848
955
  key: 0,
849
- d: We(t, !1),
956
+ d: B(t, !1),
850
957
  fill: "none",
851
- stroke: t.color ?? k.value[t.seriesIndex]?.color ?? "currentColor",
958
+ stroke: t.color ?? O.value[t.seriesIndex]?.color ?? "currentColor",
852
959
  "stroke-width": t.strokeWidth ?? 2,
853
960
  "stroke-dasharray": t.dashed ? "6 3" : void 0
854
- }, null, 8, De)),
855
- t.seriesIndex == null ? (f(), i(e, { key: 1 }, [a("line", {
856
- x1: Y(J(t, "start")),
857
- y1: E.value.top,
858
- x2: Y(J(t, "start")),
859
- y2: E.value.top + O.value,
961
+ }, null, 8, Me)),
962
+ t.seriesIndex == null ? (h(), i(e, { key: 1 }, [a("line", {
963
+ x1: x(V)(z(t, "start")),
964
+ y1: x(C).top,
965
+ x2: x(V)(z(t, "start")),
966
+ y2: x(C).top + x(T),
860
967
  stroke: t.color ?? "#999",
861
968
  "stroke-width": t.strokeWidth ?? 2,
862
969
  "stroke-dasharray": t.dashed ? "6 3" : void 0
863
- }, null, 8, Oe), a("line", {
864
- x1: Y(J(t, "end")),
865
- y1: E.value.top,
866
- x2: Y(J(t, "end")),
867
- y2: E.value.top + O.value,
970
+ }, null, 8, Ne), a("line", {
971
+ x1: x(V)(z(t, "end")),
972
+ y1: x(C).top,
973
+ x2: x(V)(z(t, "end")),
974
+ y2: x(C).top + x(T),
868
975
  stroke: t.color ?? "#999",
869
976
  "stroke-width": t.strokeWidth ?? 2,
870
977
  "stroke-dasharray": t.dashed ? "6 3" : void 0
871
- }, null, 8, G)], 64)) : r("", !0),
978
+ }, null, 8, Pe)], 64)) : r("", !0),
872
979
  a("line", {
873
- x1: Y(J(t, "start")),
874
- y1: E.value.top + O.value - 4,
875
- x2: Y(J(t, "start")),
876
- y2: E.value.top + O.value + 4,
980
+ x1: x(V)(z(t, "start")),
981
+ y1: x(C).top + x(T) - 4,
982
+ x2: x(V)(z(t, "start")),
983
+ y2: x(C).top + x(T) + 4,
877
984
  stroke: "currentColor",
878
985
  "stroke-opacity": "0.4"
879
- }, null, 8, ke),
986
+ }, null, 8, Fe),
880
987
  a("line", {
881
- x1: Y(J(t, "end")),
882
- y1: E.value.top + O.value - 4,
883
- x2: Y(J(t, "end")),
884
- y2: E.value.top + O.value + 4,
988
+ x1: x(V)(z(t, "end")),
989
+ y1: x(C).top + x(T) - 4,
990
+ x2: x(V)(z(t, "end")),
991
+ y2: x(C).top + x(T) + 4,
885
992
  stroke: "currentColor",
886
993
  "stroke-opacity": "0.4"
887
- }, null, 8, Ae)
994
+ }, null, 8, Ie)
888
995
  ], 64))), 128)),
889
- at.value && Z.value !== null ? (f(), i("line", {
996
+ de.value && x(Qe) !== null ? (h(), i("line", {
890
997
  key: 6,
891
- x1: Y(st.value),
892
- y1: E.value.top,
893
- x2: Y(st.value),
894
- y2: E.value.top + O.value,
998
+ x1: x(V)(fe.value),
999
+ y1: x(C).top,
1000
+ x2: x(V)(fe.value),
1001
+ y2: x(C).top + x(T),
895
1002
  stroke: "currentColor",
896
1003
  "stroke-opacity": "0.3",
897
1004
  "stroke-dasharray": "4 2",
898
1005
  "pointer-events": "none"
899
- }, null, 8, je)) : r("", !0),
900
- (f(!0), i(e, null, m(lt.value, (e, t) => (f(), i("circle", {
1006
+ }, null, 8, Le)) : r("", !0),
1007
+ (h(!0), i(e, null, _(Q.value, (e, t) => (h(), i("circle", {
901
1008
  key: "hd" + t,
902
1009
  cx: e.x,
903
1010
  cy: e.y,
@@ -906,82 +1013,573 @@ var B = ["width", "height"], me = ["x"], he = { key: 1 }, V = [
906
1013
  stroke: "var(--color-bg-0, #fff)",
907
1014
  "stroke-width": "2",
908
1015
  "pointer-events": "none"
909
- }, null, 8, Me))), 128)),
910
- at.value ? (f(), i("rect", {
1016
+ }, null, 8, Re))), 128)),
1017
+ de.value ? (h(), i("rect", u({
911
1018
  key: 7,
912
- x: E.value.left,
913
- y: E.value.top,
914
- width: D.value,
915
- height: O.value,
1019
+ x: x(C).left,
1020
+ y: x(C).top,
1021
+ width: x(w),
1022
+ height: x(T),
916
1023
  fill: "transparent",
917
1024
  style: {
918
1025
  cursor: "crosshair",
919
1026
  "touch-action": "none"
920
- },
921
- onMousemove: mt,
922
- onMouseleave: ht,
923
- onClick: gt,
924
- onTouchstart: x(_t, ["prevent"]),
925
- onTouchmove: x(vt, ["prevent"]),
926
- onTouchend: yt
927
- }, null, 40, Ne)) : r("", !0),
928
- (f(!0), i(e, null, m(Ge.value.labels, (e, t) => (f(), i("g", { key: "seclab" + t }, [
1027
+ }
1028
+ }, te(x(tt), !0)), null, 16, ze)) : r("", !0),
1029
+ (h(!0), i(e, null, _(H.value.labels, (e, t) => (h(), i("g", { key: "seclab" + t }, [
929
1030
  a("circle", {
930
1031
  cx: e.cx - e.textWidth / 2 - 2,
931
- cy: Je.value + e.row * q + 4,
1032
+ cy: q.value + e.row * Ke + 4,
932
1033
  r: "4",
933
1034
  fill: e.color,
934
1035
  "fill-opacity": e.fillOpacity,
935
1036
  stroke: e.color,
936
1037
  "stroke-width": "1.5"
937
- }, null, 8, Pe),
938
- e.labelText ? (f(), i("text", {
1038
+ }, null, 8, Be),
1039
+ e.labelText ? (h(), i("text", {
939
1040
  key: 0,
940
1041
  x: e.cx - e.textWidth / 2 + 8,
941
- y: Je.value + e.row * q + 8,
1042
+ y: q.value + e.row * Ke + 8,
942
1043
  "font-size": "11",
943
1044
  "font-weight": "600",
944
1045
  fill: e.color
945
- }, g(e.labelText), 9, Fe)) : r("", !0),
946
- e.descText ? (f(), i("text", {
1046
+ }, y(e.labelText), 9, Ve)) : r("", !0),
1047
+ e.descText ? (h(), i("text", {
947
1048
  key: 1,
948
1049
  x: e.cx - e.textWidth / 2 + 8,
949
- y: Je.value + e.row * q + 22,
1050
+ y: q.value + e.row * Ke + 22,
950
1051
  "font-size": "11",
951
1052
  fill: "currentColor",
952
1053
  "fill-opacity": "0.6"
953
- }, g(e.descText), 9, Ie)) : r("", !0)
1054
+ }, y(e.descText), 9, He)) : r("", !0)
954
1055
  ]))), 128))
955
- ], 8, B)),
956
- at.value && Z.value !== null && ut.value ? (f(), i("div", {
1056
+ ], 8, he)),
1057
+ de.value && x(Qe) !== null && Xe.value ? (h(), i("div", {
957
1058
  key: 1,
958
1059
  ref_key: "tooltipRef",
959
- ref: it,
1060
+ ref: $e,
960
1061
  class: "chart-tooltip-content",
961
- style: d({
1062
+ style: p({
962
1063
  position: "absolute",
963
1064
  top: "0",
964
1065
  left: "0",
965
1066
  willChange: "transform",
966
- transform: $.value ? `translate3d(${$.value.left}px, ${$.value.top}px, 0) translateY(-50%)` : "translateY(-50%)",
967
- visibility: $.value ? "visible" : "hidden"
1067
+ transform: x(et) ? `translate3d(${x(et).left}px, ${x(et).top}px, 0) translateY(-50%)` : "translateY(-50%)",
1068
+ visibility: x(et) ? "visible" : "hidden"
968
1069
  })
969
- }, [h(t.$slots, "tooltip", ee(l(ut.value)), () => [a("div", Le, [ut.value.xLabel ? (f(), i("div", Re, g(ut.value.xLabel), 1)) : r("", !0), (f(!0), i(e, null, m(ut.value.values, (e) => (f(), i("div", {
1070
+ }, [v(t.$slots, "tooltip", f(l(Xe.value)), () => [a("div", Ue, [Xe.value.xLabel ? (h(), i("div", We, y(Xe.value.xLabel), 1)) : r("", !0), (h(!0), i(e, null, _(Xe.value.values, (e) => (h(), i("div", {
970
1071
  key: e.seriesIndex,
971
1072
  class: "line-chart-tooltip-row"
972
1073
  }, [a("span", {
973
1074
  class: "line-chart-tooltip-swatch",
974
- style: d({ background: e.color })
975
- }, null, 4), o(" " + g(isFinite(e.value) ? X(e.value) : "—"), 1)]))), 128))])], !0)], 4)) : r("", !0),
976
- bt.value ? (f(), i("a", {
1075
+ style: p({ background: e.color })
1076
+ }, null, 4), o(" " + y(isFinite(e.value) ? D(e.value) : "—"), 1)]))), 128))])], !0)], 4)) : r("", !0),
1077
+ x(it) ? (h(), i("a", {
977
1078
  key: 2,
978
1079
  class: "line-chart-download-link",
979
- href: xt.value,
980
- download: `${et()}.csv`
981
- }, g(bt.value), 9, ze)) : r("", !0)
1080
+ href: x(at),
1081
+ download: `${x(ot)()}.csv`
1082
+ }, y(x(it)), 9, Ge)) : r("", !0)
982
1083
  ], 512));
983
1084
  }
984
- }), [["__scopeId", "data-v-dc8afa83"]]), We = {
1085
+ }), [["__scopeId", "data-v-083d1c2f"]]), Ze = ["width", "height"], Qe = ["x"], $e = { key: 1 }, et = [
1086
+ "x",
1087
+ "y",
1088
+ "fill"
1089
+ ], tt = ["x", "y"], nt = [
1090
+ "x1",
1091
+ "y1",
1092
+ "x2",
1093
+ "y2"
1094
+ ], rt = [
1095
+ "x1",
1096
+ "y1",
1097
+ "x2",
1098
+ "y2"
1099
+ ], it = [
1100
+ "x1",
1101
+ "y1",
1102
+ "x2",
1103
+ "y2"
1104
+ ], at = [
1105
+ "x",
1106
+ "y",
1107
+ "width",
1108
+ "height"
1109
+ ], ot = ["x", "y"], st = ["x", "y"], ct = ["transform"], lt = [
1110
+ "x",
1111
+ "y",
1112
+ "text-anchor"
1113
+ ], ut = ["x", "y"], dt = ["x", "y"], ft = [
1114
+ "data-category",
1115
+ "data-series",
1116
+ "x",
1117
+ "y",
1118
+ "width",
1119
+ "height",
1120
+ "fill",
1121
+ "fill-opacity"
1122
+ ], pt = [
1123
+ "x",
1124
+ "y",
1125
+ "width",
1126
+ "height"
1127
+ ], mt = { class: "bar-chart-tooltip" }, ht = {
1128
+ key: 0,
1129
+ class: "bar-chart-tooltip-label"
1130
+ }, gt = ["href", "download"], _t = /* @__PURE__ */ B(/* @__PURE__ */ c({
1131
+ __name: "BarChart",
1132
+ props: {
1133
+ data: {},
1134
+ y: {},
1135
+ series: {},
1136
+ categories: {},
1137
+ orientation: { default: "vertical" },
1138
+ layout: { default: "grouped" },
1139
+ width: {},
1140
+ height: {},
1141
+ title: {},
1142
+ xLabel: {},
1143
+ yLabel: {},
1144
+ valueMin: { default: 0 },
1145
+ valueTicks: {},
1146
+ valueTickFormat: {},
1147
+ tooltipValueFormat: {},
1148
+ categoryFormat: {},
1149
+ barPadding: { default: .2 },
1150
+ groupGap: { default: 1 },
1151
+ debounce: {},
1152
+ menu: {
1153
+ type: [Boolean, String],
1154
+ default: !0
1155
+ },
1156
+ valueGrid: {
1157
+ type: Boolean,
1158
+ default: !0
1159
+ },
1160
+ tooltipData: {},
1161
+ tooltipTrigger: {},
1162
+ tooltipClamp: { default: "chart" },
1163
+ csv: {},
1164
+ filename: {},
1165
+ downloadLink: { type: [Boolean, String] }
1166
+ },
1167
+ emits: ["hover"],
1168
+ setup(s, { emit: c }) {
1169
+ let d = s, ee = c, { containerRef: m, measuredWidth: g } = G({ debounce: () => d.debounce }), b = t(() => d.width ?? (g.value || 400)), S = t(() => d.height ?? 200), ne = t(() => D.value.some((e) => e.legend)), { padding: C, innerW: w, innerH: T } = K({
1170
+ title: () => d.title,
1171
+ xLabel: () => d.xLabel,
1172
+ yLabel: () => d.yLabel,
1173
+ hasInlineLegend: () => ne.value,
1174
+ width: () => b.value,
1175
+ height: () => S.value
1176
+ }), re = [];
1177
+ function E(e) {
1178
+ return {
1179
+ data: e.y ?? e.data ?? re,
1180
+ color: e.color,
1181
+ opacity: e.opacity,
1182
+ legend: e.legend
1183
+ };
1184
+ }
1185
+ let D = t(() => {
1186
+ if (d.series && d.series.length > 0) return d.series.map(E);
1187
+ let e = d.y ?? d.data;
1188
+ return e ? [{ data: e }] : [];
1189
+ }), O = t(() => {
1190
+ let e = d.categories?.length ?? 0;
1191
+ for (let t of D.value) t.data.length > e && (e = t.data.length);
1192
+ return e;
1193
+ }), k = t(() => {
1194
+ let e = O.value, t = Array(e);
1195
+ for (let n = 0; n < e; n++) t[n] = d.categories?.[n] ?? String(n);
1196
+ return t;
1197
+ }), A = t(() => d.orientation === "vertical"), j = t(() => {
1198
+ let e = Infinity, t = -Infinity;
1199
+ if (d.layout === "stacked") {
1200
+ let n = O.value;
1201
+ for (let r = 0; r < n; r++) {
1202
+ let n = 0, i = 0;
1203
+ for (let e of D.value) {
1204
+ if (r >= e.data.length) continue;
1205
+ let t = Number(e.data[r]);
1206
+ isFinite(t) && (t >= 0 ? n += t : i += t);
1207
+ }
1208
+ n > t && (t = n), i < e && (e = i);
1209
+ }
1210
+ } else for (let n of D.value) for (let r of n.data) {
1211
+ let n = Number(r);
1212
+ isFinite(n) && (n < e && (e = n), n > t && (t = n));
1213
+ }
1214
+ isFinite(e) || (e = 0), isFinite(t) || (t = 0);
1215
+ let n = d.valueMin ?? 0;
1216
+ n < e && (e = n);
1217
+ let r = t - e || 1;
1218
+ return {
1219
+ min: e,
1220
+ max: t,
1221
+ range: r
1222
+ };
1223
+ }), M = t(() => A.value ? w.value : T.value), N = t(() => A.value ? T.value : w.value), P = t(() => {
1224
+ let e = O.value;
1225
+ return e > 0 ? M.value / e : 0;
1226
+ }), F = t(() => P.value * (1 - d.barPadding)), I = t(() => {
1227
+ let e = D.value.length;
1228
+ if (e === 0) return 0;
1229
+ if (d.layout === "stacked" || e === 1) return F.value;
1230
+ let t = d.groupGap * (e - 1);
1231
+ return Math.max(1, (F.value - t) / e);
1232
+ });
1233
+ function L(e) {
1234
+ return (A.value ? C.value.left : C.value.top) + e * P.value;
1235
+ }
1236
+ let ie = t(() => {
1237
+ let { min: e, max: t } = j.value, n = d.valueMin ?? 0;
1238
+ return R(Math.max(e, Math.min(t, n)));
1239
+ });
1240
+ function R(e) {
1241
+ let { min: t, range: n } = j.value, r = N.value / n;
1242
+ return A.value ? C.value.top + T.value - (e - t) * r : C.value.left + (e - t) * r;
1243
+ }
1244
+ function ae(e, t, n, r, i, a, o, s, c) {
1245
+ let l = Math.min(e, t), u = Math.abs(e - t);
1246
+ return A.value ? {
1247
+ x: n,
1248
+ y: l,
1249
+ w: r,
1250
+ h: u,
1251
+ color: i,
1252
+ opacity: a,
1253
+ value: o,
1254
+ categoryIndex: s,
1255
+ seriesIndex: c
1256
+ } : {
1257
+ x: l,
1258
+ y: n,
1259
+ w: u,
1260
+ h: r,
1261
+ color: i,
1262
+ opacity: a,
1263
+ value: o,
1264
+ categoryIndex: s,
1265
+ seriesIndex: c
1266
+ };
1267
+ }
1268
+ let z = t(() => {
1269
+ let e = [], t = D.value, n = t.length;
1270
+ if (n === 0) return e;
1271
+ let r = O.value, i = P.value, a = F.value, o = I.value, s = (i - a) / 2, c = ie.value;
1272
+ for (let i = 0; i < r; i++) {
1273
+ let r = L(i) + s;
1274
+ if (d.layout === "stacked") {
1275
+ let o = 0, s = 0;
1276
+ for (let c = 0; c < n; c++) {
1277
+ let n = t[c], l = Number(n.data[i] ?? NaN);
1278
+ if (!isFinite(l)) continue;
1279
+ let u = l >= 0 ? o : s, d = u + l;
1280
+ e.push(ae(R(u), R(d), r, a, n.color ?? H(c), n.opacity ?? 1, l, i, c)), l >= 0 ? o = d : s = d;
1281
+ }
1282
+ } else for (let a = 0; a < n; a++) {
1283
+ let s = t[a], l = Number(s.data[i] ?? NaN);
1284
+ if (!isFinite(l)) continue;
1285
+ let u = r + (n === 1 ? 0 : a * (o + d.groupGap));
1286
+ e.push(ae(c, R(l), u, o, s.color ?? H(a), s.opacity ?? 1, l, i, a));
1287
+ }
1288
+ }
1289
+ return e;
1290
+ }), B = [
1291
+ "var(--color-primary, #3b82f6)",
1292
+ "var(--color-accent, #f59e0b)",
1293
+ "var(--color-success, #10b981)",
1294
+ "var(--color-danger, #ef4444)",
1295
+ "var(--color-info, #6366f1)",
1296
+ "var(--color-warning, #d97706)"
1297
+ ];
1298
+ function H(e) {
1299
+ return B[e % B.length];
1300
+ }
1301
+ function se(e) {
1302
+ return d.tooltipValueFormat ? d.tooltipValueFormat(e) : d.valueTickFormat ? d.valueTickFormat(e) : W(e);
1303
+ }
1304
+ let U = t(() => {
1305
+ let { min: e, max: t } = j.value, n = (e) => d.valueTickFormat ? d.valueTickFormat(e) : W(e);
1306
+ if (e === t) return [{
1307
+ value: n(e),
1308
+ pos: V(R(e))
1309
+ }];
1310
+ let r = A.value ? 50 : 80;
1311
+ return ce({
1312
+ min: e,
1313
+ max: t,
1314
+ ticks: d.valueTicks,
1315
+ targetTickCount: N.value / r
1316
+ }).map((e) => ({
1317
+ value: n(e),
1318
+ pos: V(R(e))
1319
+ }));
1320
+ }), q = t(() => {
1321
+ let e = [], t = O.value, n = (e, t) => d.categoryFormat ? d.categoryFormat(e, t) : e;
1322
+ for (let r = 0; r < t; r++) {
1323
+ let t = L(r) + P.value / 2;
1324
+ e.push({
1325
+ label: n(k.value[r], r),
1326
+ pos: t,
1327
+ anchor: "middle"
1328
+ });
1329
+ }
1330
+ return e;
1331
+ }), J = t(() => {
1332
+ let e = [];
1333
+ return D.value.forEach((t, n) => {
1334
+ t.legend && e.push({
1335
+ label: t.legend,
1336
+ color: t.color ?? H(n)
1337
+ });
1338
+ }), e;
1339
+ });
1340
+ function le() {
1341
+ if (typeof d.csv == "function") return d.csv();
1342
+ if (typeof d.csv == "string") return d.csv;
1343
+ let e = D.value.map((e) => ({
1344
+ label: e.legend,
1345
+ data: e.data
1346
+ }));
1347
+ return Z(k.value, e);
1348
+ }
1349
+ let Y = t(() => !!d.tooltipData || !!d.tooltipTrigger);
1350
+ function de(e, t) {
1351
+ let n = m.value?.getBoundingClientRect();
1352
+ if (!n) return null;
1353
+ let r = O.value;
1354
+ if (r === 0 || P.value === 0) return null;
1355
+ let i = A.value ? e - n.left - C.value.left : t - n.top - C.value.top;
1356
+ return Math.max(0, Math.min(r - 1, Math.floor(i / P.value)));
1357
+ }
1358
+ let { hoverIndex: X, tooltipRef: fe, tooltipPos: me, handlers: Q } = ue({
1359
+ enabled: () => Y.value,
1360
+ trigger: () => d.tooltipTrigger,
1361
+ clamp: () => d.tooltipClamp,
1362
+ pointerToIndex: de,
1363
+ containerRef: m,
1364
+ onHover: (e) => ee("hover", e)
1365
+ }), { svgRef: he, items: ge, downloadLinkText: _e, csvHref: ve, resolvedFilename: ye } = pe({
1366
+ filename: () => d.filename,
1367
+ legacyMenuLabel: () => d.menu,
1368
+ getCsv: le,
1369
+ downloadLink: () => d.downloadLink
1370
+ }), be = t(() => {
1371
+ let e = X.value;
1372
+ if (e !== null) return k.value[e];
1373
+ }), xe = t(() => {
1374
+ let e = X.value;
1375
+ return e === null ? null : {
1376
+ index: e,
1377
+ category: k.value[e] ?? String(e),
1378
+ values: D.value.map((t, n) => ({
1379
+ value: Number(t.data[e] ?? NaN),
1380
+ color: t.color ?? H(n),
1381
+ seriesIndex: n
1382
+ })),
1383
+ data: d.tooltipData?.[e] ?? null
1384
+ };
1385
+ }), $ = t(() => {
1386
+ let e = X.value;
1387
+ if (e === null) return null;
1388
+ let t = L(e);
1389
+ return A.value ? {
1390
+ x: t,
1391
+ y: C.value.top,
1392
+ w: P.value,
1393
+ h: T.value
1394
+ } : {
1395
+ x: C.value.left,
1396
+ y: t,
1397
+ w: w.value,
1398
+ h: P.value
1399
+ };
1400
+ });
1401
+ return (t, c) => (h(), i("div", {
1402
+ ref_key: "containerRef",
1403
+ ref: m,
1404
+ class: "bar-chart-wrapper"
1405
+ }, [
1406
+ s.menu ? (h(), n(oe, {
1407
+ key: 0,
1408
+ items: x(ge)
1409
+ }, null, 8, ["items"])) : r("", !0),
1410
+ (h(), i("svg", {
1411
+ ref_key: "svgRef",
1412
+ ref: he,
1413
+ width: b.value,
1414
+ height: S.value
1415
+ }, [
1416
+ s.title ? (h(), i("text", {
1417
+ key: 0,
1418
+ x: b.value / 2,
1419
+ y: 18,
1420
+ "text-anchor": "middle",
1421
+ "font-size": "14",
1422
+ "font-weight": "600",
1423
+ fill: "currentColor"
1424
+ }, y(s.title), 9, Qe)) : r("", !0),
1425
+ J.value.length > 0 ? (h(), i("g", $e, [(h(!0), i(e, null, _(J.value, (t, n) => (h(), i(e, { key: "ileg" + n }, [a("rect", {
1426
+ x: x(C).left + n * 120,
1427
+ y: x(C).top - x(20) / 2 - 5,
1428
+ width: "12",
1429
+ height: "10",
1430
+ fill: t.color
1431
+ }, null, 8, et), a("text", {
1432
+ x: x(C).left + n * 120 + 18,
1433
+ y: x(C).top - x(20) / 2 + 4,
1434
+ "font-size": "11",
1435
+ fill: "currentColor"
1436
+ }, y(t.label), 9, tt)], 64))), 128))])) : r("", !0),
1437
+ a("line", {
1438
+ x1: x(V)(x(C).left),
1439
+ y1: x(V)(x(C).top),
1440
+ x2: x(V)(x(C).left),
1441
+ y2: x(V)(x(C).top + x(T)),
1442
+ stroke: "currentColor",
1443
+ "stroke-opacity": "0.3"
1444
+ }, null, 8, nt),
1445
+ a("line", {
1446
+ x1: x(V)(x(C).left),
1447
+ y1: x(V)(x(C).top + x(T)),
1448
+ x2: x(V)(x(C).left + x(w)),
1449
+ y2: x(V)(x(C).top + x(T)),
1450
+ stroke: "currentColor",
1451
+ "stroke-opacity": "0.3"
1452
+ }, null, 8, rt),
1453
+ s.valueGrid ? (h(!0), i(e, { key: 2 }, _(U.value, (e, t) => (h(), i("line", {
1454
+ key: "vg" + t,
1455
+ x1: A.value ? x(C).left : e.pos,
1456
+ y1: A.value ? e.pos : x(C).top,
1457
+ x2: A.value ? x(C).left + x(w) : e.pos,
1458
+ y2: A.value ? e.pos : x(C).top + x(T),
1459
+ stroke: "currentColor",
1460
+ "stroke-opacity": "0.1"
1461
+ }, null, 8, it))), 128)) : r("", !0),
1462
+ $.value && Y.value ? (h(), i("rect", {
1463
+ key: 3,
1464
+ x: $.value.x,
1465
+ y: $.value.y,
1466
+ width: $.value.w,
1467
+ height: $.value.h,
1468
+ fill: "currentColor",
1469
+ "fill-opacity": "0.06",
1470
+ "pointer-events": "none"
1471
+ }, null, 8, at)) : r("", !0),
1472
+ A.value ? (h(!0), i(e, { key: 4 }, _(U.value, (e, t) => (h(), i("text", {
1473
+ key: "vt" + t,
1474
+ "data-testid": "value-tick",
1475
+ x: x(C).left - 6,
1476
+ y: e.pos,
1477
+ "text-anchor": "end",
1478
+ "dominant-baseline": "middle",
1479
+ "font-size": "10",
1480
+ fill: "currentColor",
1481
+ "fill-opacity": "0.6"
1482
+ }, y(e.value), 9, ot))), 128)) : (h(!0), i(e, { key: 5 }, _(U.value, (e, t) => (h(), i("text", {
1483
+ key: "vt" + t,
1484
+ "data-testid": "value-tick",
1485
+ x: e.pos,
1486
+ y: x(C).top + x(T) + 16,
1487
+ "text-anchor": "middle",
1488
+ "font-size": "10",
1489
+ fill: "currentColor",
1490
+ "fill-opacity": "0.6"
1491
+ }, y(e.value), 9, st))), 128)),
1492
+ s.yLabel ? (h(), i("text", {
1493
+ key: 6,
1494
+ x: 0,
1495
+ y: 0,
1496
+ transform: `translate(14, ${x(C).top + x(T) / 2}) rotate(-90)`,
1497
+ "text-anchor": "middle",
1498
+ "font-size": "13",
1499
+ fill: "currentColor"
1500
+ }, y(s.yLabel), 9, ct)) : r("", !0),
1501
+ A.value ? (h(!0), i(e, { key: 7 }, _(q.value, (e, t) => (h(), i("text", {
1502
+ key: "ct" + t,
1503
+ "data-testid": "category-tick",
1504
+ x: e.pos,
1505
+ y: x(C).top + x(T) + 16,
1506
+ "text-anchor": e.anchor,
1507
+ "font-size": "10",
1508
+ fill: "currentColor",
1509
+ "fill-opacity": "0.6"
1510
+ }, y(e.label), 9, lt))), 128)) : (h(!0), i(e, { key: 8 }, _(q.value, (e, t) => (h(), i("text", {
1511
+ key: "ct" + t,
1512
+ "data-testid": "category-tick",
1513
+ x: x(C).left - 6,
1514
+ y: e.pos,
1515
+ "text-anchor": "end",
1516
+ "dominant-baseline": "middle",
1517
+ "font-size": "10",
1518
+ fill: "currentColor",
1519
+ "fill-opacity": "0.6"
1520
+ }, y(e.label), 9, ut))), 128)),
1521
+ s.xLabel ? (h(), i("text", {
1522
+ key: 9,
1523
+ x: x(C).left + x(w) / 2,
1524
+ y: S.value - 4,
1525
+ "text-anchor": "middle",
1526
+ "font-size": "13",
1527
+ fill: "currentColor"
1528
+ }, y(s.xLabel), 9, dt)) : r("", !0),
1529
+ (h(!0), i(e, null, _(z.value, (e, t) => (h(), i("rect", {
1530
+ key: "bar" + t,
1531
+ "data-testid": "bar",
1532
+ "data-category": e.categoryIndex,
1533
+ "data-series": e.seriesIndex,
1534
+ x: e.x,
1535
+ y: e.y,
1536
+ width: e.w,
1537
+ height: e.h,
1538
+ fill: e.color,
1539
+ "fill-opacity": e.opacity
1540
+ }, null, 8, ft))), 128)),
1541
+ Y.value ? (h(), i("rect", u({
1542
+ key: 10,
1543
+ x: x(C).left,
1544
+ y: x(C).top,
1545
+ width: x(w),
1546
+ height: x(T),
1547
+ fill: "transparent",
1548
+ style: {
1549
+ cursor: "crosshair",
1550
+ "touch-action": "none"
1551
+ }
1552
+ }, te(x(Q), !0)), null, 16, pt)) : r("", !0)
1553
+ ], 8, Ze)),
1554
+ Y.value && x(X) !== null && xe.value ? (h(), i("div", {
1555
+ key: 1,
1556
+ ref_key: "tooltipRef",
1557
+ ref: fe,
1558
+ class: "chart-tooltip-content",
1559
+ style: p({
1560
+ position: "absolute",
1561
+ top: "0",
1562
+ left: "0",
1563
+ willChange: "transform",
1564
+ transform: x(me) ? `translate3d(${x(me).left}px, ${x(me).top}px, 0) translateY(-50%)` : "translateY(-50%)",
1565
+ visibility: x(me) ? "visible" : "hidden"
1566
+ })
1567
+ }, [v(t.$slots, "tooltip", f(l(xe.value)), () => [a("div", mt, [be.value ? (h(), i("div", ht, y(be.value), 1)) : r("", !0), (h(!0), i(e, null, _(xe.value.values, (e) => (h(), i("div", {
1568
+ key: e.seriesIndex,
1569
+ class: "bar-chart-tooltip-row"
1570
+ }, [a("span", {
1571
+ class: "bar-chart-tooltip-swatch",
1572
+ style: p({ background: e.color })
1573
+ }, null, 4), o(" " + y(isFinite(e.value) ? se(e.value) : "—"), 1)]))), 128))])], !0)], 4)) : r("", !0),
1574
+ x(_e) ? (h(), i("a", {
1575
+ key: 2,
1576
+ class: "bar-chart-download-link",
1577
+ href: x(ve),
1578
+ download: `${x(ye)()}.csv`
1579
+ }, y(x(_e)), 9, gt)) : r("", !0)
1580
+ ], 512));
1581
+ }
1582
+ }), [["__scopeId", "data-v-4f604d9f"]]), vt = {
985
1583
  "01013": "010259",
986
1584
  "01015": "010177",
987
1585
  "01029": "010177",
@@ -4142,7 +4740,7 @@ var B = ["width", "height"], me = ["x"], he = { key: 1 }, V = [
4142
4740
  51019: "510014",
4143
4741
  "02158": "020820",
4144
4742
  46102: "460957"
4145
- }, Ge = {
4743
+ }, yt = {
4146
4744
  "010259": "Butler, AL",
4147
4745
  "010177": "Calhoun (Anniston), AL - Cleburne, AL",
4148
4746
  "010172": "Chambers, AL - Randolph, AL",
@@ -5092,25 +5690,25 @@ var B = ["width", "height"], me = ["x"], he = { key: 1 }, V = [
5092
5690
  560775: "Teton, WY - Lincoln, WY",
5093
5691
  560792: "Uinta, WY",
5094
5692
  560804: "Weston, WY"
5095
- }, Ke = ["width", "height"], qe = [
5693
+ }, bt = ["width", "height"], xt = [
5096
5694
  "data-feat-id",
5097
5695
  "d",
5098
5696
  "fill",
5099
5697
  "stroke",
5100
5698
  "stroke-width"
5101
- ], Je = { key: 0 }, Ye = ["d", "stroke"], Y = ["transform"], Xe = {
5699
+ ], St = { key: 0 }, Ct = ["d", "stroke"], wt = ["transform"], Tt = {
5102
5700
  key: 0,
5103
5701
  y: 5,
5104
5702
  "font-size": "13",
5105
5703
  "font-weight": "600",
5106
5704
  fill: "currentColor"
5107
- }, X = ["x", "fill"], Ze = ["x"], Qe = {
5705
+ }, Et = ["x", "fill"], Dt = ["x"], Ot = {
5108
5706
  key: 0,
5109
5707
  y: 5,
5110
5708
  "font-size": "13",
5111
5709
  "font-weight": "600",
5112
5710
  fill: "currentColor"
5113
- }, $e = ["offset", "stop-color"], et = ["x", "fill"], tt = ["x"], nt = ["x"], Z = /* @__PURE__ */ I(/* @__PURE__ */ c({
5711
+ }, kt = ["offset", "stop-color"], At = ["x", "fill"], jt = ["x"], Mt = ["x"], Nt = /* @__PURE__ */ B(/* @__PURE__ */ c({
5114
5712
  __name: "ChoroplethMap",
5115
5713
  props: {
5116
5714
  topology: {},
@@ -5142,84 +5740,85 @@ var B = ["width", "height"], me = ["x"], he = { key: 1 }, V = [
5142
5740
  },
5143
5741
  tooltipTrigger: {},
5144
5742
  tooltipFormat: {},
5743
+ tooltipValueFormat: {},
5145
5744
  tooltipClamp: { default: "chart" }
5146
5745
  },
5147
5746
  emits: ["stateClick", "stateHover"],
5148
5747
  setup(o, { emit: s }) {
5149
- let c = o, l = s, ee = `choropleth-gradient-${y()}`, d = p(null), h = p(null), v = p(null), b = p(0), x = null, S = null, C = !1, ie = typeof window < "u" && "ontouchstart" in window, w = null, T = null;
5150
- function E() {
5151
- if (ie) return;
5748
+ let c = o, l = s, u = `choropleth-gradient-${S()}`, f = g(null), p = g(null), v = g(null), te = g(0), x = null, C = null, w = !1, T = typeof window < "u" && "ontouchstart" in window, re = null, E = null;
5749
+ function D() {
5750
+ if (T) return;
5152
5751
  let e = v.value;
5153
- e && (e.addEventListener("click", G), e.addEventListener("mouseover", G), e.addEventListener("mousemove", ke), e.addEventListener("mouseout", Ae));
5752
+ e && (e.addEventListener("click", $), e.addEventListener("mouseover", $), e.addEventListener("mousemove", Se), e.addEventListener("mouseout", Ce));
5154
5753
  }
5155
- function D() {
5754
+ function O() {
5156
5755
  let e = v.value;
5157
- e && (e.removeEventListener("click", G), e.removeEventListener("mouseover", G), e.removeEventListener("mousemove", ke), e.removeEventListener("mouseout", Ae));
5756
+ e && (e.removeEventListener("click", $), e.removeEventListener("mouseover", $), e.removeEventListener("mousemove", Se), e.removeEventListener("mouseout", Ce));
5158
5757
  }
5159
- te(() => {
5160
- d.value && (b.value = d.value.clientWidth, w = new ResizeObserver((e) => {
5758
+ ee(() => {
5759
+ f.value && (te.value = f.value.clientWidth, re = new ResizeObserver((e) => {
5161
5760
  let t = e[0];
5162
- t && (b.value = t.contentRect.width);
5163
- }), w.observe(d.value)), O(), E();
5164
- }), ne(() => {
5165
- w?.disconnect(), ae(), D(), Ee();
5761
+ t && (te.value = t.contentRect.width);
5762
+ }), re.observe(f.value)), k(), D();
5763
+ }), m(() => {
5764
+ re?.disconnect(), A(), O(), ye();
5166
5765
  });
5167
- function O() {
5168
- if (!h.value || !v.value || !c.zoom && !c.pan) return;
5169
- let e = se(h.value);
5170
- T = A().scaleExtent(c.zoom ? [1, 12] : [1, 1]).on("start", () => {
5171
- C = !0, Oe();
5766
+ function k() {
5767
+ if (!p.value || !v.value || !c.zoom && !c.pan) return;
5768
+ let e = F(p.value);
5769
+ E = P().scaleExtent(c.zoom ? [1, 12] : [1, 1]).on("start", () => {
5770
+ w = !0, xe();
5172
5771
  }).on("zoom", (e) => {
5173
5772
  v.value && v.value.setAttribute("transform", e.transform);
5174
5773
  }).on("end", () => {
5175
- C = !1;
5176
- }), c.pan || T.filter((e) => e.type === "wheel" || e.type === "dblclick"), e.call(T);
5774
+ w = !1;
5775
+ }), c.pan || E.filter((e) => e.type === "wheel" || e.type === "dblclick"), e.call(E);
5177
5776
  }
5178
- function ae() {
5179
- h.value && T && (se(h.value).on(".zoom", null), T = null);
5777
+ function A() {
5778
+ p.value && E && (F(p.value).on(".zoom", null), E = null);
5180
5779
  }
5181
- re(() => [c.zoom, c.pan], () => {
5182
- ae(), D(), O(), E();
5780
+ ne(() => [c.zoom, c.pan], () => {
5781
+ A(), O(), k(), D();
5183
5782
  });
5184
- let P = t(() => c.width ?? (b.value || 600)), ce = t(() => c.width && c.height ? c.height / c.width : .625), F = t(() => P.value * ce.value), I = t(() => {
5185
- let e = _(c.topology), t = e.objects.counties.geometries, n = /* @__PURE__ */ new Map();
5783
+ let j = t(() => c.width ?? (te.value || 600)), R = t(() => c.width && c.height ? c.height / c.width : .625), ae = t(() => j.value * R.value), z = t(() => {
5784
+ let e = b(c.topology), t = e.objects.counties.geometries, n = /* @__PURE__ */ new Map();
5186
5785
  for (let e of t) {
5187
- let t = We[String(e.id).padStart(5, "0")];
5786
+ let t = vt[String(e.id).padStart(5, "0")];
5188
5787
  t && (n.has(t) || n.set(t, []), n.get(t).push(e));
5189
5788
  }
5190
5789
  let r = [];
5191
5790
  for (let [t, i] of n) r.push({
5192
5791
  type: "Feature",
5193
5792
  id: t,
5194
- properties: { name: Ge[t] ?? t },
5195
- geometry: M(e, i)
5793
+ properties: { name: yt[t] ?? t },
5794
+ geometry: L(e, i)
5196
5795
  });
5197
5796
  return {
5198
5797
  type: "FeatureCollection",
5199
5798
  features: r
5200
5799
  };
5201
- }), L = t(() => {
5202
- if (c.geoType === "hsas") return I.value;
5800
+ }), B = t(() => {
5801
+ if (c.geoType === "hsas") return z.value;
5203
5802
  if (c.geoType === "counties") {
5204
- let e = _(c.topology);
5205
- return j(e, e.objects.counties);
5803
+ let e = b(c.topology);
5804
+ return I(e, e.objects.counties);
5206
5805
  }
5207
- let e = _(c.topology);
5208
- return j(e, e.objects.states);
5209
- }), fe = t(() => {
5806
+ let e = b(c.topology);
5807
+ return I(e, e.objects.states);
5808
+ }), V = t(() => {
5210
5809
  if (c.geoType !== "counties" && c.geoType !== "hsas") return null;
5211
- let e = _(c.topology);
5212
- return N(e, e.objects.states, (e, t) => e !== t);
5213
- }), R = t(() => oe().fitExtent([[0, Ie.value], [P.value, F.value + Ie.value]], L.value)), z = t(() => k(R.value)), B = t(() => c.geoType === "counties" || c.geoType === "hsas" ? c.strokeWidth * .5 : c.strokeWidth), me = t(() => {
5810
+ let e = b(c.topology);
5811
+ return ie(e, e.objects.states, (e, t) => e !== t);
5812
+ }), H = t(() => M().fitExtent([[0, ke.value], [j.value, ae.value + ke.value]], B.value)), se = t(() => N(H.value)), U = t(() => c.geoType === "counties" || c.geoType === "hsas" ? c.strokeWidth * .5 : c.strokeWidth), W = t(() => {
5214
5813
  let e = /* @__PURE__ */ new Map();
5215
5814
  if (!c.data) return e;
5216
5815
  for (let t of c.data) {
5217
5816
  e.set(t.id, t.value);
5218
- let n = L.value.features.find((e) => e.properties?.name === t.id);
5817
+ let n = B.value.features.find((e) => e.properties?.name === t.id);
5219
5818
  n?.id != null && e.set(String(n.id), t.value);
5220
5819
  }
5221
5820
  return e;
5222
- }), he = t(() => {
5821
+ }), ce = t(() => {
5223
5822
  if (!c.data || c.data.length === 0) return {
5224
5823
  min: 0,
5225
5824
  max: 1
@@ -5236,8 +5835,8 @@ var B = ["width", "height"], me = ["x"], he = { key: 1 }, V = [
5236
5835
  min: 0,
5237
5836
  max: 1
5238
5837
  };
5239
- }), V = t(() => Array.isArray(c.colorScale) && c.colorScale.length > 0 && "value" in c.colorScale[0]), H = t(() => Array.isArray(c.colorScale) && !V.value), ge = t(() => H.value ? "" : c.colorScale?.min ?? "#e5f0fa"), _e = t(() => H.value ? "" : c.colorScale?.max ?? "#08519c");
5240
- function ve(e) {
5838
+ }), G = t(() => Array.isArray(c.colorScale) && c.colorScale.length > 0 && "value" in c.colorScale[0]), K = t(() => Array.isArray(c.colorScale) && !G.value), q = t(() => K.value ? "" : c.colorScale?.min ?? "#e5f0fa"), J = t(() => K.value ? "" : c.colorScale?.max ?? "#08519c");
5839
+ function ue(e) {
5241
5840
  let t = e.replace("#", "");
5242
5841
  return [
5243
5842
  parseInt(t.slice(0, 2), 16),
@@ -5245,103 +5844,106 @@ var B = ["width", "height"], me = ["x"], he = { key: 1 }, V = [
5245
5844
  parseInt(t.slice(4, 6), 16)
5246
5845
  ];
5247
5846
  }
5248
- function ye(e) {
5249
- let [t, n, r] = ve(ge.value), [i, a, o] = ve(_e.value);
5847
+ function Y(e) {
5848
+ let [t, n, r] = ue(q.value), [i, a, o] = ue(J.value);
5250
5849
  return `rgb(${Math.round(t + (i - t) * e)},${Math.round(n + (a - n) * e)},${Math.round(r + (o - r) * e)})`;
5251
5850
  }
5252
- function be(e) {
5851
+ function fe(e) {
5253
5852
  let t = c.colorScale.slice().sort((e, t) => t.min - e.min);
5254
5853
  for (let n of t) if (e >= n.min) return n.color;
5255
5854
  return c.noDataColor;
5256
5855
  }
5257
- function xe(e) {
5856
+ function pe(e) {
5258
5857
  let t = c.colorScale.find((t) => t.value === String(e));
5259
5858
  return t ? t.color : c.noDataColor;
5260
5859
  }
5261
- function Se(e) {
5262
- let t = me.value.get(String(e));
5860
+ function me(e) {
5861
+ let t = W.value.get(String(e));
5263
5862
  if (t == null) return c.noDataColor;
5264
- if (V.value) return xe(t);
5265
- if (H.value) return be(t);
5266
- let { min: n, max: r } = he.value;
5267
- return ye((t - n) / (r - n));
5863
+ if (G.value) return pe(t);
5864
+ if (K.value) return fe(t);
5865
+ let { min: n, max: r } = ce.value;
5866
+ return Y((t - n) / (r - n));
5268
5867
  }
5269
- function U(e) {
5868
+ function Z(e) {
5270
5869
  return e.properties?.name ?? String(e.id);
5271
5870
  }
5272
- function W(e) {
5273
- return me.value.get(String(e.id));
5871
+ function Q(e) {
5872
+ return W.value.get(String(e.id));
5873
+ }
5874
+ function he(e) {
5875
+ return e == null ? "" : typeof e == "number" && c.tooltipValueFormat ? c.tooltipValueFormat(e) : String(e);
5274
5876
  }
5275
- let Ce = t(() => {
5877
+ let ge = t(() => {
5276
5878
  let e = /* @__PURE__ */ new Map();
5277
- for (let t of L.value.features) e.set(String(t.id), t);
5879
+ for (let t of B.value.features) e.set(String(t.id), t);
5278
5880
  return e;
5279
5881
  });
5280
- function we(e) {
5882
+ function _e(e) {
5281
5883
  let t = e;
5282
5884
  for (; t && !t.dataset?.featId;) t = t.parentElement;
5283
5885
  if (!t) return null;
5284
- let n = Ce.value.get(t.dataset.featId);
5886
+ let n = ge.value.get(t.dataset.featId);
5285
5887
  return n ? {
5286
5888
  pathEl: t,
5287
5889
  feat: n
5288
5890
  } : null;
5289
5891
  }
5290
- function Te(e, t, n) {
5291
- S || (S = document.createElement("div"), S.className = "chart-tooltip-content", S.style.position = "fixed", S.style.transform = "translateY(-50%)", document.body.appendChild(S));
5292
- let r = U(e), i = W(e), a = {
5892
+ function ve(e, t, n) {
5893
+ C || (C = document.createElement("div"), C.className = "chart-tooltip-content", C.style.position = "fixed", C.style.transform = "translateY(-50%)", document.body.appendChild(C));
5894
+ let r = Z(e), i = Q(e), a = {
5293
5895
  id: String(e.id),
5294
5896
  name: r,
5295
5897
  value: i
5296
5898
  };
5297
- c.tooltipFormat ? S.innerHTML = c.tooltipFormat(a) : S.textContent = i == null ? r : `${r}: ${i}`;
5298
- let o = d.value?.getBoundingClientRect(), { left: s, top: l } = pe(t, n, S.offsetWidth, S.offsetHeight, c.tooltipClamp, o);
5299
- S.style.left = `${s}px`, S.style.top = `${l}px`;
5899
+ c.tooltipFormat ? C.innerHTML = c.tooltipFormat(a) : i == null ? C.textContent = r : C.textContent = `${r}: ${he(i)}`;
5900
+ let o = f.value?.getBoundingClientRect(), { left: s, top: l } = le(t, n, C.offsetWidth, C.offsetHeight, c.tooltipClamp, o);
5901
+ C.style.left = `${s}px`, C.style.top = `${l}px`;
5300
5902
  }
5301
- function Ee() {
5302
- S &&= (S.remove(), null);
5903
+ function ye() {
5904
+ C &&= (C.remove(), null);
5303
5905
  }
5304
- function De(e, t) {
5305
- x && x !== e && (x.setAttribute("stroke-width", String(B.value)), x.setAttribute("stroke", c.strokeColor)), x = e, e.parentNode?.appendChild(e), e.setAttribute("stroke-width", String(B.value + 1)), e.setAttribute("stroke", "#555");
5906
+ function be(e, t) {
5907
+ x && x !== e && (x.setAttribute("stroke-width", String(U.value)), x.setAttribute("stroke", c.strokeColor)), x = e, e.parentNode?.appendChild(e), e.setAttribute("stroke-width", String(U.value + 1)), e.setAttribute("stroke", "#555");
5306
5908
  }
5307
- function Oe() {
5308
- x && (x.setAttribute("stroke-width", String(B.value)), x.setAttribute("stroke", c.strokeColor), x = null, l("stateHover", null)), Ee();
5909
+ function xe() {
5910
+ x && (x.setAttribute("stroke-width", String(U.value)), x.setAttribute("stroke", c.strokeColor), x = null, l("stateHover", null)), ye();
5309
5911
  }
5310
- function G(e) {
5311
- if (C) return;
5312
- let t = e, n = we(t.target);
5912
+ function $(e) {
5913
+ if (w) return;
5914
+ let t = e, n = _e(t.target);
5313
5915
  n && (e.type === "click" ? l("stateClick", {
5314
5916
  id: String(n.feat.id),
5315
- name: U(n.feat),
5316
- value: W(n.feat)
5317
- }) : e.type === "mouseover" && (De(n.pathEl, n.feat), c.tooltipTrigger && Te(n.feat, t.clientX, t.clientY), l("stateHover", {
5917
+ name: Z(n.feat),
5918
+ value: Q(n.feat)
5919
+ }) : e.type === "mouseover" && (be(n.pathEl, n.feat), c.tooltipTrigger && ve(n.feat, t.clientX, t.clientY), l("stateHover", {
5318
5920
  id: String(n.feat.id),
5319
- name: U(n.feat),
5320
- value: W(n.feat)
5921
+ name: Z(n.feat),
5922
+ value: Q(n.feat)
5321
5923
  })));
5322
5924
  }
5323
- function ke(e) {
5324
- C || !S || (S.style.left = `${e.clientX + 16}px`, S.style.top = `${e.clientY}px`);
5925
+ function Se(e) {
5926
+ w || !C || (C.style.left = `${e.clientX + 16}px`, C.style.top = `${e.clientY}px`);
5325
5927
  }
5326
- function Ae(e) {
5928
+ function Ce(e) {
5327
5929
  let t = e.relatedTarget;
5328
- t && v.value?.contains(t) || Oe();
5930
+ t && v.value?.contains(t) || xe();
5329
5931
  }
5330
- function je() {
5932
+ function we() {
5331
5933
  return typeof c.menu == "string" ? c.menu : "choropleth";
5332
5934
  }
5333
- let Me = t(() => c.legend && (V.value || H.value || c.data)), Ne = t(() => c.colorScale.slice().sort((e, t) => e.min - t.min)), Pe = t(() => c.title ? 24 : 0), Fe = t(() => Me.value ? 28 : 0), Ie = t(() => Pe.value + Fe.value), Le = t(() => F.value + Ie.value), Re = t(() => Pe.value + 18), ze = t(() => {
5935
+ let Te = t(() => c.legend && (G.value || K.value || c.data)), Ee = t(() => c.colorScale.slice().sort((e, t) => e.min - t.min)), De = t(() => c.title ? 24 : 0), Oe = t(() => Te.value ? 28 : 0), ke = t(() => De.value + Oe.value), Ae = t(() => ae.value + ke.value), je = t(() => De.value + 18), Me = t(() => {
5334
5936
  let e = [];
5335
5937
  for (let t = 0; t <= 10; t++) {
5336
5938
  let n = t / 10;
5337
5939
  e.push({
5338
5940
  offset: `${(n * 100).toFixed(0)}%`,
5339
- color: ye(n)
5941
+ color: Y(n)
5340
5942
  });
5341
5943
  }
5342
5944
  return e;
5343
- }), K = t(() => {
5344
- let { min: e, max: t } = he.value, n = t - e, r = [];
5945
+ }), Ne = t(() => {
5946
+ let { min: e, max: t } = ce.value, n = t - e, r = [];
5345
5947
  for (let t = 1; t <= 3; t++) {
5346
5948
  let i = t / 4, a = e + n * i, o = Number.isInteger(a) ? String(a) : a.toFixed(1).replace(/\.0$/, "");
5347
5949
  r.push({
@@ -5350,118 +5952,118 @@ var B = ["width", "height"], me = ["x"], he = { key: 1 }, V = [
5350
5952
  });
5351
5953
  }
5352
5954
  return r;
5353
- }), q = t(() => {
5955
+ }), Pe = t(() => {
5354
5956
  let e = [];
5355
- if (V.value) for (let t of c.colorScale) e.push({
5957
+ if (G.value) for (let t of c.colorScale) e.push({
5356
5958
  key: t.value,
5357
5959
  color: t.color,
5358
5960
  label: t.value
5359
5961
  });
5360
- else if (H.value) for (let t of Ne.value) e.push({
5962
+ else if (K.value) for (let t of Ee.value) e.push({
5361
5963
  key: String(t.min),
5362
5964
  color: t.color,
5363
5965
  label: t.label ?? String(t.min)
5364
5966
  });
5365
5967
  return e;
5366
- }), Be = t(() => {
5968
+ }), Fe = t(() => {
5367
5969
  let e = c.legendTitle ? c.legendTitle.length * 8 + 12 : 0;
5368
- for (let t of q.value) e += 16 + t.label.length * 7 + 12;
5369
- return e - (q.value.length > 0 ? 12 : 0);
5370
- }), Ve = t(() => {
5970
+ for (let t of Pe.value) e += 16 + t.label.length * 7 + 12;
5971
+ return e - (Pe.value.length > 0 ? 12 : 0);
5972
+ }), Ie = t(() => {
5371
5973
  let e = c.legendTitle ? c.legendTitle.length * 8 + 12 : 0;
5372
- return q.value.map((t) => {
5974
+ return Pe.value.map((t) => {
5373
5975
  let n = e;
5374
5976
  return e += 16 + t.label.length * 7 + 12, n;
5375
5977
  });
5376
- }), He = t(() => {
5377
- if (V.value || H.value) return (P.value - Be.value) / 2;
5978
+ }), Le = t(() => {
5979
+ if (G.value || K.value) return (j.value - Fe.value) / 2;
5378
5980
  let e = c.legendTitle ? c.legendTitle.length * 8 + 12 : 0;
5379
- return (P.value - e - 160) / 2;
5380
- }), Ue = t(() => {
5381
- let e = je();
5981
+ return (j.value - e - 160) / 2;
5982
+ }), Re = t(() => {
5983
+ let e = we();
5382
5984
  return [{
5383
5985
  label: "Save as SVG",
5384
5986
  action: () => {
5385
- h.value && ue(h.value, e);
5987
+ p.value && de(p.value, e);
5386
5988
  }
5387
5989
  }, {
5388
5990
  label: "Save as PNG",
5389
5991
  action: () => {
5390
- h.value && de(h.value, e);
5992
+ p.value && X(p.value, e);
5391
5993
  }
5392
5994
  }];
5393
5995
  });
5394
- return (t, s) => (f(), i("div", {
5996
+ return (t, s) => (h(), i("div", {
5395
5997
  ref_key: "containerRef",
5396
- ref: d,
5397
- class: u(["choropleth-wrapper", { pannable: o.pan }])
5398
- }, [o.menu ? (f(), n(le, {
5998
+ ref: f,
5999
+ class: d(["choropleth-wrapper", { pannable: o.pan }])
6000
+ }, [o.menu ? (h(), n(oe, {
5399
6001
  key: 0,
5400
- items: Ue.value
5401
- }, null, 8, ["items"])) : r("", !0), (f(), i("svg", {
6002
+ items: Re.value
6003
+ }, null, 8, ["items"])) : r("", !0), (h(), i("svg", {
5402
6004
  ref_key: "svgRef",
5403
- ref: h,
5404
- width: P.value,
5405
- height: Le.value
6005
+ ref: p,
6006
+ width: j.value,
6007
+ height: Ae.value
5406
6008
  }, [
5407
6009
  a("g", {
5408
6010
  ref_key: "mapGroupRef",
5409
6011
  ref: v
5410
- }, [(f(!0), i(e, null, m(L.value.features, (e) => (f(), i("path", {
6012
+ }, [(h(!0), i(e, null, _(B.value.features, (e) => (h(), i("path", {
5411
6013
  key: String(e.id),
5412
6014
  "data-feat-id": String(e.id),
5413
- d: z.value(e) ?? void 0,
5414
- fill: Se(e.id),
6015
+ d: se.value(e) ?? void 0,
6016
+ fill: me(e.id),
5415
6017
  stroke: o.strokeColor,
5416
- "stroke-width": B.value,
6018
+ "stroke-width": U.value,
5417
6019
  class: "state-path"
5418
- }, [o.tooltipTrigger ? r("", !0) : (f(), i("title", Je, g(U(e)) + g(W(e) == null ? "" : `: ${W(e)}`), 1))], 8, qe))), 128)), fe.value ? (f(), i("path", {
6020
+ }, [o.tooltipTrigger ? r("", !0) : (h(), i("title", St, y(Z(e)) + y(Q(e) == null ? "" : `: ${he(Q(e))}`), 1))], 8, xt))), 128)), V.value ? (h(), i("path", {
5419
6021
  key: 0,
5420
- d: z.value(fe.value) ?? void 0,
6022
+ d: se.value(V.value) ?? void 0,
5421
6023
  fill: "none",
5422
6024
  stroke: o.strokeColor,
5423
6025
  "stroke-width": 1,
5424
6026
  "stroke-linejoin": "round",
5425
6027
  "pointer-events": "none"
5426
- }, null, 8, Ye)) : r("", !0)], 512),
5427
- Me.value ? (f(), i("g", {
6028
+ }, null, 8, Ct)) : r("", !0)], 512),
6029
+ Te.value ? (h(), i("g", {
5428
6030
  key: 0,
5429
6031
  class: "choropleth-legend",
5430
- transform: `translate(${He.value},${Re.value})`
5431
- }, [V.value || H.value ? (f(), i(e, { key: 0 }, [o.legendTitle ? (f(), i("text", Xe, g(o.legendTitle), 1)) : r("", !0), (f(!0), i(e, null, m(q.value, (t, n) => (f(), i(e, { key: t.key }, [a("rect", {
5432
- x: Ve.value[n],
6032
+ transform: `translate(${Le.value},${je.value})`
6033
+ }, [G.value || K.value ? (h(), i(e, { key: 0 }, [o.legendTitle ? (h(), i("text", Tt, y(o.legendTitle), 1)) : r("", !0), (h(!0), i(e, null, _(Pe.value, (t, n) => (h(), i(e, { key: t.key }, [a("rect", {
6034
+ x: Ie.value[n],
5433
6035
  y: -5,
5434
6036
  width: "12",
5435
6037
  height: "12",
5436
6038
  rx: "3",
5437
6039
  fill: t.color
5438
- }, null, 8, X), a("text", {
5439
- x: Ve.value[n] + 16,
6040
+ }, null, 8, Et), a("text", {
6041
+ x: Ie.value[n] + 16,
5440
6042
  y: 5,
5441
6043
  "font-size": "13",
5442
6044
  fill: "currentColor"
5443
- }, g(t.label), 9, Ze)], 64))), 128))], 64)) : (f(), i(e, { key: 1 }, [
5444
- o.legendTitle ? (f(), i("text", Qe, g(o.legendTitle), 1)) : r("", !0),
6045
+ }, y(t.label), 9, Dt)], 64))), 128))], 64)) : (h(), i(e, { key: 1 }, [
6046
+ o.legendTitle ? (h(), i("text", Ot, y(o.legendTitle), 1)) : r("", !0),
5445
6047
  a("defs", null, [a("linearGradient", {
5446
- id: ee,
6048
+ id: u,
5447
6049
  x1: "0",
5448
6050
  x2: "1",
5449
6051
  y1: "0",
5450
6052
  y2: "0"
5451
- }, [(f(!0), i(e, null, m(ze.value, (e) => (f(), i("stop", {
6053
+ }, [(h(!0), i(e, null, _(Me.value, (e) => (h(), i("stop", {
5452
6054
  key: e.offset,
5453
6055
  offset: e.offset,
5454
6056
  "stop-color": e.color
5455
- }, null, 8, $e))), 128))])]),
6057
+ }, null, 8, kt))), 128))])]),
5456
6058
  a("rect", {
5457
6059
  x: o.legendTitle ? o.legendTitle.length * 8 + 12 : 0,
5458
6060
  y: -6,
5459
6061
  width: 160,
5460
6062
  height: 12,
5461
6063
  rx: "2",
5462
- fill: `url(#${ee})`
5463
- }, null, 8, et),
5464
- (f(!0), i(e, null, m(K.value, (e) => (f(), i("text", {
6064
+ fill: `url(#${u})`
6065
+ }, null, 8, At),
6066
+ (h(!0), i(e, null, _(Ne.value, (e) => (h(), i("text", {
5465
6067
  key: e.value,
5466
6068
  x: (o.legendTitle ? o.legendTitle.length * 8 + 12 : 0) + e.pct / 100 * 160,
5467
6069
  y: 20,
@@ -5469,20 +6071,20 @@ var B = ["width", "height"], me = ["x"], he = { key: 1 }, V = [
5469
6071
  fill: "currentColor",
5470
6072
  opacity: "0.7",
5471
6073
  "text-anchor": "middle"
5472
- }, g(e.value), 9, tt))), 128))
5473
- ], 64))], 8, Y)) : r("", !0),
5474
- o.title ? (f(), i("text", {
6074
+ }, y(e.value), 9, jt))), 128))
6075
+ ], 64))], 8, wt)) : r("", !0),
6076
+ o.title ? (h(), i("text", {
5475
6077
  key: 1,
5476
- x: P.value / 2,
6078
+ x: j.value / 2,
5477
6079
  y: 18,
5478
6080
  "text-anchor": "middle",
5479
6081
  "font-size": "14",
5480
6082
  "font-weight": "600",
5481
6083
  fill: "currentColor"
5482
- }, g(o.title), 9, nt)) : r("", !0)
5483
- ], 8, Ke))], 2));
6084
+ }, y(o.title), 9, Mt)) : r("", !0)
6085
+ ], 8, bt))], 2));
5484
6086
  }
5485
- }), [["__scopeId", "data-v-25a20d5b"]]), rt = /* @__PURE__ */ I(/* @__PURE__ */ c({
6087
+ }), [["__scopeId", "data-v-105ba317"]]), Pt = /* @__PURE__ */ B(/* @__PURE__ */ c({
5486
6088
  __name: "ChartTooltip",
5487
6089
  props: {
5488
6090
  x: {},
@@ -5493,30 +6095,30 @@ var B = ["width", "height"], me = ["x"], he = { key: 1 }, V = [
5493
6095
  },
5494
6096
  emits: ["close"],
5495
6097
  setup(e) {
5496
- return (t, o) => e.mode === "hover" && e.open ? (f(), i("div", {
6098
+ return (t, o) => e.mode === "hover" && e.open ? (h(), i("div", {
5497
6099
  key: 0,
5498
6100
  class: "chart-tooltip-content",
5499
- style: d({
6101
+ style: p({
5500
6102
  position: "absolute",
5501
6103
  left: `${e.x + e.sideOffset}px`,
5502
6104
  top: `${e.y}px`,
5503
6105
  transform: "translateY(-50%)"
5504
6106
  })
5505
- }, [h(t.$slots, "default", {}, void 0, !0)], 4)) : e.mode === "click" ? (f(), n(v(ae), {
6107
+ }, [v(t.$slots, "default", {}, void 0, !0)], 4)) : e.mode === "click" ? (h(), n(x(j), {
5506
6108
  key: 1,
5507
6109
  open: e.open
5508
6110
  }, {
5509
- default: b(() => [s(v(E), { "as-child": "" }, {
5510
- default: b(() => [a("div", {
6111
+ default: C(() => [s(x(O), { "as-child": "" }, {
6112
+ default: C(() => [a("div", {
5511
6113
  class: "chart-tooltip-anchor",
5512
- style: d({
6114
+ style: p({
5513
6115
  left: `${e.x}px`,
5514
6116
  top: `${e.y}px`
5515
6117
  })
5516
6118
  }, null, 4)]),
5517
6119
  _: 1
5518
- }), s(v(O), null, {
5519
- default: b(() => [e.open ? (f(), n(v(D), {
6120
+ }), s(x(A), null, {
6121
+ default: C(() => [e.open ? (h(), n(x(k), {
5520
6122
  key: 0,
5521
6123
  class: "chart-tooltip-content",
5522
6124
  side: "right",
@@ -5525,7 +6127,7 @@ var B = ["width", "height"], me = ["x"], he = { key: 1 }, V = [
5525
6127
  onPointerDownOutside: o[0] ||= (e) => t.$emit("close"),
5526
6128
  onEscapeKeyDown: o[1] ||= (e) => t.$emit("close")
5527
6129
  }, {
5528
- default: b(() => [h(t.$slots, "default", {}, void 0, !0)]),
6130
+ default: C(() => [v(t.$slots, "default", {}, void 0, !0)]),
5529
6131
  _: 3
5530
6132
  }, 8, ["side-offset"])) : r("", !0)]),
5531
6133
  _: 3
@@ -5533,7 +6135,7 @@ var B = ["width", "height"], me = ["x"], he = { key: 1 }, V = [
5533
6135
  _: 3
5534
6136
  }, 8, ["open"])) : r("", !0);
5535
6137
  }
5536
- }), [["__scopeId", "data-v-44377f70"]]), it = { class: "TableWrapper" }, Q = { class: "Table" }, $ = ["href", "download"], at = /* @__PURE__ */ I(/* @__PURE__ */ c({
6138
+ }), [["__scopeId", "data-v-44377f70"]]), Ft = { class: "TableWrapper" }, It = /* @__PURE__ */ B(/* @__PURE__ */ c({
5537
6139
  __name: "DataTable",
5538
6140
  props: {
5539
6141
  data: {},
@@ -5545,7 +6147,11 @@ var B = ["width", "height"], me = ["x"], he = { key: 1 }, V = [
5545
6147
  },
5546
6148
  csv: {},
5547
6149
  filename: {},
5548
- downloadLink: { type: [Boolean, String] }
6150
+ downloadMenuLink: { default: "Download" },
6151
+ fullWidth: {
6152
+ type: Boolean,
6153
+ default: !1
6154
+ }
5549
6155
  },
5550
6156
  setup(o) {
5551
6157
  let s = {
@@ -5556,25 +6162,28 @@ var B = ["width", "height"], me = ["x"], he = { key: 1 }, V = [
5556
6162
  function l(e) {
5557
6163
  return c.columnConfig?.[e]?.label ?? e;
5558
6164
  }
5559
- function ee(e) {
6165
+ function u(e) {
5560
6166
  let t = c.columnConfig?.[e]?.width;
5561
- if (t == null) return;
6167
+ if (t == null) return c.fullWidth ? void 0 : {
6168
+ width: s.medium,
6169
+ minWidth: s.medium
6170
+ };
5562
6171
  let n = typeof t == "number" ? `${t}px` : s[t];
5563
6172
  return {
5564
6173
  width: n,
5565
6174
  minWidth: n
5566
6175
  };
5567
6176
  }
5568
- function te(e) {
6177
+ function f(e) {
5569
6178
  let t = c.columnConfig?.[e]?.align;
5570
6179
  if (t) return { textAlign: t };
5571
6180
  }
5572
- function ne(e) {
6181
+ function ee(e) {
5573
6182
  return typeof e.column == "function";
5574
6183
  }
5575
- let p = t(() => {
6184
+ let m = t(() => {
5576
6185
  let e = c.data;
5577
- return ne(e) ? e.columns.map((t) => ({
6186
+ return ee(e) ? e.columns.map((t) => ({
5578
6187
  name: t.name,
5579
6188
  values: e.column(t.name),
5580
6189
  enumLabels: t.enumLabels
@@ -5582,65 +6191,60 @@ var B = ["width", "height"], me = ["x"], he = { key: 1 }, V = [
5582
6191
  name: e,
5583
6192
  values: t
5584
6193
  }));
5585
- }), h = t(() => {
5586
- let e = p.value;
6194
+ }), g = t(() => {
6195
+ let e = m.value;
5587
6196
  if (e.length === 0) return 0;
5588
6197
  let t = 0;
5589
6198
  for (let n of e) t = Math.max(t, n.values.length);
5590
6199
  return c.maxRows ? Math.min(t, c.maxRows) : t;
5591
6200
  });
5592
- function _(e, t) {
6201
+ function v(e, t) {
5593
6202
  let n = e.values[t];
5594
6203
  return n == null ? "" : e.enumLabels && typeof n == "number" ? e.enumLabels[n] ?? String(n) : typeof n == "number" ? Number.isInteger(n) ? n.toString() : n.toFixed(4) : typeof n == "boolean" ? n ? "true" : "false" : String(n);
5595
6204
  }
5596
- function v() {
6205
+ function te() {
5597
6206
  return c.filename ? c.filename : typeof c.menu == "string" ? c.menu : "data";
5598
6207
  }
5599
- function y(e) {
6208
+ function b(e) {
5600
6209
  return e.includes(",") || e.includes("\"") || e.includes("\n") ? `"${e.replace(/"/g, "\"\"")}"` : e;
5601
6210
  }
5602
- function re() {
6211
+ function x() {
5603
6212
  if (typeof c.csv == "function") return c.csv();
5604
6213
  if (typeof c.csv == "string") return c.csv;
5605
- let e = p.value, t = h.value, n = [e.map((e) => y(l(e.name))).join(",")];
6214
+ let e = m.value, t = g.value, n = [e.map((e) => b(l(e.name))).join(",")];
5606
6215
  for (let r = 0; r < t; r++) {
5607
- let t = e.map((e) => y(_(e, r)));
6216
+ let t = e.map((e) => b(v(e, r)));
5608
6217
  n.push(t.join(","));
5609
6218
  }
5610
6219
  return n.join("\n");
5611
6220
  }
5612
- let b = t(() => c.downloadLink ? [] : [{
5613
- label: "Download CSV",
5614
- action: () => fe(re(), v())
5615
- }]), x = t(() => c.downloadLink ? typeof c.downloadLink == "string" ? c.downloadLink : "Download data (CSV)" : null), S = t(() => c.downloadLink ? `data:text/csv;charset=utf-8,${encodeURIComponent(re())}` : null), C = t(() => c.menu && b.value.length > 0);
5616
- return (t, s) => (f(), i("div", { class: u(["TableOuter", { "has-menu": C.value }]) }, [
5617
- C.value ? (f(), n(le, {
5618
- key: 0,
5619
- items: b.value
5620
- }, null, 8, ["items"])) : r("", !0),
5621
- a("div", it, [a("table", Q, [
5622
- a("colgroup", null, [(f(!0), i(e, null, m(p.value, (e) => (f(), i("col", {
5623
- key: e.name,
5624
- style: d(ee(e.name))
5625
- }, null, 4))), 128))]),
5626
- a("thead", null, [a("tr", null, [(f(!0), i(e, null, m(p.value, (e) => (f(), i("th", {
5627
- key: e.name,
5628
- style: d(te(e.name))
5629
- }, g(l(e.name)), 5))), 128))])]),
5630
- a("tbody", null, [(f(!0), i(e, null, m(h.value, (t) => (f(), i("tr", { key: t }, [(f(!0), i(e, null, m(p.value, (e) => (f(), i("td", {
5631
- key: e.name,
5632
- class: u(o.columnConfig?.[e.name]?.cellClass),
5633
- style: d(te(e.name))
5634
- }, g(_(e, t - 1)), 7))), 128))]))), 128))])
5635
- ])]),
5636
- x.value ? (f(), i("a", {
5637
- key: 1,
5638
- class: "data-table-download-link",
5639
- href: S.value,
5640
- download: `${v()}.csv`
5641
- }, g(x.value), 9, $)) : r("", !0)
5642
- ], 2));
6221
+ let S = t(() => [{
6222
+ label: c.downloadMenuLink,
6223
+ action: () => fe(x(), te())
6224
+ }]), ne = t(() => !!c.menu);
6225
+ return (t, s) => (h(), i("div", { class: d(["TableOuter", {
6226
+ "full-width": o.fullWidth,
6227
+ "has-menu": ne.value
6228
+ }]) }, [ne.value ? (h(), n(oe, {
6229
+ key: 0,
6230
+ items: S.value,
6231
+ "force-dropdown": ""
6232
+ }, null, 8, ["items"])) : r("", !0), a("div", Ft, [a("table", { class: d(["Table", { "full-width": o.fullWidth }]) }, [
6233
+ a("colgroup", null, [(h(!0), i(e, null, _(m.value, (e) => (h(), i("col", {
6234
+ key: e.name,
6235
+ style: p(u(e.name))
6236
+ }, null, 4))), 128))]),
6237
+ a("thead", null, [a("tr", null, [(h(!0), i(e, null, _(m.value, (e) => (h(), i("th", {
6238
+ key: e.name,
6239
+ style: p(f(e.name))
6240
+ }, y(l(e.name)), 5))), 128))])]),
6241
+ a("tbody", null, [(h(!0), i(e, null, _(g.value, (t) => (h(), i("tr", { key: t }, [(h(!0), i(e, null, _(m.value, (e) => (h(), i("td", {
6242
+ key: e.name,
6243
+ class: d(o.columnConfig?.[e.name]?.cellClass),
6244
+ style: p(f(e.name))
6245
+ }, y(v(e, t - 1)), 7))), 128))]))), 128))])
6246
+ ], 2)])], 2));
5643
6247
  }
5644
- }), [["__scopeId", "data-v-505e2187"]]);
6248
+ }), [["__scopeId", "data-v-d5c290dc"]]);
5645
6249
  //#endregion
5646
- export { rt as ChartTooltip, Z as ChoroplethMap, at as DataTable, J as LineChart };
6250
+ export { _t as BarChart, Pt as ChartTooltip, Nt as ChoroplethMap, It as DataTable, Xe as LineChart };