@cfasim-ui/charts 0.2.3 → 0.3.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,11 +1,9 @@
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 d, normalizeStyle as f, onMounted as p, onUnmounted as ee, openBlock as m, ref as h, renderList as g, renderSlot as _, toDisplayString as v, unref as y, useId as b, watch as x, withCtx as S, withModifiers as C } from "vue";
2
- import { DropdownMenuContent as w, DropdownMenuItem as T, DropdownMenuPortal as E, DropdownMenuRoot as D, DropdownMenuTrigger as O, PopoverAnchor as k, PopoverContent as A, PopoverPortal as j, PopoverRoot as M } from "reka-ui";
3
- import { geoAlbersUsa as N, geoPath as P } from "d3-geo";
4
- import { zoom as te } from "d3-zoom";
5
- import { select as ne } from "d3-selection";
6
- import { feature as re, merge as ie, mesh as F } from "topojson-client";
7
- import ae from "us-atlas/states-10m.json";
8
- import I from "us-atlas/counties-10m.json";
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 d, normalizeStyle as f, onMounted as p, onUnmounted as ee, openBlock as m, ref as h, renderList as g, renderSlot as _, toDisplayString as v, toRaw as y, unref as b, useId as x, watch as S, withCtx as C, withModifiers as w } from "vue";
2
+ import { DropdownMenuContent as T, DropdownMenuItem as E, DropdownMenuPortal as D, DropdownMenuRoot as O, DropdownMenuTrigger as k, PopoverAnchor as A, PopoverContent as j, PopoverPortal as M, PopoverRoot as N } from "reka-ui";
3
+ import { geoAlbersUsa as P, geoPath as te } from "d3-geo";
4
+ import { zoom as ne } from "d3-zoom";
5
+ import { select as re } from "d3-selection";
6
+ import { feature as F, merge as I, mesh as ie } from "topojson-client";
9
7
  //#region src/ChartMenu/ChartMenu.vue?vue&type=script&setup=true&lang.ts
