@cfasim-ui/charts 0.1.10 → 0.2.2

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,17 +1,17 @@
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, normalizeClass as l, normalizeStyle as u, onMounted as d, onUnmounted as f, openBlock as p, ref as m, renderList as h, toDisplayString as g, unref as _, useId as v, watch as y, withCtx as b } from "vue";
2
- import { DropdownMenuContent as x, DropdownMenuItem as S, DropdownMenuPortal as C, DropdownMenuRoot as w, DropdownMenuTrigger as T } from "reka-ui";
3
- import { geoAlbersUsa as E, geoPath as D } from "d3-geo";
4
- import { zoom as ee } from "d3-zoom";
5
- import { select as O } from "d3-selection";
6
- import { feature as k, merge as A, mesh as te } from "topojson-client";
7
- import j from "us-atlas/states-10m.json";
8
- import M 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, 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";
9
9
  //#region src/ChartMenu/ChartMenu.vue?vue&type=script&setup=true&lang.ts
10
- var N = { class: "chart-menu-trigger-area" }, P = ["aria-label"], F = /* @__PURE__ */ c({
10
+ var L = { class: "chart-menu-trigger-area" }, R = ["aria-label"], z = /* @__PURE__ */ c({
11
11
  __name: "ChartMenu",
12
12
  props: { items: {} },
13
13
  setup(t) {
14
- return (r, c) => (p(), i("div", N, [t.items.length === 1 ? (p(), i("button", {
14
+ return (r, c) => (m(), i("div", L, [t.items.length === 1 ? (m(), i("button", {
15
15
  key: 0,
16
16
  class: "chart-menu-button chart-menu-single",
17
17
  "aria-label": t.items[0].label,
@@ -26,12 +26,15 @@ var N = { class: "chart-menu-trigger-area" }, P = ["aria-label"], F = /* @__PURE
26
26
  "stroke-linecap": "round",
27
27
  "stroke-linejoin": "round",
28
28
  "aria-hidden": "true"
29
- }, [a("path", { d: "M7 1v8M3 6l4 4 4-4M2 13h10" })], -1)]], 8, P)) : (p(), n(_(w), { key: 1 }, {
30
- default: b(() => [s(_(T), {
29
+ }, [a("path", { d: "M7 1v8M3 6l4 4 4-4M2 13h10" })], -1)]], 8, R)) : (m(), n(y(D), {
30
+ key: 1,
31
+ modal: !1
32
+ }, {
33
+ default: S(() => [s(y(O), {
31
34
  class: "chart-menu-button",
32
35
  "aria-label": "Chart options"
33
36
  }, {
34
- default: b(() => [...c[2] ||= [a("svg", {
37
+ default: S(() => [...c[2] ||= [a("svg", {
35
38
  width: "16",
36
39
  height: "16",
37
40
  viewBox: "0 0 16 16",
@@ -55,18 +58,18 @@ var N = { class: "chart-menu-trigger-area" }, P = ["aria-label"], F = /* @__PURE
55
58
  })
56
59
  ], -1)]]),
57
60
  _: 1
58
- }), s(_(C), null, {
59
- default: b(() => [s(_(x), {
61
+ }), s(y(E), null, {
62
+ default: S(() => [s(y(w), {
60
63
  class: "chart-menu-content",
61
64
  "side-offset": 4,
62
65
  align: "end"
63
66
  }, {
64
- default: b(() => [(p(!0), i(e, null, h(t.items, (e) => (p(), n(_(S), {
67
+ default: S(() => [(m(!0), i(e, null, g(t.items, (e) => (m(), n(y(T), {
65
68
  key: e.label,
66
69
  class: "chart-menu-item",
67
70
  onSelect: e.action
68
71
  }, {
69
- default: b(() => [o(g(e.label), 1)]),
72
+ default: S(() => [o(v(e.label), 1)]),
70
73
  _: 2
71
74
  }, 1032, ["onSelect"]))), 128))]),
72
75
  _: 1
@@ -76,24 +79,24 @@ var N = { class: "chart-menu-trigger-area" }, P = ["aria-label"], F = /* @__PURE
76
79
  _: 1
77
80
  }))]));
78
81
  }
79
- }), I = (e, t) => {
82
+ }), B = (e, t) => {
80
83
  let n = e.__vccOpts || e;
81
84
  for (let [e, r] of t) n[e] = r;
82
85
  return n;
83
- }, L = /* @__PURE__ */ I(F, [["__scopeId", "data-v-adef2467"]]);
86
+ }, oe = /* @__PURE__ */ B(z, [["__scopeId", "data-v-fe2f6904"]]);
84
87
  //#endregion
85
88
  //#region src/ChartMenu/download.ts
86
- function R(e, t) {
89
+ function V(e, t) {
87
90
  let n = URL.createObjectURL(e), r = document.createElement("a");
88
91
  r.href = n, r.download = t, r.click(), URL.revokeObjectURL(n);
89
92
  }
90
- function ne(e, t) {
93
+ function se(e, t) {
91
94
  let n = e.cloneNode(!0);
92
95
  n.setAttribute("xmlns", "http://www.w3.org/2000/svg");
93
96
  let r = new XMLSerializer().serializeToString(n);
94
- R(new Blob([r], { type: "image/svg+xml" }), `${t}.svg`);
97
+ V(new Blob([r], { type: "image/svg+xml" }), `${t}.svg`);
95
98
  }
96
- function re(e, t) {
99
+ function ce(e, t) {
97
100
  let n = e.cloneNode(!0);
98
101
  n.setAttribute("xmlns", "http://www.w3.org/2000/svg");
99
102
  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;
@@ -102,21 +105,21 @@ function re(e, t) {
102
105
  e.width = s * 2, e.height = c * 2;
103
106
  let n = e.getContext("2d");
104
107
  n.scale(2, 2), n.drawImage(o, 0, 0, s, c), e.toBlob((e) => {
105
- e && R(e, `${t}.png`);
108
+ e && V(e, `${t}.png`);
106
109
  }), URL.revokeObjectURL(a);
107
110
  }, o.src = a;
108
111
  }
109
- function z(e, t) {
110
- R(new Blob([e], { type: "text/csv" }), `${t}.csv`);
112
+ function le(e, t) {
113
+ V(new Blob([e], { type: "text/csv" }), `${t}.csv`);
111
114
  }
112
115
  //#endregion
113
116
  //#region src/LineChart/LineChart.vue?vue&type=script&setup=true&lang.ts
114
- var B = ["width", "height"], V = ["x"], ie = [
117
+ var H = ["width", "height"], ue = ["x"], de = [
115
118
  "x1",
116
119
  "y1",
117
120
  "x2",
118
121
  "y2"
119
- ], H = [
122
+ ], fe = [
120
123
  "x1",
121
124
  "y1",
122
125
  "x2",
@@ -126,22 +129,46 @@ var B = ["width", "height"], V = ["x"], ie = [
126
129
  "y1",
127
130
  "x2",
128
131
  "y2"
129
- ], ae = [
132
+ ], pe = [
130
133
  "x1",
131
134
  "y1",
132
135
  "x2",
133
136
  "y2"
134
- ], W = ["x", "y"], G = ["transform"], K = ["x", "y"], q = ["x", "y"], J = [
137
+ ], me = ["x", "y"], W = ["transform"], G = ["x", "y"], he = ["x", "y"], ge = [
135
138
  "d",
136
139
  "fill",
137
140
  "fill-opacity"
138
- ], Y = [
141
+ ], _e = [
139
142
  "d",
140
143
  "stroke",
141
144
  "stroke-width",
142
145
  "stroke-opacity",
143
146
  "stroke-dasharray"
144
- ], oe = /* @__PURE__ */ I(/* @__PURE__ */ c({
147
+ ], ve = [
148
+ "cx",
149
+ "cy",
150
+ "r",
151
+ "fill",
152
+ "fill-opacity",
153
+ "stroke"
154
+ ], ye = [
155
+ "x1",
156
+ "y1",
157
+ "x2",
158
+ "y2"
159
+ ], be = [
160
+ "cx",
161
+ "cy",
162
+ "fill"
163
+ ], xe = [
164
+ "x",
165
+ "y",
166
+ "width",
167
+ "height"
168
+ ], K = { class: "line-chart-tooltip" }, q = {
169
+ key: 0,
170
+ class: "line-chart-tooltip-label"
171
+ }, Se = 50, J = /* @__PURE__ */ B(/* @__PURE__ */ c({
145
172
  __name: "LineChart",
146
173
  props: {
147
174
  data: {},
@@ -162,38 +189,41 @@ var B = ["width", "height"], V = ["x"], ie = [
162
189
  default: !0
163
190
  },
164
191
  xGrid: { type: Boolean },
165
- yGrid: { type: Boolean }
192
+ yGrid: { type: Boolean },
193
+ tooltipData: {},
194
+ tooltipTrigger: {}
166
195
  },
167
- setup(o) {
168
- let s = o, c = m(null), l = m(null), u = m(0), _ = null, v = null;
169
- d(() => {
170
- c.value && (u.value = c.value.clientWidth, _ = new ResizeObserver((e) => {
196
+ emits: ["hover"],
197
+ setup(s, { emit: c }) {
198
+ let u = s, y = c, b = h(null), x = h(null), S = h(0), w = null, T = null;
199
+ p(() => {
200
+ b.value && (S.value = b.value.clientWidth, w = new ResizeObserver((e) => {
171
201
  let t = e[0];
172
- t && (s.debounce ? (v && clearTimeout(v), v = setTimeout(() => {
173
- u.value = t.contentRect.width;
174
- }, s.debounce)) : u.value = t.contentRect.width);
175
- }), _.observe(c.value));
176
- }), f(() => {
177
- _?.disconnect(), v && clearTimeout(v);
202
+ t && (u.debounce ? (T && clearTimeout(T), T = setTimeout(() => {
203
+ S.value = t.contentRect.width;
204
+ }, u.debounce)) : S.value = t.contentRect.width);
205
+ }), w.observe(b.value));
206
+ }), ee(() => {
207
+ w?.disconnect(), T && clearTimeout(T);
178
208
  });
179
- let y = t(() => s.width ?? (u.value || 400)), b = t(() => s.height ?? 200), x = t(() => ({
180
- top: s.title ? 30 : 10,
209
+ let E = t(() => u.width ?? (S.value || 400)), D = t(() => u.height ?? 200), O = t(() => ({
210
+ top: u.title ? 30 : 10,
181
211
  right: 10,
182
- bottom: s.xLabel ? 46 : 30,
183
- left: s.yLabel ? 66 : 50
184
- })), S = t(() => y.value - x.value.left - x.value.right), C = t(() => b.value - x.value.top - x.value.bottom), w = t(() => s.series && s.series.length > 0 ? s.series : s.data ? [{ data: s.data }] : []), T = t(() => s.areas ?? []), E = t(() => {
212
+ bottom: u.xLabel ? 46 : 30,
213
+ left: u.yLabel ? 66 : 50
214
+ })), k = t(() => E.value - O.value.left - O.value.right), A = t(() => D.value - O.value.top - O.value.bottom), j = t(() => u.series && u.series.length > 0 ? u.series : u.data ? [{ data: u.data }] : []), M = t(() => u.areas ?? []), N = t(() => {
185
215
  let e = 0;
186
- for (let t of w.value) t.data.length > e && (e = t.data.length);
187
- for (let t of T.value) t.upper.length > e && (e = t.upper.length), t.lower.length > e && (e = t.lower.length);
216
+ for (let t of j.value) t.data.length > e && (e = t.data.length);
217
+ for (let t of M.value) t.upper.length > e && (e = t.upper.length), t.lower.length > e && (e = t.lower.length);
188
218
  return e;
189
- }), D = t(() => {
219
+ }), P = t(() => {
190
220
  let e = Infinity, t = -Infinity;
191
- for (let n of w.value) for (let r of n.data) isFinite(r) && (r < e && (e = r), r > t && (t = r));
192
- for (let n of T.value) {
221
+ for (let n of j.value) for (let r of n.data) isFinite(r) && (r < e && (e = r), r > t && (t = r));
222
+ for (let n of M.value) {
193
223
  for (let r of n.upper) isFinite(r) && (r < e && (e = r), r > t && (t = r));
194
224
  for (let r of n.lower) isFinite(r) && (r < e && (e = r), r > t && (t = r));
195
225
  }
196
- return isFinite(e) ? (s.yMin != null && s.yMin < e && (e = s.yMin), {
226
+ return isFinite(e) ? (u.yMin != null && u.yMin < e && (e = u.yMin), {
197
227
  min: e,
198
228
  max: t,
199
229
  range: t - e || 1
@@ -203,23 +233,31 @@ var B = ["width", "height"], V = ["x"], ie = [
203
233
  range: 1
204
234
  };
205
235
  });
206
- function ee(e) {
236
+ function te(e) {
207
237
  if (e.length === 0) return "";
208
- let { min: t, range: n } = D.value, r = E.value, i = S.value / (r - 1 || 1), a = C.value / n, o = x.value.top + C.value, s = "", c = !1;
238
+ let { min: t, range: n } = P.value, r = N.value, i = k.value / (r - 1 || 1), a = A.value / n, o = O.value.top + A.value, s = "", c = !1;
209
239
  for (let n = 0; n < e.length; n++) {
210
240
  if (!isFinite(e[n])) {
211
241
  c = !1;
212
242
  continue;
213
243
  }
214
- let r = x.value.left + n * i, l = o - (e[n] - t) * a;
244
+ let r = O.value.left + n * i, l = o - (e[n] - t) * a;
215
245
  s += c ? `L${r},${l}` : `M${r},${l}`, c = !0;
216
246
  }
217
247
  return s;
218
248
  }
219
- function O(e, t) {
249
+ function ne(e) {
250
+ let { min: t, range: n } = P.value, r = N.value, i = k.value / (r - 1 || 1), a = A.value / n, o = O.value.top + A.value, s = [];
251
+ for (let n = 0; n < e.length; n++) isFinite(e[n]) && s.push({
252
+ x: O.value.left + n * i,
253
+ y: o - (e[n] - t) * a
254
+ });
255
+ return s;
256
+ }
257
+ function re(e, t) {
220
258
  let n = Math.min(e.length, t.length);
221
259
  if (n === 0) return "";
222
- let { min: r, range: i } = D.value, a = E.value, o = S.value / (a - 1 || 1), s = C.value / i, c = x.value.top + C.value, l = (e) => x.value.left + e * o, u = (e) => c - (e - r) * s, d = [], f = [];
260
+ let { min: r, range: i } = P.value, a = N.value, o = k.value / (a - 1 || 1), s = A.value / i, c = O.value.top + A.value, l = (e) => O.value.left + e * o, u = (e) => c - (e - r) * s, d = [], f = [];
223
261
  for (let r = 0; r < n; r++) isFinite(e[r]) && isFinite(t[r]) ? f.push(r) : f.length && (d.push(f), f = []);
224
262
  f.length && d.push(f);
225
263
  let p = "";
@@ -231,61 +269,61 @@ var B = ["width", "height"], V = ["x"], ie = [
231
269
  }
232
270
  return p;
233
271
  }
234
- function k(e, t) {
272
+ function ie(e, t) {
235
273
  let n = e / t, r = 10 ** Math.floor(Math.log10(n)), i = n / r, a;
236
274
  return a = i <= 1.5 ? 1 : i <= 3 ? 2 : i <= 7 ? 5 : 10, a * r;
237
275
  }
238
- function A(e) {
276
+ function F(e) {
239
277
  return Math.round(e) + .5;
240
278
  }
241
- let te = new Intl.NumberFormat();
242
- function j(e) {
243
- return Math.abs(e) >= 1e3 ? te.format(e) : Number.isInteger(e) ? e.toString() : e.toFixed(1);
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);
244
282
  }
245
- let M = t(() => {
246
- let { min: e, max: t } = D.value;
283
+ let L = t(() => {
284
+ let { min: e, max: t } = P.value;
247
285
  if (e === t) return [{
248
- value: j(e),
249
- y: A(x.value.top + C.value / 2)
286
+ value: I(e),
287
+ y: F(O.value.top + A.value / 2)
250
288
  }];
251
- let n = Math.max(3, Math.floor(C.value / 50)), r = k(t - e, n), i = Math.ceil(e / r) * r, a = [];
289
+ let n = Math.max(3, Math.floor(A.value / 50)), r = ie(t - e, n), i = Math.ceil(e / r) * r, a = [];
252
290
  for (let n = i; n <= t; n += r) a.push({
253
- value: j(n),
254
- y: A(x.value.top + C.value - (n - e) / D.value.range * C.value)
291
+ value: I(n),
292
+ y: F(O.value.top + A.value - (n - e) / P.value.range * A.value)
255
293
  });
256
294
  return a;
257
- }), N = t(() => {
258
- let e = E.value;
295
+ }), R = t(() => {
296
+ let e = N.value;
259
297
  if (e <= 1) return [];
260
- let t = s.xLabels;
298
+ let t = u.xLabels;
261
299
  if (t && t.length === e) {
262
- let n = Math.max(3, Math.floor(S.value / 80)), r = Math.max(1, Math.round((e - 1) / n)), i = [];
300
+ let n = Math.max(3, Math.floor(k.value / 80)), r = Math.max(1, Math.round((e - 1) / n)), i = [];
263
301
  for (let n = 0; n < e; n += r) i.push({
264
302
  value: t[n],
265
- x: A(x.value.left + n / (e - 1) * S.value)
303
+ x: F(O.value.left + n / (e - 1) * k.value)
266
304
  });
267
305
  return i;
268
306
  }
269
- let n = s.xMin ?? 0, r = Math.max(3, Math.floor(S.value / 80)), i = k(e - 1, r), a = [];
307
+ let n = u.xMin ?? 0, r = Math.max(3, Math.floor(k.value / 80)), i = ie(e - 1, r), a = [];
270
308
  for (let t = 0; t <= e - 1; t += i) {
271
309
  let r = Math.round(t);
272
310
  a.push({
273
- value: j(r + n),
274
- x: A(x.value.left + r / (e - 1) * S.value)
311
+ value: I(r + n),
312
+ x: F(O.value.left + r / (e - 1) * k.value)
275
313
  });
276
314
  }
277
315
  return a;
278
316
  });
279
- function P() {
280
- return typeof s.menu == "string" ? s.menu : "chart";
317
+ function z() {
318
+ return typeof u.menu == "string" ? u.menu : "chart";
281
319
  }
282
- function F() {
283
- return l.value;
320
+ function B() {
321
+ return x.value;
284
322
  }
285
- function I() {
286
- let e = w.value;
323
+ function V() {
324
+ let e = j.value;
287
325
  if (e.length === 0) return "";
288
- let t = E.value, n = [(e.length === 1 ? ["index", "value"] : ["index", ...e.map((e, t) => `series_${t}`)]).join(",")];
326
+ let t = N.value, n = [(e.length === 1 ? ["index", "value"] : ["index", ...e.map((e, t) => `series_${t}`)]).join(",")];
289
327
  for (let r = 0; r < t; r++) {
290
328
  let t = [r.toString()];
291
329
  for (let n of e) t.push(r < n.data.length ? String(n.data[r]) : "");
@@ -293,140 +331,277 @@ var B = ["width", "height"], V = ["x"], ie = [
293
331
  }
294
332
  return n.join("\n");
295
333
  }
296
- let R = t(() => {
297
- let e = P();
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;
336
+ 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
+ if (e === null) return [];
341
+ let { min: t, range: n } = P.value, r = A.value / n, i = O.value.top + A.value;
342
+ return j.value.filter((t) => e < t.data.length && isFinite(t.data[e])).map((n) => ({
343
+ x: Z.value,
344
+ y: i - (n.data[e] - t) * r,
345
+ color: n.color ?? "currentColor"
346
+ }));
347
+ }), Q = t(() => {
348
+ let e = J.value;
349
+ return e === null ? null : {
350
+ index: e,
351
+ xLabel: u.xLabels?.[e],
352
+ values: j.value.map((t, n) => ({
353
+ value: t.data[e],
354
+ color: t.color ?? "currentColor",
355
+ seriesIndex: n
356
+ })),
357
+ data: u.tooltipData?.[e] ?? null
358
+ };
359
+ });
360
+ function Te(e) {
361
+ return "touches" in e ? e.touches[0] ?? null : e;
362
+ }
363
+ function Ee(e) {
364
+ let t = b.value?.getBoundingClientRect();
365
+ if (!t) return null;
366
+ let n = N.value;
367
+ if (n <= 1) return null;
368
+ let r = e - t.left, i = k.value / (n - 1 || 1), a = (r - O.value.left) / i;
369
+ return Math.round(Math.max(0, Math.min(n - 1, a)));
370
+ }
371
+ function De(e, t) {
372
+ let n = Ce.value;
373
+ 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);
375
+ n.style.left = `${a + 16}px`, n.style.top = `${o}px`;
376
+ }
377
+ function Oe(e) {
378
+ let t = Te(e);
379
+ if (!t) return;
380
+ let n = Ee(t.clientX);
381
+ n !== null && (J.value = n, De(t.clientX, t.clientY), y("hover", { index: n }));
382
+ }
383
+ function ke(e) {
384
+ Oe(e);
385
+ }
386
+ function Ae() {
387
+ u.tooltipTrigger !== "click" && (J.value = null, y("hover", null));
388
+ }
389
+ function je(e) {
390
+ if (u.tooltipTrigger !== "click") return;
391
+ let t = Te(e);
392
+ 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 }));
395
+ }
396
+ function Me(e) {
397
+ Y.value = !0, Oe(e);
398
+ }
399
+ function Ne(e) {
400
+ Oe(e);
401
+ }
402
+ function Pe() {
403
+ Y.value = !1, J.value = null, y("hover", null);
404
+ }
405
+ let Fe = t(() => {
406
+ let e = z();
298
407
  return [
299
408
  {
300
409
  label: "Save as SVG",
301
410
  action: () => {
302
- let t = F();
303
- t && ne(t, e);
411
+ let t = B();
412
+ t && se(t, e);
304
413
  }
305
414
  },
306
415
  {
307
416
  label: "Save as PNG",
308
417
  action: () => {
309
- let t = F();
310
- t && re(t, e);
418
+ let t = B();
419
+ t && ce(t, e);
311
420
  }
312
421
  },
313
422
  {
314
423
  label: "Download CSV",
315
- action: () => z(I(), e)
424
+ action: () => le(V(), e)
316
425
  }
317
426
  ];
318
427
  });
319
- return (t, s) => (p(), i("div", {
428
+ return (t, c) => (m(), i("div", {
320
429
  ref_key: "containerRef",
321
- ref: c,
430
+ ref: b,
322
431
  class: "line-chart-wrapper"
323
- }, [o.menu ? (p(), n(L, {
324
- key: 0,
325
- items: R.value
326
- }, null, 8, ["items"])) : r("", !0), (p(), i("svg", {
327
- ref_key: "svgRef",
328
- ref: l,
329
- width: y.value,
330
- height: b.value
331
432
  }, [
332
- o.title ? (p(), i("text", {
433
+ s.menu ? (m(), n(oe, {
333
434
  key: 0,
334
- x: y.value / 2,
335
- y: 18,
336
- "text-anchor": "middle",
337
- "font-size": "14",
338
- "font-weight": "600",
339
- fill: "currentColor"
340
- }, g(o.title), 9, V)) : r("", !0),
341
- a("line", {
342
- x1: A(x.value.left),
343
- y1: A(x.value.top),
344
- x2: A(x.value.left),
345
- y2: A(x.value.top + C.value),
346
- stroke: "currentColor",
347
- "stroke-opacity": "0.3"
348
- }, null, 8, ie),
349
- a("line", {
350
- x1: A(x.value.left),
351
- y1: A(x.value.top + C.value),
352
- x2: A(x.value.left + S.value),
353
- y2: A(x.value.top + C.value),
354
- stroke: "currentColor",
355
- "stroke-opacity": "0.3"
356
- }, null, 8, H),
357
- o.yGrid ? (p(!0), i(e, { key: 1 }, h(M.value, (e, t) => (p(), i("line", {
358
- key: "yg" + t,
359
- x1: x.value.left,
360
- y1: e.y,
361
- x2: x.value.left + S.value,
362
- y2: e.y,
363
- stroke: "currentColor",
364
- "stroke-opacity": "0.1"
365
- }, null, 8, U))), 128)) : r("", !0),
366
- o.xGrid ? (p(!0), i(e, { key: 2 }, h(N.value, (e, t) => (p(), i("line", {
367
- key: "xg" + t,
368
- x1: e.x,
369
- y1: x.value.top,
370
- x2: e.x,
371
- y2: x.value.top + C.value,
372
- stroke: "currentColor",
373
- "stroke-opacity": "0.1"
374
- }, null, 8, ae))), 128)) : r("", !0),
375
- (p(!0), i(e, null, h(M.value, (e, t) => (p(), i("text", {
376
- key: "y" + t,
377
- x: x.value.left - 6,
378
- y: e.y,
379
- "text-anchor": "end",
380
- "dominant-baseline": "middle",
381
- "font-size": "10",
382
- fill: "currentColor",
383
- "fill-opacity": "0.6"
384
- }, g(e.value), 9, W))), 128)),
385
- o.yLabel ? (p(), i("text", {
386
- key: 3,
387
- x: 0,
388
- y: 0,
389
- transform: `translate(14, ${x.value.top + C.value / 2}) rotate(-90)`,
390
- "text-anchor": "middle",
391
- "font-size": "13",
392
- fill: "currentColor"
393
- }, g(o.yLabel), 9, G)) : r("", !0),
394
- (p(!0), i(e, null, h(N.value, (e, t) => (p(), i("text", {
395
- key: "x" + t,
396
- x: e.x,
397
- y: x.value.top + C.value + 16,
398
- "text-anchor": "middle",
399
- "font-size": "10",
400
- fill: "currentColor",
401
- "fill-opacity": "0.6"
402
- }, g(e.value), 9, K))), 128)),
403
- o.xLabel ? (p(), i("text", {
404
- key: 4,
405
- x: x.value.left + S.value / 2,
406
- y: b.value - 4,
407
- "text-anchor": "middle",
408
- "font-size": "13",
409
- fill: "currentColor"
410
- }, g(o.xLabel), 9, q)) : r("", !0),
411
- (p(!0), i(e, null, h(T.value, (e, t) => (p(), i("path", {
412
- key: "area" + t,
413
- d: O(e.upper, e.lower),
414
- fill: e.color ?? "currentColor",
415
- "fill-opacity": e.opacity ?? .2,
416
- stroke: "none"
417
- }, null, 8, J))), 128)),
418
- (p(!0), i(e, null, h(w.value, (e, t) => (p(), i("path", {
419
- key: t,
420
- d: ee(e.data),
421
- fill: "none",
422
- stroke: e.color ?? "currentColor",
423
- "stroke-width": e.strokeWidth ?? 1.5,
424
- "stroke-opacity": e.opacity ?? o.lineOpacity,
425
- "stroke-dasharray": e.dashed ? "6 3" : void 0
426
- }, null, 8, Y))), 128))
427
- ], 8, B))], 512));
435
+ items: Fe.value
436
+ }, null, 8, ["items"])) : r("", !0),
437
+ (m(), i("svg", {
438
+ ref_key: "svgRef",
439
+ ref: x,
440
+ width: E.value,
441
+ height: D.value
442
+ }, [
443
+ s.title ? (m(), i("text", {
444
+ key: 0,
445
+ x: E.value / 2,
446
+ y: 18,
447
+ "text-anchor": "middle",
448
+ "font-size": "14",
449
+ "font-weight": "600",
450
+ fill: "currentColor"
451
+ }, v(s.title), 9, ue)) : r("", !0),
452
+ 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),
457
+ stroke: "currentColor",
458
+ "stroke-opacity": "0.3"
459
+ }, null, 8, de),
460
+ 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),
465
+ stroke: "currentColor",
466
+ "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", {
469
+ key: "yg" + t,
470
+ x1: O.value.left,
471
+ y1: e.y,
472
+ x2: O.value.left + k.value,
473
+ y2: e.y,
474
+ stroke: "currentColor",
475
+ "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", {
478
+ key: "xg" + t,
479
+ x1: e.x,
480
+ y1: O.value.top,
481
+ x2: e.x,
482
+ y2: O.value.top + A.value,
483
+ stroke: "currentColor",
484
+ "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", {
487
+ key: "y" + t,
488
+ x: O.value.left - 6,
489
+ y: e.y,
490
+ "text-anchor": "end",
491
+ "dominant-baseline": "middle",
492
+ "font-size": "10",
493
+ fill: "currentColor",
494
+ "fill-opacity": "0.6"
495
+ }, v(e.value), 9, me))), 128)),
496
+ s.yLabel ? (m(), i("text", {
497
+ key: 3,
498
+ x: 0,
499
+ y: 0,
500
+ transform: `translate(14, ${O.value.top + A.value / 2}) rotate(-90)`,
501
+ "text-anchor": "middle",
502
+ "font-size": "13",
503
+ fill: "currentColor"
504
+ }, v(s.yLabel), 9, W)) : r("", !0),
505
+ (m(!0), i(e, null, g(R.value, (e, t) => (m(), i("text", {
506
+ key: "x" + t,
507
+ x: e.x,
508
+ y: O.value.top + A.value + 16,
509
+ "text-anchor": "middle",
510
+ "font-size": "10",
511
+ fill: "currentColor",
512
+ "fill-opacity": "0.6"
513
+ }, v(e.value), 9, G))), 128)),
514
+ s.xLabel ? (m(), i("text", {
515
+ key: 4,
516
+ x: O.value.left + k.value / 2,
517
+ y: D.value - 4,
518
+ "text-anchor": "middle",
519
+ "font-size": "13",
520
+ fill: "currentColor"
521
+ }, v(s.xLabel), 9, he)) : r("", !0),
522
+ (m(!0), i(e, null, g(M.value, (e, t) => (m(), i("path", {
523
+ key: "area" + t,
524
+ d: re(e.upper, e.lower),
525
+ fill: e.color ?? "currentColor",
526
+ "fill-opacity": e.opacity ?? .2,
527
+ stroke: "none"
528
+ }, null, 8, ge))), 128)),
529
+ (m(!0), i(e, null, g(j.value, (t, n) => (m(), i(e, { key: n }, [t.line === !1 ? r("", !0) : (m(), i("path", {
530
+ key: 0,
531
+ d: te(t.data),
532
+ fill: "none",
533
+ stroke: t.color ?? "currentColor",
534
+ "stroke-width": t.strokeWidth ?? 1.5,
535
+ "stroke-opacity": t.lineOpacity ?? t.opacity ?? s.lineOpacity,
536
+ "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", {
538
+ key: n,
539
+ cx: e.x,
540
+ cy: e.y,
541
+ r: t.dotRadius ?? (t.strokeWidth ?? 1.5) + 1,
542
+ fill: t.dotFill ?? t.color ?? "currentColor",
543
+ "fill-opacity": t.dotOpacity ?? t.opacity ?? s.lineOpacity,
544
+ stroke: t.dotStroke ?? "none"
545
+ }, null, 8, ve))), 128)) : r("", !0)], 64))), 128)),
546
+ X.value && J.value !== null ? (m(), i("line", {
547
+ key: 5,
548
+ x1: F(Z.value),
549
+ y1: O.value.top,
550
+ x2: F(Z.value),
551
+ y2: O.value.top + A.value,
552
+ stroke: "currentColor",
553
+ "stroke-opacity": "0.3",
554
+ "stroke-dasharray": "4 2",
555
+ "pointer-events": "none"
556
+ }, null, 8, ye)) : r("", !0),
557
+ (m(!0), i(e, null, g(we.value, (e, t) => (m(), i("circle", {
558
+ key: "hd" + t,
559
+ cx: e.x,
560
+ cy: e.y,
561
+ r: "4",
562
+ fill: e.color,
563
+ stroke: "var(--color-bg-0, #fff)",
564
+ "stroke-width": "2",
565
+ "pointer-events": "none"
566
+ }, null, 8, be))), 128)),
567
+ X.value ? (m(), i("rect", {
568
+ key: 6,
569
+ x: O.value.left,
570
+ y: O.value.top,
571
+ width: k.value,
572
+ height: A.value,
573
+ fill: "transparent",
574
+ style: {
575
+ cursor: "crosshair",
576
+ "touch-action": "none"
577
+ },
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", {
587
+ key: 1,
588
+ ref_key: "tooltipRef",
589
+ ref: Ce,
590
+ class: "chart-tooltip-content",
591
+ style: {
592
+ position: "absolute",
593
+ transform: "translateY(-50%)"
594
+ }
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", {
596
+ key: e.seriesIndex,
597
+ class: "line-chart-tooltip-row"
598
+ }, [a("span", {
599
+ class: "line-chart-tooltip-swatch",
600
+ style: f({ background: e.color })
601
+ }, null, 4), o(" " + v(isFinite(e.value) ? I(e.value) : "—"), 1)]))), 128))])], !0)], 512)) : r("", !0)
602
+ ], 512));
428
603
  }
429
- }), [["__scopeId", "data-v-128f8091"]]), se = {
604
+ }), [["__scopeId", "data-v-4ea55781"]]), Y = {
430
605
  "01013": "010259",
431
606
  "01015": "010177",
432
607
  "01029": "010177",
@@ -3587,7 +3762,7 @@ var B = ["width", "height"], V = ["x"], ie = [
3587
3762
  51019: "510014",
3588
3763
  "02158": "020820",
3589
3764
  46102: "460957"
3590
- }, ce = {
3765
+ }, Ce = {
3591
3766
  "010259": "Butler, AL",
3592
3767
  "010177": "Calhoun (Anniston), AL - Cleburne, AL",
3593
3768
  "010172": "Chambers, AL - Randolph, AL",
@@ -4537,26 +4712,25 @@ var B = ["width", "height"], V = ["x"], ie = [
4537
4712
  560775: "Teton, WY - Lincoln, WY",
4538
4713
  560792: "Uinta, WY",
4539
4714
  560804: "Weston, WY"
4540
- }, le = ["width", "height"], ue = [
4715
+ }, X = ["width", "height"], Z = [
4716
+ "data-feat-id",
4541
4717
  "d",
4542
4718
  "fill",
4543
4719
  "stroke",
4544
- "stroke-width",
4545
- "onClick",
4546
- "onMouseenter"
4547
- ], de = ["d", "stroke"], fe = ["transform"], pe = {
4720
+ "stroke-width"
4721
+ ], we = { key: 0 }, Q = ["d", "stroke"], Te = ["transform"], Ee = {
4548
4722
  key: 0,
4549
4723
  y: 5,
4550
4724
  "font-size": "13",
4551
4725
  "font-weight": "600",
4552
4726
  fill: "currentColor"
4553
- }, me = ["x", "fill"], he = ["x"], ge = {
4727
+ }, De = ["x", "fill"], Oe = ["x"], ke = {
4554
4728
  key: 0,
4555
4729
  y: 5,
4556
4730
  "font-size": "13",
4557
4731
  "font-weight": "600",
4558
4732
  fill: "currentColor"
4559
- }, _e = ["offset", "stop-color"], ve = ["x", "fill"], ye = ["x"], be = ["x"], xe = /* @__PURE__ */ I(/* @__PURE__ */ c({
4733
+ }, Ae = ["offset", "stop-color"], je = ["x", "fill"], Me = ["x"], Ne = ["x"], Pe = /* @__PURE__ */ B(/* @__PURE__ */ c({
4560
4734
  __name: "ChoroplethMap",
4561
4735
  props: {
4562
4736
  data: {},
@@ -4584,50 +4758,65 @@ var B = ["width", "height"], V = ["x"], ie = [
4584
4758
  pan: {
4585
4759
  type: Boolean,
4586
4760
  default: !1
4587
- }
4761
+ },
4762
+ tooltipTrigger: {},
4763
+ tooltipFormat: {}
4588
4764
  },
4589
4765
  emits: ["stateClick", "stateHover"],
4590
4766
  setup(o, { emit: s }) {
4591
- let c = o, u = s, _ = `choropleth-gradient-${v()}`, b = m(null), x = m(null), S = m(null), C = m(0), w = null, T = null, N = null;
4592
- d(() => {
4593
- b.value && (C.value = b.value.clientWidth, T = new ResizeObserver((e) => {
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
+ function A() {
4774
+ let e = y.value;
4775
+ e && (e.removeEventListener("click", $), e.removeEventListener("mouseover", $), e.removeEventListener("mousemove", Re), e.removeEventListener("mouseout", ze));
4776
+ }
4777
+ p(() => {
4778
+ f.value && (S.value = f.value.clientWidth, D = new ResizeObserver((e) => {
4594
4779
  let t = e[0];
4595
- t && (C.value = t.contentRect.width);
4596
- }), T.observe(b.value)), P();
4597
- }), f(() => {
4598
- T?.disconnect(), F();
4780
+ t && (S.value = t.contentRect.width);
4781
+ }), D.observe(f.value)), j(), k();
4782
+ }), ee(() => {
4783
+ D?.disconnect(), M(), A(), Fe();
4599
4784
  });
4600
- function P() {
4601
- if (!x.value || !S.value || !c.zoom && !c.pan) return;
4602
- let e = O(x.value);
4603
- N = ee().scaleExtent(c.zoom ? [1, 12] : [1, 1]).on("zoom", (e) => {
4604
- S.value && S.value.setAttribute("transform", e.transform);
4605
- }), c.pan || N.filter((e) => e.type === "wheel" || e.type === "dblclick"), e.call(N);
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();
4790
+ }).on("zoom", (e) => {
4791
+ y.value && y.value.setAttribute("transform", e.transform);
4792
+ }).on("end", () => {
4793
+ T = !1;
4794
+ }), c.pan || O.filter((e) => e.type === "wheel" || e.type === "dblclick"), e.call(O);
4606
4795
  }
4607
- function F() {
4608
- x.value && N && (O(x.value).on(".zoom", null), N = null);
4796
+ function M() {
4797
+ _.value && O && (ne(_.value).on(".zoom", null), O = null);
4609
4798
  }
4610
- y(() => [c.zoom, c.pan], () => {
4611
- F(), P();
4799
+ x(() => [c.zoom, c.pan], () => {
4800
+ M(), A(), j(), k();
4612
4801
  });
4613
- let I = t(() => c.width ?? (C.value || 600)), R = t(() => c.width && c.height ? c.height / c.width : .625), z = t(() => I.value * R.value), B = j, V = M, ie = t(() => {
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(() => {
4614
4803
  let e = V.objects.counties.geometries, t = /* @__PURE__ */ new Map();
4615
4804
  for (let n of e) {
4616
- let e = se[String(n.id).padStart(5, "0")];
4805
+ let e = Y[String(n.id).padStart(5, "0")];
4617
4806
  e && (t.has(e) || t.set(e, []), t.get(e).push(n));
4618
4807
  }
4619
4808
  let n = [];
4620
4809
  for (let [e, r] of t) n.push({
4621
4810
  type: "Feature",
4622
4811
  id: e,
4623
- properties: { name: ce[e] ?? e },
4624
- geometry: A(V, r)
4812
+ properties: { name: Ce[e] ?? e },
4813
+ geometry: ie(V, r)
4625
4814
  });
4626
4815
  return {
4627
4816
  type: "FeatureCollection",
4628
4817
  features: n
4629
4818
  };
4630
- }), H = t(() => c.geoType === "hsas" ? ie.value : c.geoType === "counties" ? k(V, V.objects.counties) : k(B, B.objects.states)), U = t(() => c.geoType !== "counties" && c.geoType !== "hsas" ? null : te(V, V.objects.states, (e, t) => e !== t)), ae = t(() => E().fitExtent([[0, Pe.value], [I.value, z.value + Pe.value]], H.value)), W = t(() => D(ae.value)), G = t(() => c.geoType === "counties" || c.geoType === "hsas" ? c.strokeWidth * .5 : c.strokeWidth), K = t(() => {
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(() => {
4631
4820
  let e = /* @__PURE__ */ new Map();
4632
4821
  if (!c.data) return e;
4633
4822
  for (let t of c.data) {
@@ -4636,7 +4825,7 @@ var B = ["width", "height"], V = ["x"], ie = [
4636
4825
  n?.id != null && e.set(String(n.id), t.value);
4637
4826
  }
4638
4827
  return e;
4639
- }), q = t(() => {
4828
+ }), me = t(() => {
4640
4829
  if (!c.data || c.data.length === 0) return {
4641
4830
  min: 0,
4642
4831
  max: 1
@@ -4653,8 +4842,8 @@ var B = ["width", "height"], V = ["x"], ie = [
4653
4842
  min: 0,
4654
4843
  max: 1
4655
4844
  };
4656
- }), J = t(() => Array.isArray(c.colorScale) && c.colorScale.length > 0 && "value" in c.colorScale[0]), Y = t(() => Array.isArray(c.colorScale) && !J.value), oe = t(() => Y.value ? "" : c.colorScale?.min ?? "#e5f0fa"), xe = t(() => Y.value ? "" : c.colorScale?.max ?? "#08519c");
4657
- function X(e) {
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) {
4658
4847
  let t = e.replace("#", "");
4659
4848
  return [
4660
4849
  parseInt(t.slice(0, 2), 16),
@@ -4662,66 +4851,101 @@ var B = ["width", "height"], V = ["x"], ie = [
4662
4851
  parseInt(t.slice(4, 6), 16)
4663
4852
  ];
4664
4853
  }
4665
- function Z(e) {
4666
- let [t, n, r] = X(oe.value), [i, a, o] = X(xe.value);
4854
+ function ve(e) {
4855
+ let [t, n, r] = _e(he.value), [i, a, o] = _e(ge.value);
4667
4856
  return `rgb(${Math.round(t + (i - t) * e)},${Math.round(n + (a - n) * e)},${Math.round(r + (o - r) * e)})`;
4668
4857
  }
4669
- function Se(e) {
4858
+ function ye(e) {
4670
4859
  let t = c.colorScale.slice().sort((e, t) => t.min - e.min);
4671
4860
  for (let n of t) if (e >= n.min) return n.color;
4672
4861
  return c.noDataColor;
4673
4862
  }
4674
- function Ce(e) {
4863
+ function be(e) {
4675
4864
  let t = c.colorScale.find((t) => t.value === String(e));
4676
4865
  return t ? t.color : c.noDataColor;
4677
4866
  }
4678
- function we(e) {
4679
- let t = K.value.get(String(e));
4867
+ function xe(e) {
4868
+ let t = pe.value.get(String(e));
4680
4869
  if (t == null) return c.noDataColor;
4681
- if (J.value) return Ce(t);
4682
- if (Y.value) return Se(t);
4683
- let { min: n, max: r } = q.value;
4684
- return Z((t - n) / (r - n));
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));
4685
4874
  }
4686
- function Te(e) {
4875
+ function K(e) {
4687
4876
  return e.properties?.name ?? String(e.id);
4688
4877
  }
4689
- function Q(e) {
4690
- return K.value.get(String(e.id));
4878
+ function q(e) {
4879
+ return pe.value.get(String(e.id));
4691
4880
  }
4692
- function Ee(e) {
4693
- u("stateClick", {
4694
- id: String(e.id),
4695
- name: Te(e),
4696
- value: Q(e)
4697
- });
4881
+ let Se = t(() => {
4882
+ let e = /* @__PURE__ */ new Map();
4883
+ for (let t of H.value.features) e.set(String(t.id), t);
4884
+ return e;
4885
+ });
4886
+ function J(e) {
4887
+ let t = e;
4888
+ for (; t && !t.dataset?.featId;) t = t.parentElement;
4889
+ if (!t) return null;
4890
+ let n = Se.value.get(t.dataset.featId);
4891
+ return n ? {
4892
+ pathEl: t,
4893
+ feat: n
4894
+ } : null;
4698
4895
  }
4699
- function De(e, t) {
4700
- let n = t.currentTarget;
4701
- w = n, n.setAttribute("stroke-width", String(G.value + 1)), u("stateHover", {
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));
4898
+ let r = K(e), i = q(e), a = {
4702
4899
  id: String(e.id),
4703
- name: Te(e),
4704
- value: Q(e)
4705
- });
4900
+ name: r,
4901
+ value: i
4902
+ };
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`;
4904
+ }
4905
+ function Fe() {
4906
+ w &&= (w.remove(), null);
4907
+ }
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");
4910
+ }
4911
+ function Le() {
4912
+ C && (C.setAttribute("stroke-width", String(U.value)), C.setAttribute("stroke", c.strokeColor), C = null, l("stateHover", null)), Fe();
4706
4913
  }
4707
- function Oe() {
4708
- w &&= (w.setAttribute("stroke-width", String(G.value)), null), u("stateHover", null);
4914
+ function $(e) {
4915
+ if (T) return;
4916
+ let t = e, n = J(t.target);
4917
+ n && (e.type === "click" ? l("stateClick", {
4918
+ id: String(n.feat.id),
4919
+ name: K(n.feat),
4920
+ value: q(n.feat)
4921
+ }) : e.type === "mouseover" && (Ie(n.pathEl, n.feat), c.tooltipTrigger && Pe(n.feat, t.clientX, t.clientY), l("stateHover", {
4922
+ id: String(n.feat.id),
4923
+ name: K(n.feat),
4924
+ value: q(n.feat)
4925
+ })));
4709
4926
  }
4710
- function ke() {
4927
+ function Re(e) {
4928
+ T || !w || (w.style.left = `${e.clientX + 16}px`, w.style.top = `${e.clientY}px`);
4929
+ }
4930
+ function ze(e) {
4931
+ let t = e.relatedTarget;
4932
+ t && y.value?.contains(t) || Le();
4933
+ }
4934
+ function Be() {
4711
4935
  return typeof c.menu == "string" ? c.menu : "choropleth";
4712
4936
  }
4713
- let Ae = t(() => c.legend && (J.value || Y.value || c.data)), je = t(() => c.colorScale.slice().sort((e, t) => e.min - t.min)), Me = t(() => c.title ? 24 : 0), Ne = t(() => Ae.value ? 28 : 0), Pe = t(() => Me.value + Ne.value), Fe = t(() => z.value + Pe.value), Ie = t(() => Me.value + 18), Le = t(() => {
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(() => {
4714
4938
  let e = [];
4715
4939
  for (let t = 0; t <= 10; t++) {
4716
4940
  let n = t / 10;
4717
4941
  e.push({
4718
4942
  offset: `${(n * 100).toFixed(0)}%`,
4719
- color: Z(n)
4943
+ color: ve(n)
4720
4944
  });
4721
4945
  }
4722
4946
  return e;
4723
- }), Re = t(() => {
4724
- let { min: e, max: t } = q.value, n = t - e, r = [];
4947
+ }), Ye = t(() => {
4948
+ let { min: e, max: t } = me.value, n = t - e, r = [];
4725
4949
  for (let t = 1; t <= 3; t++) {
4726
4950
  let i = t / 4, a = e + n * i, o = Number.isInteger(a) ? String(a) : a.toFixed(1).replace(/\.0$/, "");
4727
4951
  r.push({
@@ -4730,120 +4954,118 @@ var B = ["width", "height"], V = ["x"], ie = [
4730
4954
  });
4731
4955
  }
4732
4956
  return r;
4733
- }), $ = t(() => {
4957
+ }), Xe = t(() => {
4734
4958
  let e = [];
4735
- if (J.value) for (let t of c.colorScale) e.push({
4959
+ if (W.value) for (let t of c.colorScale) e.push({
4736
4960
  key: t.value,
4737
4961
  color: t.color,
4738
4962
  label: t.value
4739
4963
  });
4740
- else if (Y.value) for (let t of je.value) e.push({
4964
+ else if (G.value) for (let t of He.value) e.push({
4741
4965
  key: String(t.min),
4742
4966
  color: t.color,
4743
4967
  label: t.label ?? String(t.min)
4744
4968
  });
4745
4969
  return e;
4746
- }), ze = t(() => {
4970
+ }), Ze = t(() => {
4747
4971
  let e = c.legendTitle ? c.legendTitle.length * 8 + 12 : 0;
4748
- for (let t of $.value) e += 16 + t.label.length * 7 + 12;
4749
- return e - ($.value.length > 0 ? 12 : 0);
4750
- }), Be = t(() => {
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(() => {
4751
4975
  let e = c.legendTitle ? c.legendTitle.length * 8 + 12 : 0;
4752
- return $.value.map((t) => {
4976
+ return Xe.value.map((t) => {
4753
4977
  let n = e;
4754
4978
  return e += 16 + t.label.length * 7 + 12, n;
4755
4979
  });
4756
- }), Ve = t(() => {
4757
- if (J.value || Y.value) return (I.value - ze.value) / 2;
4980
+ }), $e = t(() => {
4981
+ if (W.value || G.value) return (L.value - Ze.value) / 2;
4758
4982
  let e = c.legendTitle ? c.legendTitle.length * 8 + 12 : 0;
4759
- return (I.value - e - 160) / 2;
4760
- }), He = t(() => {
4761
- let e = ke();
4983
+ return (L.value - e - 160) / 2;
4984
+ }), et = t(() => {
4985
+ let e = Be();
4762
4986
  return [{
4763
4987
  label: "Save as SVG",
4764
4988
  action: () => {
4765
- x.value && ne(x.value, e);
4989
+ _.value && se(_.value, e);
4766
4990
  }
4767
4991
  }, {
4768
4992
  label: "Save as PNG",
4769
4993
  action: () => {
4770
- x.value && re(x.value, e);
4994
+ _.value && ce(_.value, e);
4771
4995
  }
4772
4996
  }];
4773
4997
  });
4774
- return (t, s) => (p(), i("div", {
4998
+ return (t, s) => (m(), i("div", {
4775
4999
  ref_key: "containerRef",
4776
- ref: b,
4777
- class: l(["choropleth-wrapper", { pannable: o.pan }])
4778
- }, [o.menu ? (p(), n(L, {
5000
+ ref: f,
5001
+ class: u(["choropleth-wrapper", { pannable: o.pan }])
5002
+ }, [o.menu ? (m(), n(oe, {
4779
5003
  key: 0,
4780
- items: He.value
4781
- }, null, 8, ["items"])) : r("", !0), (p(), i("svg", {
5004
+ items: et.value
5005
+ }, null, 8, ["items"])) : r("", !0), (m(), i("svg", {
4782
5006
  ref_key: "svgRef",
4783
- ref: x,
4784
- width: I.value,
4785
- height: Fe.value
5007
+ ref: _,
5008
+ width: L.value,
5009
+ height: Ke.value
4786
5010
  }, [
4787
5011
  a("g", {
4788
5012
  ref_key: "mapGroupRef",
4789
- ref: S
4790
- }, [(p(!0), i(e, null, h(H.value.features, (e) => (p(), i("path", {
5013
+ ref: y
5014
+ }, [(m(!0), i(e, null, g(H.value.features, (e) => (m(), i("path", {
4791
5015
  key: String(e.id),
4792
- d: W.value(e) ?? void 0,
4793
- fill: we(e.id),
5016
+ "data-feat-id": String(e.id),
5017
+ d: fe.value(e) ?? void 0,
5018
+ fill: xe(e.id),
4794
5019
  stroke: o.strokeColor,
4795
- "stroke-width": G.value,
4796
- class: "state-path",
4797
- onClick: (t) => Ee(e),
4798
- onMouseenter: (t) => De(e, t),
4799
- onMouseleave: Oe
4800
- }, [a("title", null, g(Te(e)) + g(Q(e) == null ? "" : `: ${Q(e)}`), 1)], 40, ue))), 128)), U.value ? (p(), i("path", {
5020
+ "stroke-width": U.value,
5021
+ 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", {
4801
5023
  key: 0,
4802
- d: W.value(U.value) ?? void 0,
5024
+ d: fe.value(ue.value) ?? void 0,
4803
5025
  fill: "none",
4804
5026
  stroke: o.strokeColor,
4805
5027
  "stroke-width": 1,
4806
5028
  "stroke-linejoin": "round",
4807
5029
  "pointer-events": "none"
4808
- }, null, 8, de)) : r("", !0)], 512),
4809
- Ae.value ? (p(), i("g", {
5030
+ }, null, 8, Q)) : r("", !0)], 512),
5031
+ Ve.value ? (m(), i("g", {
4810
5032
  key: 0,
4811
5033
  class: "choropleth-legend",
4812
- transform: `translate(${Ve.value},${Ie.value})`
4813
- }, [J.value || Y.value ? (p(), i(e, { key: 0 }, [o.legendTitle ? (p(), i("text", pe, g(o.legendTitle), 1)) : r("", !0), (p(!0), i(e, null, h($.value, (t, n) => (p(), i(e, { key: t.key }, [a("rect", {
4814
- x: Be.value[n],
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],
4815
5037
  y: -5,
4816
5038
  width: "12",
4817
5039
  height: "12",
4818
5040
  rx: "3",
4819
5041
  fill: t.color
4820
- }, null, 8, me), a("text", {
4821
- x: Be.value[n] + 16,
5042
+ }, null, 8, De), a("text", {
5043
+ x: Qe.value[n] + 16,
4822
5044
  y: 5,
4823
5045
  "font-size": "13",
4824
5046
  fill: "currentColor"
4825
- }, g(t.label), 9, he)], 64))), 128))], 64)) : (p(), i(e, { key: 1 }, [
4826
- o.legendTitle ? (p(), i("text", ge, g(o.legendTitle), 1)) : r("", !0),
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),
4827
5049
  a("defs", null, [a("linearGradient", {
4828
- id: _,
5050
+ id: d,
4829
5051
  x1: "0",
4830
5052
  x2: "1",
4831
5053
  y1: "0",
4832
5054
  y2: "0"
4833
- }, [(p(!0), i(e, null, h(Le.value, (e) => (p(), i("stop", {
5055
+ }, [(m(!0), i(e, null, g(Je.value, (e) => (m(), i("stop", {
4834
5056
  key: e.offset,
4835
5057
  offset: e.offset,
4836
5058
  "stop-color": e.color
4837
- }, null, 8, _e))), 128))])]),
5059
+ }, null, 8, Ae))), 128))])]),
4838
5060
  a("rect", {
4839
5061
  x: o.legendTitle ? o.legendTitle.length * 8 + 12 : 0,
4840
5062
  y: -6,
4841
5063
  width: 160,
4842
5064
  height: 12,
4843
5065
  rx: "2",
4844
- fill: `url(#${_})`
4845
- }, null, 8, ve),
4846
- (p(!0), i(e, null, h(Re.value, (e) => (p(), i("text", {
5066
+ fill: `url(#${d})`
5067
+ }, null, 8, je),
5068
+ (m(!0), i(e, null, g(Ye.value, (e) => (m(), i("text", {
4847
5069
  key: e.value,
4848
5070
  x: (o.legendTitle ? o.legendTitle.length * 8 + 12 : 0) + e.pct / 100 * 160,
4849
5071
  y: 20,
@@ -4851,20 +5073,71 @@ var B = ["width", "height"], V = ["x"], ie = [
4851
5073
  fill: "currentColor",
4852
5074
  opacity: "0.7",
4853
5075
  "text-anchor": "middle"
4854
- }, g(e.value), 9, ye))), 128))
4855
- ], 64))], 8, fe)) : r("", !0),
4856
- o.title ? (p(), i("text", {
5076
+ }, v(e.value), 9, Me))), 128))
5077
+ ], 64))], 8, Te)) : r("", !0),
5078
+ o.title ? (m(), i("text", {
4857
5079
  key: 1,
4858
- x: I.value / 2,
5080
+ x: L.value / 2,
4859
5081
  y: 18,
4860
5082
  "text-anchor": "middle",
4861
5083
  "font-size": "14",
4862
5084
  "font-weight": "600",
4863
5085
  fill: "currentColor"
4864
- }, g(o.title), 9, be)) : r("", !0)
4865
- ], 8, le))], 2));
5086
+ }, v(o.title), 9, Ne)) : r("", !0)
5087
+ ], 8, X))], 2));
4866
5088
  }
4867
- }), [["__scopeId", "data-v-64b95aef"]]), X = { class: "TableWrapper" }, Z = { class: "Table" }, Se = /* @__PURE__ */ I(/* @__PURE__ */ c({
5089
+ }), [["__scopeId", "data-v-7f5b0832"]]), Fe = /* @__PURE__ */ B(/* @__PURE__ */ c({
5090
+ __name: "ChartTooltip",
5091
+ props: {
5092
+ x: {},
5093
+ y: {},
5094
+ open: { type: Boolean },
5095
+ mode: { default: "hover" },
5096
+ sideOffset: { default: 16 }
5097
+ },
5098
+ emits: ["close"],
5099
+ setup(e) {
5100
+ return (t, o) => e.mode === "hover" && e.open ? (m(), i("div", {
5101
+ key: 0,
5102
+ class: "chart-tooltip-content",
5103
+ style: f({
5104
+ position: "absolute",
5105
+ left: `${e.x + e.sideOffset}px`,
5106
+ top: `${e.y}px`,
5107
+ transform: "translateY(-50%)"
5108
+ })
5109
+ }, [_(t.$slots, "default", {}, void 0, !0)], 4)) : e.mode === "click" ? (m(), n(y(M), {
5110
+ key: 1,
5111
+ open: e.open
5112
+ }, {
5113
+ default: S(() => [s(y(k), { "as-child": "" }, {
5114
+ default: S(() => [a("div", {
5115
+ class: "chart-tooltip-anchor",
5116
+ style: f({
5117
+ left: `${e.x}px`,
5118
+ top: `${e.y}px`
5119
+ })
5120
+ }, null, 4)]),
5121
+ _: 1
5122
+ }), s(y(j), null, {
5123
+ default: S(() => [e.open ? (m(), n(y(A), {
5124
+ key: 0,
5125
+ class: "chart-tooltip-content",
5126
+ side: "right",
5127
+ "side-offset": e.sideOffset,
5128
+ "update-position-strategy": "always",
5129
+ onPointerDownOutside: o[0] ||= (e) => t.$emit("close"),
5130
+ onEscapeKeyDown: o[1] ||= (e) => t.$emit("close")
5131
+ }, {
5132
+ default: S(() => [_(t.$slots, "default", {}, void 0, !0)]),
5133
+ _: 3
5134
+ }, 8, ["side-offset"])) : r("", !0)]),
5135
+ _: 3
5136
+ })]),
5137
+ _: 3
5138
+ }, 8, ["open"])) : r("", !0);
5139
+ }
5140
+ }), [["__scopeId", "data-v-44377f70"]]), Ie = { class: "TableWrapper" }, Le = { class: "Table" }, $ = /* @__PURE__ */ B(/* @__PURE__ */ c({
4868
5141
  __name: "DataTable",
4869
5142
  props: {
4870
5143
  data: {},
@@ -4881,10 +5154,10 @@ var B = ["width", "height"], V = ["x"], ie = [
4881
5154
  medium: "150px",
4882
5155
  large: "250px"
4883
5156
  }, c = o;
4884
- function d(e) {
5157
+ function l(e) {
4885
5158
  return c.columnConfig?.[e]?.label ?? e;
4886
5159
  }
4887
- function f(e) {
5160
+ function d(e) {
4888
5161
  let t = c.columnConfig?.[e]?.width;
4889
5162
  if (t == null) return;
4890
5163
  let n = typeof t == "number" ? `${t}px` : s[t];
@@ -4893,16 +5166,16 @@ var B = ["width", "height"], V = ["x"], ie = [
4893
5166
  minWidth: n
4894
5167
  };
4895
5168
  }
4896
- function m(e) {
5169
+ function p(e) {
4897
5170
  let t = c.columnConfig?.[e]?.align;
4898
5171
  if (t) return { textAlign: t };
4899
5172
  }
4900
- function _(e) {
5173
+ function ee(e) {
4901
5174
  return typeof e.column == "function";
4902
5175
  }
4903
- let v = t(() => {
5176
+ let h = t(() => {
4904
5177
  let e = c.data;
4905
- return _(e) ? e.columns.map((t) => ({
5178
+ return ee(e) ? e.columns.map((t) => ({
4906
5179
  name: t.name,
4907
5180
  values: e.column(t.name),
4908
5181
  enumLabels: t.enumLabels
@@ -4910,54 +5183,54 @@ var B = ["width", "height"], V = ["x"], ie = [
4910
5183
  name: e,
4911
5184
  values: t
4912
5185
  }));
4913
- }), y = t(() => {
4914
- let e = v.value;
5186
+ }), _ = t(() => {
5187
+ let e = h.value;
4915
5188
  if (e.length === 0) return 0;
4916
5189
  let t = 0;
4917
5190
  for (let n of e) t = Math.max(t, n.values.length);
4918
5191
  return c.maxRows ? Math.min(t, c.maxRows) : t;
4919
5192
  });
4920
- function b(e, t) {
5193
+ function y(e, t) {
4921
5194
  let n = e.values[t];
4922
5195
  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);
4923
5196
  }
4924
- function x() {
5197
+ function b() {
4925
5198
  return typeof c.menu == "string" ? c.menu : "data";
4926
5199
  }
4927
- function S(e) {
5200
+ function x(e) {
4928
5201
  return e.includes(",") || e.includes("\"") || e.includes("\n") ? `"${e.replace(/"/g, "\"\"")}"` : e;
4929
5202
  }
4930
- function C() {
4931
- let e = v.value, t = y.value, n = [e.map((e) => S(d(e.name))).join(",")];
5203
+ function S() {
5204
+ let e = h.value, t = _.value, n = [e.map((e) => x(l(e.name))).join(",")];
4932
5205
  for (let r = 0; r < t; r++) {
4933
- let t = e.map((e) => S(b(e, r)));
5206
+ let t = e.map((e) => x(y(e, r)));
4934
5207
  n.push(t.join(","));
4935
5208
  }
4936
5209
  return n.join("\n");
4937
5210
  }
4938
- let w = t(() => [{
5211
+ let C = t(() => [{
4939
5212
  label: "Download CSV",
4940
- action: () => z(C(), x())
5213
+ action: () => le(S(), b())
4941
5214
  }]);
4942
- return (t, s) => (p(), i("div", { class: l(["TableOuter", { "has-menu": o.menu }]) }, [o.menu ? (p(), n(L, {
5215
+ return (t, s) => (m(), i("div", { class: u(["TableOuter", { "has-menu": o.menu }]) }, [o.menu ? (m(), n(oe, {
4943
5216
  key: 0,
4944
- items: w.value
4945
- }, null, 8, ["items"])) : r("", !0), a("div", X, [a("table", Z, [
4946
- a("colgroup", null, [(p(!0), i(e, null, h(v.value, (e) => (p(), i("col", {
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", {
4947
5220
  key: e.name,
4948
- style: u(f(e.name))
5221
+ style: f(d(e.name))
4949
5222
  }, null, 4))), 128))]),
4950
- a("thead", null, [a("tr", null, [(p(!0), i(e, null, h(v.value, (e) => (p(), i("th", {
5223
+ a("thead", null, [a("tr", null, [(m(!0), i(e, null, g(h.value, (e) => (m(), i("th", {
4951
5224
  key: e.name,
4952
- style: u(m(e.name))
4953
- }, g(d(e.name)), 5))), 128))])]),
4954
- a("tbody", null, [(p(!0), i(e, null, h(y.value, (t) => (p(), i("tr", { key: t }, [(p(!0), i(e, null, h(v.value, (e) => (p(), i("td", {
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", {
4955
5228
  key: e.name,
4956
- class: l(o.columnConfig?.[e.name]?.cellClass),
4957
- style: u(m(e.name))
4958
- }, g(b(e, t - 1)), 7))), 128))]))), 128))])
5229
+ class: u(o.columnConfig?.[e.name]?.cellClass),
5230
+ style: f(p(e.name))
5231
+ }, v(y(e, t - 1)), 7))), 128))]))), 128))])
4959
5232
  ])])], 2));
4960
5233
  }
4961
5234
  }), [["__scopeId", "data-v-dbfb7c84"]]);
4962
5235
  //#endregion
4963
- export { xe as ChoroplethMap, Se as DataTable, oe as LineChart };
5236
+ export { Fe as ChartTooltip, Pe as ChoroplethMap, $ as DataTable, J as LineChart };