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