@cfasim-ui/charts 0.2.2 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,3 +1,4 @@
1
+ import { Topology } from 'topojson-specification';
1
2
  export type GeoType = "states" | "counties" | "hsas";
2
3
  export interface StateData {
3
4
  /** FIPS code (e.g. "06" for California, "04015" for a county) or name */
@@ -24,6 +25,10 @@ export interface CategoricalStop {
24
25
  color: string;
25
26
  }
26
27
  type __VLS_Props = {
28
+ /** TopoJSON topology object (e.g. from us-atlas/states-10m.json or us-atlas/counties-10m.json).
29
+ * Must contain a "states" object for geoType="states", or both "states" and "counties" objects
30
+ * for geoType="counties" or geoType="hsas". */
31
+ topology: Topology;
27
32
  data?: StateData[];
28
33
  /** Geographic type: "states" (default), "counties", or "hsas" (Health Service Areas) */
29
34
  geoType?: GeoType;
package/dist/index.css CHANGED
@@ -1,2 +1,2 @@
1
- .chart-menu-trigger-area[data-v-fe2f6904]{z-index:1;position:absolute;top:0;right:0}.chart-menu-button[data-v-fe2f6904]{border:1px solid var(--color-border);background:var(--color-bg-0,#fff);width:28px;height:28px;color:var(--color-text-secondary);cursor:pointer;opacity:0;border-radius:.25em;justify-content:center;align-items:center;transition:opacity .15s;display:flex}.chart-menu-button[data-state=open][data-v-fe2f6904]{opacity:1}.chart-menu-button[data-v-fe2f6904]:hover{background:var(--color-bg-1,#0000000d);color:var(--color-text)}.chart-menu-content{z-index:100;background:var(--color-bg-0);border:1px solid var(--color-border);border-radius:.25em;min-width:140px;padding:.25em;box-shadow:0 4px 6px -1px #0000001a,0 2px 4px -2px #0000001a}.chart-menu-item{font-size:var(--font-size-sm);cursor:pointer;-webkit-user-select:none;user-select:none;white-space:nowrap;border-radius:.25em;outline:none;align-items:center;padding:.375em .5em;display:flex}.chart-menu-item[data-highlighted]{background:var(--color-primary);color:#fff}.line-chart-wrapper[data-v-4ea55781]{width:100%;position:relative}.line-chart-wrapper[data-v-4ea55781]:hover .chart-menu-button{opacity:1}.line-chart-tooltip-label[data-v-4ea55781]{margin-bottom:.25em;font-weight:600}.line-chart-tooltip-row[data-v-4ea55781]{align-items:center;gap:.375em;display:flex}.line-chart-tooltip-swatch[data-v-4ea55781]{border-radius:50%;flex-shrink:0;width:.625em;height:.625em;display:inline-block}.choropleth-wrapper[data-v-7f5b0832]{width:100%;position:relative}.choropleth-wrapper.pannable svg[data-v-7f5b0832]{cursor:grab}.choropleth-wrapper.pannable svg[data-v-7f5b0832]:active{cursor:grabbing}.choropleth-wrapper[data-v-7f5b0832]:hover .chart-menu-button{opacity:1}.state-path[data-v-7f5b0832]{cursor:pointer}.chart-tooltip-anchor[data-v-44377f70]{pointer-events:none;width:1px;height:1px;position:absolute}.chart-tooltip-content{z-index:100;background:var(--color-bg-0,#fff);border:1px solid var(--color-border,#e5e7eb);font-size:var(--font-size-sm,.875rem);pointer-events:none;border-radius:.375em;padding:.5em .75em;box-shadow:0 4px 6px -1px #0000001a,0 2px 4px -2px #0000001a}.TableOuter[data-v-dbfb7c84]{display:inline-block;position:relative}.TableOuter.has-menu[data-v-dbfb7c84]{padding-top:32px}.TableOuter[data-v-dbfb7c84]:hover .chart-menu-button{opacity:1}.TableWrapper[data-v-dbfb7c84]{font-size:var(--font-size-sm);overflow-x:auto}.Table[data-v-dbfb7c84]{border-collapse:collapse;font-variant-numeric:tabular-nums;border:1px solid var(--color-border)}.Table tr[data-v-dbfb7c84],.Table th[data-v-dbfb7c84],.Table td[data-v-dbfb7c84]{background:0 0;border:none}.Table th[data-v-dbfb7c84],.Table td[data-v-dbfb7c84]{white-space:nowrap;padding:.75em 1.25em}.Table th[data-v-dbfb7c84]{border-bottom:1px solid var(--color-border-header);font-weight:600;position:sticky;top:0}.Table tbody td[data-v-dbfb7c84]{border-bottom:1px solid var(--color-border)}.Table tbody tr:last-child td[data-v-dbfb7c84]{border-bottom:none}
1
+ .chart-menu-trigger-area[data-v-fe2f6904]{z-index:1;position:absolute;top:0;right:0}.chart-menu-button[data-v-fe2f6904]{border:1px solid var(--color-border);background:var(--color-bg-0,#fff);width:28px;height:28px;color:var(--color-text-secondary);cursor:pointer;opacity:0;border-radius:.25em;justify-content:center;align-items:center;transition:opacity .15s;display:flex}.chart-menu-button[data-state=open][data-v-fe2f6904]{opacity:1}.chart-menu-button[data-v-fe2f6904]:hover{background:var(--color-bg-1,#0000000d);color:var(--color-text)}.chart-menu-content{z-index:100;background:var(--color-bg-0);border:1px solid var(--color-border);border-radius:.25em;min-width:140px;padding:.25em;box-shadow:0 4px 6px -1px #0000001a,0 2px 4px -2px #0000001a}.chart-menu-item{font-size:var(--font-size-sm);cursor:pointer;-webkit-user-select:none;user-select:none;white-space:nowrap;border-radius:.25em;outline:none;align-items:center;padding:.375em .5em;display:flex}.chart-menu-item[data-highlighted]{background:var(--color-primary);color:#fff}.line-chart-wrapper[data-v-4ea55781]{width:100%;position:relative}.line-chart-wrapper[data-v-4ea55781]:hover .chart-menu-button{opacity:1}.line-chart-tooltip-label[data-v-4ea55781]{margin-bottom:.25em;font-weight:600}.line-chart-tooltip-row[data-v-4ea55781]{align-items:center;gap:.375em;display:flex}.line-chart-tooltip-swatch[data-v-4ea55781]{border-radius:50%;flex-shrink:0;width:.625em;height:.625em;display:inline-block}.choropleth-wrapper[data-v-ffaf1671]{width:100%;position:relative}.choropleth-wrapper.pannable svg[data-v-ffaf1671]{cursor:grab}.choropleth-wrapper.pannable svg[data-v-ffaf1671]:active{cursor:grabbing}.choropleth-wrapper[data-v-ffaf1671]:hover .chart-menu-button{opacity:1}.state-path[data-v-ffaf1671]{cursor:pointer}.chart-tooltip-anchor[data-v-44377f70]{pointer-events:none;width:1px;height:1px;position:absolute}.chart-tooltip-content{z-index:100;background:var(--color-bg-0,#fff);border:1px solid var(--color-border,#e5e7eb);font-size:var(--font-size-sm,.875rem);pointer-events:none;border-radius:.375em;padding:.5em .75em;box-shadow:0 4px 6px -1px #0000001a,0 2px 4px -2px #0000001a}.TableOuter[data-v-dbfb7c84]{display:inline-block;position:relative}.TableOuter.has-menu[data-v-dbfb7c84]{padding-top:32px}.TableOuter[data-v-dbfb7c84]:hover .chart-menu-button{opacity:1}.TableWrapper[data-v-dbfb7c84]{font-size:var(--font-size-sm);overflow-x:auto}.Table[data-v-dbfb7c84]{border-collapse:collapse;font-variant-numeric:tabular-nums;border:1px solid var(--color-border)}.Table tr[data-v-dbfb7c84],.Table th[data-v-dbfb7c84],.Table td[data-v-dbfb7c84]{background:0 0;border:none}.Table th[data-v-dbfb7c84],.Table td[data-v-dbfb7c84]{white-space:nowrap;padding:.75em 1.25em}.Table th[data-v-dbfb7c84]{border-bottom:1px solid var(--color-border-header);font-weight:600;position:sticky;top:0}.Table tbody td[data-v-dbfb7c84]{border-bottom:1px solid var(--color-border)}.Table tbody tr:last-child td[data-v-dbfb7c84]{border-bottom:none}
2
2
  /*$vite$:1*/
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 = 50, J = /* @__PURE__ */ B(/* @__PURE__ */ c({
172
170
  __name: "LineChart",
173
171
  props: {
174
172
  data: {},
@@ -195,16 +193,16 @@ var H = ["width", "height"], ue = ["x"], de = [
195
193
  },
196
194
  emits: ["hover"],
197
195
  setup(s, { emit: c }) {
198
- let u = s, y = c, b = h(null), x = h(null), S = h(0), w = null, T = null;
196
+ let u = s, y = c, b = h(null), x = h(null), S = h(0), C = null, T = null;
199
197
  p(() => {
200
- b.value && (S.value = b.value.clientWidth, w = new ResizeObserver((e) => {
198
+ b.value && (S.value = b.value.clientWidth, C = new ResizeObserver((e) => {
201
199
  let t = e[0];
202
200
  t && (u.debounce ? (T && clearTimeout(T), T = setTimeout(() => {
203
201
  S.value = t.contentRect.width;
204
202
  }, u.debounce)) : S.value = t.contentRect.width);
205
- }), w.observe(b.value));
203
+ }), C.observe(b.value));
206
204
  }), ee(() => {
207
- w?.disconnect(), T && clearTimeout(T);
205
+ C?.disconnect(), T && clearTimeout(T);
208
206
  });
209
207
  let E = t(() => u.width ?? (S.value || 400)), D = t(() => u.height ?? 200), O = t(() => ({
210
208
  top: u.title ? 30 : 10,
@@ -269,30 +267,30 @@ var H = ["width", "height"], ue = ["x"], de = [
269
267
  }
270
268
  return p;
271
269
  }
272
- function ie(e, t) {
270
+ function F(e, t) {
273
271
  let n = e / t, r = 10 ** Math.floor(Math.log10(n)), i = n / r, a;
274
272
  return a = i <= 1.5 ? 1 : i <= 3 ? 2 : i <= 7 ? 5 : 10, a * r;
275
273
  }
276
- function F(e) {
274
+ function I(e) {
277
275
  return Math.round(e) + .5;
278
276
  }
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);
277
+ let ie = new Intl.NumberFormat();
278
+ function L(e) {
279
+ return Math.abs(e) >= 1e3 ? ie.format(e) : Number.isInteger(e) ? e.toString() : e.toFixed(1);
282
280
  }
283
- let L = t(() => {
281
+ let R = t(() => {
284
282
  let { min: e, max: t } = P.value;
285
283
  if (e === t) return [{
286
- value: I(e),
287
- y: F(O.value.top + A.value / 2)
284
+ value: L(e),
285
+ y: I(O.value.top + A.value / 2)
288
286
  }];
289
- let n = Math.max(3, Math.floor(A.value / 50)), r = ie(t - e, n), i = Math.ceil(e / r) * r, a = [];
287
+ let n = Math.max(3, Math.floor(A.value / 50)), r = F(t - e, n), i = Math.ceil(e / r) * r, a = [];
290
288
  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)
289
+ value: L(n),
290
+ y: I(O.value.top + A.value - (n - e) / P.value.range * A.value)
293
291
  });
294
292
  return a;
295
- }), R = t(() => {
293
+ }), z = t(() => {
296
294
  let e = N.value;
297
295
  if (e <= 1) return [];
298
296
  let t = u.xLabels;
@@ -300,27 +298,27 @@ var H = ["width", "height"], ue = ["x"], de = [
300
298
  let n = Math.max(3, Math.floor(k.value / 80)), r = Math.max(1, Math.round((e - 1) / n)), i = [];
301
299
  for (let n = 0; n < e; n += r) i.push({
302
300
  value: t[n],
303
- x: F(O.value.left + n / (e - 1) * k.value)
301
+ x: I(O.value.left + n / (e - 1) * k.value)
304
302
  });
305
303
  return i;
306
304
  }
307
- let n = u.xMin ?? 0, r = Math.max(3, Math.floor(k.value / 80)), i = ie(e - 1, r), a = [];
305
+ let n = u.xMin ?? 0, r = Math.max(3, Math.floor(k.value / 80)), i = F(e - 1, r), a = [];
308
306
  for (let t = 0; t <= e - 1; t += i) {
309
307
  let r = Math.round(t);
310
308
  a.push({
311
- value: I(r + n),
312
- x: F(O.value.left + r / (e - 1) * k.value)
309
+ value: L(r + n),
310
+ x: I(O.value.left + r / (e - 1) * k.value)
313
311
  });
314
312
  }
315
313
  return a;
316
314
  });
317
- function z() {
315
+ function B() {
318
316
  return typeof u.menu == "string" ? u.menu : "chart";
319
317
  }
320
- function B() {
318
+ function V() {
321
319
  return x.value;
322
320
  }
323
- function V() {
321
+ function J() {
324
322
  let e = j.value;
325
323
  if (e.length === 0) return "";
326
324
  let t = N.value, n = [(e.length === 1 ? ["index", "value"] : ["index", ...e.map((e, t) => `series_${t}`)]).join(",")];
@@ -331,21 +329,21 @@ var H = ["width", "height"], ue = ["x"], de = [
331
329
  }
332
330
  return n.join("\n");
333
331
  }
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;
332
+ let Y = h(null), X = h(!1), Se = h(null), Z = t(() => !!u.tooltipData || !!u.tooltipTrigger), Ce = t(() => {
333
+ if (Y.value === null) return 0;
336
334
  let e = N.value, t = k.value / (e - 1 || 1);
337
- return O.value.left + J.value * t;
335
+ return O.value.left + Y.value * t;
338
336
  }), we = t(() => {
339
- let e = J.value;
337
+ let e = Y.value;
340
338
  if (e === null) return [];
341
339
  let { min: t, range: n } = P.value, r = A.value / n, i = O.value.top + A.value;
342
340
  return j.value.filter((t) => e < t.data.length && isFinite(t.data[e])).map((n) => ({
343
- x: Z.value,
341
+ x: Ce.value,
344
342
  y: i - (n.data[e] - t) * r,
345
343
  color: n.color ?? "currentColor"
346
344
  }));
347
345
  }), Q = t(() => {
348
- let e = J.value;
346
+ let e = Y.value;
349
347
  return e === null ? null : {
350
348
  index: e,
351
349
  xLabel: u.xLabels?.[e],
@@ -369,59 +367,59 @@ var H = ["width", "height"], ue = ["x"], de = [
369
367
  return Math.round(Math.max(0, Math.min(n - 1, a)));
370
368
  }
371
369
  function De(e, t) {
372
- let n = Ce.value;
370
+ let n = Se.value;
373
371
  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);
372
+ let r = b.value.getBoundingClientRect(), i = X.value ? xe : 0, a = e - r.left, o = Math.max(0, t - r.top - i);
375
373
  n.style.left = `${a + 16}px`, n.style.top = `${o}px`;
376
374
  }
377
375
  function Oe(e) {
378
376
  let t = Te(e);
379
377
  if (!t) return;
380
378
  let n = Ee(t.clientX);
381
- n !== null && (J.value = n, De(t.clientX, t.clientY), y("hover", { index: n }));
379
+ n !== null && (Y.value = n, De(t.clientX, t.clientY), y("hover", { index: n }));
382
380
  }
383
381
  function ke(e) {
384
382
  Oe(e);
385
383
  }
386
384
  function Ae() {
387
- u.tooltipTrigger !== "click" && (J.value = null, y("hover", null));
385
+ u.tooltipTrigger !== "click" && (Y.value = null, y("hover", null));
388
386
  }
389
387
  function je(e) {
390
388
  if (u.tooltipTrigger !== "click") return;
391
389
  let t = Te(e);
392
390
  if (!t) return;
393
391
  let n = Ee(t.clientX);
394
- n !== null && (J.value = J.value === n ? null : n, y("hover", J.value === null ? null : { index: n }));
392
+ n !== null && (Y.value = Y.value === n ? null : n, y("hover", Y.value === null ? null : { index: n }));
395
393
  }
396
394
  function Me(e) {
397
- Y.value = !0, Oe(e);
395
+ X.value = !0, Oe(e);
398
396
  }
399
397
  function Ne(e) {
400
398
  Oe(e);
401
399
  }
402
400
  function Pe() {
403
- Y.value = !1, J.value = null, y("hover", null);
401
+ X.value = !1, Y.value = null, y("hover", null);
404
402
  }
405
- let Fe = t(() => {
406
- let e = z();
403
+ let $ = t(() => {
404
+ let e = B();
407
405
  return [
408
406
  {
409
407
  label: "Save as SVG",
410
408
  action: () => {
411
- let t = B();
412
- t && se(t, e);
409
+ let t = V();
410
+ t && oe(t, e);
413
411
  }
414
412
  },
415
413
  {
416
414
  label: "Save as PNG",
417
415
  action: () => {
418
- let t = B();
419
- t && ce(t, e);
416
+ let t = V();
417
+ t && se(t, e);
420
418
  }
421
419
  },
422
420
  {
423
421
  label: "Download CSV",
424
- action: () => le(V(), e)
422
+ action: () => H(J(), e)
425
423
  }
426
424
  ];
427
425
  });
@@ -430,9 +428,9 @@ var H = ["width", "height"], ue = ["x"], de = [
430
428
  ref: b,
431
429
  class: "line-chart-wrapper"
432
430
  }, [
433
- s.menu ? (m(), n(oe, {
431
+ s.menu ? (m(), n(ae, {
434
432
  key: 0,
435
- items: Fe.value
433
+ items: $.value
436
434
  }, null, 8, ["items"])) : r("", !0),
437
435
  (m(), i("svg", {
438
436
  ref_key: "svgRef",
@@ -448,24 +446,24 @@ var H = ["width", "height"], ue = ["x"], de = [
448
446
  "font-size": "14",
449
447
  "font-weight": "600",
450
448
  fill: "currentColor"
451
- }, v(s.title), 9, ue)) : r("", !0),
449
+ }, v(s.title), 9, le)) : r("", !0),
452
450
  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),
451
+ x1: I(O.value.left),
452
+ y1: I(O.value.top),
453
+ x2: I(O.value.left),
454
+ y2: I(O.value.top + A.value),
457
455
  stroke: "currentColor",
458
456
  "stroke-opacity": "0.3"
459
- }, null, 8, de),
457
+ }, null, 8, U),
460
458
  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),
459
+ x1: I(O.value.left),
460
+ y1: I(O.value.top + A.value),
461
+ x2: I(O.value.left + k.value),
462
+ y2: I(O.value.top + A.value),
465
463
  stroke: "currentColor",
466
464
  "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", {
465
+ }, null, 8, ue),
466
+ s.yGrid ? (m(!0), i(e, { key: 1 }, g(R.value, (e, t) => (m(), i("line", {
469
467
  key: "yg" + t,
470
468
  x1: O.value.left,
471
469
  y1: e.y,
@@ -473,8 +471,8 @@ var H = ["width", "height"], ue = ["x"], de = [
473
471
  y2: e.y,
474
472
  stroke: "currentColor",
475
473
  "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", {
474
+ }, null, 8, de))), 128)) : r("", !0),
475
+ s.xGrid ? (m(!0), i(e, { key: 2 }, g(z.value, (e, t) => (m(), i("line", {
478
476
  key: "xg" + t,
479
477
  x1: e.x,
480
478
  y1: O.value.top,
@@ -482,8 +480,8 @@ var H = ["width", "height"], ue = ["x"], de = [
482
480
  y2: O.value.top + A.value,
483
481
  stroke: "currentColor",
484
482
  "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", {
483
+ }, null, 8, W))), 128)) : r("", !0),
484
+ (m(!0), i(e, null, g(R.value, (e, t) => (m(), i("text", {
487
485
  key: "y" + t,
488
486
  x: O.value.left - 6,
489
487
  y: e.y,
@@ -492,7 +490,7 @@ var H = ["width", "height"], ue = ["x"], de = [
492
490
  "font-size": "10",
493
491
  fill: "currentColor",
494
492
  "fill-opacity": "0.6"
495
- }, v(e.value), 9, me))), 128)),
493
+ }, v(e.value), 9, G))), 128)),
496
494
  s.yLabel ? (m(), i("text", {
497
495
  key: 3,
498
496
  x: 0,
@@ -501,8 +499,8 @@ var H = ["width", "height"], ue = ["x"], de = [
501
499
  "text-anchor": "middle",
502
500
  "font-size": "13",
503
501
  fill: "currentColor"
504
- }, v(s.yLabel), 9, W)) : r("", !0),
505
- (m(!0), i(e, null, g(R.value, (e, t) => (m(), i("text", {
502
+ }, v(s.yLabel), 9, fe)) : r("", !0),
503
+ (m(!0), i(e, null, g(z.value, (e, t) => (m(), i("text", {
506
504
  key: "x" + t,
507
505
  x: e.x,
508
506
  y: O.value.top + A.value + 16,
@@ -510,7 +508,7 @@ var H = ["width", "height"], ue = ["x"], de = [
510
508
  "font-size": "10",
511
509
  fill: "currentColor",
512
510
  "fill-opacity": "0.6"
513
- }, v(e.value), 9, G))), 128)),
511
+ }, v(e.value), 9, pe))), 128)),
514
512
  s.xLabel ? (m(), i("text", {
515
513
  key: 4,
516
514
  x: O.value.left + k.value / 2,
@@ -518,14 +516,14 @@ var H = ["width", "height"], ue = ["x"], de = [
518
516
  "text-anchor": "middle",
519
517
  "font-size": "13",
520
518
  fill: "currentColor"
521
- }, v(s.xLabel), 9, he)) : r("", !0),
519
+ }, v(s.xLabel), 9, me)) : r("", !0),
522
520
  (m(!0), i(e, null, g(M.value, (e, t) => (m(), i("path", {
523
521
  key: "area" + t,
524
522
  d: re(e.upper, e.lower),
525
523
  fill: e.color ?? "currentColor",
526
524
  "fill-opacity": e.opacity ?? .2,
527
525
  stroke: "none"
528
- }, null, 8, ge))), 128)),
526
+ }, null, 8, he))), 128)),
529
527
  (m(!0), i(e, null, g(j.value, (t, n) => (m(), i(e, { key: n }, [t.line === !1 ? r("", !0) : (m(), i("path", {
530
528
  key: 0,
531
529
  d: te(t.data),
@@ -534,7 +532,7 @@ var H = ["width", "height"], ue = ["x"], de = [
534
532
  "stroke-width": t.strokeWidth ?? 1.5,
535
533
  "stroke-opacity": t.lineOpacity ?? t.opacity ?? s.lineOpacity,
536
534
  "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", {
535
+ }, null, 8, ge)), t.dots ? (m(!0), i(e, { key: 1 }, g(ne(t.data), (e, n) => (m(), i("circle", {
538
536
  key: n,
539
537
  cx: e.x,
540
538
  cy: e.y,
@@ -542,18 +540,18 @@ var H = ["width", "height"], ue = ["x"], de = [
542
540
  fill: t.dotFill ?? t.color ?? "currentColor",
543
541
  "fill-opacity": t.dotOpacity ?? t.opacity ?? s.lineOpacity,
544
542
  stroke: t.dotStroke ?? "none"
545
- }, null, 8, ve))), 128)) : r("", !0)], 64))), 128)),
546
- X.value && J.value !== null ? (m(), i("line", {
543
+ }, null, 8, _e))), 128)) : r("", !0)], 64))), 128)),
544
+ Z.value && Y.value !== null ? (m(), i("line", {
547
545
  key: 5,
548
- x1: F(Z.value),
546
+ x1: I(Ce.value),
549
547
  y1: O.value.top,
550
- x2: F(Z.value),
548
+ x2: I(Ce.value),
551
549
  y2: O.value.top + A.value,
552
550
  stroke: "currentColor",
553
551
  "stroke-opacity": "0.3",
554
552
  "stroke-dasharray": "4 2",
555
553
  "pointer-events": "none"
556
- }, null, 8, ye)) : r("", !0),
554
+ }, null, 8, ve)) : r("", !0),
557
555
  (m(!0), i(e, null, g(we.value, (e, t) => (m(), i("circle", {
558
556
  key: "hd" + t,
559
557
  cx: e.x,
@@ -563,8 +561,8 @@ var H = ["width", "height"], ue = ["x"], de = [
563
561
  stroke: "var(--color-bg-0, #fff)",
564
562
  "stroke-width": "2",
565
563
  "pointer-events": "none"
566
- }, null, 8, be))), 128)),
567
- X.value ? (m(), i("rect", {
564
+ }, null, 8, K))), 128)),
565
+ Z.value ? (m(), i("rect", {
568
566
  key: 6,
569
567
  x: O.value.left,
570
568
  y: O.value.top,
@@ -578,27 +576,27 @@ var H = ["width", "height"], ue = ["x"], de = [
578
576
  onMousemove: ke,
579
577
  onMouseleave: Ae,
580
578
  onClick: je,
581
- onTouchstart: C(Me, ["prevent"]),
582
- onTouchmove: C(Ne, ["prevent"]),
579
+ onTouchstart: w(Me, ["prevent"]),
580
+ onTouchmove: w(Ne, ["prevent"]),
583
581
  onTouchend: Pe
584
- }, null, 40, xe)) : r("", !0)
585
- ], 8, H)),
586
- X.value && J.value !== null && Q.value ? (m(), i("div", {
582
+ }, null, 40, q)) : r("", !0)
583
+ ], 8, ce)),
584
+ Z.value && Y.value !== null && Q.value ? (m(), i("div", {
587
585
  key: 1,
588
586
  ref_key: "tooltipRef",
589
- ref: Ce,
587
+ ref: Se,
590
588
  class: "chart-tooltip-content",
591
589
  style: {
592
590
  position: "absolute",
593
591
  transform: "translateY(-50%)"
594
592
  }
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", {
593
+ }, [_(t.$slots, "tooltip", d(l(Q.value)), () => [a("div", ye, [Q.value.xLabel ? (m(), i("div", be, v(Q.value.xLabel), 1)) : r("", !0), (m(!0), i(e, null, g(Q.value.values, (e) => (m(), i("div", {
596
594
  key: e.seriesIndex,
597
595
  class: "line-chart-tooltip-row"
598
596
  }, [a("span", {
599
597
  class: "line-chart-tooltip-swatch",
600
598
  style: f({ background: e.color })
601
- }, null, 4), o(" " + v(isFinite(e.value) ? I(e.value) : "—"), 1)]))), 128))])], !0)], 512)) : r("", !0)
599
+ }, null, 4), o(" " + v(isFinite(e.value) ? L(e.value) : "—"), 1)]))), 128))])], !0)], 512)) : r("", !0)
602
600
  ], 512));
