nuxt-charts 3.0.0 → 3.1.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.
- package/README.md +53 -6
- package/dist/module.json +1 -1
- package/dist/module.mjs +56 -3
- package/dist/runtime/assets/components.css +1 -1
- package/dist/runtime/assets/theme.css +1 -1
- package/dist/runtime/components/AreaChart.vue +1 -0
- package/dist/runtime/components/BarChart.vue +1 -0
- package/dist/runtime/components/DataChart.vue +91 -0
- package/dist/runtime/components/DataChart.vue.d.ts +27 -0
- package/dist/runtime/components/DottedMap.vue +261 -0
- package/dist/runtime/components/DottedMap.vue.d.ts +45 -0
- package/dist/runtime/components/LineChart.vue +1 -0
- package/dist/runtime/components/MetricChart.vue +322 -0
- package/dist/runtime/components/MetricChart.vue.d.ts +54 -0
- package/dist/runtime/components/TopoJSONMap.vue +273 -0
- package/dist/runtime/components/TopoJSONMap.vue.d.ts +45 -0
- package/dist/runtime/components/internal/CartesianFrame.vue +73 -4
- package/dist/runtime/components/internal/CartesianFrame.vue.d.ts +5 -0
- package/dist/runtime/components/internal/ChartAccessibility.vue.d.ts +1 -1
- package/dist/runtime/components/internal/CubeBarShape.vue.d.ts +1 -1
- package/dist/runtime/components/internal/MapCanvas.vue +297 -0
- package/dist/runtime/components/internal/MapCanvas.vue.d.ts +79 -0
- package/dist/runtime/components/internal/VariantBarShape.vue.d.ts +2 -2
- package/dist/runtime/data/world.json +182 -0
- package/dist/runtime/maps.d.ts +2 -0
- package/dist/runtime/maps.js +1 -0
- package/dist/runtime/spec/csv.d.ts +14 -0
- package/dist/runtime/spec/csv.js +13 -0
- package/dist/runtime/spec/index.d.ts +11 -0
- package/dist/runtime/spec/index.js +5 -0
- package/dist/runtime/spec/metric.d.ts +130 -0
- package/dist/runtime/spec/metric.js +63 -0
- package/dist/runtime/spec/resolve.d.ts +44 -0
- package/dist/runtime/spec/resolve.js +41 -0
- package/dist/runtime/spec/transform.d.ts +58 -0
- package/dist/runtime/spec/transform.js +199 -0
- package/dist/runtime/spec/types.d.ts +132 -0
- package/dist/runtime/spec/types.js +2 -0
- package/dist/runtime/types/charts.d.ts +131 -0
- package/dist/runtime/types/maps.d.ts +237 -0
- package/dist/runtime/types/maps.js +0 -0
- package/dist/runtime/types.d.ts +3 -0
- package/dist/runtime/utils/axis.d.ts +18 -0
- package/dist/runtime/utils/axis.js +44 -1
- package/dist/runtime/utils/dottedMap.d.ts +14 -0
- package/dist/runtime/utils/dottedMap.js +69 -0
- package/dist/runtime/utils/maps.d.ts +33 -0
- package/dist/runtime/utils/maps.js +77 -0
- package/package.json +23 -3
|
@@ -0,0 +1,297 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import { computed, onBeforeUnmount, onMounted, shallowRef, useId, watch } from "vue";
|
|
3
|
+
import { select } from "d3-selection";
|
|
4
|
+
import { zoom, zoomIdentity } from "d3-zoom";
|
|
5
|
+
import { categoriesToSeries } from "../../utils/categories";
|
|
6
|
+
import { themeToVars } from "../../utils/theme";
|
|
7
|
+
import ChartTooltip from "./ChartTooltip.vue";
|
|
8
|
+
import ChartLegend from "./ChartLegend.vue";
|
|
9
|
+
import ChartAccessibility from "./ChartAccessibility.vue";
|
|
10
|
+
import ChartEmptyState from "./ChartEmptyState.vue";
|
|
11
|
+
import ChartSkeleton from "./ChartSkeleton.vue";
|
|
12
|
+
defineOptions({ inheritAttrs: false });
|
|
13
|
+
const props = defineProps({
|
|
14
|
+
height: { type: [Number, String], required: false },
|
|
15
|
+
width: { type: [Number, String], required: false },
|
|
16
|
+
projection: { type: [String, Function, Object], required: false },
|
|
17
|
+
fitView: { type: Boolean, required: false },
|
|
18
|
+
fitViewPadding: { type: Number, required: false },
|
|
19
|
+
padding: { type: [Number, Object], required: false },
|
|
20
|
+
disableZoom: { type: Boolean, required: false },
|
|
21
|
+
zoomFactor: { type: Number, required: false },
|
|
22
|
+
zoomExtent: { type: Array, required: false },
|
|
23
|
+
zoomOnScroll: { type: Boolean, required: false },
|
|
24
|
+
zoomDuration: { type: Number, required: false },
|
|
25
|
+
duration: { type: Number, required: false },
|
|
26
|
+
showControls: { type: Boolean, required: false },
|
|
27
|
+
hideTooltip: { type: Boolean, required: false },
|
|
28
|
+
hideLegend: { type: Boolean, required: false },
|
|
29
|
+
categories: { type: Object, required: false },
|
|
30
|
+
legendPosition: { type: String, required: false },
|
|
31
|
+
legendStyle: { type: [String, Object], required: false },
|
|
32
|
+
backgroundColor: { type: String, required: false },
|
|
33
|
+
theme: { type: Object, required: false },
|
|
34
|
+
showGraticule: { type: Boolean, required: false },
|
|
35
|
+
showSphere: { type: Boolean, required: false },
|
|
36
|
+
graticuleColor: { type: String, required: false },
|
|
37
|
+
sphereColor: { type: String, required: false },
|
|
38
|
+
ariaLabel: { type: String, required: false },
|
|
39
|
+
ariaDescription: { type: String, required: false },
|
|
40
|
+
accessibleDataTable: { type: Boolean, required: false },
|
|
41
|
+
maxDataPoints: { type: Number, required: false },
|
|
42
|
+
emptyLabel: { type: String, required: false },
|
|
43
|
+
error: { type: String, required: false },
|
|
44
|
+
legendVariant: { type: String, required: false },
|
|
45
|
+
tooltipVariant: { type: String, required: false },
|
|
46
|
+
tooltipRoundness: { type: String, required: false },
|
|
47
|
+
loading: { type: Boolean, required: false },
|
|
48
|
+
loadingLabel: { type: String, required: false },
|
|
49
|
+
marks: { type: Array, required: true },
|
|
50
|
+
size: { type: Array, required: true },
|
|
51
|
+
geometryError: { type: String, required: false },
|
|
52
|
+
sphere: { type: String, required: false },
|
|
53
|
+
graticule: { type: String, required: false },
|
|
54
|
+
tooltipTitle: { type: Function, required: false },
|
|
55
|
+
tooltipValue: { type: Function, required: false },
|
|
56
|
+
heatmap: { type: Boolean, required: false },
|
|
57
|
+
heatmapBlur: { type: Number, required: false },
|
|
58
|
+
heatmapThreshold: { type: Number, required: false }
|
|
59
|
+
});
|
|
60
|
+
const emit = defineEmits(["resize", "click", "mouseenter", "mouseleave", "zoom"]);
|
|
61
|
+
const viewport = shallowRef();
|
|
62
|
+
const svg = shallowRef();
|
|
63
|
+
const transform = shallowRef(zoomIdentity);
|
|
64
|
+
const hovered = shallowRef();
|
|
65
|
+
const tooltipPosition = shallowRef({ x: 0, y: 0 });
|
|
66
|
+
const blurId = `vc-map-blur-${useId().replace(/:/g, "")}`;
|
|
67
|
+
const descriptionId = `vc-map-description-${useId().replace(/:/g, "")}`;
|
|
68
|
+
let behavior;
|
|
69
|
+
let observer;
|
|
70
|
+
let animation = 0;
|
|
71
|
+
const limits = computed(() => props.zoomExtent ?? [1, 8]);
|
|
72
|
+
function initial() {
|
|
73
|
+
const [width, height] = props.size;
|
|
74
|
+
const k = Math.max(limits.value[0], Math.min(limits.value[1], props.zoomFactor ?? 1));
|
|
75
|
+
return zoomIdentity.translate(width / 2, height / 2).scale(k).translate(-width / 2, -height / 2);
|
|
76
|
+
}
|
|
77
|
+
const stateError = computed(() => props.error ?? props.geometryError);
|
|
78
|
+
const legends = computed(() => categoriesToSeries(props.categories ?? {}).filter((item) => !item.hidden).map((item) => ({ value: item.name, color: item.color, inactive: props.categories?.[item.dataKey]?.inactive })));
|
|
79
|
+
const legendAlign = computed(() => props.legendPosition?.includes("left") ? "flex-start" : props.legendPosition?.includes("right") ? "flex-end" : "center");
|
|
80
|
+
const rootStyle = computed(() => ({
|
|
81
|
+
...themeToVars(props.theme),
|
|
82
|
+
width: typeof props.width === "number" ? `${props.width}px` : props.width ?? "100%",
|
|
83
|
+
flexDirection: props.legendPosition?.startsWith("top") ? "column-reverse" : "column"
|
|
84
|
+
}));
|
|
85
|
+
const tooltipStyle = computed(() => ({
|
|
86
|
+
left: `${tooltipPosition.value.x}px`,
|
|
87
|
+
top: `${tooltipPosition.value.y}px`,
|
|
88
|
+
transform: `translate(${tooltipPosition.value.x > props.size[0] / 2 ? "calc(-100% - 10px)" : "10px"}, ${tooltipPosition.value.y > props.size[1] / 2 ? "calc(-100% - 10px)" : "10px"})`
|
|
89
|
+
}));
|
|
90
|
+
const label = computed(() => props.ariaLabel ?? "Geographic map");
|
|
91
|
+
const heatmap = computed(() => props.heatmap && transform.value.k < (props.heatmapThreshold ?? 4));
|
|
92
|
+
const points = computed(() => props.marks.filter((mark) => mark.kind === "point"));
|
|
93
|
+
const visibleMarks = computed(() => heatmap.value ? props.marks.filter((mark) => mark.kind !== "point") : props.marks);
|
|
94
|
+
const title = computed(() => {
|
|
95
|
+
const mark = hovered.value;
|
|
96
|
+
return mark ? props.tooltipTitle?.(mark.values) ?? mark.label ?? String(mark.values.name ?? mark.values.id ?? "Location") : "";
|
|
97
|
+
});
|
|
98
|
+
const tooltipItems = computed(() => {
|
|
99
|
+
const mark = hovered.value;
|
|
100
|
+
if (!mark) return [];
|
|
101
|
+
const values = mark.values.data ?? mark.values;
|
|
102
|
+
const numeric = Object.entries(values).filter(([key, value]) => typeof value === "number" && !["lat", "lng", "latitude", "longitude", "x", "y", "radius", "id"].includes(key));
|
|
103
|
+
if (numeric.length) return numeric.map(([name, value]) => ({ name: String(props.categories?.[name]?.name ?? name), value: props.tooltipValue?.(value) ?? value, color: mark.color }));
|
|
104
|
+
const latitude = values.latitude ?? values.lat;
|
|
105
|
+
const longitude = values.longitude ?? values.lng;
|
|
106
|
+
if (typeof latitude === "number" && typeof longitude === "number") return [{ name: "Coordinates", value: `${latitude.toFixed(2)}, ${longitude.toFixed(2)}`, color: mark.color }];
|
|
107
|
+
return [{ name: mark.kind === "link" ? "Route" : "Region", value: mark.label ?? String(values.id ?? title.value), color: mark.color }];
|
|
108
|
+
});
|
|
109
|
+
const accessibleRows = computed(() => props.marks.filter((mark) => mark.kind !== "dot").map((mark) => {
|
|
110
|
+
const fields = mark.values.data ?? mark.values;
|
|
111
|
+
const value = Object.entries(fields).filter(([, value2]) => typeof value2 === "number" || typeof value2 === "string").map(([key, value2]) => `${key}: ${value2}`).join(", ");
|
|
112
|
+
return {
|
|
113
|
+
label: mark.label ?? String(mark.values.id ?? mark.key),
|
|
114
|
+
values: [{ label: "Type", value: mark.kind }, { label: "Data", value }]
|
|
115
|
+
};
|
|
116
|
+
}));
|
|
117
|
+
function apply(next) {
|
|
118
|
+
if (svg.value && behavior) select(svg.value).call(behavior.transform, next);
|
|
119
|
+
}
|
|
120
|
+
function moveTo(next) {
|
|
121
|
+
cancelAnimationFrame(animation);
|
|
122
|
+
const duration = window.matchMedia("(prefers-reduced-motion: reduce)").matches ? 0 : props.zoomDuration ?? props.duration ?? 250;
|
|
123
|
+
if (!duration) return apply(next);
|
|
124
|
+
const start = performance.now();
|
|
125
|
+
const from = transform.value;
|
|
126
|
+
function tick(now) {
|
|
127
|
+
const t = Math.min(1, (now - start) / duration);
|
|
128
|
+
const ease = 1 - Math.pow(1 - t, 3);
|
|
129
|
+
apply(zoomIdentity.translate(from.x + (next.x - from.x) * ease, from.y + (next.y - from.y) * ease).scale(from.k + (next.k - from.k) * ease));
|
|
130
|
+
if (t < 1) animation = requestAnimationFrame(tick);
|
|
131
|
+
}
|
|
132
|
+
animation = requestAnimationFrame(tick);
|
|
133
|
+
}
|
|
134
|
+
function zoomTo(value) {
|
|
135
|
+
const k = Math.max(limits.value[0], Math.min(limits.value[1], value));
|
|
136
|
+
const center = [props.size[0] / 2, props.size[1] / 2];
|
|
137
|
+
const local = transform.value.invert(center);
|
|
138
|
+
moveTo(zoomIdentity.translate(center[0] - local[0] * k, center[1] - local[1] * k).scale(k));
|
|
139
|
+
}
|
|
140
|
+
function resetView() {
|
|
141
|
+
if (svg.value) moveTo(initial());
|
|
142
|
+
}
|
|
143
|
+
function fitBounds(bounds) {
|
|
144
|
+
const [[x0, y0], [x1, y1]] = bounds;
|
|
145
|
+
if (![x0, y0, x1, y1].every(Number.isFinite)) return;
|
|
146
|
+
const [width, height] = props.size;
|
|
147
|
+
const padding = props.fitViewPadding ?? 24;
|
|
148
|
+
const k = Math.max(limits.value[0], Math.min(limits.value[1], (width - padding * 2) / Math.max(1, x1 - x0), (height - padding * 2) / Math.max(1, y1 - y0)));
|
|
149
|
+
moveTo(zoomIdentity.translate(width / 2 - (x0 + x1) * k / 2, height / 2 - (y0 + y1) * k / 2).scale(k));
|
|
150
|
+
}
|
|
151
|
+
function configureZoom() {
|
|
152
|
+
if (!svg.value) return;
|
|
153
|
+
const element = select(svg.value);
|
|
154
|
+
element.on(".zoom", null);
|
|
155
|
+
behavior = zoom().extent([[0, 0], props.size]).scaleExtent([limits.value[0], limits.value[1]]).translateExtent([[0, 0], props.size]).clickDistance(4).filter((event) => !props.disableZoom && (!event.ctrlKey || event.type === "wheel") && !event.button && (event.type !== "wheel" || props.zoomOnScroll === true)).on("zoom", (event) => {
|
|
156
|
+
if (event.sourceEvent) {
|
|
157
|
+
cancelAnimationFrame(animation);
|
|
158
|
+
hovered.value = void 0;
|
|
159
|
+
}
|
|
160
|
+
transform.value = event.transform;
|
|
161
|
+
emit("zoom", { x: event.transform.x, y: event.transform.y, k: event.transform.k });
|
|
162
|
+
});
|
|
163
|
+
element.call(behavior);
|
|
164
|
+
apply(transform.value);
|
|
165
|
+
}
|
|
166
|
+
function positionTooltip(event) {
|
|
167
|
+
const rect = viewport.value?.getBoundingClientRect();
|
|
168
|
+
if (!rect) return;
|
|
169
|
+
let x;
|
|
170
|
+
let y;
|
|
171
|
+
if ("clientX" in event) {
|
|
172
|
+
x = event.clientX;
|
|
173
|
+
y = event.clientY;
|
|
174
|
+
} else {
|
|
175
|
+
const target = event.target.getBoundingClientRect();
|
|
176
|
+
x = target.x + target.width / 2;
|
|
177
|
+
y = target.y + target.height / 2;
|
|
178
|
+
}
|
|
179
|
+
tooltipPosition.value = {
|
|
180
|
+
x: Math.max(10, Math.min(rect.width - 10, x - rect.x)),
|
|
181
|
+
y: Math.max(10, Math.min(rect.height - 10, y - rect.y))
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
function enter(mark, event) {
|
|
185
|
+
hovered.value = mark;
|
|
186
|
+
positionTooltip(event);
|
|
187
|
+
emit("mouseenter", mark, event);
|
|
188
|
+
}
|
|
189
|
+
function leave(mark, event) {
|
|
190
|
+
hovered.value = void 0;
|
|
191
|
+
emit("mouseleave", mark, event);
|
|
192
|
+
}
|
|
193
|
+
function onKey(event) {
|
|
194
|
+
if (event.target !== svg.value || props.disableZoom) return;
|
|
195
|
+
if (event.key === "+" || event.key === "=") zoomTo(transform.value.k * 1.5);
|
|
196
|
+
else if (event.key === "-") zoomTo(transform.value.k / 1.5);
|
|
197
|
+
else if (event.key === "0" || event.key === "Home") resetView();
|
|
198
|
+
else if (["ArrowLeft", "ArrowRight", "ArrowUp", "ArrowDown"].includes(event.key)) {
|
|
199
|
+
const dx = event.key === "ArrowLeft" ? 40 : event.key === "ArrowRight" ? -40 : 0;
|
|
200
|
+
const dy = event.key === "ArrowUp" ? 40 : event.key === "ArrowDown" ? -40 : 0;
|
|
201
|
+
if (svg.value && behavior) select(svg.value).call(behavior.translateBy, dx / transform.value.k, dy / transform.value.k);
|
|
202
|
+
} else return;
|
|
203
|
+
event.preventDefault();
|
|
204
|
+
}
|
|
205
|
+
watch(svg, (element) => {
|
|
206
|
+
if (element) {
|
|
207
|
+
configureZoom();
|
|
208
|
+
apply(initial());
|
|
209
|
+
}
|
|
210
|
+
});
|
|
211
|
+
watch(() => [props.disableZoom, props.zoomOnScroll, props.zoomExtent], configureZoom, { deep: true });
|
|
212
|
+
watch(() => [props.zoomFactor, props.size], () => {
|
|
213
|
+
configureZoom();
|
|
214
|
+
if (svg.value) apply(initial());
|
|
215
|
+
}, { deep: true });
|
|
216
|
+
watch(() => props.marks, () => {
|
|
217
|
+
hovered.value = void 0;
|
|
218
|
+
});
|
|
219
|
+
onMounted(() => {
|
|
220
|
+
observer = new ResizeObserver((entries) => {
|
|
221
|
+
const rect = entries[0]?.contentRect;
|
|
222
|
+
if (rect && rect.width > 0 && rect.height > 0) emit("resize", [rect.width, rect.height]);
|
|
223
|
+
});
|
|
224
|
+
if (viewport.value) observer.observe(viewport.value);
|
|
225
|
+
});
|
|
226
|
+
onBeforeUnmount(() => {
|
|
227
|
+
observer?.disconnect();
|
|
228
|
+
cancelAnimationFrame(animation);
|
|
229
|
+
if (svg.value) select(svg.value).on(".zoom", null);
|
|
230
|
+
});
|
|
231
|
+
defineExpose({
|
|
232
|
+
zoomIn: () => zoomTo(transform.value.k * 1.5),
|
|
233
|
+
zoomOut: () => zoomTo(transform.value.k / 1.5),
|
|
234
|
+
zoomTo,
|
|
235
|
+
resetView,
|
|
236
|
+
fitBounds
|
|
237
|
+
});
|
|
238
|
+
</script>
|
|
239
|
+
|
|
240
|
+
<template>
|
|
241
|
+
<div
|
|
242
|
+
class="vue-chrts vc-map"
|
|
243
|
+
v-bind="{ id: $attrs.id, class: $attrs.class }"
|
|
244
|
+
:style="[rootStyle, $attrs.style]"
|
|
245
|
+
>
|
|
246
|
+
<div ref="viewport" class="vc-map__viewport" :style="{ height: typeof height === 'string' ? height : `${height ?? 400}px`, background: backgroundColor }">
|
|
247
|
+
<ChartSkeleton v-if="loading" :height="size[1]" shape="wave" :label="loadingLabel" />
|
|
248
|
+
<ChartEmptyState v-else-if="stateError || !marks.length" :height="size[1]" :message="stateError ?? emptyLabel ?? 'No geographic data'" />
|
|
249
|
+
<svg
|
|
250
|
+
v-else ref="svg" :viewBox="`0 0 ${size[0]} ${size[1]}`"
|
|
251
|
+
class="vc-map__svg" :class="{ 'vc-map__svg--zoomable': !disableZoom }"
|
|
252
|
+
role="group" :aria-label="label"
|
|
253
|
+
:aria-describedby="ariaDescription ? descriptionId : void 0" tabindex="0"
|
|
254
|
+
@keydown="onKey" @mousemove="hovered && positionTooltip($event)"
|
|
255
|
+
@mouseleave="hovered = void 0"
|
|
256
|
+
>
|
|
257
|
+
<desc v-if="ariaDescription" :id="descriptionId">{{ ariaDescription }}</desc>
|
|
258
|
+
<defs><filter :id="blurId" x="-50%" y="-50%" width="200%" height="200%"><feGaussianBlur :stdDeviation="heatmapBlur ?? 12" /></filter></defs>
|
|
259
|
+
<g :transform="transform.toString()">
|
|
260
|
+
<path v-if="sphere" :d="sphere" :fill="sphereColor ?? 'var(--vc-surface-bg)'" :stroke="graticuleColor ?? 'var(--vc-grid-color)'" vector-effect="non-scaling-stroke" />
|
|
261
|
+
<path v-if="graticule" :d="graticule" fill="none" :stroke="graticuleColor ?? 'var(--vc-grid-color)'" stroke-width="0.5" vector-effect="non-scaling-stroke" />
|
|
262
|
+
<g
|
|
263
|
+
v-for="mark in visibleMarks" :key="mark.key"
|
|
264
|
+
:class="['vc-map__mark', `vc-map__${mark.kind}`]"
|
|
265
|
+
:style="{ cursor: mark.cursor ?? 'pointer' }"
|
|
266
|
+
:tabindex="mark.kind === 'dot' ? void 0 : 0" role="button"
|
|
267
|
+
:aria-label="mark.label ?? String(mark.values.id ?? mark.key)"
|
|
268
|
+
@mouseenter="enter(mark, $event)" @mouseleave="leave(mark, $event)"
|
|
269
|
+
@focus="enter(mark, $event)" @blur="leave(mark, $event)"
|
|
270
|
+
@click.stop="emit('click', mark, $event)"
|
|
271
|
+
@keydown.enter.prevent.stop="emit('click', mark, $event)"
|
|
272
|
+
@keydown.space.prevent.stop="emit('click', mark, $event)"
|
|
273
|
+
>
|
|
274
|
+
<slot :name="mark.kind" :values="mark.values" :x="mark.x" :y="mark.y" :path="mark.path" :color="mark.color" :radius="mark.radius" :scale="transform.k">
|
|
275
|
+
<path v-if="mark.path" :d="mark.path" :fill="mark.kind === 'link' ? 'none' : mark.color" :stroke="mark.stroke" :stroke-width="mark.strokeWidth" :stroke-dasharray="mark.dasharray" vector-effect="non-scaling-stroke" />
|
|
276
|
+
<polygon v-else-if="mark.polygon" :points="mark.polygon" :fill="mark.color" :stroke="mark.stroke" :stroke-width="mark.strokeWidth" :stroke-opacity="mark.strokeOpacity" />
|
|
277
|
+
<circle v-else :cx="mark.x" :cy="mark.y" :r="mark.kind === 'point' || mark.kind === 'pin' ? (mark.radius ?? 5) / transform.k : mark.radius" :fill="mark.color" :stroke="mark.stroke" :stroke-width="mark.strokeWidth" :stroke-opacity="mark.strokeOpacity" vector-effect="non-scaling-stroke" />
|
|
278
|
+
<text v-if="mark.showLabel && mark.label" :x="mark.x" :y="mark.y" :transform="`translate(${mark.x}, ${mark.y}) scale(${1 / transform.k}) translate(${-mark.x}, ${-mark.y})`" :dy="-(mark.radius ?? 5) - 6" text-anchor="middle" class="vc-map__label">{{ mark.label }}</text>
|
|
279
|
+
</slot>
|
|
280
|
+
</g>
|
|
281
|
+
<g v-if="heatmap" :filter="`url(#${blurId})`" pointer-events="none"><circle v-for="point in points" :key="point.key" :cx="point.x" :cy="point.y" :r="Math.max(point.radius ?? 5, (heatmapBlur ?? 12) * 1.5) / transform.k" :fill="point.color" fill-opacity="0.75" /></g>
|
|
282
|
+
<slot :width="size[0]" :height="size[1]" :transform="{ x: transform.x, y: transform.y, k: transform.k }" />
|
|
283
|
+
</g>
|
|
284
|
+
</svg>
|
|
285
|
+
<div v-if="showControls && !disableZoom && !loading && !stateError && marks.length" class="vc-map__controls">
|
|
286
|
+
<button type="button" aria-label="Zoom in" @click="zoomTo(transform.k * 1.5)">+</button>
|
|
287
|
+
<button type="button" aria-label="Zoom out" @click="zoomTo(transform.k / 1.5)">−</button>
|
|
288
|
+
<button type="button" aria-label="Reset map view" @click="resetView">↺</button>
|
|
289
|
+
</div>
|
|
290
|
+
<div v-if="hovered && !hideTooltip" class="vc-map__tooltip" :style="tooltipStyle" role="status">
|
|
291
|
+
<slot name="tooltip" :values="hovered.values" :kind="hovered.kind"><ChartTooltip :active="true" :label="title" :payload="tooltipItems" :variant="tooltipVariant" :roundness="tooltipRoundness" /></slot>
|
|
292
|
+
</div>
|
|
293
|
+
</div>
|
|
294
|
+
<div v-if="!hideLegend && (legends.length || $slots.legend)" class="vc-map__legend" :style="[legendStyle, { justifyContent: legendAlign }]"><slot name="legend" :items="legends"><ChartLegend :payload="legends" :variant="legendVariant" /></slot></div>
|
|
295
|
+
<ChartAccessibility :label="label" :description="ariaDescription" :rows="accessibleRows" :show-table="accessibleDataTable" />
|
|
296
|
+
</div>
|
|
297
|
+
</template>
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import type { MapBaseProps, MapZoom } from "../../types/maps.js";
|
|
2
|
+
import type { MapMark } from "../../utils/maps.js";
|
|
3
|
+
type __VLS_Props = MapBaseProps & {
|
|
4
|
+
marks: MapMark[];
|
|
5
|
+
size: [number, number];
|
|
6
|
+
geometryError?: string;
|
|
7
|
+
sphere?: string;
|
|
8
|
+
graticule?: string;
|
|
9
|
+
tooltipTitle?: (datum: Record<string, unknown>) => string | number;
|
|
10
|
+
tooltipValue?: (value: number) => string;
|
|
11
|
+
heatmap?: boolean;
|
|
12
|
+
heatmapBlur?: number;
|
|
13
|
+
heatmapThreshold?: number;
|
|
14
|
+
};
|
|
15
|
+
declare function zoomTo(value: number): void;
|
|
16
|
+
declare function resetView(): void;
|
|
17
|
+
declare function fitBounds(bounds: [[number, number], [number, number]]): void;
|
|
18
|
+
declare var __VLS_12: import("../../types/maps.js").MapInteractionKind, __VLS_13: {
|
|
19
|
+
values: Record<string, unknown>;
|
|
20
|
+
x: number | undefined;
|
|
21
|
+
y: number | undefined;
|
|
22
|
+
path: string | undefined;
|
|
23
|
+
color: string;
|
|
24
|
+
radius: number | undefined;
|
|
25
|
+
scale: number;
|
|
26
|
+
}, __VLS_15: {
|
|
27
|
+
width: number;
|
|
28
|
+
height: number;
|
|
29
|
+
transform: {
|
|
30
|
+
x: number;
|
|
31
|
+
y: number;
|
|
32
|
+
k: number;
|
|
33
|
+
};
|
|
34
|
+
}, __VLS_17: {
|
|
35
|
+
values: Record<string, unknown>;
|
|
36
|
+
kind: import("../../types/maps.js").MapInteractionKind;
|
|
37
|
+
}, __VLS_24: {
|
|
38
|
+
items: {
|
|
39
|
+
value: string;
|
|
40
|
+
color: string;
|
|
41
|
+
inactive: boolean | undefined;
|
|
42
|
+
}[];
|
|
43
|
+
};
|
|
44
|
+
type __VLS_Slots = {} & {
|
|
45
|
+
[K in NonNullable<typeof __VLS_12>]?: (props: typeof __VLS_13) => any;
|
|
46
|
+
} & {
|
|
47
|
+
default?: (props: typeof __VLS_15) => any;
|
|
48
|
+
} & {
|
|
49
|
+
tooltip?: (props: typeof __VLS_17) => any;
|
|
50
|
+
} & {
|
|
51
|
+
legend?: (props: typeof __VLS_24) => any;
|
|
52
|
+
};
|
|
53
|
+
declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {
|
|
54
|
+
zoomIn: () => void;
|
|
55
|
+
zoomOut: () => void;
|
|
56
|
+
zoomTo: typeof zoomTo;
|
|
57
|
+
resetView: typeof resetView;
|
|
58
|
+
fitBounds: typeof fitBounds;
|
|
59
|
+
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
60
|
+
click: (mark: MapMark, event: MouseEvent | KeyboardEvent) => any;
|
|
61
|
+
mouseenter: (mark: MapMark, event: MouseEvent | FocusEvent) => any;
|
|
62
|
+
mouseleave: (mark: MapMark, event: MouseEvent | FocusEvent) => any;
|
|
63
|
+
resize: (size: [number, number]) => any;
|
|
64
|
+
zoom: (transform: MapZoom) => any;
|
|
65
|
+
}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
66
|
+
onClick?: ((mark: MapMark, event: MouseEvent | KeyboardEvent) => any) | undefined;
|
|
67
|
+
onMouseenter?: ((mark: MapMark, event: MouseEvent | FocusEvent) => any) | undefined;
|
|
68
|
+
onMouseleave?: ((mark: MapMark, event: MouseEvent | FocusEvent) => any) | undefined;
|
|
69
|
+
onResize?: ((size: [number, number]) => any) | undefined;
|
|
70
|
+
onZoom?: ((transform: MapZoom) => any) | undefined;
|
|
71
|
+
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
72
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
73
|
+
declare const _default: typeof __VLS_export;
|
|
74
|
+
export default _default;
|
|
75
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
76
|
+
new (): {
|
|
77
|
+
$slots: S;
|
|
78
|
+
};
|
|
79
|
+
};
|
|
@@ -25,10 +25,10 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {
|
|
|
25
25
|
height: number;
|
|
26
26
|
filter: string;
|
|
27
27
|
fill: string;
|
|
28
|
-
radius: number | [number, number, number, number];
|
|
29
|
-
color: string;
|
|
30
28
|
x: number | null;
|
|
29
|
+
radius: number | [number, number, number, number];
|
|
31
30
|
y: number | null;
|
|
31
|
+
color: string;
|
|
32
32
|
opacity: number;
|
|
33
33
|
bufferFill: string;
|
|
34
34
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|