10
8
  var L = { class: "chart-menu-trigger-area" }, R = ["aria-label"], z = /* @__PURE__ */ c({
11
9
  __name: "ChartMenu",
@@ -26,15 +24,15 @@ var L = { class: "chart-menu-trigger-area" }, R = ["aria-label"], z = /* @__PURE
26
24
  "stroke-linecap": "round",
27
25
  "stroke-linejoin": "round",
28
26
  "aria-hidden": "true"
29
- }, [a("path", { d: "M7 1v8M3 6l4 4 4-4M2 13h10" })], -1)]], 8, R)) : (m(), n(y(D), {
27
+ }, [a("path", { d: "M7 1v8M3 6l4 4 4-4M2 13h10" })], -1)]], 8, R)) : (m(), n(b(O), {
30
28
  key: 1,
31
29
  modal: !1
32
30
  }, {
33
- default: S(() => [s(y(O), {
31
+ default: C(() => [s(b(k), {
34
32
  class: "chart-menu-button",
35
33
  "aria-label": "Chart options"
36
34
  }, {
37
- default: S(() => [...c[2] ||= [a("svg", {
35
+ default: C(() => [...c[2] ||= [a("svg", {
38
36
  width: "16",
39
37
  height: "16",
40
38
  viewBox: "0 0 16 16",
@@ -58,18 +56,18 @@ var L = { class: "chart-menu-trigger-area" }, R = ["aria-label"], z = /* @__PURE
58
56
  })
59
57
  ], -1)]]),
60
58
  _: 1
61
- }), s(y(E), null, {
62
- default: S(() => [s(y(w), {
59
+ }), s(b(D), null, {
60
+ default: C(() => [s(b(T), {
63
61
  class: "chart-menu-content",
64
62
  "side-offset": 4,
65
63
  align: "end"
66
64
  }, {
67
- default: S(() => [(m(!0), i(e, null, g(t.items, (e) => (m(), n(y(T), {
65
+ default: C(() => [(m(!0), i(e, null, g(t.items, (e) => (m(), n(b(E), {
68
66
  key: e.label,
69
67
  class: "chart-menu-item",
70
68
  onSelect: e.action
71
69
  }, {
72
- default: S(() => [o(v(e.label), 1)]),
70
+ default: C(() => [o(v(e.label), 1)]),
73
71
  _: 2
74
72
  }, 1032, ["onSelect"]))), 128))]),
75
73
  _: 1
@@ -83,20 +81,20 @@ var L = { class: "chart-menu-trigger-area" }, R = ["aria-label"], z = /* @__PURE
83
81
  let n = e.__vccOpts || e;
84
82
  for (let [e, r] of t) n[e] = r;
85
83
  return n;
86
- }, oe = /* @__PURE__ */ B(z, [["__scopeId", "data-v-fe2f6904"]]);
84
+ }, ae = /* @__PURE__ */ B(z, [["__scopeId", "data-v-fe2f6904"]]);
87
85
  //#endregion
88
86
  //#region src/ChartMenu/download.ts
89
87
  function V(e, t) {
90
88
  let n = URL.createObjectURL(e), r = document.createElement("a");
91
89
  r.href = n, r.download = t, r.click(), URL.revokeObjectURL(n);
92
90
  }
93
- function se(e, t) {
91
+ function oe(e, t) {
94
92
  let n = e.cloneNode(!0);
95
93
  n.setAttribute("xmlns", "http://www.w3.org/2000/svg");
96
94
  let r = new XMLSerializer().serializeToString(n);
97
95
  V(new Blob([r], { type: "image/svg+xml" }), `${t}.svg`);
98
96
  }
99
- function ce(e, t) {
97
+ function se(e, t) {
100
98
  let n = e.cloneNode(!0);
101
99
  n.setAttribute("xmlns", "http://www.w3.org/2000/svg");
102
100
  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;
@@ -109,66 +107,66 @@ function ce(e, t) {
109
107
  }), URL.revokeObjectURL(a);
110
108
  }, o.src = a;
111
109
  }
112
- function le(e, t) {
110
+ function H(e, t) {
113
111
  V(new Blob([e], { type: "text/csv" }), `${t}.csv`);
114
112
  }
115
113
  //#endregion
116
114
  //#region src/LineChart/LineChart.vue?vue&type=script&setup=true&lang.ts
117
- var H = ["width", "height"], ue = ["x"], de = [
115
+ var ce = ["width", "height"], le = ["x"], U = [
118
116
  "x1",
119
117
  "y1",
120
118
  "x2",
121
119
  "y2"
122
- ], fe = [
120
+ ], ue = [
123
121
  "x1",
124
122
  "y1",
125
123
  "x2",
126
124
  "y2"
127
- ], U = [
125
+ ], de = [
128
126
  "x1",
129
127
  "y1",
130
128
  "x2",
131
129
  "y2"
132
- ], pe = [
130
+ ], W = [
133
131
  "x1",
134
132
  "y1",
135
133
  "x2",
136
134
  "y2"
137
- ], me = ["x", "y"], W = ["transform"], G = ["x", "y"], he = ["x", "y"], ge = [
135
+ ], G = ["x", "y"], fe = ["transform"], pe = ["x", "y"], me = ["x", "y"], he = [
138
136
  "d",
139
137
  "fill",
140
138
  "fill-opacity"
141
- ], _e = [
139
+ ], ge = [
142
140
  "d",
143
141
  "stroke",
144
142
  "stroke-width",
145
143
  "stroke-opacity",
146
144
  "stroke-dasharray"
147
- ], ve = [
145
+ ], _e = [
148
146
  "cx",
149
147
  "cy",
150
148
  "r",
151
149
  "fill",
152
150
  "fill-opacity",
153
151
  "stroke"
154
- ], ye = [
152
+ ], ve = [
155
153
  "x1",
156
154
  "y1",
157
155
  "x2",
158
156
  "y2"
159
- ], be = [
157
+ ], K = [
160
158
  "cx",
161
159
  "cy",
162
160
  "fill"
163
- ], xe = [
161
+ ], q = [
164
162
  "x",
165
163
  "y",
166
164
  "width",
167
165
  "height"
168
- ], K = { class: "line-chart-tooltip" }, q = {
166
+ ], ye = { class: "line-chart-tooltip" }, be = {
169
167
  key: 0,
170
168
  class: "line-chart-tooltip-label"
171
- }, Se = 50, J = /* @__PURE__ */ B(/* @__PURE__ */ c({
169
+ }, xe = ["href", "download"], Se = 50, J = /* @__PURE__ */ B(/* @__PURE__ */ c({
172
170
  __name: "LineChart",
173
171
  props: {
174
172
  data: {},
@@ -191,20 +189,23 @@ var H = ["width", "height"], ue = ["x"], de = [
191
189
  xGrid: { type: Boolean },
192
190
  yGrid: { type: Boolean },
193
191
  tooltipData: {},
194
- tooltipTrigger: {}
192
+ tooltipTrigger: {},
193
+ csv: {},
194
+ filename: {},
195
+ downloadLink: { type: [Boolean, String] }
195
196
  },
196
197
  emits: ["hover"],
197
198
  setup(s, { emit: c }) {
198
- let u = s, y = c, b = h(null), x = h(null), S = h(0), w = null, T = null;
199
+ let u = s, y = c, b = h(null), x = h(null), S = h(0), C = null, T = null;
199
200
  p(() => {
200
- b.value && (S.value = b.value.clientWidth, w = new ResizeObserver((e) => {
201
+ b.value && (S.value = b.value.clientWidth, C = new ResizeObserver((e) => {
201
202
  let t = e[0];
202
203
  t && (u.debounce ? (T && clearTimeout(T), T = setTimeout(() => {
203
204
  S.value = t.contentRect.width;
204
205
  }, u.debounce)) : S.value = t.contentRect.width);
205
- }), w.observe(b.value));
206
+ }), C.observe(b.value));
206
207
  }), ee(() => {
207
- w?.disconnect(), T && clearTimeout(T);
208
+ C?.disconnect(), T && clearTimeout(T);
208
209
  });
209
210
  let E = t(() => u.width ?? (S.value || 400)), D = t(() => u.height ?? 200), O = t(() => ({
210
211
  top: u.title ? 30 : 10,
@@ -269,30 +270,30 @@ var H = ["width", "height"], ue = ["x"], de = [
269
270
  }
270
271
  return p;
271
272
  }
272
- function ie(e, t) {
273
+ function F(e, t) {
273
274
  let n = e / t, r = 10 ** Math.floor(Math.log10(n)), i = n / r, a;
274
275
  return a = i <= 1.5 ? 1 : i <= 3 ? 2 : i <= 7 ? 5 : 10, a * r;
275
276
  }
276
- function F(e) {
277
+ function I(e) {
277
278
  return Math.round(e) + .5;
278
279
  }
279
- let ae = new Intl.NumberFormat();
280
- function I(e) {
281
- return Math.abs(e) >= 1e3 ? ae.format(e) : Number.isInteger(e) ? e.toString() : e.toFixed(1);
280
+ let ie = new Intl.NumberFormat();
281
+ function L(e) {
282
+ return Math.abs(e) >= 1e3 ? ie.format(e) : Number.isInteger(e) ? e.toString() : e.toFixed(1);
282
283
  }
283
- let L = t(() => {
284
+ let R = t(() => {
284
285
  let { min: e, max: t } = P.value;
285
286
  if (e === t) return [{
286
- value: I(e),
287
- y: F(O.value.top + A.value / 2)
287
+ value: L(e),
288
+ y: I(O.value.top + A.value / 2)
288
289
  }];
289
- let n = Math.max(3, Math.floor(A.value / 50)), r = ie(t - e, n), i = Math.ceil(e / r) * r, a = [];
290
+ let n = Math.max(3, Math.floor(A.value / 50)), r = F(t - e, n), i = Math.ceil(e / r) * r, a = [];
290
291
  for (let n = i; n <= t; n += r) a.push({
291
- value: I(n),
292
- y: F(O.value.top + A.value - (n - e) / P.value.range * A.value)
292
+ value: L(n),
293
+ y: I(O.value.top + A.value - (n - e) / P.value.range * A.value)
293
294
  });
294
295
  return a;
295
- }), R = t(() => {
296
+ }), z = t(() => {
296
297
  let e = N.value;
297
298
  if (e <= 1) return [];
298
299
  let t = u.xLabels;
@@ -300,27 +301,29 @@ var H = ["width", "height"], ue = ["x"], de = [
300
301
  let n = Math.max(3, Math.floor(k.value / 80)), r = Math.max(1, Math.round((e - 1) / n)), i = [];
301
302
  for (let n = 0; n < e; n += r) i.push({
302
303
  value: t[n],
303
- x: F(O.value.left + n / (e - 1) * k.value)
304
+ x: I(O.value.left + n / (e - 1) * k.value)
304
305
  });
305
306
  return i;
306
307
  }
307
- let n = u.xMin ?? 0, r = Math.max(3, Math.floor(k.value / 80)), i = ie(e - 1, r), a = [];
308
+ let n = u.xMin ?? 0, r = Math.max(3, Math.floor(k.value / 80)), i = F(e - 1, r), a = [];
308
309
  for (let t = 0; t <= e - 1; t += i) {
309
310
  let r = Math.round(t);
310
311
  a.push({
311
- value: I(r + n),
312
- x: F(O.value.left + r / (e - 1) * k.value)
312
+ value: L(r + n),
313
+ x: I(O.value.left + r / (e - 1) * k.value)
313
314
  });
314
315
  }
315
316
  return a;
316
317
  });
317
- function z() {
318
- return typeof u.menu == "string" ? u.menu : "chart";
319
- }
320
318
  function B() {
321
- return x.value;
319
+ return u.filename ? u.filename : typeof u.menu == "string" ? u.menu : "chart";
322
320
  }
323
321
  function V() {
322
+ return x.value;
323
+ }
324
+ function J() {
325
+ if (typeof u.csv == "function") return u.csv();
326
+ if (typeof u.csv == "string") return u.csv;
324
327
  let e = j.value;
325
328
  if (e.length === 0) return "";
326
329
  let t = N.value, n = [(e.length === 1 ? ["index", "value"] : ["index", ...e.map((e, t) => `series_${t}`)]).join(",")];
@@ -331,21 +334,21 @@ var H = ["width", "height"], ue = ["x"], de = [
331
334
  }
332
335
  return n.join("\n");
333
336
  }
334
- let J = h(null), Y = h(!1), Ce = h(null), X = t(() => !!u.tooltipData || !!u.tooltipTrigger), Z = t(() => {
335
- if (J.value === null) return 0;
337
+ let Y = h(null), X = h(!1), Ce = h(null), we = t(() => !!u.tooltipData || !!u.tooltipTrigger), Te = t(() => {
338
+ if (Y.value === null) return 0;
336
339
  let e = N.value, t = k.value / (e - 1 || 1);
337
- return O.value.left + J.value * t;
338
- }), we = t(() => {
339
- let e = J.value;
340
+ return O.value.left + Y.value * t;
341
+ }), Ee = t(() => {
342
+ let e = Y.value;
340
343
  if (e === null) return [];
341
344
  let { min: t, range: n } = P.value, r = A.value / n, i = O.value.top + A.value;
342
345
  return j.value.filter((t) => e < t.data.length && isFinite(t.data[e])).map((n) => ({
343
- x: Z.value,
346
+ x: Te.value,
344
347
  y: i - (n.data[e] - t) * r,
345
348
  color: n.color ?? "currentColor"
346
349
  }));
347
- }), Q = t(() => {
348
- let e = J.value;
350
+ }), Z = t(() => {
351
+ let e = Y.value;
349
352
  return e === null ? null : {
350
353
  index: e,
351
354
  xLabel: u.xLabels?.[e],
@@ -357,10 +360,10 @@ var H = ["width", "height"], ue = ["x"], de = [
357
360
  data: u.tooltipData?.[e] ?? null
358
361
  };
359
362
  });
360
- function Te(e) {
363
+ function De(e) {
361
364
  return "touches" in e ? e.touches[0] ?? null : e;
362
365
  }
363
- function Ee(e) {
366
+ function Oe(e) {
364
367
  let t = b.value?.getBoundingClientRect();
365
368
  if (!t) return null;
366
369
  let n = N.value;
@@ -368,71 +371,67 @@ var H = ["width", "height"], ue = ["x"], de = [
368
371
  let r = e - t.left, i = k.value / (n - 1 || 1), a = (r - O.value.left) / i;
369
372
  return Math.round(Math.max(0, Math.min(n - 1, a)));
370
373
  }
371
- function De(e, t) {
374
+ function ke(e, t) {
372
375
  let n = Ce.value;
373
376
  if (!n) return;
374
- let r = b.value.getBoundingClientRect(), i = Y.value ? Se : 0, a = e - r.left, o = Math.max(0, t - r.top - i);
377
+ let r = b.value.getBoundingClientRect(), i = X.value ? Se : 0, a = e - r.left, o = Math.max(0, t - r.top - i);
375
378
  n.style.left = `${a + 16}px`, n.style.top = `${o}px`;
376
379
  }
377
- function Oe(e) {
378
- let t = Te(e);
380
+ function Ae(e) {
381
+ let t = De(e);
379
382
  if (!t) return;
380
- let n = Ee(t.clientX);
381
- n !== null && (J.value = n, De(t.clientX, t.clientY), y("hover", { index: n }));
383
+ let n = Oe(t.clientX);
384
+ n !== null && (Y.value = n, ke(t.clientX, t.clientY), y("hover", { index: n }));
382
385
  }
383
- function ke(e) {
384
- Oe(e);
386
+ function je(e) {
387
+ Ae(e);
385
388
  }
386
- function Ae() {
387
- u.tooltipTrigger !== "click" && (J.value = null, y("hover", null));
389
+ function Me() {
390
+ u.tooltipTrigger !== "click" && (Y.value = null, y("hover", null));
388
391
  }
389
- function je(e) {
392
+ function Ne(e) {
390
393
  if (u.tooltipTrigger !== "click") return;
391
- let t = Te(e);
394
+ let t = De(e);
392
395
  if (!t) return;
393
- let n = Ee(t.clientX);
394
- n !== null && (J.value = J.value === n ? null : n, y("hover", J.value === null ? null : { index: n }));
396
+ let n = Oe(t.clientX);
397
+ n !== null && (Y.value = Y.value === n ? null : n, y("hover", Y.value === null ? null : { index: n }));
395
398
  }
396
- function Me(e) {
397
- Y.value = !0, Oe(e);
399
+ function Pe(e) {
400
+ X.value = !0, Ae(e);
398
401
  }
399
- function Ne(e) {
400
- Oe(e);
402
+ function Fe(e) {
403
+ Ae(e);
401
404
  }
402
- function Pe() {
403
- Y.value = !1, J.value = null, y("hover", null);
405
+ function Q() {
406
+ X.value = !1, Y.value = null, y("hover", null);
404
407
  }
405
- let Fe = t(() => {
406
- let e = z();
407
- return [
408
- {
409
- label: "Save as SVG",
410
- action: () => {
411
- let t = B();
412
- t && se(t, e);
413
- }
414
- },
415
- {
416
- label: "Save as PNG",
417
- action: () => {
418
- let t = B();
419
- t && ce(t, e);
420
- }
421
- },
422
- {
423
- label: "Download CSV",
424
- action: () => le(V(), e)
408
+ let $ = t(() => u.downloadLink ? typeof u.downloadLink == "string" ? u.downloadLink : "Download data (CSV)" : null), Ie = t(() => u.downloadLink ? `data:text/csv;charset=utf-8,${encodeURIComponent(J())}` : null), Le = t(() => {
409
+ let e = B(), t = [{
410
+ label: "Save as SVG",
411
+ action: () => {
412
+ let t = V();
413
+ t && oe(t, e);
425
414
  }
426
- ];
415
+ }, {
416
+ label: "Save as PNG",
417
+ action: () => {
418
+ let t = V();
419
+ t && se(t, e);
420
+ }
421
+ }];
422
+ return u.downloadLink || t.push({
423
+ label: "Download CSV",
424
+ action: () => H(J(), e)
425
+ }), t;
427
426
  });
428
427
  return (t, c) => (m(), i("div", {
429
428
  ref_key: "containerRef",
430
429
  ref: b,
431
430
  class: "line-chart-wrapper"
432
431
  }, [
433
- s.menu ? (m(), n(oe, {
432
+ s.menu ? (m(), n(ae, {
434
433
  key: 0,
435
- items: Fe.value
434
+ items: Le.value
436
435
  }, null, 8, ["items"])) : r("", !0),
437
436
  (m(), i("svg", {
438
437
  ref_key: "svgRef",
@@ -448,24 +447,24 @@ var H = ["width", "height"], ue = ["x"], de = [
448
447
  "font-size": "14",
449
448
  "font-weight": "600",
450
449
  fill: "currentColor"
451
- }, v(s.title), 9, ue)) : r("", !0),
450
+ }, v(s.title), 9, le)) : r("", !0),
452
451
  a("line", {
453
- x1: F(O.value.left),
454
- y1: F(O.value.top),
455
- x2: F(O.value.left),
456
- y2: F(O.value.top + A.value),
452
+ x1: I(O.value.left),
453
+ y1: I(O.value.top),
454
+ x2: I(O.value.left),
455
+ y2: I(O.value.top + A.value),
457
456
  stroke: "currentColor",
458
457
  "stroke-opacity": "0.3"
459
- }, null, 8, de),
458
+ }, null, 8, U),
460
459
  a("line", {
461
- x1: F(O.value.left),
462
- y1: F(O.value.top + A.value),
463
- x2: F(O.value.left + k.value),
464
- y2: F(O.value.top + A.value),
460
+ x1: I(O.value.left),
461
+ y1: I(O.value.top + A.value),
462
+ x2: I(O.value.left + k.value),
463
+ y2: I(O.value.top + A.value),
465
464
  stroke: "currentColor",
466
465
  "stroke-opacity": "0.3"
467
- }, null, 8, fe),
468
- s.yGrid ? (m(!0), i(e, { key: 1 }, g(L.value, (e, t) => (m(), i("line", {
466
+ }, null, 8, ue),
467
+ s.yGrid ? (m(!0), i(e, { key: 1 }, g(R.value, (e, t) => (m(), i("line", {
469
468
  key: "yg" + t,
470
469
  x1: O.value.left,
471
470
  y1: e.y,
@@ -473,8 +472,8 @@ var H = ["width", "height"], ue = ["x"], de = [
473
472
  y2: e.y,
474
473
  stroke: "currentColor",
475
474
  "stroke-opacity": "0.1"
476
- }, null, 8, U))), 128)) : r("", !0),
477
- s.xGrid ? (m(!0), i(e, { key: 2 }, g(R.value, (e, t) => (m(), i("line", {
475
+ }, null, 8, de))), 128)) : r("", !0),
476
+ s.xGrid ? (m(!0), i(e, { key: 2 }, g(z.value, (e, t) => (m(), i("line", {
478
477
  key: "xg" + t,
479
478
  x1: e.x,
480
479
  y1: O.value.top,
@@ -482,8 +481,8 @@ var H = ["width", "height"], ue = ["x"], de = [
482
481
  y2: O.value.top + A.value,
483
482
  stroke: "currentColor",
484
483
  "stroke-opacity": "0.1"
485
- }, null, 8, pe))), 128)) : r("", !0),
486
- (m(!0), i(e, null, g(L.value, (e, t) => (m(), i("text", {
484
+ }, null, 8, W))), 128)) : r("", !0),
485
+ (m(!0), i(e, null, g(R.value, (e, t) => (m(), i("text", {
487
486
  key: "y" + t,
488
487
  x: O.value.left - 6,
489
488
  y: e.y,
@@ -492,7 +491,7 @@ var H = ["width", "height"], ue = ["x"], de = [
492
491
  "font-size": "10",
493
492
  fill: "currentColor",
494
493
  "fill-opacity": "0.6"
495
- }, v(e.value), 9, me))), 128)),
494
+ }, v(e.value), 9, G))), 128)),
496
495
  s.yLabel ? (m(), i("text", {
497
496
  key: 3,
498
497
  x: 0,
@@ -501,8 +500,8 @@ var H = ["width", "height"], ue = ["x"], de = [
501
500
  "text-anchor": "middle",
502
501
  "font-size": "13",
503
502
  fill: "currentColor"
504
- }, v(s.yLabel), 9, W)) : r("", !0),
505
- (m(!0), i(e, null, g(R.value, (e, t) => (m(), i("text", {
503
+ }, v(s.yLabel), 9, fe)) : r("", !0),
504
+ (m(!0), i(e, null, g(z.value, (e, t) => (m(), i("text", {
506
505
  key: "x" + t,
507
506
  x: e.x,
508
507
  y: O.value.top + A.value + 16,
@@ -510,7 +509,7 @@ var H = ["width", "height"], ue = ["x"], de = [
510
509
  "font-size": "10",
511
510
  fill: "currentColor",
512
511
  "fill-opacity": "0.6"
513
- }, v(e.value), 9, G))), 128)),
512
+ }, v(e.value), 9, pe))), 128)),
514
513
  s.xLabel ? (m(), i("text", {
515
514
  key: 4,
516
515
  x: O.value.left + k.value / 2,
@@ -518,14 +517,14 @@ var H = ["width", "height"], ue = ["x"], de = [
518
517
  "text-anchor": "middle",
519
518
  "font-size": "13",
520
519
  fill: "currentColor"
521
- }, v(s.xLabel), 9, he)) : r("", !0),
520
+ }, v(s.xLabel), 9, me)) : r("", !0),
522
521
  (m(!0), i(e, null, g(M.value, (e, t) => (m(), i("path", {
523
522
  key: "area" + t,
524
523
  d: re(e.upper, e.lower),
525
524
  fill: e.color ?? "currentColor",
526
525
  "fill-opacity": e.opacity ?? .2,
527
526
  stroke: "none"
528
- }, null, 8, ge))), 128)),
527
+ }, null, 8, he))), 128)),
529
528
  (m(!0), i(e, null, g(j.value, (t, n) => (m(), i(e, { key: n }, [t.line === !1 ? r("", !0) : (m(), i("path", {
530
529
  key: 0,
531
530
  d: te(t.data),
@@ -534,7 +533,7 @@ var H = ["width", "height"], ue = ["x"], de = [
534
533
  "stroke-width": t.strokeWidth ?? 1.5,
535
534
  "stroke-opacity": t.lineOpacity ?? t.opacity ?? s.lineOpacity,
536
535
  "stroke-dasharray": t.dashed ? "6 3" : void 0
537
- }, null, 8, _e)), t.dots ? (m(!0), i(e, { key: 1 }, g(ne(t.data), (e, n) => (m(), i("circle", {
536
+ }, null, 8, ge)), t.dots ? (m(!0), i(e, { key: 1 }, g(ne(t.data), (e, n) => (m(), i("circle", {
538
537
  key: n,
539
538
  cx: e.x,
540
539
  cy: e.y,
@@ -542,19 +541,19 @@ var H = ["width", "height"], ue = ["x"], de = [
542
541
  fill: t.dotFill ?? t.color ?? "currentColor",
543
542
  "fill-opacity": t.dotOpacity ?? t.opacity ?? s.lineOpacity,
544
543
  stroke: t.dotStroke ?? "none"
545
- }, null, 8, ve))), 128)) : r("", !0)], 64))), 128)),
546
- X.value && J.value !== null ? (m(), i("line", {
544
+ }, null, 8, _e))), 128)) : r("", !0)], 64))), 128)),
545
+ we.value && Y.value !== null ? (m(), i("line", {
547
546
  key: 5,
548
- x1: F(Z.value),
547
+ x1: I(Te.value),
549
548
  y1: O.value.top,
550
- x2: F(Z.value),
549
+ x2: I(Te.value),
551
550
  y2: O.value.top + A.value,
552
551
  stroke: "currentColor",
553
552
  "stroke-opacity": "0.3",
554
553
  "stroke-dasharray": "4 2",
555
554
  "pointer-events": "none"
556
- }, null, 8, ye)) : r("", !0),
557
- (m(!0), i(e, null, g(we.value, (e, t) => (m(), i("circle", {
555
+ }, null, 8, ve)) : r("", !0),
556
+ (m(!0), i(e, null, g(Ee.value, (e, t) => (m(), i("circle", {
558
557
  key: "hd" + t,
559
558
  cx: e.x,
560
559
  cy: e.y,
@@ -563,8 +562,8 @@ var H = ["width", "height"], ue = ["x"], de = [
563
562
  stroke: "var(--color-bg-0, #fff)",
564
563
  "stroke-width": "2",
565
564
  "pointer-events": "none"
566
- }, null, 8, be))), 128)),
567
- X.value ? (m(), i("rect", {
565
+ }, null, 8, K))), 128)),
566
+ we.value ? (m(), i("rect", {
568
567
  key: 6,
569
568
  x: O.value.left,
570
569
  y: O.value.top,
@@ -575,15 +574,15 @@ var H = ["width", "height"], ue = ["x"], de = [
575
574
  cursor: "crosshair",
576
575
  "touch-action": "none"
577
576
  },
578
- onMousemove: ke,
579
- onMouseleave: Ae,
580
- onClick: je,
581
- onTouchstart: C(Me, ["prevent"]),
582
- onTouchmove: C(Ne, ["prevent"]),
583
- onTouchend: Pe
584
- }, null, 40, xe)) : r("", !0)
585
- ], 8, H)),
586
- X.value && J.value !== null && Q.value ? (m(), i("div", {
577
+ onMousemove: je,
578
+ onMouseleave: Me,
579
+ onClick: Ne,
580
+ onTouchstart: w(Pe, ["prevent"]),
581
+ onTouchmove: w(Fe, ["prevent"]),
582
+ onTouchend: Q
583
+ }, null, 40, q)) : r("", !0)
584
+ ], 8, ce)),
585
+ we.value && Y.value !== null && Z.value ? (m(), i("div", {
587
586
  key: 1,
588
587
  ref_key: "tooltipRef",
589
588
  ref: Ce,
@@ -592,16 +591,22 @@ var H = ["width", "height"], ue = ["x"], de = [
592
591
  position: "absolute",
593
592
  transform: "translateY(-50%)"
594
593
  }
595
- }, [_(t.$slots, "tooltip", d(l(Q.value)), () => [a("div", K, [Q.value.xLabel ? (m(), i("div", q, v(Q.value.xLabel), 1)) : r("", !0), (m(!0), i(e, null, g(Q.value.values, (e) => (m(), i("div", {
594
+ }, [_(t.$slots, "tooltip", d(l(Z.value)), () => [a("div", ye, [Z.value.xLabel ? (m(), i("div", be, v(Z.value.xLabel), 1)) : r("", !0), (m(!0), i(e, null, g(Z.value.values, (e) => (m(), i("div", {
596
595
  key: e.seriesIndex,
597
596
  class: "line-chart-tooltip-row"
598
597
  }, [a("span", {
599
598
  class: "line-chart-tooltip-swatch",
600
599
  style: f({ background: e.color })
601
- }, null, 4), o(" " + v(isFinite(e.value) ? I(e.value) : "—"), 1)]))), 128))])], !0)], 512)) : r("", !0)
600
+ }, null, 4), o(" " + v(isFinite(e.value) ? L(e.value) : "—"), 1)]))), 128))])], !0)], 512)) : r("", !0),
601
+ $.value ? (m(), i("a", {
602
+ key: 2,
603
+ class: "line-chart-download-link",
604
+ href: Ie.value,
605
+ download: `${B()}.csv`
606
+ }, v($.value), 9, xe)) : r("", !0)
602
607
  ], 512));
603
608
  }
604
- }), [["__scopeId", "data-v-4ea55781"]]), Y = {
609
+ }), [["__scopeId", "data-v-61fdeef2"]]), Y = {
605
610
  "01013": "010259",
606
611
  "01015": "010177",
607
612
  "01029": "010177",
@@ -3762,7 +3767,7 @@ var H = ["width", "height"], ue = ["x"], de = [
3762
3767
  51019: "510014",
3763
3768
  "02158": "020820",
3764
3769
  46102: "460957"
3765
- }, Ce = {
3770
+ }, X = {
3766
3771
  "010259": "Butler, AL",
3767
3772
  "010177": "Calhoun (Anniston), AL - Cleburne, AL",
3768
3773
  "010172": "Chambers, AL - Randolph, AL",
@@ -4712,27 +4717,28 @@ var H = ["width", "height"], ue = ["x"], de = [
4712
4717
  560775: "Teton, WY - Lincoln, WY",
4713
4718
  560792: "Uinta, WY",
4714
4719
  560804: "Weston, WY"
4715
- }, X = ["width", "height"], Z = [
4720
+ }, Ce = ["width", "height"], we = [
4716
4721
  "data-feat-id",
4717
4722
  "d",
4718
4723
  "fill",
4719
4724
  "stroke",
4720
4725
  "stroke-width"
4721
- ], we = { key: 0 }, Q = ["d", "stroke"], Te = ["transform"], Ee = {
4726
+ ], Te = { key: 0 }, Ee = ["d", "stroke"], Z = ["transform"], De = {
4722
4727
  key: 0,
4723
4728
  y: 5,
4724
4729
  "font-size": "13",
4725
4730
  "font-weight": "600",
4726
4731
  fill: "currentColor"
4727
- }, De = ["x", "fill"], Oe = ["x"], ke = {
4732
+ }, Oe = ["x", "fill"], ke = ["x"], Ae = {
4728
4733
  key: 0,
4729
4734
  y: 5,
4730
4735
  "font-size": "13",
4731
4736
  "font-weight": "600",
4732
4737
  fill: "currentColor"
4733
- }, Ae = ["offset", "stop-color"], je = ["x", "fill"], Me = ["x"], Ne = ["x"], Pe = /* @__PURE__ */ B(/* @__PURE__ */ c({
4738
+ }, je = ["offset", "stop-color"], Me = ["x", "fill"], Ne = ["x"], Pe = ["x"], Fe = /* @__PURE__ */ B(/* @__PURE__ */ c({
4734
4739
  __name: "ChoroplethMap",
4735
4740
  props: {
4741
+ topology: {},
4736
4742
  data: {},
4737
4743
  geoType: { default: "states" },
4738
4744
  width: {},
@@ -4764,68 +4770,80 @@ var H = ["width", "height"], ue = ["x"], de = [
4764
4770
  },
4765
4771
  emits: ["stateClick", "stateHover"],
4766
4772
  setup(o, { emit: s }) {
4767
- let c = o, l = s, d = `choropleth-gradient-${b()}`, f = h(null), _ = h(null), y = h(null), S = h(0), C = null, w = null, T = !1, E = typeof window < "u" && "ontouchstart" in window, D = null, O = null;
4768
- function k() {
4769
- if (E) return;
4770
- let e = y.value;
4771
- e && (e.addEventListener("click", $), e.addEventListener("mouseover", $), e.addEventListener("mousemove", Re), e.addEventListener("mouseout", ze));
4772
- }
4773
+ let c = o, l = s, d = `choropleth-gradient-${x()}`, f = h(null), _ = h(null), b = h(null), C = h(0), w = null, T = null, E = !1, D = typeof window < "u" && "ontouchstart" in window, O = null, k = null;
4773
4774
  function A() {
4774
- let e = y.value;
4775
- e && (e.removeEventListener("click", $), e.removeEventListener("mouseover", $), e.removeEventListener("mousemove", Re), e.removeEventListener("mouseout", ze));
4775
+ if (D) return;
4776
+ let e = b.value;
4777
+ e && (e.addEventListener("click", Q), e.addEventListener("mouseover", Q), e.addEventListener("mousemove", $), e.addEventListener("mouseout", Ie));
4778
+ }
4779
+ function j() {
4780
+ let e = b.value;
4781
+ e && (e.removeEventListener("click", Q), e.removeEventListener("mouseover", Q), e.removeEventListener("mousemove", $), e.removeEventListener("mouseout", Ie));
4776
4782
  }
4777
4783
  p(() => {
4778
- f.value && (S.value = f.value.clientWidth, D = new ResizeObserver((e) => {
4784
+ f.value && (C.value = f.value.clientWidth, O = new ResizeObserver((e) => {
4779
4785
  let t = e[0];
4780
- t && (S.value = t.contentRect.width);
4781
- }), D.observe(f.value)), j(), k();
4786
+ t && (C.value = t.contentRect.width);
4787
+ }), O.observe(f.value)), M(), A();
4782
4788
  }), ee(() => {
4783
- D?.disconnect(), M(), A(), Fe();
4789
+ O?.disconnect(), N(), j(), Se();
4784
4790
  });
4785
- function j() {
4786
- if (!_.value || !y.value || !c.zoom && !c.pan) return;
4787
- let e = ne(_.value);
4788
- O = te().scaleExtent(c.zoom ? [1, 12] : [1, 1]).on("start", () => {
4789
- T = !0, Le();
4791
+ function M() {
4792
+ if (!_.value || !b.value || !c.zoom && !c.pan) return;
4793
+ let e = re(_.value);
4794
+ k = ne().scaleExtent(c.zoom ? [1, 12] : [1, 1]).on("start", () => {
4795
+ E = !0, Fe();
4790
4796
  }).on("zoom", (e) => {
4791
- y.value && y.value.setAttribute("transform", e.transform);
4797
+ b.value && b.value.setAttribute("transform", e.transform);
4792
4798
  }).on("end", () => {
4793
- T = !1;
4794
- }), c.pan || O.filter((e) => e.type === "wheel" || e.type === "dblclick"), e.call(O);
4799
+ E = !1;
4800
+ }), c.pan || k.filter((e) => e.type === "wheel" || e.type === "dblclick"), e.call(k);
4795
4801
  }
4796
- function M() {
4797
- _.value && O && (ne(_.value).on(".zoom", null), O = null);
4802
+ function N() {
4803
+ _.value && k && (re(_.value).on(".zoom", null), k = null);
4798
4804
  }
4799
- x(() => [c.zoom, c.pan], () => {
4800
- M(), A(), j(), k();
4805
+ S(() => [c.zoom, c.pan], () => {
4806
+ N(), j(), M(), A();
4801
4807
  });
4802
- let L = t(() => c.width ?? (S.value || 600)), R = t(() => c.width && c.height ? c.height / c.width : .625), z = t(() => L.value * R.value), B = ae, V = I, le = t(() => {
4803
- let e = V.objects.counties.geometries, t = /* @__PURE__ */ new Map();
4804
- for (let n of e) {
4805
- let e = Y[String(n.id).padStart(5, "0")];
4806
- e && (t.has(e) || t.set(e, []), t.get(e).push(n));
4808
+ let L = t(() => c.width ?? (C.value || 600)), R = t(() => c.width && c.height ? c.height / c.width : .625), z = t(() => L.value * R.value), B = t(() => {
4809
+ let e = y(c.topology), t = e.objects.counties.geometries, n = /* @__PURE__ */ new Map();
4810
+ for (let e of t) {
4811
+ let t = Y[String(e.id).padStart(5, "0")];
4812
+ t && (n.has(t) || n.set(t, []), n.get(t).push(e));
4807
4813
  }
4808
- let n = [];
4809
- for (let [e, r] of t) n.push({
4814
+ let r = [];
4815
+ for (let [t, i] of n) r.push({
4810
4816
  type: "Feature",
4811
- id: e,
4812
- properties: { name: Ce[e] ?? e },
4813
- geometry: ie(V, r)
4817
+ id: t,
4818
+ properties: { name: X[t] ?? t },
4819
+ geometry: I(e, i)
4814
4820
  });
4815
4821
  return {
4816
4822
  type: "FeatureCollection",
4817
- features: n
4823
+ features: r
4818
4824
  };
4819
- }), H = t(() => c.geoType === "hsas" ? le.value : c.geoType === "counties" ? re(V, V.objects.counties) : re(B, B.objects.states)), ue = t(() => c.geoType !== "counties" && c.geoType !== "hsas" ? null : F(V, V.objects.states, (e, t) => e !== t)), de = t(() => N().fitExtent([[0, Ge.value], [L.value, z.value + Ge.value]], H.value)), fe = t(() => P(de.value)), U = t(() => c.geoType === "counties" || c.geoType === "hsas" ? c.strokeWidth * .5 : c.strokeWidth), pe = t(() => {
4825
+ }), V = t(() => {
4826
+ if (c.geoType === "hsas") return B.value;
4827
+ if (c.geoType === "counties") {
4828
+ let e = y(c.topology);
4829
+ return F(e, e.objects.counties);
4830
+ }
4831
+ let e = y(c.topology);
4832
+ return F(e, e.objects.states);
4833
+ }), H = t(() => {
4834
+ if (c.geoType !== "counties" && c.geoType !== "hsas") return null;
4835
+ let e = y(c.topology);
4836
+ return ie(e, e.objects.states, (e, t) => e !== t);
4837
+ }), ce = t(() => P().fitExtent([[0, He.value], [L.value, z.value + He.value]], V.value)), le = t(() => te(ce.value)), U = t(() => c.geoType === "counties" || c.geoType === "hsas" ? c.strokeWidth * .5 : c.strokeWidth), ue = t(() => {
4820
4838
  let e = /* @__PURE__ */ new Map();
4821
4839
  if (!c.data) return e;
4822
4840
  for (let t of c.data) {
4823
4841
  e.set(t.id, t.value);
4824
- let n = H.value.features.find((e) => e.properties?.name === t.id);
4842
+ let n = V.value.features.find((e) => e.properties?.name === t.id);
4825
4843
  n?.id != null && e.set(String(n.id), t.value);
4826
4844
  }
4827
4845
  return e;
4828
- }), me = t(() => {
4846
+ }), de = t(() => {
4829
4847
  if (!c.data || c.data.length === 0) return {
4830
4848
  min: 0,
4831
4849
  max: 1
@@ -4842,8 +4860,8 @@ var H = ["width", "height"], ue = ["x"], de = [
4842
4860
  min: 0,
4843
4861
  max: 1
4844
4862
  };
4845
- }), W = t(() => Array.isArray(c.colorScale) && c.colorScale.length > 0 && "value" in c.colorScale[0]), G = t(() => Array.isArray(c.colorScale) && !W.value), he = t(() => G.value ? "" : c.colorScale?.min ?? "#e5f0fa"), ge = t(() => G.value ? "" : c.colorScale?.max ?? "#08519c");
4846
- function _e(e) {
4863
+ }), W = t(() => Array.isArray(c.colorScale) && c.colorScale.length > 0 && "value" in c.colorScale[0]), G = t(() => Array.isArray(c.colorScale) && !W.value), fe = t(() => G.value ? "" : c.colorScale?.min ?? "#e5f0fa"), pe = t(() => G.value ? "" : c.colorScale?.max ?? "#08519c");
4864
+ function me(e) {
4847
4865
  let t = e.replace("#", "");
4848
4866
  return [
4849
4867
  parseInt(t.slice(0, 2), 16),
@@ -4851,101 +4869,101 @@ var H = ["width", "height"], ue = ["x"], de = [
4851
4869
  parseInt(t.slice(4, 6), 16)
4852
4870
  ];
4853
4871
  }
4854
- function ve(e) {
4855
- let [t, n, r] = _e(he.value), [i, a, o] = _e(ge.value);
4872
+ function he(e) {
4873
+ let [t, n, r] = me(fe.value), [i, a, o] = me(pe.value);
4856
4874
  return `rgb(${Math.round(t + (i - t) * e)},${Math.round(n + (a - n) * e)},${Math.round(r + (o - r) * e)})`;
4857
4875
  }
4858
- function ye(e) {
4876
+ function ge(e) {
4859
4877
  let t = c.colorScale.slice().sort((e, t) => t.min - e.min);
4860
4878
  for (let n of t) if (e >= n.min) return n.color;
4861
4879
  return c.noDataColor;
4862
4880
  }
4863
- function be(e) {
4881
+ function _e(e) {
4864
4882
  let t = c.colorScale.find((t) => t.value === String(e));
4865
4883
  return t ? t.color : c.noDataColor;
4866
4884
  }
4867
- function xe(e) {
4868
- let t = pe.value.get(String(e));
4885
+ function ve(e) {
4886
+ let t = ue.value.get(String(e));
4869
4887
  if (t == null) return c.noDataColor;
4870
- if (W.value) return be(t);
4871
- if (G.value) return ye(t);
4872
- let { min: n, max: r } = me.value;
4873
- return ve((t - n) / (r - n));
4888
+ if (W.value) return _e(t);
4889
+ if (G.value) return ge(t);
4890
+ let { min: n, max: r } = de.value;
4891
+ return he((t - n) / (r - n));
4874
4892
  }
4875
4893
  function K(e) {
4876
4894
  return e.properties?.name ?? String(e.id);
4877
4895
  }
4878
4896
  function q(e) {
4879
- return pe.value.get(String(e.id));
4897
+ return ue.value.get(String(e.id));
4880
4898
  }
4881
- let Se = t(() => {
4899
+ let ye = t(() => {
4882
4900
  let e = /* @__PURE__ */ new Map();
4883
- for (let t of H.value.features) e.set(String(t.id), t);
4901
+ for (let t of V.value.features) e.set(String(t.id), t);
4884
4902
  return e;
4885
4903
  });
4886
- function J(e) {
4904
+ function be(e) {
4887
4905
  let t = e;
4888
4906
  for (; t && !t.dataset?.featId;) t = t.parentElement;
4889
4907
  if (!t) return null;
4890
- let n = Se.value.get(t.dataset.featId);
4908
+ let n = ye.value.get(t.dataset.featId);
4891
4909
  return n ? {
4892
4910
  pathEl: t,
4893
4911
  feat: n
4894
4912
  } : null;
4895
4913
  }
4896
- function Pe(e, t, n) {
4897
- w || (w = document.createElement("div"), w.className = "chart-tooltip-content", w.style.position = "fixed", w.style.transform = "translateY(-50%)", document.body.appendChild(w));
4914
+ function xe(e, t, n) {
4915
+ T || (T = document.createElement("div"), T.className = "chart-tooltip-content", T.style.position = "fixed", T.style.transform = "translateY(-50%)", document.body.appendChild(T));
4898
4916
  let r = K(e), i = q(e), a = {
4899
4917
  id: String(e.id),
4900
4918
  name: r,
4901
4919
  value: i
4902
4920
  };
4903
- c.tooltipFormat ? w.innerHTML = c.tooltipFormat(a) : w.textContent = i == null ? r : `${r}: ${i}`, w.style.left = `${t + 16}px`, w.style.top = `${n}px`;
4921
+ c.tooltipFormat ? T.innerHTML = c.tooltipFormat(a) : T.textContent = i == null ? r : `${r}: ${i}`, T.style.left = `${t + 16}px`, T.style.top = `${n}px`;
4904
4922
  }
4905
- function Fe() {
4906
- w &&= (w.remove(), null);
4923
+ function Se() {
4924
+ T &&= (T.remove(), null);
4907
4925
  }
4908
- function Ie(e, t) {
4909
- C && C !== e && (C.setAttribute("stroke-width", String(U.value)), C.setAttribute("stroke", c.strokeColor)), C = e, e.parentNode?.appendChild(e), e.setAttribute("stroke-width", String(U.value + 1)), e.setAttribute("stroke", "#555");
4926
+ function J(e, t) {
4927
+ w && w !== e && (w.setAttribute("stroke-width", String(U.value)), w.setAttribute("stroke", c.strokeColor)), w = e, e.parentNode?.appendChild(e), e.setAttribute("stroke-width", String(U.value + 1)), e.setAttribute("stroke", "#555");
4910
4928
  }
4911
- function Le() {
4912
- C && (C.setAttribute("stroke-width", String(U.value)), C.setAttribute("stroke", c.strokeColor), C = null, l("stateHover", null)), Fe();
4929
+ function Fe() {
4930
+ w && (w.setAttribute("stroke-width", String(U.value)), w.setAttribute("stroke", c.strokeColor), w = null, l("stateHover", null)), Se();
4913
4931
  }
4914
- function $(e) {
4915
- if (T) return;
4916
- let t = e, n = J(t.target);
4932
+ function Q(e) {
4933
+ if (E) return;
4934
+ let t = e, n = be(t.target);
4917
4935
  n && (e.type === "click" ? l("stateClick", {
4918
4936
  id: String(n.feat.id),
4919
4937
  name: K(n.feat),
4920
4938
  value: q(n.feat)
4921
- }) : e.type === "mouseover" && (Ie(n.pathEl, n.feat), c.tooltipTrigger && Pe(n.feat, t.clientX, t.clientY), l("stateHover", {
4939
+ }) : e.type === "mouseover" && (J(n.pathEl, n.feat), c.tooltipTrigger && xe(n.feat, t.clientX, t.clientY), l("stateHover", {
4922
4940
  id: String(n.feat.id),
4923
4941
  name: K(n.feat),
4924
4942
  value: q(n.feat)
4925
4943
  })));
4926
4944
  }
4927
- function Re(e) {
4928
- T || !w || (w.style.left = `${e.clientX + 16}px`, w.style.top = `${e.clientY}px`);
4945
+ function $(e) {
4946
+ E || !T || (T.style.left = `${e.clientX + 16}px`, T.style.top = `${e.clientY}px`);
4929
4947
  }
4930
- function ze(e) {
4948
+ function Ie(e) {
4931
4949
  let t = e.relatedTarget;
4932
- t && y.value?.contains(t) || Le();
4950
+ t && b.value?.contains(t) || Fe();
4933
4951
  }
4934
- function Be() {
4952
+ function Le() {
4935
4953
  return typeof c.menu == "string" ? c.menu : "choropleth";
4936
4954
  }
4937
- let Ve = t(() => c.legend && (W.value || G.value || c.data)), He = t(() => c.colorScale.slice().sort((e, t) => e.min - t.min)), Ue = t(() => c.title ? 24 : 0), We = t(() => Ve.value ? 28 : 0), Ge = t(() => Ue.value + We.value), Ke = t(() => z.value + Ge.value), qe = t(() => Ue.value + 18), Je = t(() => {
4955
+ let Re = t(() => c.legend && (W.value || G.value || c.data)), ze = t(() => c.colorScale.slice().sort((e, t) => e.min - t.min)), Be = t(() => c.title ? 24 : 0), Ve = t(() => Re.value ? 28 : 0), He = t(() => Be.value + Ve.value), Ue = t(() => z.value + He.value), We = t(() => Be.value + 18), Ge = t(() => {
4938
4956
  let e = [];
4939
4957
  for (let t = 0; t <= 10; t++) {
4940
4958
  let n = t / 10;
4941
4959
  e.push({
4942
4960
  offset: `${(n * 100).toFixed(0)}%`,
4943
- color: ve(n)
4961
+ color: he(n)
4944
4962
  });
4945
4963
  }
4946
4964
  return e;
4947
- }), Ye = t(() => {
4948
- let { min: e, max: t } = me.value, n = t - e, r = [];
4965
+ }), Ke = t(() => {
4966
+ let { min: e, max: t } = de.value, n = t - e, r = [];
4949
4967
  for (let t = 1; t <= 3; t++) {
4950
4968
  let i = t / 4, a = e + n * i, o = Number.isInteger(a) ? String(a) : a.toFixed(1).replace(/\.0$/, "");
4951
4969
  r.push({
@@ -4954,44 +4972,44 @@ var H = ["width", "height"], ue = ["x"], de = [
4954
4972
  });
4955
4973
  }
4956
4974
  return r;
4957
- }), Xe = t(() => {
4975
+ }), qe = t(() => {
4958
4976
  let e = [];
4959
4977
  if (W.value) for (let t of c.colorScale) e.push({
4960
4978
  key: t.value,
4961
4979
  color: t.color,
4962
4980
  label: t.value
4963
4981
  });
4964
- else if (G.value) for (let t of He.value) e.push({
4982
+ else if (G.value) for (let t of ze.value) e.push({
4965
4983
  key: String(t.min),
4966
4984
  color: t.color,
4967
4985
  label: t.label ?? String(t.min)
4968
4986
  });
4969
4987
  return e;
4970
- }), Ze = t(() => {
4988
+ }), Je = t(() => {
4971
4989
  let e = c.legendTitle ? c.legendTitle.length * 8 + 12 : 0;
4972
- for (let t of Xe.value) e += 16 + t.label.length * 7 + 12;
4973
- return e - (Xe.value.length > 0 ? 12 : 0);
4974
- }), Qe = t(() => {
4990
+ for (let t of qe.value) e += 16 + t.label.length * 7 + 12;
4991
+ return e - (qe.value.length > 0 ? 12 : 0);
4992
+ }), Ye = t(() => {
4975
4993
  let e = c.legendTitle ? c.legendTitle.length * 8 + 12 : 0;
4976
- return Xe.value.map((t) => {
4994
+ return qe.value.map((t) => {
4977
4995
  let n = e;
4978
4996
  return e += 16 + t.label.length * 7 + 12, n;
4979
4997
  });
4980
- }), $e = t(() => {
4981
- if (W.value || G.value) return (L.value - Ze.value) / 2;
4998
+ }), Xe = t(() => {
4999
+ if (W.value || G.value) return (L.value - Je.value) / 2;
4982
5000
  let e = c.legendTitle ? c.legendTitle.length * 8 + 12 : 0;
4983
5001
  return (L.value - e - 160) / 2;
4984
- }), et = t(() => {
4985
- let e = Be();
5002
+ }), Ze = t(() => {
5003
+ let e = Le();
4986
5004
  return [{
4987
5005
  label: "Save as SVG",
4988
5006
  action: () => {
4989
- _.value && se(_.value, e);
5007
+ _.value && oe(_.value, e);
4990
5008
  }
4991
5009
  }, {
4992
5010
  label: "Save as PNG",
4993
5011
  action: () => {
4994
- _.value && ce(_.value, e);
5012
+ _.value && se(_.value, e);
4995
5013
  }
4996
5014
  }];
4997
5015
  });
@@ -4999,64 +5017,64 @@ var H = ["width", "height"], ue = ["x"], de = [
4999
5017
  ref_key: "containerRef",
5000
5018
  ref: f,
5001
5019
  class: u(["choropleth-wrapper", { pannable: o.pan }])
5002
- }, [o.menu ? (m(), n(oe, {
5020
+ }, [o.menu ? (m(), n(ae, {
5003
5021
  key: 0,
5004
- items: et.value
5022
+ items: Ze.value
5005
5023
  }, null, 8, ["items"])) : r("", !0), (m(), i("svg", {
5006
5024
  ref_key: "svgRef",
5007
5025
  ref: _,
5008
5026
  width: L.value,
5009
- height: Ke.value
5027
+ height: Ue.value
5010
5028
  }, [
5011
5029
  a("g", {
5012
5030
  ref_key: "mapGroupRef",
5013
- ref: y
5014
- }, [(m(!0), i(e, null, g(H.value.features, (e) => (m(), i("path", {
5031
+ ref: b
5032
+ }, [(m(!0), i(e, null, g(V.value.features, (e) => (m(), i("path", {
5015
5033
  key: String(e.id),
5016
5034
  "data-feat-id": String(e.id),
5017
- d: fe.value(e) ?? void 0,
5018
- fill: xe(e.id),
5035
+ d: le.value(e) ?? void 0,
5036
+ fill: ve(e.id),
5019
5037
  stroke: o.strokeColor,
5020
5038
  "stroke-width": U.value,
5021
5039
  class: "state-path"
5022
- }, [o.tooltipTrigger ? r("", !0) : (m(), i("title", we, v(K(e)) + v(q(e) == null ? "" : `: ${q(e)}`), 1))], 8, Z))), 128)), ue.value ? (m(), i("path", {
5040
+ }, [o.tooltipTrigger ? r("", !0) : (m(), i("title", Te, v(K(e)) + v(q(e) == null ? "" : `: ${q(e)}`), 1))], 8, we))), 128)), H.value ? (m(), i("path", {
5023
5041
  key: 0,
5024
- d: fe.value(ue.value) ?? void 0,
5042
+ d: le.value(H.value) ?? void 0,
5025
5043
  fill: "none",
5026
5044
  stroke: o.strokeColor,
5027
5045
  "stroke-width": 1,
5028
5046
  "stroke-linejoin": "round",
5029
5047
  "pointer-events": "none"
5030
- }, null, 8, Q)) : r("", !0)], 512),
5031
- Ve.value ? (m(), i("g", {
5048
+ }, null, 8, Ee)) : r("", !0)], 512),
5049
+ Re.value ? (m(), i("g", {
5032
5050
  key: 0,
5033
5051
  class: "choropleth-legend",
5034
- transform: `translate(${$e.value},${qe.value})`
5035
- }, [W.value || G.value ? (m(), i(e, { key: 0 }, [o.legendTitle ? (m(), i("text", Ee, v(o.legendTitle), 1)) : r("", !0), (m(!0), i(e, null, g(Xe.value, (t, n) => (m(), i(e, { key: t.key }, [a("rect", {
5036
- x: Qe.value[n],
5052
+ transform: `translate(${Xe.value},${We.value})`
5053
+ }, [W.value || G.value ? (m(), i(e, { key: 0 }, [o.legendTitle ? (m(), i("text", De, v(o.legendTitle), 1)) : r("", !0), (m(!0), i(e, null, g(qe.value, (t, n) => (m(), i(e, { key: t.key }, [a("rect", {
5054
+ x: Ye.value[n],
5037
5055
  y: -5,
5038
5056
  width: "12",
5039
5057
  height: "12",
5040
5058
  rx: "3",
5041
5059
  fill: t.color
5042
- }, null, 8, De), a("text", {
5043
- x: Qe.value[n] + 16,
5060
+ }, null, 8, Oe), a("text", {
5061
+ x: Ye.value[n] + 16,
5044
5062
  y: 5,
5045
5063
  "font-size": "13",
5046
5064
  fill: "currentColor"
5047
- }, v(t.label), 9, Oe)], 64))), 128))], 64)) : (m(), i(e, { key: 1 }, [
5048
- o.legendTitle ? (m(), i("text", ke, v(o.legendTitle), 1)) : r("", !0),
5065
+ }, v(t.label), 9, ke)], 64))), 128))], 64)) : (m(), i(e, { key: 1 }, [
5066
+ o.legendTitle ? (m(), i("text", Ae, v(o.legendTitle), 1)) : r("", !0),
5049
5067
  a("defs", null, [a("linearGradient", {
5050
5068
  id: d,
5051
5069
  x1: "0",
5052
5070
  x2: "1",
5053
5071
  y1: "0",
5054
5072
  y2: "0"
5055
- }, [(m(!0), i(e, null, g(Je.value, (e) => (m(), i("stop", {
5073
+ }, [(m(!0), i(e, null, g(Ge.value, (e) => (m(), i("stop", {
5056
5074
  key: e.offset,
5057
5075
  offset: e.offset,
5058
5076
  "stop-color": e.color
5059
- }, null, 8, Ae))), 128))])]),
5077
+ }, null, 8, je))), 128))])]),
5060
5078
  a("rect", {
5061
5079
  x: o.legendTitle ? o.legendTitle.length * 8 + 12 : 0,
5062
5080
  y: -6,
@@ -5064,8 +5082,8 @@ var H = ["width", "height"], ue = ["x"], de = [
5064
5082
  height: 12,
5065
5083
  rx: "2",
5066
5084
  fill: `url(#${d})`
5067
- }, null, 8, je),
5068
- (m(!0), i(e, null, g(Ye.value, (e) => (m(), i("text", {
5085
+ }, null, 8, Me),
5086
+ (m(!0), i(e, null, g(Ke.value, (e) => (m(), i("text", {
5069
5087
  key: e.value,
5070
5088
  x: (o.legendTitle ? o.legendTitle.length * 8 + 12 : 0) + e.pct / 100 * 160,
5071
5089
  y: 20,
@@ -5073,8 +5091,8 @@ var H = ["width", "height"], ue = ["x"], de = [
5073
5091
  fill: "currentColor",
5074
5092
  opacity: "0.7",
5075
5093
  "text-anchor": "middle"
5076
- }, v(e.value), 9, Me))), 128))
5077
- ], 64))], 8, Te)) : r("", !0),
5094
+ }, v(e.value), 9, Ne))), 128))
5095
+ ], 64))], 8, Z)) : r("", !0),
5078
5096
  o.title ? (m(), i("text", {
5079
5097
  key: 1,
5080
5098
  x: L.value / 2,
@@ -5083,10 +5101,10 @@ var H = ["width", "height"], ue = ["x"], de = [
5083
5101
  "font-size": "14",
5084
5102
  "font-weight": "600",
5085
5103
  fill: "currentColor"
5086
- }, v(o.title), 9, Ne)) : r("", !0)
5087
- ], 8, X))], 2));
5104
+ }, v(o.title), 9, Pe)) : r("", !0)
5105
+ ], 8, Ce))], 2));
5088
5106
  }
5089
- }), [["__scopeId", "data-v-af9f8a22"]]), Fe = /* @__PURE__ */ B(/* @__PURE__ */ c({
5107
+ }), [["__scopeId", "data-v-ffaf1671"]]), Q = /* @__PURE__ */ B(/* @__PURE__ */ c({
5090
5108
  __name: "ChartTooltip",
5091
5109
  props: {
5092
5110
  x: {},
@@ -5106,12 +5124,12 @@ var H = ["width", "height"], ue = ["x"], de = [
5106
5124
  top: `${e.y}px`,
5107
5125
  transform: "translateY(-50%)"
5108
5126
  })
5109
- }, [_(t.$slots, "default", {}, void 0, !0)], 4)) : e.mode === "click" ? (m(), n(y(M), {
5127
+ }, [_(t.$slots, "default", {}, void 0, !0)], 4)) : e.mode === "click" ? (m(), n(b(N), {
5110
5128
  key: 1,
5111
5129
  open: e.open
5112
5130
  }, {
5113
- default: S(() => [s(y(k), { "as-child": "" }, {
5114
- default: S(() => [a("div", {
5131
+ default: C(() => [s(b(A), { "as-child": "" }, {
5132
+ default: C(() => [a("div", {
5115
5133
  class: "chart-tooltip-anchor",
5116
5134
  style: f({
5117
5135
  left: `${e.x}px`,
@@ -5119,8 +5137,8 @@ var H = ["width", "height"], ue = ["x"], de = [
5119
5137
  })
5120
5138
  }, null, 4)]),
5121
5139
  _: 1
5122
- }), s(y(j), null, {
5123
- default: S(() => [e.open ? (m(), n(y(A), {
5140
+ }), s(b(M), null, {
5141
+ default: C(() => [e.open ? (m(), n(b(j), {
5124
5142
  key: 0,
5125
5143
  class: "chart-tooltip-content",
5126
5144
  side: "right",
@@ -5129,7 +5147,7 @@ var H = ["width", "height"], ue = ["x"], de = [
5129
5147
  onPointerDownOutside: o[0] ||= (e) => t.$emit("close"),
5130
5148
  onEscapeKeyDown: o[1] ||= (e) => t.$emit("close")
5131
5149
  }, {
5132
- default: S(() => [_(t.$slots, "default", {}, void 0, !0)]),
5150
+ default: C(() => [_(t.$slots, "default", {}, void 0, !0)]),
5133
5151
  _: 3
5134
5152
  }, 8, ["side-offset"])) : r("", !0)]),
5135
5153
  _: 3
@@ -5137,7 +5155,7 @@ var H = ["width", "height"], ue = ["x"], de = [
5137
5155
  _: 3
5138
5156
  }, 8, ["open"])) : r("", !0);
5139
5157
  }
5140
- }), [["__scopeId", "data-v-44377f70"]]), Ie = { class: "TableWrapper" }, Le = { class: "Table" }, $ = /* @__PURE__ */ B(/* @__PURE__ */ c({
5158
+ }), [["__scopeId", "data-v-44377f70"]]), $ = { class: "TableWrapper" }, Ie = { class: "Table" }, Le = ["href", "download"], Re = /* @__PURE__ */ B(/* @__PURE__ */ c({
5141
5159
  __name: "DataTable",
5142
5160
  props: {
5143
5161
  data: {},
@@ -5146,7 +5164,10 @@ var H = ["width", "height"], ue = ["x"], de = [
5146
5164
  menu: {
5147
5165
  type: [Boolean, String],
5148
5166
  default: !0
5149
- }
5167
+ },
5168
+ csv: {},
5169
+ filename: {},
5170
+ downloadLink: { type: [Boolean, String] }
5150
5171
  },
5151
5172
  setup(o) {
5152
5173
  let s = {
@@ -5195,12 +5216,14 @@ var H = ["width", "height"], ue = ["x"], de = [
5195
5216
  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);
5196
5217
  }
5197
5218
  function b() {
5198
- return typeof c.menu == "string" ? c.menu : "data";
5219
+ return c.filename ? c.filename : typeof c.menu == "string" ? c.menu : "data";
5199
5220
  }
5200
5221
  function x(e) {
5201
5222
  return e.includes(",") || e.includes("\"") || e.includes("\n") ? `"${e.replace(/"/g, "\"\"")}"` : e;
5202
5223
  }
5203
5224
  function S() {
5225
+ if (typeof c.csv == "function") return c.csv();
5226
+ if (typeof c.csv == "string") return c.csv;
5204
5227
  let e = h.value, t = _.value, n = [e.map((e) => x(l(e.name))).join(",")];
5205
5228
  for (let r = 0; r < t; r++) {
5206
5229
  let t = e.map((e) => x(y(e, r)));
@@ -5208,29 +5231,38 @@ var H = ["width", "height"], ue = ["x"], de = [
5208
5231
  }
5209
5232
  return n.join("\n");
5210
5233
  }
5211
- let C = t(() => [{
5234
+ let C = t(() => c.downloadLink ? [] : [{
5212
5235
  label: "Download CSV",
5213
- action: () => le(S(), b())
5214
- }]);
5215
- return (t, s) => (m(), i("div", { class: u(["TableOuter", { "has-menu": o.menu }]) }, [o.menu ? (m(), n(oe, {
5216
- key: 0,
5217
- items: C.value
5218
- }, null, 8, ["items"])) : r("", !0), a("div", Ie, [a("table", Le, [
5219
- a("colgroup", null, [(m(!0), i(e, null, g(h.value, (e) => (m(), i("col", {
5220
- key: e.name,
5221
- style: f(d(e.name))
5222
- }, null, 4))), 128))]),
5223
- a("thead", null, [a("tr", null, [(m(!0), i(e, null, g(h.value, (e) => (m(), i("th", {
5224
- key: e.name,
5225
- style: f(p(e.name))
5226
- }, v(l(e.name)), 5))), 128))])]),
5227
- a("tbody", null, [(m(!0), i(e, null, g(_.value, (t) => (m(), i("tr", { key: t }, [(m(!0), i(e, null, g(h.value, (e) => (m(), i("td", {
5228
- key: e.name,
5229
- class: u(o.columnConfig?.[e.name]?.cellClass),
5230
- style: f(p(e.name))
5231
- }, v(y(e, t - 1)), 7))), 128))]))), 128))])
5232
- ])])], 2));
5236
+ action: () => H(S(), b())
5237
+ }]), w = t(() => c.downloadLink ? typeof c.downloadLink == "string" ? c.downloadLink : "Download data (CSV)" : null), T = t(() => c.downloadLink ? `data:text/csv;charset=utf-8,${encodeURIComponent(S())}` : null), E = t(() => c.menu && C.value.length > 0);
5238
+ return (t, s) => (m(), i("div", { class: u(["TableOuter", { "has-menu": E.value }]) }, [
5239
+ E.value ? (m(), n(ae, {
5240
+ key: 0,
5241
+ items: C.value
5242
+ }, null, 8, ["items"])) : r("", !0),
5243
+ a("div", $, [a("table", Ie, [
5244
+ a("colgroup", null, [(m(!0), i(e, null, g(h.value, (e) => (m(), i("col", {
5245
+ key: e.name,
5246
+ style: f(d(e.name))
5247
+ }, null, 4))), 128))]),
5248
+ a("thead", null, [a("tr", null, [(m(!0), i(e, null, g(h.value, (e) => (m(), i("th", {
5249
+ key: e.name,
5250
+ style: f(p(e.name))
5251
+ }, v(l(e.name)), 5))), 128))])]),
5252
+ a("tbody", null, [(m(!0), i(e, null, g(_.value, (t) => (m(), i("tr", { key: t }, [(m(!0), i(e, null, g(h.value, (e) => (m(), i("td", {
5253
+ key: e.name,
5254
+ class: u(o.columnConfig?.[e.name]?.cellClass),
5255
+ style: f(p(e.name))
5256
+ }, v(y(e, t - 1)), 7))), 128))]))), 128))])
5257
+ ])]),
5258
+ w.value ? (m(), i("a", {
5259
+ key: 1,
5260
+ class: "data-table-download-link",
5261
+ href: T.value,
5262
+ download: `${b()}.csv`
5263
+ }, v(w.value), 9, Le)) : r("", !0)
5264
+ ], 2));
5233
5265
  }
5234
- }), [["__scopeId", "data-v-dbfb7c84"]]);
5266
+ }), [["__scopeId", "data-v-505e2187"]]);
5235
5267
  //#endregion
5236
- export { Fe as ChartTooltip, Pe as ChoroplethMap, $ as DataTable, J as LineChart };
5268
+ export { Q as ChartTooltip, Fe as ChoroplethMap, Re as DataTable, J as LineChart };