603
601
  }
604
602
  }), [["__scopeId", "data-v-4ea55781"]]), Y = {
@@ -3762,7 +3760,7 @@ var H = ["width", "height"], ue = ["x"], de = [
3762
3760
  51019: "510014",
3763
3761
  "02158": "020820",
3764
3762
  46102: "460957"
3765
- }, Ce = {
3763
+ }, X = {
3766
3764
  "010259": "Butler, AL",
3767
3765
  "010177": "Calhoun (Anniston), AL - Cleburne, AL",
3768
3766
  "010172": "Chambers, AL - Randolph, AL",
@@ -4712,27 +4710,28 @@ var H = ["width", "height"], ue = ["x"], de = [
4712
4710
  560775: "Teton, WY - Lincoln, WY",
4713
4711
  560792: "Uinta, WY",
4714
4712
  560804: "Weston, WY"
4715
- }, X = ["width", "height"], Z = [
4713
+ }, Se = ["width", "height"], Z = [
4716
4714
  "data-feat-id",
4717
4715
  "d",
4718
4716
  "fill",
4719
4717
  "stroke",
4720
4718
  "stroke-width"
4721
- ], we = { key: 0 }, Q = ["d", "stroke"], Te = ["transform"], Ee = {
4719
+ ], Ce = { key: 0 }, we = ["d", "stroke"], Q = ["transform"], Te = {
4722
4720
  key: 0,
4723
4721
  y: 5,
4724
4722
  "font-size": "13",
4725
4723
  "font-weight": "600",
4726
4724
  fill: "currentColor"
4727
- }, De = ["x", "fill"], Oe = ["x"], ke = {
4725
+ }, Ee = ["x", "fill"], De = ["x"], Oe = {
4728
4726
  key: 0,
4729
4727
  y: 5,
4730
4728
  "font-size": "13",
4731
4729
  "font-weight": "600",
4732
4730
  fill: "currentColor"
4733
- }, Ae = ["offset", "stop-color"], je = ["x", "fill"], Me = ["x"], Ne = ["x"], Pe = /* @__PURE__ */ B(/* @__PURE__ */ c({
4731
+ }, ke = ["offset", "stop-color"], Ae = ["x", "fill"], je = ["x"], Me = ["x"], Ne = /* @__PURE__ */ B(/* @__PURE__ */ c({
4734
4732
  __name: "ChoroplethMap",
4735
4733
  props: {
4734
+ topology: {},
4736
4735
  data: {},
4737
4736
  geoType: { default: "states" },
4738
4737
  width: {},
@@ -4764,68 +4763,80 @@ var H = ["width", "height"], ue = ["x"], de = [
4764
4763
  },
4765
4764
  emits: ["stateClick", "stateHover"],
4766
4765
  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
- }
4766
+ 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
4767
  function A() {
4774
- let e = y.value;
4775
- e && (e.removeEventListener("click", $), e.removeEventListener("mouseover", $), e.removeEventListener("mousemove", Re), e.removeEventListener("mouseout", ze));
4768
+ if (D) return;
4769
+ let e = b.value;
4770
+ e && (e.addEventListener("click", $), e.addEventListener("mouseover", $), e.addEventListener("mousemove", Fe), e.addEventListener("mouseout", Ie));
4771
+ }
4772
+ function j() {
4773
+ let e = b.value;
4774
+ e && (e.removeEventListener("click", $), e.removeEventListener("mouseover", $), e.removeEventListener("mousemove", Fe), e.removeEventListener("mouseout", Ie));
4776
4775
  }
4777
4776
  p(() => {
4778
- f.value && (S.value = f.value.clientWidth, D = new ResizeObserver((e) => {
4777
+ f.value && (C.value = f.value.clientWidth, O = new ResizeObserver((e) => {
4779
4778
  let t = e[0];
4780
- t && (S.value = t.contentRect.width);
4781
- }), D.observe(f.value)), j(), k();
4779
+ t && (C.value = t.contentRect.width);
4780
+ }), O.observe(f.value)), M(), A();
4782
4781
  }), ee(() => {
4783
- D?.disconnect(), M(), A(), Fe();
4782
+ O?.disconnect(), N(), j(), J();
4784
4783
  });
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();
4784
+ function M() {
4785
+ if (!_.value || !b.value || !c.zoom && !c.pan) return;
4786
+ let e = re(_.value);
4787
+ k = ne().scaleExtent(c.zoom ? [1, 12] : [1, 1]).on("start", () => {
4788
+ E = !0, Pe();
4790
4789
  }).on("zoom", (e) => {
4791
- y.value && y.value.setAttribute("transform", e.transform);
4790
+ b.value && b.value.setAttribute("transform", e.transform);
4792
4791
  }).on("end", () => {
4793
- T = !1;
4794
- }), c.pan || O.filter((e) => e.type === "wheel" || e.type === "dblclick"), e.call(O);
4792
+ E = !1;
4793
+ }), c.pan || k.filter((e) => e.type === "wheel" || e.type === "dblclick"), e.call(k);
4795
4794
  }
4796
- function M() {
4797
- _.value && O && (ne(_.value).on(".zoom", null), O = null);
4795
+ function N() {
4796
+ _.value && k && (re(_.value).on(".zoom", null), k = null);
4798
4797
  }
4799
- x(() => [c.zoom, c.pan], () => {
4800
- M(), A(), j(), k();
4798
+ S(() => [c.zoom, c.pan], () => {
4799
+ N(), j(), M(), A();
4801
4800
  });
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));
4801
+ 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(() => {
4802
+ let e = y(c.topology), t = e.objects.counties.geometries, n = /* @__PURE__ */ new Map();
4803
+ for (let e of t) {
4804
+ let t = Y[String(e.id).padStart(5, "0")];
4805
+ t && (n.has(t) || n.set(t, []), n.get(t).push(e));
4807
4806
  }
4808
- let n = [];
4809
- for (let [e, r] of t) n.push({
4807
+ let r = [];
4808
+ for (let [t, i] of n) r.push({
4810
4809
  type: "Feature",
4811
- id: e,
4812
- properties: { name: Ce[e] ?? e },
4813
- geometry: ie(V, r)
4810
+ id: t,
4811
+ properties: { name: X[t] ?? t },
4812
+ geometry: I(e, i)
4814
4813
  });
4815
4814
  return {
4816
4815
  type: "FeatureCollection",
4817
- features: n
4816
+ features: r
4818
4817
  };
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(() => {
4818
+ }), V = t(() => {
4819
+ if (c.geoType === "hsas") return B.value;
4820
+ if (c.geoType === "counties") {
4821
+ let e = y(c.topology);
4822
+ return F(e, e.objects.counties);
4823
+ }
4824
+ let e = y(c.topology);
4825
+ return F(e, e.objects.states);
4826
+ }), H = t(() => {
4827
+ if (c.geoType !== "counties" && c.geoType !== "hsas") return null;
4828
+ let e = y(c.topology);
4829
+ return ie(e, e.objects.states, (e, t) => e !== t);
4830
+ }), 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
4831
  let e = /* @__PURE__ */ new Map();
4821
4832
  if (!c.data) return e;
4822
4833
  for (let t of c.data) {
4823
4834
  e.set(t.id, t.value);
4824
- let n = H.value.features.find((e) => e.properties?.name === t.id);
4835
+ let n = V.value.features.find((e) => e.properties?.name === t.id);
4825
4836
  n?.id != null && e.set(String(n.id), t.value);
4826
4837
  }
4827
4838
  return e;
4828
- }), me = t(() => {
4839
+ }), de = t(() => {
4829
4840
  if (!c.data || c.data.length === 0) return {
4830
4841
  min: 0,
4831
4842
  max: 1
@@ -4842,8 +4853,8 @@ var H = ["width", "height"], ue = ["x"], de = [
4842
4853
  min: 0,
4843
4854
  max: 1
4844
4855
  };
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) {
4856
+ }), 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");
4857
+ function me(e) {
4847
4858
  let t = e.replace("#", "");
4848
4859
  return [
4849
4860
  parseInt(t.slice(0, 2), 16),
@@ -4851,101 +4862,101 @@ var H = ["width", "height"], ue = ["x"], de = [
4851
4862
  parseInt(t.slice(4, 6), 16)
4852
4863
  ];
4853
4864
  }
4854
- function ve(e) {
4855
- let [t, n, r] = _e(he.value), [i, a, o] = _e(ge.value);
4865
+ function he(e) {
4866
+ let [t, n, r] = me(fe.value), [i, a, o] = me(pe.value);
4856
4867
  return `rgb(${Math.round(t + (i - t) * e)},${Math.round(n + (a - n) * e)},${Math.round(r + (o - r) * e)})`;
4857
4868
  }
4858
- function ye(e) {
4869
+ function ge(e) {
4859
4870
  let t = c.colorScale.slice().sort((e, t) => t.min - e.min);
4860
4871
  for (let n of t) if (e >= n.min) return n.color;
4861
4872
  return c.noDataColor;
4862
4873
  }
4863
- function be(e) {
4874
+ function _e(e) {
4864
4875
  let t = c.colorScale.find((t) => t.value === String(e));
4865
4876
  return t ? t.color : c.noDataColor;
4866
4877
  }
4867
- function xe(e) {
4868
- let t = pe.value.get(String(e));
4878
+ function ve(e) {
4879
+ let t = ue.value.get(String(e));
4869
4880
  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));
4881
+ if (W.value) return _e(t);
4882
+ if (G.value) return ge(t);
4883
+ let { min: n, max: r } = de.value;
4884
+ return he((t - n) / (r - n));
4874
4885
  }
4875
4886
  function K(e) {
4876
4887
  return e.properties?.name ?? String(e.id);
4877
4888
  }
4878
4889
  function q(e) {
4879
- return pe.value.get(String(e.id));
4890
+ return ue.value.get(String(e.id));
4880
4891
  }
4881
- let Se = t(() => {
4892
+ let ye = t(() => {
4882
4893
  let e = /* @__PURE__ */ new Map();
4883
- for (let t of H.value.features) e.set(String(t.id), t);
4894
+ for (let t of V.value.features) e.set(String(t.id), t);
4884
4895
  return e;
4885
4896
  });
4886
- function J(e) {
4897
+ function be(e) {
4887
4898
  let t = e;
4888
4899
  for (; t && !t.dataset?.featId;) t = t.parentElement;
4889
4900
  if (!t) return null;
4890
- let n = Se.value.get(t.dataset.featId);
4901
+ let n = ye.value.get(t.dataset.featId);
4891
4902
  return n ? {
4892
4903
  pathEl: t,
4893
4904
  feat: n
4894
4905
  } : null;
4895
4906
  }
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));
4907
+ function xe(e, t, n) {
4908
+ T || (T = document.createElement("div"), T.className = "chart-tooltip-content", T.style.position = "fixed", T.style.transform = "translateY(-50%)", document.body.appendChild(T));
4898
4909
  let r = K(e), i = q(e), a = {
4899
4910
  id: String(e.id),
4900
4911
  name: r,
4901
4912
  value: i
4902
4913
  };
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`;
4914
+ 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
4915
  }
4905
- function Fe() {
4906
- w &&= (w.remove(), null);
4916
+ function J() {
4917
+ T &&= (T.remove(), null);
4907
4918
  }
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");
4919
+ function Ne(e, t) {
4920
+ 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
4921
  }
4911
- function Le() {
4912
- C && (C.setAttribute("stroke-width", String(U.value)), C.setAttribute("stroke", c.strokeColor), C = null, l("stateHover", null)), Fe();
4922
+ function Pe() {
4923
+ w && (w.setAttribute("stroke-width", String(U.value)), w.setAttribute("stroke", c.strokeColor), w = null, l("stateHover", null)), J();
4913
4924
  }
4914
4925
  function $(e) {
4915
- if (T) return;
4916
- let t = e, n = J(t.target);
4926
+ if (E) return;
4927
+ let t = e, n = be(t.target);
4917
4928
  n && (e.type === "click" ? l("stateClick", {
4918
4929
  id: String(n.feat.id),
4919
4930
  name: K(n.feat),
4920
4931
  value: q(n.feat)
4921
- }) : e.type === "mouseover" && (Ie(n.pathEl, n.feat), c.tooltipTrigger && Pe(n.feat, t.clientX, t.clientY), l("stateHover", {
4932
+ }) : e.type === "mouseover" && (Ne(n.pathEl, n.feat), c.tooltipTrigger && xe(n.feat, t.clientX, t.clientY), l("stateHover", {
4922
4933
  id: String(n.feat.id),
4923
4934
  name: K(n.feat),
4924
4935
  value: q(n.feat)
4925
4936
  })));
4926
4937
  }
4927
- function Re(e) {
4928
- T || !w || (w.style.left = `${e.clientX + 16}px`, w.style.top = `${e.clientY}px`);
4938
+ function Fe(e) {
4939
+ E || !T || (T.style.left = `${e.clientX + 16}px`, T.style.top = `${e.clientY}px`);
4929
4940
  }
4930
- function ze(e) {
4941
+ function Ie(e) {
4931
4942
  let t = e.relatedTarget;
4932
- t && y.value?.contains(t) || Le();
4943
+ t && b.value?.contains(t) || Pe();
4933
4944
  }
4934
- function Be() {
4945
+ function Le() {
4935
4946
  return typeof c.menu == "string" ? c.menu : "choropleth";
4936
4947
  }
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(() => {
4948
+ 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
4949
  let e = [];
4939
4950
  for (let t = 0; t <= 10; t++) {
4940
4951
  let n = t / 10;
4941
4952
  e.push({
4942
4953
  offset: `${(n * 100).toFixed(0)}%`,
4943
- color: ve(n)
4954
+ color: he(n)
4944
4955
  });
4945
4956
  }
4946
4957
  return e;
4947
- }), Ye = t(() => {
4948
- let { min: e, max: t } = me.value, n = t - e, r = [];
4958
+ }), Ke = t(() => {
4959
+ let { min: e, max: t } = de.value, n = t - e, r = [];
4949
4960
  for (let t = 1; t <= 3; t++) {
4950
4961
  let i = t / 4, a = e + n * i, o = Number.isInteger(a) ? String(a) : a.toFixed(1).replace(/\.0$/, "");
4951
4962
  r.push({
@@ -4954,44 +4965,44 @@ var H = ["width", "height"], ue = ["x"], de = [
4954
4965
  });
4955
4966
  }
4956
4967
  return r;
4957
- }), Xe = t(() => {
4968
+ }), qe = t(() => {
4958
4969
  let e = [];
4959
4970
  if (W.value) for (let t of c.colorScale) e.push({
4960
4971
  key: t.value,
4961
4972
  color: t.color,
4962
4973
  label: t.value
4963
4974
  });
4964
- else if (G.value) for (let t of He.value) e.push({
4975
+ else if (G.value) for (let t of ze.value) e.push({
4965
4976
  key: String(t.min),
4966
4977
  color: t.color,
4967
4978
  label: t.label ?? String(t.min)
4968
4979
  });
4969
4980
  return e;
4970
- }), Ze = t(() => {
4981
+ }), Je = t(() => {
4971
4982
  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(() => {
4983
+ for (let t of qe.value) e += 16 + t.label.length * 7 + 12;
4984
+ return e - (qe.value.length > 0 ? 12 : 0);
4985
+ }), Ye = t(() => {
4975
4986
  let e = c.legendTitle ? c.legendTitle.length * 8 + 12 : 0;
4976
- return Xe.value.map((t) => {
4987
+ return qe.value.map((t) => {
4977
4988
  let n = e;
4978
4989
  return e += 16 + t.label.length * 7 + 12, n;
4979
4990
  });
4980
- }), $e = t(() => {
4981
- if (W.value || G.value) return (L.value - Ze.value) / 2;
4991
+ }), Xe = t(() => {
4992
+ if (W.value || G.value) return (L.value - Je.value) / 2;
4982
4993
  let e = c.legendTitle ? c.legendTitle.length * 8 + 12 : 0;
4983
4994
  return (L.value - e - 160) / 2;
4984
- }), et = t(() => {
4985
- let e = Be();
4995
+ }), Ze = t(() => {
4996
+ let e = Le();
4986
4997
  return [{
4987
4998
  label: "Save as SVG",
4988
4999
  action: () => {
4989
- _.value && se(_.value, e);
5000
+ _.value && oe(_.value, e);
4990
5001
  }
4991
5002
  }, {
4992
5003
  label: "Save as PNG",
4993
5004
  action: () => {
4994
- _.value && ce(_.value, e);
5005
+ _.value && se(_.value, e);
4995
5006
  }
4996
5007
  }];
4997
5008
  });
@@ -4999,64 +5010,64 @@ var H = ["width", "height"], ue = ["x"], de = [
4999
5010
  ref_key: "containerRef",
5000
5011
  ref: f,
5001
5012
  class: u(["choropleth-wrapper", { pannable: o.pan }])
5002
- }, [o.menu ? (m(), n(oe, {
5013
+ }, [o.menu ? (m(), n(ae, {
5003
5014
  key: 0,
5004
- items: et.value
5015
+ items: Ze.value
5005
5016
  }, null, 8, ["items"])) : r("", !0), (m(), i("svg", {
5006
5017
  ref_key: "svgRef",
5007
5018
  ref: _,
5008
5019
  width: L.value,
5009
- height: Ke.value
5020
+ height: Ue.value
5010
5021
  }, [
5011
5022
  a("g", {
5012
5023
  ref_key: "mapGroupRef",
5013
- ref: y
5014
- }, [(m(!0), i(e, null, g(H.value.features, (e) => (m(), i("path", {
5024
+ ref: b
5025
+ }, [(m(!0), i(e, null, g(V.value.features, (e) => (m(), i("path", {
5015
5026
  key: String(e.id),
5016
5027
  "data-feat-id": String(e.id),
5017
- d: fe.value(e) ?? void 0,
5018
- fill: xe(e.id),
5028
+ d: le.value(e) ?? void 0,
5029
+ fill: ve(e.id),
5019
5030
  stroke: o.strokeColor,
5020
5031
  "stroke-width": U.value,
5021
5032
  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", {
5033
+ }, [o.tooltipTrigger ? r("", !0) : (m(), i("title", Ce, v(K(e)) + v(q(e) == null ? "" : `: ${q(e)}`), 1))], 8, Z))), 128)), H.value ? (m(), i("path", {
5023
5034
  key: 0,
5024
- d: fe.value(ue.value) ?? void 0,
5035
+ d: le.value(H.value) ?? void 0,
5025
5036
  fill: "none",
5026
5037
  stroke: o.strokeColor,
5027
5038
  "stroke-width": 1,
5028
5039
  "stroke-linejoin": "round",
5029
5040
  "pointer-events": "none"
5030
- }, null, 8, Q)) : r("", !0)], 512),
5031
- Ve.value ? (m(), i("g", {
5041
+ }, null, 8, we)) : r("", !0)], 512),
5042
+ Re.value ? (m(), i("g", {
5032
5043
  key: 0,
5033
5044
  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],
5045
+ transform: `translate(${Xe.value},${We.value})`
5046
+ }, [W.value || G.value ? (m(), i(e, { key: 0 }, [o.legendTitle ? (m(), i("text", Te, v(o.legendTitle), 1)) : r("", !0), (m(!0), i(e, null, g(qe.value, (t, n) => (m(), i(e, { key: t.key }, [a("rect", {
5047
+ x: Ye.value[n],
5037
5048
  y: -5,
5038
5049
  width: "12",
5039
5050
  height: "12",
5040
5051
  rx: "3",
5041
5052
  fill: t.color
5042
- }, null, 8, De), a("text", {
5043
- x: Qe.value[n] + 16,
5053
+ }, null, 8, Ee), a("text", {
5054
+ x: Ye.value[n] + 16,
5044
5055
  y: 5,
5045
5056
  "font-size": "13",
5046
5057
  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),
5058
+ }, v(t.label), 9, De)], 64))), 128))], 64)) : (m(), i(e, { key: 1 }, [
5059
+ o.legendTitle ? (m(), i("text", Oe, v(o.legendTitle), 1)) : r("", !0),
5049
5060
  a("defs", null, [a("linearGradient", {
5050
5061
  id: d,
5051
5062
  x1: "0",
5052
5063
  x2: "1",
5053
5064
  y1: "0",
5054
5065
  y2: "0"
5055
- }, [(m(!0), i(e, null, g(Je.value, (e) => (m(), i("stop", {
5066
+ }, [(m(!0), i(e, null, g(Ge.value, (e) => (m(), i("stop", {
5056
5067
  key: e.offset,
5057
5068
  offset: e.offset,
5058
5069
  "stop-color": e.color
5059
- }, null, 8, Ae))), 128))])]),
5070
+ }, null, 8, ke))), 128))])]),
5060
5071
  a("rect", {
5061
5072
  x: o.legendTitle ? o.legendTitle.length * 8 + 12 : 0,
5062
5073
  y: -6,
@@ -5064,8 +5075,8 @@ var H = ["width", "height"], ue = ["x"], de = [
5064
5075
  height: 12,
5065
5076
  rx: "2",
5066
5077
  fill: `url(#${d})`
5067
- }, null, 8, je),
5068
- (m(!0), i(e, null, g(Ye.value, (e) => (m(), i("text", {
5078
+ }, null, 8, Ae),
5079
+ (m(!0), i(e, null, g(Ke.value, (e) => (m(), i("text", {
5069
5080
  key: e.value,
5070
5081
  x: (o.legendTitle ? o.legendTitle.length * 8 + 12 : 0) + e.pct / 100 * 160,
5071
5082
  y: 20,
@@ -5073,8 +5084,8 @@ var H = ["width", "height"], ue = ["x"], de = [
5073
5084
  fill: "currentColor",
5074
5085
  opacity: "0.7",
5075
5086
  "text-anchor": "middle"
5076
- }, v(e.value), 9, Me))), 128))
5077
- ], 64))], 8, Te)) : r("", !0),
5087
+ }, v(e.value), 9, je))), 128))
5088
+ ], 64))], 8, Q)) : r("", !0),
5078
5089
  o.title ? (m(), i("text", {
5079
5090
  key: 1,
5080
5091
  x: L.value / 2,
@@ -5083,10 +5094,10 @@ var H = ["width", "height"], ue = ["x"], de = [
5083
5094
  "font-size": "14",
5084
5095
  "font-weight": "600",
5085
5096
  fill: "currentColor"
5086
- }, v(o.title), 9, Ne)) : r("", !0)
5087
- ], 8, X))], 2));
5097
+ }, v(o.title), 9, Me)) : r("", !0)
5098
+ ], 8, Se))], 2));
5088
5099
  }
