vvplot 0.3.0 → 0.4.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/dist/vvplot.esm.js +107 -72
- package/dist/vvplot.esm.min.js +17 -17
- package/dist/vvplot.global.js +107 -72
- package/dist/vvplot.global.min.js +17 -17
- package/package.json +1 -1
package/dist/vvplot.global.js
CHANGED
|
@@ -1698,6 +1698,15 @@ var VVPlot = (function(exports, vue) {
|
|
|
1698
1698
|
}
|
|
1699
1699
|
throw new Error(`Invalid level values: ${x2}`);
|
|
1700
1700
|
}
|
|
1701
|
+
/**
|
|
1702
|
+
* Check if two GEnumLevel are equal, i.e. they have the same labels in the same order
|
|
1703
|
+
* @param {string[]} level
|
|
1704
|
+
*/
|
|
1705
|
+
static isEqual(a, b) {
|
|
1706
|
+
if (a instanceof this && b instanceof this) {
|
|
1707
|
+
return a.length === b.length && Array(a.length).fill().every((_, i) => a[i].label === b[i].label);
|
|
1708
|
+
}
|
|
1709
|
+
}
|
|
1701
1710
|
/**
|
|
1702
1711
|
* build a GEnumLevel
|
|
1703
1712
|
* @param {string[]} level
|
|
@@ -2651,7 +2660,7 @@ var VVPlot = (function(exports, vue) {
|
|
|
2651
2660
|
result[key] = cates.map((x2) => x2.group).map((i) => group.categories[i][key]);
|
|
2652
2661
|
}
|
|
2653
2662
|
return result;
|
|
2654
|
-
}, { core_attrs: ["x", "y", "xnudge", "ynudge"] });
|
|
2663
|
+
}, { core_attrs: ["x", "y", "width", "height", "xnudge", "ynudge"] });
|
|
2655
2664
|
const curve = Object.assign(function(data) {
|
|
2656
2665
|
if (data.points != null) return data;
|
|
2657
2666
|
let missingAes = ["x", "y"].filter((a) => data[a] == null);
|
|
@@ -6119,6 +6128,7 @@ var VVPlot = (function(exports, vue) {
|
|
|
6119
6128
|
c = 100,
|
|
6120
6129
|
l = 65,
|
|
6121
6130
|
h_start = 0,
|
|
6131
|
+
alpha: alpha2 = 1,
|
|
6122
6132
|
direction = 1,
|
|
6123
6133
|
limits,
|
|
6124
6134
|
oob: oob2 = oob_censor,
|
|
@@ -6133,7 +6143,7 @@ var VVPlot = (function(exports, vue) {
|
|
|
6133
6143
|
v = this.oob(v, { min: scale_min, max: scale_max });
|
|
6134
6144
|
if (v === null) return null_value;
|
|
6135
6145
|
if (isNaN(v)) return na_value;
|
|
6136
|
-
return hcl(h_start + h_min + h_interval * (v - scale_min) / scale_interval * direction, c, l).toString();
|
|
6146
|
+
return hcl(h_start + h_min + h_interval * (v - scale_min) / scale_interval * direction, c, l, alpha2).toString();
|
|
6137
6147
|
});
|
|
6138
6148
|
};
|
|
6139
6149
|
return Object.assign(fn, { title, limits, oob: oob2 }, etc);
|
|
@@ -6225,12 +6235,13 @@ var VVPlot = (function(exports, vue) {
|
|
|
6225
6235
|
return Object.assign(fn, { title, limits, oob: oob2 }, etc);
|
|
6226
6236
|
}
|
|
6227
6237
|
function palette_scale_auto({
|
|
6238
|
+
alpha: alpha2,
|
|
6228
6239
|
limits,
|
|
6229
6240
|
oob: oob2 = oob_censor,
|
|
6230
6241
|
title,
|
|
6231
6242
|
...etc
|
|
6232
6243
|
} = {}) {
|
|
6233
|
-
let scale_hue = palette_scale_hue(), scale_gradient = palette_scale_gradient();
|
|
6244
|
+
let scale_hue = palette_scale_hue({ alpha: alpha2 }), scale_gradient = palette_scale_gradient();
|
|
6234
6245
|
let fn = function(arr) {
|
|
6235
6246
|
if (arr.level != null) {
|
|
6236
6247
|
return scale_hue.call(this, arr);
|
|
@@ -6241,15 +6252,13 @@ var VVPlot = (function(exports, vue) {
|
|
|
6241
6252
|
return Object.assign(fn, { title, limits, oob: oob2 }, etc);
|
|
6242
6253
|
}
|
|
6243
6254
|
function palette_scale_dynamic({
|
|
6244
|
-
discrete,
|
|
6245
|
-
continuous: continuous2,
|
|
6255
|
+
discrete = palette_scale_hue(),
|
|
6256
|
+
continuous: continuous2 = palette_scale_gradient(),
|
|
6246
6257
|
limits,
|
|
6247
6258
|
oob: oob2 = oob_censor,
|
|
6248
6259
|
title,
|
|
6249
6260
|
...etc
|
|
6250
6261
|
} = {}) {
|
|
6251
|
-
discrete ??= palette_scale_hue();
|
|
6252
|
-
continuous2 ??= palette_scale_gradient();
|
|
6253
6262
|
let fn = function(arr) {
|
|
6254
6263
|
if (arr.level != null) {
|
|
6255
6264
|
return discrete.call(this, arr);
|
|
@@ -6601,6 +6610,9 @@ var VVPlot = (function(exports, vue) {
|
|
|
6601
6610
|
if (obj == null) return {};
|
|
6602
6611
|
return Object.fromEntries(Object.entries(obj).map(([k, v]) => [k, expr(k, v)]));
|
|
6603
6612
|
}
|
|
6613
|
+
function is_categorical(v) {
|
|
6614
|
+
return typeof v === "string" || typeof v === "boolean" || typeof v === "symbol" || typeof v === "object" && typeof v.valueOf() !== "number" && typeof v.valueOf() !== "bigint";
|
|
6615
|
+
}
|
|
6604
6616
|
class GLayer {
|
|
6605
6617
|
/**
|
|
6606
6618
|
* Create a graphic layer from schema
|
|
@@ -6657,9 +6669,9 @@ var VVPlot = (function(exports, vue) {
|
|
|
6657
6669
|
if ($$data == null) $$data = $data;
|
|
6658
6670
|
$$aes = { ...$aes, ...$$aes };
|
|
6659
6671
|
let data = {};
|
|
6660
|
-
|
|
6672
|
+
this.$fnames = {};
|
|
6661
6673
|
for (const aes in $$aes) {
|
|
6662
|
-
|
|
6674
|
+
this.$fnames[aes] = String($$aes[aes]);
|
|
6663
6675
|
data[aes] = $$data.map($$aes[aes]);
|
|
6664
6676
|
}
|
|
6665
6677
|
data.$raw = $$data;
|
|
@@ -6699,21 +6711,18 @@ var VVPlot = (function(exports, vue) {
|
|
|
6699
6711
|
...vvgeom[$$geom]?.scale_attrs ?? []
|
|
6700
6712
|
]);
|
|
6701
6713
|
this.$data = data;
|
|
6702
|
-
this.$fns = fns;
|
|
6703
6714
|
this.data = { ...data };
|
|
6704
6715
|
for (const aes in data) {
|
|
6705
6716
|
if ($$scales[aes] != null) {
|
|
6706
6717
|
let scale = new Scale($$scales[aes]);
|
|
6707
6718
|
scale.aesthetics = aes;
|
|
6708
|
-
|
|
6709
|
-
scale.title = fns[aes];
|
|
6710
|
-
}
|
|
6719
|
+
scale._title = this.$fnames[aes];
|
|
6711
6720
|
let values = this.$data[aes];
|
|
6712
6721
|
if (!values?.length) continue;
|
|
6713
6722
|
if (!scale.asis) {
|
|
6714
6723
|
if ($$levels?.[aes] != null) {
|
|
6715
6724
|
scale.level = $$levels[aes];
|
|
6716
|
-
} else if (values.some(
|
|
6725
|
+
} else if (values.some(is_categorical)) {
|
|
6717
6726
|
scale.level = GEnumLevel.from(values);
|
|
6718
6727
|
} else {
|
|
6719
6728
|
scale.extent = numutils.extent(values);
|
|
@@ -6780,15 +6789,13 @@ var VVPlot = (function(exports, vue) {
|
|
|
6780
6789
|
if (!scale.asis) {
|
|
6781
6790
|
if (levels?.[aes] != null) {
|
|
6782
6791
|
scale.level = levels[aes];
|
|
6783
|
-
} else if (values.some(
|
|
6792
|
+
} else if (values.some(is_categorical)) {
|
|
6784
6793
|
scale.level = GEnumLevel.from(values);
|
|
6785
6794
|
} else {
|
|
6786
6795
|
scale.extent = numutils.extent(values);
|
|
6787
6796
|
}
|
|
6788
6797
|
}
|
|
6789
|
-
|
|
6790
|
-
scale.title = this.layers.map((layer) => layer.$fns?.[aes]).find((s) => s != null);
|
|
6791
|
-
}
|
|
6798
|
+
scale._title = this.layers.reduce((v, layer) => v ?? layer.$fnames?.[aes], null);
|
|
6792
6799
|
for (const layer of this.layers) {
|
|
6793
6800
|
if (!layer.localScales.has(aes)) {
|
|
6794
6801
|
layer.applyScale(aes, scale);
|
|
@@ -6823,7 +6830,7 @@ var VVPlot = (function(exports, vue) {
|
|
|
6823
6830
|
let fn = vvgeom[layer.geom].get_values ?? vvgeom[layer.geom].get_range;
|
|
6824
6831
|
return fn?.(layer.$data, aes);
|
|
6825
6832
|
});
|
|
6826
|
-
if (values.some(
|
|
6833
|
+
if (values.some(is_categorical)) {
|
|
6827
6834
|
this.levels[aes] = GEnumLevel.from(values);
|
|
6828
6835
|
} else {
|
|
6829
6836
|
values = this.layers.flatMap((layer) => vvgeom[layer.geom].get_range?.(layer.$data, aes)).filter((v) => !isNaN(v));
|
|
@@ -6934,6 +6941,9 @@ var VVPlot = (function(exports, vue) {
|
|
|
6934
6941
|
let min = this.$limits?.min ?? (this.level ? 0 : this._limits?.min), max = this.$limits?.max ?? this.level?.length ?? this._limits?.max;
|
|
6935
6942
|
return { 0: min, 1: max, length: 2, min, max };
|
|
6936
6943
|
}
|
|
6944
|
+
toString() {
|
|
6945
|
+
return this.title ?? String(this._fn);
|
|
6946
|
+
}
|
|
6937
6947
|
}
|
|
6938
6948
|
class DiscreteCoordScale extends Function {
|
|
6939
6949
|
constructor(level, { min, max } = {}) {
|
|
@@ -14583,7 +14593,9 @@ var VVPlot = (function(exports, vue) {
|
|
|
14583
14593
|
const iRef = vue.useTemplateRef("i");
|
|
14584
14594
|
function getPosition(event) {
|
|
14585
14595
|
let rect2 = iRef.value.getBoundingClientRect();
|
|
14586
|
-
let
|
|
14596
|
+
let scaleX = rect2.width / iRef.value.getBBox().width;
|
|
14597
|
+
let offsetX = event.clientX - rect2.left;
|
|
14598
|
+
let l = offsetX / scaleX - __props.layout.left, r = __props.layout.left + __props.layout.width - offsetX / scaleX;
|
|
14587
14599
|
let result = { l, r };
|
|
14588
14600
|
let { x: x2, y: y2 } = __props.pos2coord({ h: l });
|
|
14589
14601
|
if (x2) result.x = x2;
|
|
@@ -14618,11 +14630,13 @@ var VVPlot = (function(exports, vue) {
|
|
|
14618
14630
|
moveTimer = clearTimeout(moveTimer);
|
|
14619
14631
|
let hmin0 = 0, hmax0 = __props.layout.width;
|
|
14620
14632
|
let boundary = __props.coord2pos(act);
|
|
14633
|
+
let rect2 = iRef.value.getBoundingClientRect();
|
|
14634
|
+
let scaleX = rect2.width / iRef.value.getBBox().width;
|
|
14621
14635
|
e.target.setPointerCapture(e.pointerId);
|
|
14622
14636
|
e.target.onpointermove = (ev) => {
|
|
14623
14637
|
movementX += ev.movementX;
|
|
14624
14638
|
if (!pointerMoved) return;
|
|
14625
|
-
let dh = oob_squish_any(-movementX, { min: boundary.hmin - hmin0, max: boundary.hmax - hmax0 });
|
|
14639
|
+
let dh = oob_squish_any(-movementX / scaleX, { min: boundary.hmin - hmin0, max: boundary.hmax - hmax0 });
|
|
14626
14640
|
let { xmin, xmax, ymin, ymax } = __props.pos2coord({ hmin: hmin0 + dh, hmax: hmax0 + dh });
|
|
14627
14641
|
Object.assign(rangePreview, { xmin, xmax, ymin, ymax });
|
|
14628
14642
|
};
|
|
@@ -14649,12 +14663,14 @@ var VVPlot = (function(exports, vue) {
|
|
|
14649
14663
|
min: __props.coord2pos(act).hmin,
|
|
14650
14664
|
max: __props.coord2pos({ hmin: coord0.hmax - mrh, hmax: coord0.hmin + mrh }).hmin
|
|
14651
14665
|
};
|
|
14666
|
+
let rect2 = iRef.value.getBoundingClientRect();
|
|
14667
|
+
let scaleX = rect2.width / iRef.value.getBBox().width;
|
|
14652
14668
|
let movementX2 = 0;
|
|
14653
14669
|
e.target.setPointerCapture(e.pointerId);
|
|
14654
14670
|
e.target.onpointermove = (ev) => {
|
|
14655
14671
|
movementX2 += ev.movementX;
|
|
14656
14672
|
let { xmin, xmax, ymin, ymax } = __props.pos2coord({
|
|
14657
|
-
hmin: oob_squish_any(hmax - (hmax - hmin) * position.r / Math.max(position.r - movementX2, 1), boundary),
|
|
14673
|
+
hmin: oob_squish_any(hmax - (hmax - hmin) * position.r / Math.max(position.r - movementX2 / scaleX, 1), boundary),
|
|
14658
14674
|
hmax
|
|
14659
14675
|
});
|
|
14660
14676
|
Object.assign(rangePreview, { xmin, xmax, ymin, ymax });
|
|
@@ -14677,6 +14693,8 @@ var VVPlot = (function(exports, vue) {
|
|
|
14677
14693
|
min: __props.coord2pos({ hmin: coord0.hmax - mrh, hmax: coord0.hmin + mrh }).hmax,
|
|
14678
14694
|
max: __props.coord2pos(act).hmax
|
|
14679
14695
|
};
|
|
14696
|
+
let rect2 = iRef.value.getBoundingClientRect();
|
|
14697
|
+
rect2.width / iRef.value.getBBox().width;
|
|
14680
14698
|
let movementX2 = 0;
|
|
14681
14699
|
e.target.setPointerCapture(e.pointerId);
|
|
14682
14700
|
e.target.onpointermove = (ev) => {
|
|
@@ -15002,7 +15020,9 @@ var VVPlot = (function(exports, vue) {
|
|
|
15002
15020
|
const iRef = vue.useTemplateRef("i");
|
|
15003
15021
|
function getPosition(event) {
|
|
15004
15022
|
let rect2 = iRef.value.getBoundingClientRect();
|
|
15005
|
-
let
|
|
15023
|
+
let scaleY = rect2.height / iRef.value.getBBox().height;
|
|
15024
|
+
let offsetY = event.clientY - rect2.top;
|
|
15025
|
+
let t = offsetY / scaleY - __props.layout.top, b = __props.layout.top + __props.layout.height - offsetY / scaleY;
|
|
15006
15026
|
let result = { t, b };
|
|
15007
15027
|
let { x: x2, y: y2 } = __props.pos2coord({ v: t });
|
|
15008
15028
|
if (x2) result.x = x2;
|
|
@@ -15037,11 +15057,13 @@ var VVPlot = (function(exports, vue) {
|
|
|
15037
15057
|
moveTimer = clearTimeout(moveTimer);
|
|
15038
15058
|
let vmin0 = 0, vmax0 = __props.layout.height;
|
|
15039
15059
|
let boundary = __props.coord2pos(act);
|
|
15060
|
+
let rect2 = iRef.value.getBoundingClientRect();
|
|
15061
|
+
let scaleY = rect2.height / iRef.value.getBBox().height;
|
|
15040
15062
|
e.target.setPointerCapture(e.pointerId);
|
|
15041
15063
|
e.target.onpointermove = (ev) => {
|
|
15042
15064
|
movementY += ev.movementY;
|
|
15043
15065
|
if (!pointerMoved) return;
|
|
15044
|
-
let dv = oob_squish_any(-movementY, { min: boundary.vmin - vmin0, max: boundary.vmax - vmax0 });
|
|
15066
|
+
let dv = oob_squish_any(-movementY / scaleY, { min: boundary.vmin - vmin0, max: boundary.vmax - vmax0 });
|
|
15045
15067
|
let { xmin, xmax, ymin, ymax } = __props.pos2coord({ vmin: vmin0 + dv, vmax: vmax0 + dv });
|
|
15046
15068
|
Object.assign(rangePreview, { xmin, xmax, ymin, ymax });
|
|
15047
15069
|
};
|
|
@@ -15068,12 +15090,14 @@ var VVPlot = (function(exports, vue) {
|
|
|
15068
15090
|
min: __props.coord2pos(act).vmin,
|
|
15069
15091
|
max: __props.coord2pos({ vmin: coord0.vmax - mrv, vmax: coord0.vmin + mrv }).vmin
|
|
15070
15092
|
};
|
|
15093
|
+
let rect2 = iRef.value.getBoundingClientRect();
|
|
15094
|
+
let scaleY = rect2.height / iRef.value.getBBox().height;
|
|
15071
15095
|
let movementY2 = 0;
|
|
15072
15096
|
e.target.setPointerCapture(e.pointerId);
|
|
15073
15097
|
e.target.onpointermove = (ev) => {
|
|
15074
15098
|
movementY2 += ev.movementY;
|
|
15075
15099
|
let { xmin, xmax, ymin, ymax } = __props.pos2coord({
|
|
15076
|
-
vmin: oob_squish_any(vmax - (vmax - vmin) * position.b / Math.max(position.b - movementY2, 1), boundary),
|
|
15100
|
+
vmin: oob_squish_any(vmax - (vmax - vmin) * position.b / Math.max(position.b - movementY2 / scaleY, 1), boundary),
|
|
15077
15101
|
vmax
|
|
15078
15102
|
});
|
|
15079
15103
|
Object.assign(rangePreview, { xmin, xmax, ymin, ymax });
|
|
@@ -15096,13 +15120,15 @@ var VVPlot = (function(exports, vue) {
|
|
|
15096
15120
|
min: __props.coord2pos({ vmin: coord0.vmax - mrv, vmax: coord0.vmin + mrv }).vmax,
|
|
15097
15121
|
max: __props.coord2pos(act).vmax
|
|
15098
15122
|
};
|
|
15123
|
+
let rect2 = iRef.value.getBoundingClientRect();
|
|
15124
|
+
let scaleY = rect2.height / iRef.value.getBBox().height;
|
|
15099
15125
|
let movementY2 = 0;
|
|
15100
15126
|
e.target.setPointerCapture(e.pointerId);
|
|
15101
15127
|
e.target.onpointermove = (ev) => {
|
|
15102
15128
|
movementY2 += ev.movementY;
|
|
15103
15129
|
let { xmin, xmax, ymin, ymax } = __props.pos2coord({
|
|
15104
15130
|
vmin,
|
|
15105
|
-
vmax: oob_squish_any(vmin + (vmax - vmin) * position.t / Math.max(position.t + movementY2, 1), boundary)
|
|
15131
|
+
vmax: oob_squish_any(vmin + (vmax - vmin) * position.t / Math.max(position.t + movementY2 / scaleY, 1), boundary)
|
|
15106
15132
|
});
|
|
15107
15133
|
Object.assign(rangePreview, { xmin, xmax, ymin, ymax });
|
|
15108
15134
|
};
|
|
@@ -15549,8 +15575,8 @@ var VVPlot = (function(exports, vue) {
|
|
|
15549
15575
|
canvas2.addEventListener(evt, function(e) {
|
|
15550
15576
|
if (e._vhandled) return;
|
|
15551
15577
|
const rect2 = canvas2.getBoundingClientRect();
|
|
15552
|
-
const x2 = e.clientX - rect2.left;
|
|
15553
|
-
const y2 = e.clientY - rect2.top;
|
|
15578
|
+
const x2 = (e.clientX - rect2.left) * canvas2.width / rect2.width;
|
|
15579
|
+
const y2 = (e.clientY - rect2.top) * canvas2.height / rect2.height;
|
|
15554
15580
|
for (const [path2, data] of path_data) {
|
|
15555
15581
|
if (ctx.isPointInPath(path2, x2, y2)) {
|
|
15556
15582
|
emit(evt, e, __props.getCoord(e), data);
|
|
@@ -15645,8 +15671,8 @@ var VVPlot = (function(exports, vue) {
|
|
|
15645
15671
|
canvas2.addEventListener(evt, function(e) {
|
|
15646
15672
|
if (e._vhandled) return;
|
|
15647
15673
|
const rect2 = canvas2.getBoundingClientRect();
|
|
15648
|
-
const x2 = e.clientX - rect2.left;
|
|
15649
|
-
const y2 = e.clientY - rect2.top;
|
|
15674
|
+
const x2 = (e.clientX - rect2.left) * canvas2.width / rect2.width;
|
|
15675
|
+
const y2 = (e.clientY - rect2.top) * canvas2.height / rect2.height;
|
|
15650
15676
|
for (const [path2, data] of path_data) {
|
|
15651
15677
|
if (ctx.isPointInPath(path2, x2, y2)) {
|
|
15652
15678
|
emit(evt, e, __props.getCoord(e), data);
|
|
@@ -15752,8 +15778,8 @@ var VVPlot = (function(exports, vue) {
|
|
|
15752
15778
|
canvas2.addEventListener(evt, function(e) {
|
|
15753
15779
|
if (e._vhandled) return;
|
|
15754
15780
|
const rect2 = canvas2.getBoundingClientRect();
|
|
15755
|
-
const x2 = e.clientX - rect2.left;
|
|
15756
|
-
const y2 = e.clientY - rect2.top;
|
|
15781
|
+
const x2 = (e.clientX - rect2.left) * canvas2.width / rect2.width;
|
|
15782
|
+
const y2 = (e.clientY - rect2.top) * canvas2.height / rect2.height;
|
|
15757
15783
|
for (const [path2, data] of path_data) {
|
|
15758
15784
|
if (ctx.isPointInPath(path2, x2, y2)) {
|
|
15759
15785
|
emit(evt, e, __props.getCoord(e), data);
|
|
@@ -15841,8 +15867,8 @@ var VVPlot = (function(exports, vue) {
|
|
|
15841
15867
|
canvas2.addEventListener(evt, function(e) {
|
|
15842
15868
|
if (e._vhandled) return;
|
|
15843
15869
|
const rect2 = canvas2.getBoundingClientRect();
|
|
15844
|
-
const x2 = e.clientX - rect2.left;
|
|
15845
|
-
const y2 = e.clientY - rect2.top;
|
|
15870
|
+
const x2 = (e.clientX - rect2.left) * canvas2.width / rect2.width;
|
|
15871
|
+
const y2 = (e.clientY - rect2.top) * canvas2.height / rect2.height;
|
|
15846
15872
|
for (const [path2, data] of path_data) {
|
|
15847
15873
|
if (ctx.isPointInPath(path2, x2, y2)) {
|
|
15848
15874
|
emit(evt, e, __props.getCoord(e), data);
|
|
@@ -15952,8 +15978,8 @@ var VVPlot = (function(exports, vue) {
|
|
|
15952
15978
|
canvas2.addEventListener(evt, function(e) {
|
|
15953
15979
|
if (e._vhandled) return;
|
|
15954
15980
|
const rect2 = canvas2.getBoundingClientRect();
|
|
15955
|
-
const x2 = e.clientX - rect2.left;
|
|
15956
|
-
const y2 = e.clientY - rect2.top;
|
|
15981
|
+
const x2 = (e.clientX - rect2.left) * canvas2.width / rect2.width;
|
|
15982
|
+
const y2 = (e.clientY - rect2.top) * canvas2.height / rect2.height;
|
|
15957
15983
|
for (const [path2, data] of path_data) {
|
|
15958
15984
|
if (ctx.isPointInPath(path2, x2, y2)) {
|
|
15959
15985
|
emit(evt, e, __props.getCoord(e), data);
|
|
@@ -16045,8 +16071,8 @@ var VVPlot = (function(exports, vue) {
|
|
|
16045
16071
|
canvas2.addEventListener(evt, function(e) {
|
|
16046
16072
|
if (e._vhandled) return;
|
|
16047
16073
|
const rect2 = canvas2.getBoundingClientRect();
|
|
16048
|
-
const x2 = e.clientX - rect2.left;
|
|
16049
|
-
const y2 = e.clientY - rect2.top;
|
|
16074
|
+
const x2 = (e.clientX - rect2.left) * canvas2.width / rect2.width;
|
|
16075
|
+
const y2 = (e.clientY - rect2.top) * canvas2.height / rect2.height;
|
|
16050
16076
|
for (const [path2, data] of path_data) {
|
|
16051
16077
|
if (ctx.isPointInPath(path2, x2, y2)) {
|
|
16052
16078
|
emit(evt, e, __props.getCoord(e), data);
|
|
@@ -16136,8 +16162,8 @@ var VVPlot = (function(exports, vue) {
|
|
|
16136
16162
|
canvas2.addEventListener(evt, function(e) {
|
|
16137
16163
|
if (e._vhandled) return;
|
|
16138
16164
|
const rect2 = canvas2.getBoundingClientRect();
|
|
16139
|
-
const x2 = e.clientX - rect2.left;
|
|
16140
|
-
const y2 = e.clientY - rect2.top;
|
|
16165
|
+
const x2 = (e.clientX - rect2.left) * canvas2.width / rect2.width;
|
|
16166
|
+
const y2 = (e.clientY - rect2.top) * canvas2.height / rect2.height;
|
|
16141
16167
|
for (const [path2, data] of path_data) {
|
|
16142
16168
|
if (ctx.isPointInPath(path2, x2, y2)) {
|
|
16143
16169
|
emit(evt, e, __props.getCoord(e), data);
|
|
@@ -16262,8 +16288,8 @@ var VVPlot = (function(exports, vue) {
|
|
|
16262
16288
|
canvas2.addEventListener(evt, function(e) {
|
|
16263
16289
|
if (e._vhandled) return;
|
|
16264
16290
|
const rect2 = canvas2.getBoundingClientRect();
|
|
16265
|
-
const x2 = e.clientX - rect2.left;
|
|
16266
|
-
const y2 = e.clientY - rect2.top;
|
|
16291
|
+
const x2 = (e.clientX - rect2.left) * canvas2.width / rect2.width;
|
|
16292
|
+
const y2 = (e.clientY - rect2.top) * canvas2.height / rect2.height;
|
|
16267
16293
|
for (const [path2, data] of path_data) {
|
|
16268
16294
|
if (ctx.isPointInPath(path2, x2, y2)) {
|
|
16269
16295
|
emit(evt, e, __props.getCoord(e), data);
|
|
@@ -16416,8 +16442,8 @@ var VVPlot = (function(exports, vue) {
|
|
|
16416
16442
|
canvas2.addEventListener(evt, function(e) {
|
|
16417
16443
|
if (e._vhandled) return;
|
|
16418
16444
|
const rect2 = canvas2.getBoundingClientRect();
|
|
16419
|
-
const x2 = e.clientX - rect2.left;
|
|
16420
|
-
const y2 = e.clientY - rect2.top;
|
|
16445
|
+
const x2 = (e.clientX - rect2.left) * canvas2.width / rect2.width;
|
|
16446
|
+
const y2 = (e.clientY - rect2.top) * canvas2.height / rect2.height;
|
|
16421
16447
|
for (const [path2, data] of path_data) {
|
|
16422
16448
|
if (ctx.isPointInPath(path2, x2, y2)) {
|
|
16423
16449
|
emit(evt, e, __props.getCoord(e), data);
|
|
@@ -16561,10 +16587,11 @@ var VVPlot = (function(exports, vue) {
|
|
|
16561
16587
|
"stroke-dasharray": parseLinetype(__props.linetype).join(" ") || null
|
|
16562
16588
|
};
|
|
16563
16589
|
if (d != null) {
|
|
16564
|
-
let transform =
|
|
16565
|
-
if (
|
|
16566
|
-
if (__props.
|
|
16567
|
-
|
|
16590
|
+
let transform = [], tslX = __props.x + __props.translateX, tslY = __props.y + __props.translateY;
|
|
16591
|
+
if (tslX !== 0 || tslY !== 0) transform.push(`translate(${tslX},${tslY})`);
|
|
16592
|
+
if (__props.size != 1) transform.push(`scale(${__props.size})`);
|
|
16593
|
+
if (__props.angle) transform.push(`rotate(${__props.angle})`);
|
|
16594
|
+
Object.assign(result, { d, transform: transform.join(" ") || null });
|
|
16568
16595
|
} else {
|
|
16569
16596
|
let transform = __props.translateX || __props.translateY ? `translate(${__props.translateX}, ${__props.translateY})` : null;
|
|
16570
16597
|
Object.assign(result, { cx: __props.x, cy: __props.y, r: __props.size / 2, transform });
|
|
@@ -16980,9 +17007,9 @@ var VVPlot = (function(exports, vue) {
|
|
|
16980
17007
|
let vbind = {
|
|
16981
17008
|
cx: ch,
|
|
16982
17009
|
cy: cv,
|
|
16983
|
-
rx: 1 / Math.sqrt(tr / 2 + disc),
|
|
16984
|
-
ry: 1 / Math.sqrt(tr / 2 - disc),
|
|
16985
|
-
angle: -Math.atan2(2 * B, A - C) / 2 * 180 / Math.PI,
|
|
17010
|
+
rx: 1 / Math.sqrt(tr / 2 + disc) || 0,
|
|
17011
|
+
ry: 1 / Math.sqrt(tr / 2 - disc) || 0,
|
|
17012
|
+
angle: -Math.atan2(2 * B, A - C) / 2 * 180 / Math.PI || 0,
|
|
16986
17013
|
fill,
|
|
16987
17014
|
color: color2,
|
|
16988
17015
|
linetype,
|
|
@@ -18234,18 +18261,23 @@ var VVPlot = (function(exports, vue) {
|
|
|
18234
18261
|
}));
|
|
18235
18262
|
let binds = categorize(keys.map((v) => v.bind));
|
|
18236
18263
|
let group = Map.groupBy(keys.map((v) => v.label), (v, i) => binds.categories[binds[i]]);
|
|
18237
|
-
return Array.from(group).map(([bind, labels]) =>
|
|
18238
|
-
bind,
|
|
18239
|
-
|
|
18240
|
-
|
|
18264
|
+
return Array.from(group).map(([$bind, labels]) => {
|
|
18265
|
+
let bind = { tile: {}, line: {}, point: {}, text: {} };
|
|
18266
|
+
for (let geom in bind) {
|
|
18267
|
+
for (let prop2 of Object.keys(element[geom].props)) {
|
|
18268
|
+
if ($bind[prop2]) bind[geom][prop2] = $bind[prop2];
|
|
18269
|
+
}
|
|
18270
|
+
}
|
|
18271
|
+
return { bind, label: labels.join("; ") };
|
|
18272
|
+
});
|
|
18241
18273
|
});
|
|
18242
18274
|
const geoms = vue.computed(() => {
|
|
18243
18275
|
let { text: text2, line: line2, point: point2, tile: tile2 } = __props.appearances;
|
|
18244
18276
|
let result = {};
|
|
18245
|
-
if (
|
|
18277
|
+
if (tile2 != null) result.tile = { width: 10, height: 10, fill: "transparent", ...tile2 };
|
|
18246
18278
|
if (line2 != null) result.line = { x1: -5, x2: 5, color: "black", ...line2 };
|
|
18247
18279
|
if (point2 != null) result.point = { size: 6, ...point2 };
|
|
18248
|
-
if (
|
|
18280
|
+
if (text2 != null) result.text = { size: 4, text: "a", ...text2 };
|
|
18249
18281
|
return result;
|
|
18250
18282
|
});
|
|
18251
18283
|
const width = vue.ref(0);
|
|
@@ -18268,7 +18300,7 @@ var VVPlot = (function(exports, vue) {
|
|
|
18268
18300
|
}, [
|
|
18269
18301
|
vue.createElementVNode("g", _hoisted_3$1, [
|
|
18270
18302
|
(vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(geoms.value, (bind, geom) => {
|
|
18271
|
-
return vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(element[geom]), vue.mergeProps({ ref_for: true }, { ...bind, ...v.bind }), null, 16);
|
|
18303
|
+
return vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(element[geom]), vue.mergeProps({ ref_for: true }, { ...bind, ...v.bind[geom] }), null, 16);
|
|
18272
18304
|
}), 256))
|
|
18273
18305
|
]),
|
|
18274
18306
|
_cache[0] || (_cache[0] = vue.createTextVNode()),
|
|
@@ -18291,7 +18323,7 @@ var VVPlot = (function(exports, vue) {
|
|
|
18291
18323
|
gradientbar: _sfc_main$v
|
|
18292
18324
|
};
|
|
18293
18325
|
const title = vue.computed(() => {
|
|
18294
|
-
return __props.scales.
|
|
18326
|
+
return __props.scales.reduce((v, [s]) => v ?? s.title, null) ?? __props.scales.reduce((v, [s]) => v ?? s._title, null);
|
|
18295
18327
|
});
|
|
18296
18328
|
const breaks = vue.computed(() => {
|
|
18297
18329
|
let scale_funcs = __props.scales.map(([s]) => s);
|
|
@@ -18310,10 +18342,10 @@ var VVPlot = (function(exports, vue) {
|
|
|
18310
18342
|
let result = { scales: __props.scales.map(([s]) => s) };
|
|
18311
18343
|
if (__props.type == "legendkey") {
|
|
18312
18344
|
result.appearances = {
|
|
18313
|
-
|
|
18345
|
+
tile: obj_merge(...__props.scales.flatMap(([s, a]) => [a.rect, a.tile, a.polygon, a.ellipse])),
|
|
18314
18346
|
line: obj_merge(...__props.scales.flatMap(([s, a]) => [a.line, a.linerange, a.curve])),
|
|
18315
18347
|
point: obj_merge(...__props.scales.flatMap(([s, a]) => [a.point])),
|
|
18316
|
-
|
|
18348
|
+
text: obj_merge(...__props.scales.flatMap(([s, a]) => [a.text, a.markdown]))
|
|
18317
18349
|
};
|
|
18318
18350
|
} else if (__props.type == "gradientbar") {
|
|
18319
18351
|
let max = __props.scales.map(([s]) => s.limits?.max).filter((v) => v != null).reduce((a, b) => Math.min(a, b), Infinity);
|
|
@@ -18340,15 +18372,13 @@ var VVPlot = (function(exports, vue) {
|
|
|
18340
18372
|
},
|
|
18341
18373
|
setup(__props) {
|
|
18342
18374
|
const guides = vue.computed(() => {
|
|
18343
|
-
let guide_scales = new Map(
|
|
18344
|
-
Array.from(__props.scales).filter(([fn]) => fn.legend !== false)
|
|
18345
|
-
);
|
|
18375
|
+
let guide_scales = new Map(Array.from(__props.scales).filter(([fn]) => fn.legend !== false));
|
|
18346
18376
|
let scale_fns = Array.from(guide_scales.keys());
|
|
18347
18377
|
let keys = scale_fns.map((s) => s.key);
|
|
18348
|
-
let
|
|
18349
|
-
for (let i
|
|
18350
|
-
while (keys.includes("_guide_" +
|
|
18351
|
-
|
|
18378
|
+
let n = 1;
|
|
18379
|
+
for (let i = 0; i < keys.length; i++) {
|
|
18380
|
+
while (keys.includes("_guide_" + n)) n++;
|
|
18381
|
+
keys[i] ??= keys.find((_, j) => keys[j] != null && GEnumLevel.isEqual(scale_fns[j].level, scale_fns[i].level)) ?? "_guide_" + n;
|
|
18352
18382
|
}
|
|
18353
18383
|
let types = scale_fns.map((s) => getGuideType(s));
|
|
18354
18384
|
let groups = interaction(keys, types);
|
|
@@ -18660,13 +18690,16 @@ var VVPlot = (function(exports, vue) {
|
|
|
18660
18690
|
}
|
|
18661
18691
|
function getCoord(event) {
|
|
18662
18692
|
let rect2 = svgRef.value.getBoundingClientRect();
|
|
18663
|
-
let
|
|
18693
|
+
let scaleX = rect2.width / svgRef.value.clientWidth, scaleY = rect2.height / svgRef.value.clientHeight;
|
|
18694
|
+
let offsetX = event.clientX - rect2.left, offsetY = event.clientY - rect2.top;
|
|
18695
|
+
let l = offsetX / scaleX - (panel.left + innerRect.left), t = offsetY / scaleY - (panel.top + innerRect.top), r = panel.left + innerRect.right - offsetX / scaleX, b = panel.top + innerRect.bottom - offsetY / scaleY;
|
|
18664
18696
|
let { x: x2, y: y2 } = pos2coord({ h: l, v: t });
|
|
18665
18697
|
return { l, t, r, b, x: x2, y: y2 };
|
|
18666
18698
|
}
|
|
18667
18699
|
function isInPlot(event) {
|
|
18668
18700
|
let rect2 = svgRef.value.getBoundingClientRect();
|
|
18669
|
-
|
|
18701
|
+
let scaleX = rect2.width / svgRef.value.clientWidth, scaleY = rect2.height / svgRef.value.clientHeight;
|
|
18702
|
+
return event.clientX - rect2.left > panel.l * scaleX && rect2.right - event.clientX > panel.r * scaleX && event.clientY - rect2.top > panel.t * scaleY && rect2.bottom - event.clientY > panel.b * scaleY;
|
|
18670
18703
|
}
|
|
18671
18704
|
function dispatchPointerEvent(e) {
|
|
18672
18705
|
if (!layers.value || e._vhandled || !isInPlot(e)) return e;
|
|
@@ -18790,6 +18823,8 @@ var VVPlot = (function(exports, vue) {
|
|
|
18790
18823
|
}
|
|
18791
18824
|
let act = props.action.find((a) => a.action == "move" && ["buttons", "ctrlKey", "shiftKey", "altKey", "metaKey"].every((k) => a[k] == e[k]));
|
|
18792
18825
|
if (act) {
|
|
18826
|
+
let rect2 = svgRef.value.getBoundingClientRect();
|
|
18827
|
+
let scaleX = rect2.width / svgRef.value.clientWidth, scaleY = rect2.height / svgRef.value.clientHeight;
|
|
18793
18828
|
e.target.setPointerCapture(e.pointerId);
|
|
18794
18829
|
svg2.style.userSelect = "none";
|
|
18795
18830
|
moveTimer = clearTimeout(moveTimer);
|
|
@@ -18800,13 +18835,13 @@ var VVPlot = (function(exports, vue) {
|
|
|
18800
18835
|
let [h, v] = __props.flip ? [y2, x2] : [x2, y2];
|
|
18801
18836
|
if (h) {
|
|
18802
18837
|
movementX += ev.movementX;
|
|
18803
|
-
let dh = oob_squish_any(-movementX, { min: boundary.hmin - hmin0, max: boundary.hmax - hmax0 });
|
|
18838
|
+
let dh = oob_squish_any(-movementX / scaleX, { min: boundary.hmin - hmin0, max: boundary.hmax - hmax0 });
|
|
18804
18839
|
h1 = hmin0 + dh;
|
|
18805
18840
|
h2 = hmax0 + dh;
|
|
18806
18841
|
}
|
|
18807
18842
|
if (v) {
|
|
18808
18843
|
movementY += ev.movementY;
|
|
18809
|
-
let dv = oob_squish_any(-movementY, { min: boundary.vmin - vmin0, max: boundary.vmax - vmax0 });
|
|
18844
|
+
let dv = oob_squish_any(-movementY / scaleY, { min: boundary.vmin - vmin0, max: boundary.vmax - vmax0 });
|
|
18810
18845
|
v1 = vmin0 + dv;
|
|
18811
18846
|
v2 = vmax0 + dv;
|
|
18812
18847
|
}
|