vvplot 0.4.3 → 0.4.4

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 CHANGED
@@ -28,19 +28,24 @@ const data = [{ x: 1, y: 2 }, { x: 2, y: 3 }, { x: 3, y: 5 }]
28
28
  <link rel="stylesheet" href="https://unpkg.com/vvplot@latest/dist/style.css">
29
29
  </head>
30
30
  <body>
31
- <div id="plot"></div>
31
+ <div id="plot" style="display:flex">
32
+ <v-v-plot :data="data" :width="600" :height="400" legend-teleport="#legend">
33
+ <v-v-geom-point :x="d => d.Weight_in_lbs" :y="d => d.Miles_per_Gallon"
34
+ :color="d => d.Origin"></v-v-geom-point>
35
+ </v-v-plot>
36
+ <div id="legend"></div>
37
+ </div>
32
38
  <script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>
33
39
  <script src="https://unpkg.com/vvplot@latest/dist/vvplot.global.js"></script>
34
40
  <script>
35
41
  const { createApp, ref } = Vue
36
42
  const { components } = VVPlot
37
- const data = [{ x: 1, y: 2 }, { x: 2, y: 3 }, { x: 3, y: 5 }]
38
- let template = `<VVPlot :data="data" :width="600" :height="400">
39
- <VVGeomPoint :x="d => d.x" :y="d => d.y" />
40
- </VVPlot>`
43
+ const data = ref([])
44
+ fetch("https://cdn.jsdelivr.net/npm/vega-datasets@latest/data/cars.json")
45
+ .then(response => response.json())
46
+ .then(json => data.value = json)
41
47
  let app = createApp({
42
- setup() { return { data } },
43
- template
48
+ setup() { return { data } }
44
49
  })
