vvplot 0.1.1 → 0.1.3
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/Selection.js +1320 -809
- package/dist/break.js +2 -2
- package/dist/components.d.ts +3 -0
- package/dist/components.js +16 -15
- package/dist/index.d.ts +3 -0
- package/dist/index.js +16 -15
- package/dist/scale.js +40 -34
- package/dist/style.css +0 -5
- package/dist/theme.js +20 -17
- package/dist/utils.js +50 -7
- package/package.json +6 -3
package/dist/break.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
function break_number({ step: $step, minor = false } = {}) {
|
|
2
|
-
return function({ min, max } = {}) {
|
|
1
|
+
function break_number({ step: $step, minor: $minor = false } = {}) {
|
|
2
|
+
return function({ min, max, minor = $minor } = {}) {
|
|
3
3
|
let interval = max - min, step = $step;
|
|
4
4
|
if (isNaN(interval) || interval < 0) return [];
|
|
5
5
|
if (interval == 0) return [min];
|
package/dist/components.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ import { default as VVAxisY } from './AxisY.vue';
|
|
|
5
5
|
import { default as VVGeom } from './Geom.vue';
|
|
6
6
|
import { default as VVGeomBar } from './GeomBar.vue';
|
|
7
7
|
import { default as VVGeomBlank } from './GeomBlank.vue';
|
|
8
|
+
import { default as VVGeomBoxplot } from './GeomBoxplot.vue';
|
|
8
9
|
import { default as VVGeomCurve } from './GeomCurve.vue';
|
|
9
10
|
import { default as VVGeomDensity } from './GeomDensity.vue';
|
|
10
11
|
import { default as VVGeomHistogram } from './GeomHistogram.vue';
|
|
@@ -36,6 +37,8 @@ export { VVGeomBar }
|
|
|
36
37
|
|
|
37
38
|
export { VVGeomBlank }
|
|
38
39
|
|
|
40
|
+
export { VVGeomBoxplot }
|
|
41
|
+
|
|
39
42
|
export { VVGeomCurve }
|
|
40
43
|
|
|
41
44
|
export { VVGeomDensity }
|
package/dist/components.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { _sfc_main$1, _sfc_main$3, _sfc_main$4, _sfc_main$5, _sfc_main$6, _sfc_main$7, _sfc_main$8, _sfc_main$9, _sfc_main$10, _sfc_main$11, _sfc_main$12, _sfc_main$13, _sfc_main$14, _sfc_main$15, _sfc_main$16, _sfc_main$17, _sfc_main$18, _sfc_main$19, _sfc_main$20, _sfc_main$21, _sfc_main$22, _sfc_main, _sfc_main$2 } from "./Selection.js";
|
|
1
|
+
import { _sfc_main$1, _sfc_main$3, _sfc_main$4, _sfc_main$5, _sfc_main$6, _sfc_main$7, _sfc_main$8, _sfc_main$9, _sfc_main$10, _sfc_main$11, _sfc_main$12, _sfc_main$13, _sfc_main$14, _sfc_main$15, _sfc_main$16, _sfc_main$17, _sfc_main$18, _sfc_main$19, _sfc_main$20, _sfc_main$21, _sfc_main$22, _sfc_main$23, _sfc_main, _sfc_main$2 } from "./Selection.js";
|
|
2
2
|
export {
|
|
3
3
|
_sfc_main$1 as VVAction,
|
|
4
4
|
_sfc_main$3 as VVAxis,
|
|
@@ -7,20 +7,21 @@ export {
|
|
|
7
7
|
_sfc_main$6 as VVGeom,
|
|
8
8
|
_sfc_main$7 as VVGeomBar,
|
|
9
9
|
_sfc_main$8 as VVGeomBlank,
|
|
10
|
-
_sfc_main$9 as
|
|
11
|
-
_sfc_main$10 as
|
|
12
|
-
_sfc_main$11 as
|
|
13
|
-
_sfc_main$12 as
|
|
14
|
-
_sfc_main$13 as
|
|
15
|
-
_sfc_main$14 as
|
|
16
|
-
_sfc_main$15 as
|
|
17
|
-
_sfc_main$16 as
|
|
18
|
-
_sfc_main$17 as
|
|
19
|
-
_sfc_main$18 as
|
|
20
|
-
_sfc_main$19 as
|
|
21
|
-
_sfc_main$20 as
|
|
22
|
-
_sfc_main$21 as
|
|
23
|
-
_sfc_main$22 as
|
|
10
|
+
_sfc_main$9 as VVGeomBoxplot,
|
|
11
|
+
_sfc_main$10 as VVGeomCurve,
|
|
12
|
+
_sfc_main$11 as VVGeomDensity,
|
|
13
|
+
_sfc_main$12 as VVGeomHistogram,
|
|
14
|
+
_sfc_main$13 as VVGeomLine,
|
|
15
|
+
_sfc_main$14 as VVGeomLinerange,
|
|
16
|
+
_sfc_main$15 as VVGeomPath,
|
|
17
|
+
_sfc_main$16 as VVGeomPoint,
|
|
18
|
+
_sfc_main$17 as VVGeomPolygon,
|
|
19
|
+
_sfc_main$18 as VVGeomRect,
|
|
20
|
+
_sfc_main$19 as VVGeomSegment,
|
|
21
|
+
_sfc_main$20 as VVGeomStick,
|
|
22
|
+
_sfc_main$21 as VVGeomText,
|
|
23
|
+
_sfc_main$22 as VVGeomTextsegment,
|
|
24
|
+
_sfc_main$23 as VVGeomTile,
|
|
24
25
|
_sfc_main as VVPlot,
|
|
25
26
|
_sfc_main$2 as VVSelection
|
|
26
27
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ import { default as VVAxisY } from './AxisY.vue';
|
|
|
5
5
|
import { default as VVGeom } from './Geom.vue';
|
|
6
6
|
import { default as VVGeomBar } from './GeomBar.vue';
|
|
7
7
|
import { default as VVGeomBlank } from './GeomBlank.vue';
|
|
8
|
+
import { default as VVGeomBoxplot } from './GeomBoxplot.vue';
|
|
8
9
|
import { default as VVGeomCurve } from './GeomCurve.vue';
|
|
9
10
|
import { default as VVGeomDensity } from './GeomDensity.vue';
|
|
10
11
|
import { default as VVGeomHistogram } from './GeomHistogram.vue';
|
|
@@ -36,6 +37,8 @@ export { VVGeomBar }
|
|
|
36
37
|
|
|
37
38
|
export { VVGeomBlank }
|
|
38
39
|
|
|
40
|
+
export { VVGeomBoxplot }
|
|
41
|
+
|
|
39
42
|
export { VVGeomCurve }
|
|
40
43
|
|
|
41
44
|
export { VVGeomDensity }
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { _sfc_main$1, _sfc_main$3, _sfc_main$4, _sfc_main$5, _sfc_main$6, _sfc_main$7, _sfc_main$8, _sfc_main$9, _sfc_main$10, _sfc_main$11, _sfc_main$12, _sfc_main$13, _sfc_main$14, _sfc_main$15, _sfc_main$16, _sfc_main$17, _sfc_main$18, _sfc_main$19, _sfc_main$20, _sfc_main$21, _sfc_main$22, _sfc_main, _sfc_main$2 } from "./Selection.js";
|
|
1
|
+
import { _sfc_main$1, _sfc_main$3, _sfc_main$4, _sfc_main$5, _sfc_main$6, _sfc_main$7, _sfc_main$8, _sfc_main$9, _sfc_main$10, _sfc_main$11, _sfc_main$12, _sfc_main$13, _sfc_main$14, _sfc_main$15, _sfc_main$16, _sfc_main$17, _sfc_main$18, _sfc_main$19, _sfc_main$20, _sfc_main$21, _sfc_main$22, _sfc_main$23, _sfc_main, _sfc_main$2 } from "./Selection.js";
|
|
2
2
|
export {
|
|
3
3
|
_sfc_main$1 as VVAction,
|
|
4
4
|
_sfc_main$3 as VVAxis,
|
|
@@ -7,20 +7,21 @@ export {
|
|
|
7
7
|
_sfc_main$6 as VVGeom,
|
|
8
8
|
_sfc_main$7 as VVGeomBar,
|
|
9
9
|
_sfc_main$8 as VVGeomBlank,
|
|
10
|
-
_sfc_main$9 as
|
|
11
|
-
_sfc_main$10 as
|
|
12
|
-
_sfc_main$11 as
|
|
13
|
-
_sfc_main$12 as
|
|
14
|
-
_sfc_main$13 as
|
|
15
|
-
_sfc_main$14 as
|
|
16
|
-
_sfc_main$15 as
|
|
17
|
-
_sfc_main$16 as
|
|
18
|
-
_sfc_main$17 as
|
|
19
|
-
_sfc_main$18 as
|
|
20
|
-
_sfc_main$19 as
|
|
21
|
-
_sfc_main$20 as
|
|
22
|
-
_sfc_main$21 as
|
|
23
|
-
_sfc_main$22 as
|
|
10
|
+
_sfc_main$9 as VVGeomBoxplot,
|
|
11
|
+
_sfc_main$10 as VVGeomCurve,
|
|
12
|
+
_sfc_main$11 as VVGeomDensity,
|
|
13
|
+
_sfc_main$12 as VVGeomHistogram,
|
|
14
|
+
_sfc_main$13 as VVGeomLine,
|
|
15
|
+
_sfc_main$14 as VVGeomLinerange,
|
|
16
|
+
_sfc_main$15 as VVGeomPath,
|
|
17
|
+
_sfc_main$16 as VVGeomPoint,
|
|
18
|
+
_sfc_main$17 as VVGeomPolygon,
|
|
19
|
+
_sfc_main$18 as VVGeomRect,
|
|
20
|
+
_sfc_main$19 as VVGeomSegment,
|
|
21
|
+
_sfc_main$20 as VVGeomStick,
|
|
22
|
+
_sfc_main$21 as VVGeomText,
|
|
23
|
+
_sfc_main$22 as VVGeomTextsegment,
|
|
24
|
+
_sfc_main$23 as VVGeomTile,
|
|
24
25
|
_sfc_main as VVPlot,
|
|
25
26
|
_sfc_main$2 as VVSelection
|
|
26
27
|
};
|
package/dist/scale.js
CHANGED
|
@@ -2691,6 +2691,11 @@ const oob = {
|
|
|
2691
2691
|
return value;
|
|
2692
2692
|
}
|
|
2693
2693
|
};
|
|
2694
|
+
function custom_scale(func, { title, ...etc } = {}) {
|
|
2695
|
+
return Object.assign(function(arr) {
|
|
2696
|
+
return arr.map(func);
|
|
2697
|
+
}, { title }, etc);
|
|
2698
|
+
}
|
|
2694
2699
|
function manual_scale({
|
|
2695
2700
|
values = {},
|
|
2696
2701
|
na_value = null,
|
|
@@ -2729,6 +2734,16 @@ function continuous_scale({
|
|
|
2729
2734
|
};
|
|
2730
2735
|
return Object.assign(fn, { title, limits, oob: oob2 }, etc);
|
|
2731
2736
|
}
|
|
2737
|
+
function identity_scale_number({ title, ...etc } = {}) {
|
|
2738
|
+
return Object.assign(function(arr) {
|
|
2739
|
+
return arr.map((v) => +v);
|
|
2740
|
+
}, { asis: true, title }, etc);
|
|
2741
|
+
}
|
|
2742
|
+
function identity_scale_string({ title, ...etc } = {}) {
|
|
2743
|
+
return Object.assign(function(arr) {
|
|
2744
|
+
return arr.map((v) => String(v ?? ""));
|
|
2745
|
+
}, { asis: true, title }, etc);
|
|
2746
|
+
}
|
|
2732
2747
|
function palette_scale_hue({
|
|
2733
2748
|
h = [15, 375],
|
|
2734
2749
|
c = 100,
|
|
@@ -2875,29 +2890,6 @@ function palette_scale_dynamic({
|
|
|
2875
2890
|
};
|
|
2876
2891
|
return Object.assign(fn, { title, limits, oob: oob2 }, etc);
|
|
2877
2892
|
}
|
|
2878
|
-
const palette_scales = {
|
|
2879
|
-
identity: scale_identity_string,
|
|
2880
|
-
discrete: palette_scale_hue,
|
|
2881
|
-
hue: palette_scale_hue,
|
|
2882
|
-
manual: palette_scale_manual,
|
|
2883
|
-
continuous: palette_scale_gradient,
|
|
2884
|
-
gradient: palette_scale_gradient,
|
|
2885
|
-
gradient2: palette_scale_gradient2,
|
|
2886
|
-
gradientn: palette_scale_gradientn,
|
|
2887
|
-
dynamic: palette_scale_dynamic,
|
|
2888
|
-
auto: palette_scale_auto,
|
|
2889
|
-
default: palette_scale_auto
|
|
2890
|
-
};
|
|
2891
|
-
function scale_identity_number({ title, ...etc } = {}) {
|
|
2892
|
-
return Object.assign(function(arr) {
|
|
2893
|
-
return arr.map((v) => +v);
|
|
2894
|
-
}, { title }, etc);
|
|
2895
|
-
}
|
|
2896
|
-
function scale_identity_string({ title, ...etc } = {}) {
|
|
2897
|
-
return Object.assign(function(arr) {
|
|
2898
|
-
return arr.map((v) => String(v ?? ""));
|
|
2899
|
-
}, { title }, etc);
|
|
2900
|
-
}
|
|
2901
2893
|
function shape_scale_discrete({ title, ...etc } = {}) {
|
|
2902
2894
|
let shapes = ["circle", "square", "triangle", "diamond", "plus"];
|
|
2903
2895
|
let fn = function(arr) {
|
|
@@ -2926,39 +2918,53 @@ function linetype_scale_discrete({ title, ...etc } = {}) {
|
|
|
2926
2918
|
};
|
|
2927
2919
|
return Object.assign(fn, { title }, etc);
|
|
2928
2920
|
}
|
|
2921
|
+
const palette_scales = {
|
|
2922
|
+
identity: ({ title, ...etc } = {}) => identity_scale_string({ legend: false, title, ...etc }),
|
|
2923
|
+
discrete: palette_scale_hue,
|
|
2924
|
+
hue: palette_scale_hue,
|
|
2925
|
+
manual: palette_scale_manual,
|
|
2926
|
+
continuous: palette_scale_gradient,
|
|
2927
|
+
gradient: palette_scale_gradient,
|
|
2928
|
+
gradient2: palette_scale_gradient2,
|
|
2929
|
+
gradientn: palette_scale_gradientn,
|
|
2930
|
+
dynamic: palette_scale_dynamic,
|
|
2931
|
+
auto: palette_scale_auto,
|
|
2932
|
+
custom: custom_scale,
|
|
2933
|
+
default: palette_scale_auto
|
|
2934
|
+
};
|
|
2929
2935
|
const vvscale = {
|
|
2930
2936
|
color: palette_scales,
|
|
2931
2937
|
stroke: palette_scales,
|
|
2932
2938
|
fill: palette_scales,
|
|
2933
2939
|
alpha: {
|
|
2934
2940
|
continuous: continuous_scale,
|
|
2941
|
+
custom: custom_scale,
|
|
2935
2942
|
default: ({ title, ...etc } = {}) => continuous_scale({ range: [0.1, 1], title, ...etc })
|
|
2936
2943
|
},
|
|
2937
2944
|
size: {
|
|
2938
|
-
identity:
|
|
2945
|
+
identity: ({ title, ...etc } = {}) => identity_scale_number({ legend: false, title, ...etc }),
|
|
2939
2946
|
continuous: continuous_scale,
|
|
2947
|
+
custom: custom_scale,
|
|
2940
2948
|
default: ({ title, ...etc } = {}) => continuous_scale({ range: [1, 6], title, ...etc })
|
|
2941
2949
|
},
|
|
2942
2950
|
linewidth: {
|
|
2943
|
-
identity:
|
|
2951
|
+
identity: ({ title, ...etc } = {}) => identity_scale_number({ legend: false, title, ...etc }),
|
|
2944
2952
|
continuous: continuous_scale,
|
|
2945
2953
|
manual: manual_scale,
|
|
2954
|
+
custom: custom_scale,
|
|
2946
2955
|
default: ({ title, ...etc } = {}) => continuous_scale({ range: [1, 6], title, ...etc })
|
|
2947
2956
|
},
|
|
2948
2957
|
linetype: {
|
|
2949
|
-
identity:
|
|
2958
|
+
identity: ({ title, ...etc } = {}) => identity_scale_string({ legend: false, title, ...etc }),
|
|
2950
2959
|
discrete: linetype_scale_discrete,
|
|
2951
|
-
default: linetype_scale_discrete
|
|
2960
|
+
default: linetype_scale_discrete,
|
|
2961
|
+
custom: custom_scale
|
|
2952
2962
|
},
|
|
2953
2963
|
shape: {
|
|
2954
|
-
identity:
|
|
2964
|
+
identity: ({ title, ...etc } = {}) => identity_scale_string({ legend: false, title, ...etc }),
|
|
2955
2965
|
discrete: shape_scale_discrete,
|
|
2956
|
-
default: shape_scale_discrete
|
|
2957
|
-
|
|
2958
|
-
custom(func, { title, ...etc } = {}) {
|
|
2959
|
-
return Object.assign(function(arr) {
|
|
2960
|
-
return arr.map(func);
|
|
2961
|
-
}, { title }, etc);
|
|
2966
|
+
default: shape_scale_discrete,
|
|
2967
|
+
custom: custom_scale
|
|
2962
2968
|
}
|
|
2963
2969
|
};
|
|
2964
2970
|
export {
|
package/dist/style.css
CHANGED
package/dist/theme.js
CHANGED
|
@@ -41,6 +41,9 @@ const theme_base = {
|
|
|
41
41
|
},
|
|
42
42
|
legend: {
|
|
43
43
|
spacing: 4
|
|
44
|
+
},
|
|
45
|
+
selection: {
|
|
46
|
+
background: "#00000020"
|
|
44
47
|
}
|
|
45
48
|
};
|
|
46
49
|
const theme_default = {
|
|
@@ -123,7 +126,7 @@ function themeMerge(...themes) {
|
|
|
123
126
|
if (t[k] === null) {
|
|
124
127
|
acc[k] = null;
|
|
125
128
|
} else {
|
|
126
|
-
acc[k] =
|
|
129
|
+
acc[k] = obj_merge(acc[k], t[k]);
|
|
127
130
|
}
|
|
128
131
|
}
|
|
129
132
|
return acc ?? void 0;
|
|
@@ -153,19 +156,19 @@ function themePreprocess(theme2, flip = false) {
|
|
|
153
156
|
...rest
|
|
154
157
|
} = theme2;
|
|
155
158
|
if (flip) {
|
|
156
|
-
axis_h = obj_merge(
|
|
157
|
-
axis_v = obj_merge(
|
|
158
|
-
grid_h = obj_merge(
|
|
159
|
-
grid_v = obj_merge(
|
|
159
|
+
axis_h = obj_merge(axis_h, axis_y);
|
|
160
|
+
axis_v = obj_merge(axis_v, axis_x);
|
|
161
|
+
grid_h = obj_merge(grid_h, grid_x);
|
|
162
|
+
grid_v = obj_merge(grid_v, grid_y);
|
|
160
163
|
plot.margin_h = margin_y === void 0 ? margin_h : margin_y;
|
|
161
164
|
plot.margin_v = margin_x === void 0 ? margin_v : margin_x;
|
|
162
165
|
plot.padding_h = padding_y === void 0 ? padding_h : padding_y;
|
|
163
166
|
plot.padding_v = padding_x === void 0 ? padding_v : padding_x;
|
|
164
167
|
} else {
|
|
165
|
-
axis_h = obj_merge(
|
|
166
|
-
axis_v = obj_merge(
|
|
167
|
-
grid_h = obj_merge(
|
|
168
|
-
grid_v = obj_merge(
|
|
168
|
+
axis_h = obj_merge(axis_h, axis_x);
|
|
169
|
+
axis_v = obj_merge(axis_v, axis_y);
|
|
170
|
+
grid_h = obj_merge(grid_h, grid_y);
|
|
171
|
+
grid_v = obj_merge(grid_v, grid_x);
|
|
169
172
|
plot.margin_h = margin_x === void 0 ? margin_h : margin_x;
|
|
170
173
|
plot.margin_v = margin_y === void 0 ? margin_v : margin_y;
|
|
171
174
|
plot.padding_h = padding_x === void 0 ? padding_h : padding_x;
|
|
@@ -191,24 +194,24 @@ function themeBuild(theme2) {
|
|
|
191
194
|
}
|
|
192
195
|
return {
|
|
193
196
|
axis: {
|
|
194
|
-
h: obj_merge(["axis", "axis_h"].map((k) => theme2?.[k])),
|
|
195
|
-
v: obj_merge(["axis", "axis_v"].map((k) => theme2?.[k])),
|
|
197
|
+
h: obj_merge(...["axis", "axis_h"].map((k) => theme2?.[k])),
|
|
198
|
+
v: obj_merge(...["axis", "axis_v"].map((k) => theme2?.[k])),
|
|
196
199
|
left: obj_merge(
|
|
197
|
-
["axis", "axis_v", "axis_left"].map((k) => theme2?.[k])
|
|
200
|
+
...["axis", "axis_v", "axis_left"].map((k) => theme2?.[k])
|
|
198
201
|
),
|
|
199
202
|
right: obj_merge(
|
|
200
|
-
["axis", "axis_v", "axis_right"].map((k) => theme2?.[k])
|
|
203
|
+
...["axis", "axis_v", "axis_right"].map((k) => theme2?.[k])
|
|
201
204
|
),
|
|
202
205
|
top: obj_merge(
|
|
203
|
-
["axis", "axis_h", "axis_top"].map((k) => theme2?.[k])
|
|
206
|
+
...["axis", "axis_h", "axis_top"].map((k) => theme2?.[k])
|
|
204
207
|
),
|
|
205
208
|
bottom: obj_merge(
|
|
206
|
-
["axis", "axis_h", "axis_bottom"].map((k) => theme2?.[k])
|
|
209
|
+
...["axis", "axis_h", "axis_bottom"].map((k) => theme2?.[k])
|
|
207
210
|
)
|
|
208
211
|
},
|
|
209
212
|
grid: {
|
|
210
|
-
h: _grid_build(obj_merge(["grid", "grid_h"].map((k) => theme2?.[k]))),
|
|
211
|
-
v: _grid_build(obj_merge(["grid", "grid_v"].map((k) => theme2?.[k])))
|
|
213
|
+
h: _grid_build(obj_merge(...["grid", "grid_h"].map((k) => theme2?.[k]))),
|
|
214
|
+
v: _grid_build(obj_merge(...["grid", "grid_v"].map((k) => theme2?.[k])))
|
|
212
215
|
},
|
|
213
216
|
plot: {
|
|
214
217
|
margin: {
|
package/dist/utils.js
CHANGED
|
@@ -111,11 +111,11 @@ const numutils = {
|
|
|
111
111
|
return arr[lo] * (hi - idx) + arr[hi] * (idx - lo);
|
|
112
112
|
},
|
|
113
113
|
extent(arr, { na_rm = true, infinity_rm = true } = {}) {
|
|
114
|
-
if (arr.length == 0) return [];
|
|
115
114
|
if (na_rm) arr = arr.filter(isContinuous);
|
|
116
115
|
if (infinity_rm) arr = arr.filter((x) => isFinite(x));
|
|
116
|
+
if (arr.length == 0) return new Array(2);
|
|
117
117
|
let min = Array.from(arr).reduce((a, b) => a < b ? a : b, Infinity), max = Array.from(arr).reduce((a, b) => a > b ? a : b, -Infinity);
|
|
118
|
-
return
|
|
118
|
+
return Object.assign([min, max], { min, max });
|
|
119
119
|
}
|
|
120
120
|
};
|
|
121
121
|
const vecutils = {
|
|
@@ -134,23 +134,66 @@ const vecutils = {
|
|
|
134
134
|
if (values.some((v) => v.length != length))
|
|
135
135
|
throw new Error("Arrays must have the same length");
|
|
136
136
|
return Array.from({ length }, (_, i) => values.reduce((s, a) => +a[i] + s, nums));
|
|
137
|
+
},
|
|
138
|
+
/* vectorized opposite of numbers */
|
|
139
|
+
opposite(value) {
|
|
140
|
+
if (value == null) return null;
|
|
141
|
+
if (!Array.isArray(value) && typeof value != "number")
|
|
142
|
+
throw new Error("Arguments must be numbers or arrays");
|
|
143
|
+
if (Array.isArray(value))
|
|
144
|
+
return value.map((v) => v == null ? v : -v);
|
|
145
|
+
return -value;
|
|
146
|
+
},
|
|
147
|
+
/* vectorized concat of strings */
|
|
148
|
+
concat(...values) {
|
|
149
|
+
if (values.some((x) => x == null)) return null;
|
|
150
|
+
let arrs = values.filter((x) => Array.isArray(x));
|
|
151
|
+
if (arrs.length == 0) return [values.join("")];
|
|
152
|
+
if (values.some((v) => v.length == 0))
|
|
153
|
+
return [];
|
|
154
|
+
let length = arrs[0].length;
|
|
155
|
+
if (arrs.some((v) => v.length != length))
|
|
156
|
+
throw new Error("Arrays must have the same length");
|
|
157
|
+
return Array.from({ length }, (_, i) => values.map((a) => Array.isArray(a) ? a[i] : a).join(""));
|
|
158
|
+
},
|
|
159
|
+
/* vectorized function application */
|
|
160
|
+
apply(func, ...values) {
|
|
161
|
+
if (values.some((x) => x == null)) return null;
|
|
162
|
+
let arrs = values.filter((x) => Array.isArray(x));
|
|
163
|
+
if (arrs.length == 0) return [func(...values)];
|
|
164
|
+
if (values.some((v) => v.length == 0))
|
|
165
|
+
return [];
|
|
166
|
+
let length = arrs[0].length;
|
|
167
|
+
if (arrs.some((v) => v.length != length))
|
|
168
|
+
throw new Error("Arrays must have the same length");
|
|
169
|
+
return Array.from({ length }, (_, i) => func(...values.map((a) => Array.isArray(a) ? a[i] : a)));
|
|
137
170
|
}
|
|
138
171
|
};
|
|
139
|
-
function obj_merge(arr) {
|
|
172
|
+
function obj_merge(...arr) {
|
|
140
173
|
arr = arr.filter((x) => x !== void 0);
|
|
141
174
|
if (arr.length == 0) return void 0;
|
|
142
175
|
arr = arr.slice(arr.findIndex((x) => x == null) + 1);
|
|
143
176
|
if (arr.length == 0) return null;
|
|
144
|
-
return arr.reduce((a, c) =>
|
|
177
|
+
return arr.reduce((a, c) => {
|
|
178
|
+
for (let k in c) {
|
|
179
|
+
if (c[k] === null) delete a[k];
|
|
180
|
+
if (c[k] != void 0) a[k] = c[k];
|
|
181
|
+
}
|
|
182
|
+
return a;
|
|
183
|
+
}, {});
|
|
145
184
|
}
|
|
146
185
|
function str_c(...args) {
|
|
147
186
|
if (args.some((x) => x === void 0)) return void 0;
|
|
148
187
|
if (args.some((x) => x === null)) return null;
|
|
149
188
|
return args.join("");
|
|
150
189
|
}
|
|
151
|
-
function unique(arr) {
|
|
152
|
-
|
|
153
|
-
|
|
190
|
+
function unique(arr, mapper = null) {
|
|
191
|
+
let map = /* @__PURE__ */ new Map();
|
|
192
|
+
for (let i in arr) {
|
|
193
|
+
let key = mapper ? mapper(arr[i]) : arr[i];
|
|
194
|
+
if (!map.has(key)) map.set(key, arr[i]);
|
|
195
|
+
}
|
|
196
|
+
return Array.from(map.values());
|
|
154
197
|
}
|
|
155
198
|
function compare(a, b, { numeric = false } = {}) {
|
|
156
199
|
if (typeof a != "number" || typeof b != "number")
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vvplot",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist"
|
|
@@ -15,8 +15,6 @@
|
|
|
15
15
|
"imports": {
|
|
16
16
|
"#base/*": "./src/*"
|
|
17
17
|
},
|
|
18
|
-
"homepage": "https://fan-ix.github.io/vvplot/",
|
|
19
|
-
"repository": "https://github.com/Fan-iX/vvplot/",
|
|
20
18
|
"exports": {
|
|
21
19
|
".": "./dist/index.js",
|
|
22
20
|
"./components": "./dist/components.js",
|
|
@@ -26,6 +24,11 @@
|
|
|
26
24
|
"./label": "./dist/label.js",
|
|
27
25
|
"./style.css": "./dist/style.css"
|
|
28
26
|
},
|
|
27
|
+
"homepage": "https://fan-ix.github.io/vvplot/",
|
|
28
|
+
"repository": "https://github.com/Fan-iX/vvplot/",
|
|
29
|
+
"publishConfig": {
|
|
30
|
+
"access": "public"
|
|
31
|
+
},
|
|
29
32
|
"dependencies": {
|
|
30
33
|
"@vueuse/core": "^13.7.0",
|
|
31
34
|
"d3": "^7.9.0",
|