5089
- }), [["__scopeId", "data-v-7f5b0832"]]), Fe = /* @__PURE__ */ B(/* @__PURE__ */ c({
5100
+ }), [["__scopeId", "data-v-ffaf1671"]]), Pe = /* @__PURE__ */ B(/* @__PURE__ */ c({
5090
5101
  __name: "ChartTooltip",
5091
5102
  props: {
5092
5103
  x: {},
@@ -5106,12 +5117,12 @@ var H = ["width", "height"], ue = ["x"], de = [
5106
5117
  top: `${e.y}px`,
5107
5118
  transform: "translateY(-50%)"
5108
5119
  })
5109
- }, [_(t.$slots, "default", {}, void 0, !0)], 4)) : e.mode === "click" ? (m(), n(y(M), {
5120
+ }, [_(t.$slots, "default", {}, void 0, !0)], 4)) : e.mode === "click" ? (m(), n(b(N), {
5110
5121
  key: 1,
5111
5122
  open: e.open
5112
5123
  }, {
5113
- default: S(() => [s(y(k), { "as-child": "" }, {
5114
- default: S(() => [a("div", {
5124
+ default: C(() => [s(b(A), { "as-child": "" }, {
5125
+ default: C(() => [a("div", {
5115
5126
  class: "chart-tooltip-anchor",
5116
5127
  style: f({
5117
5128
  left: `${e.x}px`,
@@ -5119,8 +5130,8 @@ var H = ["width", "height"], ue = ["x"], de = [
5119
5130
  })
5120
5131
  }, null, 4)]),
5121
5132
  _: 1
5122
- }), s(y(j), null, {
5123
- default: S(() => [e.open ? (m(), n(y(A), {
5133
+ }), s(b(M), null, {
5134
+ default: C(() => [e.open ? (m(), n(b(j), {
5124
5135
  key: 0,
5125
5136
  class: "chart-tooltip-content",
5126
5137
  side: "right",
@@ -5129,7 +5140,7 @@ var H = ["width", "height"], ue = ["x"], de = [
5129
5140
  onPointerDownOutside: o[0] ||= (e) => t.$emit("close"),
5130
5141
  onEscapeKeyDown: o[1] ||= (e) => t.$emit("close")
5131
5142
  }, {
5132
- default: S(() => [_(t.$slots, "default", {}, void 0, !0)]),
5143
+ default: C(() => [_(t.$slots, "default", {}, void 0, !0)]),
5133
5144
  _: 3
5134
5145
  }, 8, ["side-offset"])) : r("", !0)]),
5135
5146
  _: 3
@@ -5137,7 +5148,7 @@ var H = ["width", "height"], ue = ["x"], de = [
5137
5148
  _: 3
5138
5149
  }, 8, ["open"])) : r("", !0);
5139
5150
  }
5140
- }), [["__scopeId", "data-v-44377f70"]]), Ie = { class: "TableWrapper" }, Le = { class: "Table" }, $ = /* @__PURE__ */ B(/* @__PURE__ */ c({
5151
+ }), [["__scopeId", "data-v-44377f70"]]), $ = { class: "TableWrapper" }, Fe = { class: "Table" }, Ie = /* @__PURE__ */ B(/* @__PURE__ */ c({
5141
5152
  __name: "DataTable",
5142
5153
  props: {
5143
5154
  data: {},
@@ -5210,12 +5221,12 @@ var H = ["width", "height"], ue = ["x"], de = [
5210
5221
  }
5211
5222
  let C = t(() => [{
5212
5223
  label: "Download CSV",
5213
- action: () => le(S(), b())
5224
+ action: () => H(S(), b())
5214
5225
  }]);
5215
- return (t, s) => (m(), i("div", { class: u(["TableOuter", { "has-menu": o.menu }]) }, [o.menu ? (m(), n(oe, {
5226
+ return (t, s) => (m(), i("div", { class: u(["TableOuter", { "has-menu": o.menu }]) }, [o.menu ? (m(), n(ae, {
5216
5227
  key: 0,
5217
5228
  items: C.value
5218
- }, null, 8, ["items"])) : r("", !0), a("div", Ie, [a("table", Le, [
5229
+ }, null, 8, ["items"])) : r("", !0), a("div", $, [a("table", Fe, [
5219
5230
  a("colgroup", null, [(m(!0), i(e, null, g(h.value, (e) => (m(), i("col", {
5220
5231
  key: e.name,
5221
5232
  style: f(d(e.name))
@@ -5233,4 +5244,4 @@ var H = ["width", "height"], ue = ["x"], de = [
5233
5244
  }
5234
5245
  }), [["__scopeId", "data-v-dbfb7c84"]]);
5235
5246
  //#endregion
5236
- export { Fe as ChartTooltip, Pe as ChoroplethMap, $ as DataTable, J as LineChart };
5247
+ export { Pe as ChartTooltip, Ne as ChoroplethMap, Ie as DataTable, J as LineChart };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cfasim-ui/charts",
3
- "version": "0.2.2",
3
+ "version": "0.3.0",
4
4
  "type": "module",
5
5
  "description": "Chart visualization components for cfasim-ui",
6
6
  "license": "Apache-2.0",
@@ -33,8 +33,7 @@
33
33
  "d3-zoom": "^3.0.0",
34
34
  "reka-ui": "^2.9.2",
35
35
  "topojson-client": "^3.1.0",
36
- "us-atlas": "^3.0.1",
37
- "@cfasim-ui/shared": "0.2.2"
36
+ "@cfasim-ui/shared": "0.3.0"
38
37
  },
39
38
  "peerDependencies": {
40
39
  "vue": "^3.5.0"
@@ -49,6 +48,7 @@
49
48
  "vite-plugin-dts": "^4.5.4",
50
49
  "@vue/test-utils": "^2.4.6",
51
50
  "happy-dom": "^20.8.9",
51
+ "us-atlas": "^3.0.1",
52
52
  "vitest": "^4.1.0"
53
53
  },
54
54
  "scripts": {