45
50
  for (let c in components) {
46
51
  app.component(c, components[c])
package/dist/style.css CHANGED
@@ -1,3 +1,4 @@
1
+
1
2
  .vvplot-legend {
2
3
  display: flex;
3
4
  flex-direction: column;
@@ -1,4 +1,4 @@
1
- import { computed, isRef, reactive, unref, getCurrentScope, onScopeDispose, toValue, watch, shallowRef, getCurrentInstance, onMounted, useTemplateRef, nextTick, openBlock, createElementBlock, mergeProps, renderSlot, toDisplayString, createCommentVNode, createTextVNode, Fragment, renderList, inject, normalizeStyle, createElementVNode, createBlock, toHandlers, normalizeProps, resolveDynamicComponent, guardReactiveProps, createVNode, useModel, createPropsRestProxy, mergeModels, ref, useId, Teleport, useSlots, useAttrs, provide } from "vue";
1
+ import { computed, isRef, reactive, unref, getCurrentScope, onScopeDispose, watch, getCurrentInstance, hasInjectionContext, inject, toValue, shallowRef, readonly, watchEffect, onMounted, useTemplateRef, nextTick, openBlock, createElementBlock, mergeProps, renderSlot, toDisplayString, createCommentVNode, createTextVNode, Fragment, renderList, normalizeStyle, createElementVNode, createBlock, toHandlers, normalizeProps, resolveDynamicComponent, guardReactiveProps, createVNode, useModel, createPropsRestProxy, mergeModels, ref, useId, Teleport, useSlots, useAttrs, provide } from "vue";
2
2
  function tryOnScopeDispose(fn) {
3
3
  if (getCurrentScope()) {
4
4
  onScopeDispose(fn);
@@ -6,6 +6,17 @@ function tryOnScopeDispose(fn) {
6
6
  }
7
7
  return false;
8
8
  }
9
+ const localProvidedStateMap = /* @__PURE__ */ new WeakMap();
10
+ const injectLocal = /* @__NO_SIDE_EFFECTS__ */ (...args) => {
11
+ var _a;
12
+ const key = args[0];
13
+ const instance = (_a = getCurrentInstance()) == null ? void 0 : _a.proxy;
14
+ if (instance == null && !hasInjectionContext())
15
+ throw new Error("injectLocal must be called in setup");
16
+ if (instance && localProvidedStateMap.has(instance) && key in localProvidedStateMap.get(instance))
17
+ return localProvidedStateMap.get(instance)[key];
18
+ return inject(...args);
19
+ };
9
20
  function toReactive(objectRef) {
10
21
  if (!isRef(objectRef))
11
22
  return reactive(objectRef);
@@ -43,12 +54,79 @@ function reactiveComputed(fn) {
43
54
  }
44
55
  const isClient = typeof window !== "undefined" && typeof document !== "undefined";
45
56
  typeof WorkerGlobalScope !== "undefined" && globalThis instanceof WorkerGlobalScope;
57
+ const toString = Object.prototype.toString;
58
+ const isObject = (val) => toString.call(val) === "[object Object]";
59
+ const noop$1 = () => {
60
+ };
61
+ function pxValue(px) {
62
+ return px.endsWith("rem") ? Number.parseFloat(px) * 16 : Number.parseFloat(px);
63
+ }
64
+ function toArray(value) {
65
+ return Array.isArray(value) ? value : [value];
66
+ }
67
+ function watchImmediate(source, cb, options) {
68
+ return watch(
69
+ source,
70
+ cb,
71
+ {
72
+ ...options,
73
+ immediate: true
74
+ }
75
+ );
76
+ }
46
77
  const defaultWindow = isClient ? window : void 0;
47
78
  function unrefElement(elRef) {
48
79
  var _a;
49
80
  const plain = toValue(elRef);
50
81
  return (_a = plain == null ? void 0 : plain.$el) != null ? _a : plain;
51
82
  }
83
+ function useEventListener(...args) {
84
+ const cleanups = [];
85
+ const cleanup = () => {
86
+ cleanups.forEach((fn) => fn());
87
+ cleanups.length = 0;
88
+ };
89
+ const register = (el2, event, listener, options) => {
90
+ el2.addEventListener(event, listener, options);
91
+ return () => el2.removeEventListener(event, listener, options);
92
+ };
93
+ const firstParamTargets = computed(() => {
94
+ const test = toArray(toValue(args[0])).filter((e) => e != null);
95
+ return test.every((e) => typeof e !== "string") ? test : void 0;
96
+ });
97
+ const stopWatch = watchImmediate(
98
+ () => {
99
+ var _a, _b;
100
+ return [
101
+ (_b = (_a = firstParamTargets.value) == null ? void 0 : _a.map((e) => unrefElement(e))) != null ? _b : [defaultWindow].filter((e) => e != null),
102
+ toArray(toValue(firstParamTargets.value ? args[1] : args[0])),
103
+ toArray(unref(firstParamTargets.value ? args[2] : args[1])),
104
+ // @ts-expect-error - TypeScript gets the correct types, but somehow still complains
105
+ toValue(firstParamTargets.value ? args[3] : args[2])
106
+ ];
107
+ },
108
+ ([raw_targets, raw_events, raw_listeners, raw_options]) => {
109
+ cleanup();
110
+ if (!(raw_targets == null ? void 0 : raw_targets.length) || !(raw_events == null ? void 0 : raw_events.length) || !(raw_listeners == null ? void 0 : raw_listeners.length))
111
+ return;
112
+ const optionsClone = isObject(raw_options) ? { ...raw_options } : raw_options;
113
+ cleanups.push(
114
+ ...raw_targets.flatMap(
115
+ (el2) => raw_events.flatMap(
116
+ (event) => raw_listeners.map((listener) => register(el2, event, listener, optionsClone))
117
+ )
118
+ )
119
+ );
120
+ },
121
+ { flush: "post" }
122
+ );
123
+ const stop = () => {
124
+ stopWatch();
125
+ cleanup();
126
+ };
127
+ tryOnScopeDispose(cleanup);
128
+ return stop;
129
+ }
52
130
  // @__NO_SIDE_EFFECTS__
53
131
  function useMounted() {
54
132
  const isMounted = shallowRef(false);
@@ -68,6 +146,64 @@ function useSupported(callback) {
68
146
  return Boolean(callback());
69
147
  });
70
148
  }
149
+ const ssrWidthSymbol = /* @__PURE__ */ Symbol("vueuse-ssr-width");
150
+ // @__NO_SIDE_EFFECTS__
151
+ function useSSRWidth() {
152
+ const ssrWidth = hasInjectionContext() ? /* @__PURE__ */ injectLocal(ssrWidthSymbol, null) : null;
153
+ return typeof ssrWidth === "number" ? ssrWidth : void 0;
154
+ }
155
+ function useMediaQuery(query, options = {}) {
156
+ const { window: window2 = defaultWindow, ssrWidth = /* @__PURE__ */ useSSRWidth() } = options;
157
+ const isSupported = /* @__PURE__ */ useSupported(() => window2 && "matchMedia" in window2 && typeof window2.matchMedia === "function");
158
+ const ssrSupport = shallowRef(typeof ssrWidth === "number");
159
+ const mediaQuery = shallowRef();
160
+ const matches = shallowRef(false);
161
+ const handler = (event) => {
162
+ matches.value = event.matches;
163
+ };
164
+ watchEffect(() => {
165
+ if (ssrSupport.value) {
166
+ ssrSupport.value = !isSupported.value;
167
+ const queryStrings = toValue(query).split(",");
168
+ matches.value = queryStrings.some((queryString) => {
169
+ const not2 = queryString.includes("not all");
170
+ const minWidth = queryString.match(/\(\s*min-width:\s*(-?\d+(?:\.\d*)?[a-z]+\s*)\)/);
171
+ const maxWidth = queryString.match(/\(\s*max-width:\s*(-?\d+(?:\.\d*)?[a-z]+\s*)\)/);
172
+ let res = Boolean(minWidth || maxWidth);
173
+ if (minWidth && res) {
174
+ res = ssrWidth >= pxValue(minWidth[1]);
175
+ }
176
+ if (maxWidth && res) {
177
+ res = ssrWidth <= pxValue(maxWidth[1]);
178
+ }
179
+ return not2 ? !res : res;
180
+ });
181
+ return;
182
+ }
183
+ if (!isSupported.value)
184
+ return;
185
+ mediaQuery.value = window2.matchMedia(toValue(query));
186
+ matches.value = mediaQuery.value.matches;
187
+ });
188
+ useEventListener(mediaQuery, "change", handler, { passive: true });
189
+ return computed(() => matches.value);
190
+ }
191
+ // @__NO_SIDE_EFFECTS__
192
+ function useDevicePixelRatio(options = {}) {
193
+ const {
194
+ window: window2 = defaultWindow
195
+ } = options;
196
+ const pixelRatio = shallowRef(1);
197
+ const query = useMediaQuery(() => `(resolution: ${pixelRatio.value}dppx)`, options);
198
+ let stop = noop$1;
199
+ if (window2) {
200
+ stop = watchImmediate(query, () => pixelRatio.value = window2.devicePixelRatio);
201
+ }
202
+ return {
203
+ pixelRatio: readonly(pixelRatio),
204
+ stop
205
+ };
206
+ }
71
207
  function useResizeObserver(target2, callback, options = {}) {
72
208
  const { window: window2 = defaultWindow, ...observerOptions } = options;
73
209
  let observer;
@@ -2030,7 +2166,16 @@ function parseLinetype(linetype) {
2030
2166
  if (linetype.includes(" ")) return linetype.split(" ").map((v) => +v);
2031
2167
  return linetype.split("").map((v) => +("0x" + v));
2032
2168
  }
2033
- function serializeSVG(svgElement) {
2169
+ const unitInPx = {
2170
+ "": 1,
2171
+ "px": 1,
2172
+ "in": 96,
2173
+ "cm": 96 / 2.54,
2174
+ "mm": 96 / 25.4,
2175
+ "pt": 96 / 72,
2176
+ "pc": 16
2177
+ };
2178
+ function serializeSVG(svgElement, { unit: unit2 = "mm" } = {}) {
2034
2179
  if (!(svgElement instanceof SVGElement)) return null;
2035
2180
  function removeComments(node) {
2036
2181
  let i = node.childNodes.length;
@@ -2064,8 +2209,9 @@ function serializeSVG(svgElement) {
2064
2209
  svgClone.setAttribute("xmlns", "http://www.w3.org/2000/svg");
2065
2210
  svgClone.setAttribute("xmlns:xlink", "http://www.w3.org/1999/xlink");
2066
2211
  svgClone.setAttribute("version", "1.1");
2067
- svgClone.setAttribute("width", svgElement.scrollWidth);
2068
- svgClone.setAttribute("height", svgElement.scrollHeight);
2212
+ if (!unitInPx[unit2]) unit2 = "";
2213
+ svgClone.setAttribute("width", svgElement.scrollWidth / unitInPx[unit2] + unit2);
2214
+ svgClone.setAttribute("height", svgElement.scrollHeight / unitInPx[unit2] + unit2);
2069
2215
  svgClone.setAttribute("viewBox", `0 0 ${svgElement.scrollWidth} ${svgElement.scrollHeight}`);
2070
2216
  const serializer = new XMLSerializer();
2071
2217
  return serializer.serializeToString(svgClone);
@@ -15501,7 +15647,8 @@ const _sfc_main$Y = {
15501
15647
  data: Object,
15502
15648
  coord2pos: Function,
15503
15649
  getCoord: Function,
15504
- layout: Object
15650
+ layout: Object,
15651
+ dpi: { type: Number, default: 96 }
15505
15652
  },
15506
15653
  emits: ["click", "contextmenu", "singleclick", "dblclick", "pointermove", "pointerdown", "pointerup", "wheel"],
15507
15654
  setup(__props, { expose: __expose, emit: __emit }) {
@@ -15517,10 +15664,13 @@ const _sfc_main$Y = {
15517
15664
  const layerCanvas = computed(() => {
15518
15665
  if (containerRef.value == null) return;
15519
15666
  const canvas2 = document.createElement("canvas");
15520
- canvas2.width = __props.layout.fullWidth * (1 + __props.extendX * 2);
15521
- canvas2.height = __props.layout.fullHeight * (1 + __props.extendY * 2);
15667
+ canvas2.style.width = vBind.value.width + "px";
15668
+ canvas2.style.height = vBind.value.height + "px";
15669
+ canvas2.width = vBind.value.width * __props.dpi / 96;
15670
+ canvas2.height = vBind.value.height * __props.dpi / 96;
15522
15671
  const ctx = canvas2.getContext("2d");
15523
15672
  ctx.clearRect(0, 0, canvas2.width, canvas2.height);
15673
+ ctx.scale(__props.dpi / 96, __props.dpi / 96);
15524
15674
  ctx.translate(__props.layout.l + __props.layout.fullWidth * __props.extendX, __props.layout.t + __props.layout.fullHeight * __props.extendY);
15525
15675
  let _path_data = /* @__PURE__ */ new Map(), path_data = /* @__PURE__ */ new Map();
15526
15676
  for (const group of __props.data) {
@@ -15644,7 +15794,8 @@ const _sfc_main$X = {
15644
15794
  data: Object,
15645
15795
  coord2pos: Function,
15646
15796
  getCoord: Function,
15647
- layout: Object
15797
+ layout: Object,
15798
+ dpi: { type: Number, default: 96 }
15648
15799
  },
15649
15800
  emits: ["click", "contextmenu", "singleclick", "dblclick", "pointermove", "pointerdown", "pointerup", "wheel"],
15650
15801
  setup(__props, { expose: __expose, emit: __emit }) {
@@ -15660,10 +15811,13 @@ const _sfc_main$X = {
15660
15811
  const layerCanvas = computed(() => {
15661
15812
  if (containerRef.value == null) return;
15662
15813
  const canvas2 = document.createElement("canvas");
15663
- canvas2.width = __props.layout.fullWidth * (1 + __props.extendX * 2);
15664
- canvas2.height = __props.layout.fullHeight * (1 + __props.extendY * 2);
15814
+ canvas2.style.width = vBind.value.width + "px";
15815
+ canvas2.style.height = vBind.value.height + "px";
15816
+ canvas2.width = vBind.value.width * __props.dpi / 96;
15817
+ canvas2.height = vBind.value.height * __props.dpi / 96;
15665
15818
  const ctx = canvas2.getContext("2d");
15666
15819
  ctx.clearRect(0, 0, canvas2.width, canvas2.height);
15820
+ ctx.scale(__props.dpi / 96, __props.dpi / 96);
15667
15821
  ctx.translate(__props.layout.l + __props.layout.fullWidth * __props.extendX, __props.layout.t + __props.layout.fullHeight * __props.extendY);
15668
15822
  let _path_data = /* @__PURE__ */ new Map(), path_data = /* @__PURE__ */ new Map();
15669
15823
  for (const group of __props.data) {
@@ -15746,7 +15900,8 @@ const _sfc_main$W = {
15746
15900
  data: Object,
15747
15901
  coord2pos: Function,
15748
15902
  getCoord: Function,
15749
- layout: Object
15903
+ layout: Object,
15904
+ dpi: { type: Number, default: 96 }
15750
15905
  },
15751
15906
  emits: ["click", "contextmenu", "singleclick", "dblclick", "pointermove", "pointerdown", "pointerup", "wheel"],
15752
15907
  setup(__props, { expose: __expose, emit: __emit }) {
@@ -15762,10 +15917,13 @@ const _sfc_main$W = {
15762
15917
  const layerCanvas = computed(() => {
15763
15918
  if (containerRef.value == null) return;
15764
15919
  const canvas2 = document.createElement("canvas");
15765
- canvas2.width = __props.layout.fullWidth * (1 + __props.extendX * 2);
15766
- canvas2.height = __props.layout.fullHeight * (1 + __props.extendY * 2);
15920
+ canvas2.style.width = vBind.value.width + "px";
15921
+ canvas2.style.height = vBind.value.height + "px";
15922
+ canvas2.width = vBind.value.width * __props.dpi / 96;
15923
+ canvas2.height = vBind.value.height * __props.dpi / 96;
15767
15924
  const ctx = canvas2.getContext("2d");
15768
15925
  ctx.clearRect(0, 0, canvas2.width, canvas2.height);
15926
+ ctx.scale(__props.dpi / 96, __props.dpi / 96);
15769
15927
  ctx.translate(__props.layout.l + __props.layout.fullWidth * __props.extendX, __props.layout.t + __props.layout.fullHeight * __props.extendY);
15770
15928
  let _path_data = /* @__PURE__ */ new Map(), path_data = /* @__PURE__ */ new Map();
15771
15929
  for (const group of __props.data) {
@@ -15847,7 +16005,8 @@ const _sfc_main$V = {
15847
16005
  data: Object,
15848
16006
  coord2pos: Function,
15849
16007
  getCoord: Function,
15850
- layout: Object
16008
+ layout: Object,
16009
+ dpi: { type: Number, default: 96 }
15851
16010
  },
15852
16011
  emits: ["click", "contextmenu", "singleclick", "dblclick", "pointermove", "pointerdown", "pointerup", "wheel"],
15853
16012
  setup(__props, { expose: __expose, emit: __emit }) {
@@ -15863,10 +16022,13 @@ const _sfc_main$V = {
15863
16022
  const layerCanvas = computed(() => {
15864
16023
  if (containerRef.value == null) return;
15865
16024
  const canvas2 = document.createElement("canvas");
15866
- canvas2.width = __props.layout.fullWidth * (1 + __props.extendX * 2);
15867
- canvas2.height = __props.layout.fullHeight * (1 + __props.extendY * 2);
16025
+ canvas2.style.width = vBind.value.width + "px";
16026
+ canvas2.style.height = vBind.value.height + "px";
16027
+ canvas2.width = vBind.value.width * __props.dpi / 96;
16028
+ canvas2.height = vBind.value.height * __props.dpi / 96;
15868
16029
  const ctx = canvas2.getContext("2d");
15869
16030
  ctx.clearRect(0, 0, canvas2.width, canvas2.height);
16031
+ ctx.scale(__props.dpi / 96, __props.dpi / 96);
15870
16032
  ctx.translate(__props.layout.l + __props.layout.fullWidth * __props.extendX, __props.layout.t + __props.layout.fullHeight * __props.extendY);
15871
16033
  let _path_data = /* @__PURE__ */ new Map(), path_data = /* @__PURE__ */ new Map();
15872
16034
  for (const group of __props.data) {
@@ -15936,7 +16098,8 @@ const _sfc_main$U = {
15936
16098
  data: Object,
15937
16099
  coord2pos: Function,
15938
16100
  getCoord: Function,
15939
- layout: Object
16101
+ layout: Object,
16102
+ dpi: { type: Number, default: 96 }
15940
16103
  },
15941
16104
  emits: ["click", "contextmenu", "singleclick", "dblclick", "pointermove", "pointerdown", "pointerup", "wheel"],
15942
16105
  setup(__props, { expose: __expose, emit: __emit }) {
@@ -15959,10 +16122,13 @@ const _sfc_main$U = {
15959
16122
  const layerCanvas = computed(() => {
15960
16123
  if (containerRef.value == null) return;
15961
16124
  const canvas2 = document.createElement("canvas");
15962
- canvas2.width = __props.layout.fullWidth * (1 + __props.extendX * 2);
15963
- canvas2.height = __props.layout.fullHeight * (1 + __props.extendY * 2);
16125
+ canvas2.style.width = vBind.value.width + "px";
16126
+ canvas2.style.height = vBind.value.height + "px";
16127
+ canvas2.width = vBind.value.width * __props.dpi / 96;
16128
+ canvas2.height = vBind.value.height * __props.dpi / 96;
15964
16129
  const ctx = canvas2.getContext("2d");
15965
16130
  ctx.clearRect(0, 0, canvas2.width, canvas2.height);
16131
+ ctx.scale(__props.dpi / 96, __props.dpi / 96);
15966
16132
  ctx.translate(__props.layout.l + __props.layout.fullWidth * __props.extendX, __props.layout.t + __props.layout.fullHeight * __props.extendY);
15967
16133
  let _path_data = /* @__PURE__ */ new Map(), path_data = /* @__PURE__ */ new Map();
15968
16134
  for (const group of __props.data) {
@@ -16047,7 +16213,8 @@ const _sfc_main$T = {
16047
16213
  data: Object,
16048
16214
  coord2pos: Function,
16049
16215
  getCoord: Function,
16050
- layout: Object
16216
+ layout: Object,
16217
+ dpi: { type: Number, default: 96 }
16051
16218
  },
16052
16219
  emits: ["click", "contextmenu", "singleclick", "dblclick", "pointermove", "pointerdown", "pointerup", "wheel"],
16053
16220
  setup(__props, { expose: __expose, emit: __emit }) {
@@ -16063,10 +16230,13 @@ const _sfc_main$T = {
16063
16230
  const layerCanvas = computed(() => {
16064
16231
  if (containerRef.value == null) return;
16065
16232
  const canvas2 = document.createElement("canvas");
16066
- canvas2.width = __props.layout.fullWidth * (1 + __props.extendX * 2);
16067
- canvas2.height = __props.layout.fullHeight * (1 + __props.extendY * 2);
16233
+ canvas2.style.width = vBind.value.width + "px";
16234
+ canvas2.style.height = vBind.value.height + "px";
16235
+ canvas2.width = vBind.value.width * __props.dpi / 96;
16236
+ canvas2.height = vBind.value.height * __props.dpi / 96;
16068
16237
  const ctx = canvas2.getContext("2d");
16069
16238
  ctx.clearRect(0, 0, canvas2.width, canvas2.height);
16239
+ ctx.scale(__props.dpi / 96, __props.dpi / 96);
16070
16240
  ctx.translate(__props.layout.l + __props.layout.fullWidth * __props.extendX, __props.layout.t + __props.layout.fullHeight * __props.extendY);
16071
16241
  let _path_data = /* @__PURE__ */ new Map(), path_data = /* @__PURE__ */ new Map();
16072
16242
  for (const group of __props.data) {
@@ -16140,7 +16310,8 @@ const _sfc_main$S = {
16140
16310
  data: Object,
16141
16311
  coord2pos: Function,
16142
16312
  getCoord: Function,
16143
- layout: Object
16313
+ layout: Object,
16314
+ dpi: { type: Number, default: 96 }
16144
16315
  },
16145
16316
  emits: ["click", "contextmenu", "singleclick", "dblclick", "pointermove", "pointerdown", "pointerup", "wheel"],
16146
16317
  setup(__props, { expose: __expose, emit: __emit }) {
@@ -16156,10 +16327,13 @@ const _sfc_main$S = {
16156
16327
  const layerCanvas = computed(() => {
16157
16328
  if (containerRef.value == null) return;
16158
16329
  const canvas2 = document.createElement("canvas");
16159
- canvas2.width = __props.layout.fullWidth * (1 + __props.extendX * 2);
16160
- canvas2.height = __props.layout.fullHeight * (1 + __props.extendY * 2);
16330
+ canvas2.style.width = vBind.value.width + "px";
16331
+ canvas2.style.height = vBind.value.height + "px";
16332
+ canvas2.width = vBind.value.width * __props.dpi / 96;
16333
+ canvas2.height = vBind.value.height * __props.dpi / 96;
16161
16334
  const ctx = canvas2.getContext("2d");
16162
16335
  ctx.clearRect(0, 0, canvas2.width, canvas2.height);
16336
+ ctx.scale(__props.dpi / 96, __props.dpi / 96);
16163
16337
  ctx.translate(__props.layout.l + __props.layout.fullWidth * __props.extendX, __props.layout.t + __props.layout.fullHeight * __props.extendY);
16164
16338
  let _path_data = /* @__PURE__ */ new Map(), path_data = /* @__PURE__ */ new Map();
16165
16339
  for (const group of __props.data) {
@@ -16231,7 +16405,8 @@ const _sfc_main$R = {
16231
16405
  data: Object,
16232
16406
  coord2pos: Function,
16233
16407
  getCoord: Function,
16234
- layout: Object
16408
+ layout: Object,
16409
+ dpi: { type: Number, default: 96 }
16235
16410
  },
16236
16411
  emits: ["click", "contextmenu", "singleclick", "dblclick", "pointermove", "pointerdown", "pointerup", "wheel"],
16237
16412
  setup(__props, { expose: __expose, emit: __emit }) {
@@ -16247,10 +16422,13 @@ const _sfc_main$R = {
16247
16422
  const layerCanvas = computed(() => {
16248
16423
  if (containerRef.value == null) return;
16249
16424
  const canvas2 = document.createElement("canvas");
16250
- canvas2.width = __props.layout.fullWidth * (1 + __props.extendX * 2);
16251
- canvas2.height = __props.layout.fullHeight * (1 + __props.extendY * 2);
16425
+ canvas2.style.width = vBind.value.width + "px";
16426
+ canvas2.style.height = vBind.value.height + "px";
16427
+ canvas2.width = vBind.value.width * __props.dpi / 96;
16428
+ canvas2.height = vBind.value.height * __props.dpi / 96;
16252
16429
  const ctx = canvas2.getContext("2d");
16253
16430
  ctx.clearRect(0, 0, canvas2.width, canvas2.height);
16431
+ ctx.scale(__props.dpi / 96, __props.dpi / 96);
16254
16432
  ctx.translate(__props.layout.l + __props.layout.fullWidth * __props.extendX, __props.layout.t + __props.layout.fullHeight * __props.extendY);
16255
16433
  let _path_data = /* @__PURE__ */ new Map(), path_data = /* @__PURE__ */ new Map();
16256
16434
  for (const group of __props.data) {
@@ -16357,7 +16535,8 @@ const _sfc_main$Q = {
16357
16535
  data: Object,
16358
16536
  coord2pos: Function,
16359
16537
  getCoord: Function,
16360
- layout: Object
16538
+ layout: Object,
16539
+ dpi: { type: Number, default: 96 }
16361
16540
  },
16362
16541
  emits: ["click", "contextmenu", "singleclick", "dblclick", "pointermove", "pointerdown", "pointerup", "wheel"],
16363
16542
  setup(__props, { expose: __expose, emit: __emit }) {
@@ -16373,10 +16552,13 @@ const _sfc_main$Q = {
16373
16552
  const layerCanvas = computed(() => {
16374
16553
  if (containerRef.value == null) return;
16375
16554
  const canvas2 = document.createElement("canvas");
16376
- canvas2.width = __props.layout.fullWidth * (1 + __props.extendX * 2);
16377
- canvas2.height = __props.layout.fullHeight * (1 + __props.extendY * 2);
16555
+ canvas2.style.width = vBind.value.width + "px";
16556
+ canvas2.style.height = vBind.value.height + "px";
16557
+ canvas2.width = vBind.value.width * __props.dpi / 96;
16558
+ canvas2.height = vBind.value.height * __props.dpi / 96;
16378
16559
  const ctx = canvas2.getContext("2d");
16379
16560
  ctx.clearRect(0, 0, canvas2.width, canvas2.height);
16561
+ ctx.scale(__props.dpi / 96, __props.dpi / 96);
16380
16562
  ctx.translate(__props.layout.l + __props.layout.fullWidth * __props.extendX, __props.layout.t + __props.layout.fullHeight * __props.extendY);
16381
16563
  let _path_data = /* @__PURE__ */ new Map(), path_data = /* @__PURE__ */ new Map();
16382
16564
  for (const group of __props.data) {
@@ -16539,7 +16721,9 @@ const _sfc_main$P = {
16539
16721
  data: Object,
16540
16722
  coord2pos: Function,
16541
16723
  getCoord: Function,
16542
- layout: Object
16724
+ layout: Object,
16725
+ groupClass: null,
16726
+ groupStyle: null
16543
16727
  },
16544
16728
  emits: ["click", "contextmenu", "pointerover", "pointerout", "pointerenter", "pointerleave", "pointermove", "pointerdown", "pointerup"],
16545
16729
  setup(__props, { emit: __emit }) {
@@ -18005,7 +18189,9 @@ const _sfc_main$x = {
18005
18189
  data: Object,
18006
18190
  geom: String,
18007
18191
  render: String,
18008
- defaultRender: { type: String, default: "auto" }
18192
+ defaultRender: { type: String, default: "auto" },
18193
+ dpi: Number,
18194
+ defaultDpi: Number
18009
18195
  },
18010
18196
  setup(__props, { expose: __expose }) {
18011
18197
  const geoms = { svg, canvas };
@@ -18024,13 +18210,15 @@ const _sfc_main$x = {
18024
18210
  render: rend,
18025
18211
  dispatchEvent: (e) => layer.value?.dispatchEvent?.(e)
18026
18212
  });
18213
+ const dpi = computed(() => rend.value === "canvas" ? __props.dpi ?? __props.defaultDpi : void 0);
18027
18214
  return (_ctx, _cache) => {
18028
18215
  return openBlock(), createBlock(resolveDynamicComponent(geoms[rend.value][__props.geom]), {
18029
18216
  ref_key: "layer",
18030
18217
  ref: layer,
18031
18218
  style: normalizeStyle(style.value),
18032
- data: __props.data
18033
- }, null, 8, ["style", "data"]);
18219
+ data: __props.data,
18220
+ dpi: dpi.value
18221
+ }, null, 8, ["style", "data", "dpi"]);
18034
18222
  };
18035
18223
  }
18036
18224
  };
@@ -18570,6 +18758,7 @@ const _sfc_main$r = /* @__PURE__ */ Object.assign({ inheritAttrs: false }, {
18570
18758
  theme: Object,
18571
18759
  render: String,
18572
18760
  clip: Boolean,
18761
+ dpi: Number,
18573
18762
  action: { type: Array, default: () => [] },
18574
18763
  selections: { type: Array, default: () => [] },
18575
18764
  legendTeleport: null
@@ -19283,8 +19472,9 @@ const _sfc_main$r = /* @__PURE__ */ Object.assign({ inheritAttrs: false }, {
19283
19472
  geom: layer.geom,
19284
19473
  coord2pos,
19285
19474
  getCoord,
19286
- "default-render": props.render
19287
- }), null, 16, ["data", "layout", "geom", "default-render"]);
19475
+ "default-render": props.render,
19476
+ "default-dpi": props.dpi
19477
+ }), null, 16, ["data", "layout", "geom", "default-render", "default-dpi"]);
19288
19478
  }), 256))
19289
19479
  ], 16),
19290
19480
  _cache[3] || (_cache[3] = createTextVNode()),
@@ -19571,7 +19761,8 @@ const _sfc_main$1 = /* @__PURE__ */ Object.assign({ inheritAttrs: false }, {
19571
19761
  flip: Boolean,
19572
19762
  clip: { type: Boolean, default: true },
19573
19763
  resize: null,
19574
- legendTeleport: null
19764
+ legendTeleport: null,
19765
+ dpi: Number
19575
19766
  }, {
19576
19767
  "selectionPreview": { default: () => ({}) },
19577
19768
  "selectionPreviewModifiers": {},
@@ -19679,6 +19870,8 @@ const _sfc_main$1 = /* @__PURE__ */ Object.assign({ inheritAttrs: false }, {
19679
19870
  let arr = Array.isArray($attrs[key]) ? $attrs[key] : [$attrs[key]];
19680
19871
  plot[key] = arr.filter((f) => typeof f === "function");
19681
19872
  wrapper[key] = arr.filter((f) => typeof f !== "function");
19873
+ } else if (key.startsWith("svg-")) {
19874
+ plot[key.slice(4)] = $attrs[key];
19682
19875
  } else {
19683
19876
  wrapper[key] = $attrs[key];
19684
19877
  }
@@ -19759,7 +19952,7 @@ const _sfc_main$1 = /* @__PURE__ */ Object.assign({ inheritAttrs: false }, {
19759
19952
  aes[key] = etc[key];
19760
19953
  }
19761
19954
  } else {
19762
- if (["class", "style", "group-class", "group-style", "render"].includes(key)) {
19955
+ if (["class", "style", "group-class", "group-style", "dpi", "render"].includes(key)) {
19763
19956
  vBind2[key] = etc[key];
19764
19957
  } else if (["item-class", "item-style"].includes(key)) {
19765
19958
  attrs2[key.slice(5)] = etc[key];
@@ -20058,6 +20251,7 @@ const _sfc_main$1 = /* @__PURE__ */ Object.assign({ inheritAttrs: false }, {
20058
20251
  };
20059
20252
  });
20060
20253
  });
20254
+ const { pixelRatio } = /* @__PURE__ */ useDevicePixelRatio();
20061
20255
  const wrapperRef = useTemplateRef("wrapper");
20062
20256
  const plotRef = useTemplateRef("plot");
20063
20257
  const width = useModel(__props, "width");
@@ -20104,8 +20298,8 @@ const _sfc_main$1 = /* @__PURE__ */ Object.assign({ inheritAttrs: false }, {
20104
20298
  get svg() {
20105
20299
  return plotRef.value.svg;
20106
20300
  },
20107
- serialize() {
20108
- return serializeSVG(plotRef.value.svg);
20301
+ serialize(options) {
20302
+ return serializeSVG(plotRef.value.svg, options);
20109
20303
  }
20110
20304
  });
20111
20305
  return (_ctx, _cache) => {
@@ -20140,9 +20334,10 @@ const _sfc_main$1 = /* @__PURE__ */ Object.assign({ inheritAttrs: false }, {
20140
20334
  action: action.value,
20141
20335
  clip: __props.clip,
20142
20336
  render: __props.render,
20337
+ dpi: __props.dpi ?? 96 * unref(pixelRatio),
20143
20338
  legendTeleport: __props.legendTeleport,
20144
20339
  onSelect: _cache[3] || (_cache[3] = (d, e) => emit("select", d, e))
20145
- }), null, 16, ["paddings", "schema", "layers", "min-range", "expand-add", "expand-mult", "reverse", "flip", "coord-levels", "levels", "scales", "axes", "theme", "selections", "transition", "selection-preview", "selection-preview-theme", "action", "clip", "render", "legendTeleport"]),
20340
+ }), null, 16, ["paddings", "schema", "layers", "min-range", "expand-add", "expand-mult", "reverse", "flip", "coord-levels", "levels", "scales", "axes", "theme", "selections", "transition", "selection-preview", "selection-preview-theme", "action", "clip", "render", "dpi", "legendTeleport"]),
20146
20341
  _cache[4] || (_cache[4] = createTextVNode()),
20147
20342
  createElementVNode("div", {
20148
20343
  class: "vvplot-panel-container",