vvplot 0.1.2 → 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.
@@ -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 }
@@ -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 VVGeomCurve,
11
- _sfc_main$10 as VVGeomDensity,
12
- _sfc_main$11 as VVGeomHistogram,
13
- _sfc_main$12 as VVGeomLine,
14
- _sfc_main$13 as VVGeomLinerange,
15
- _sfc_main$14 as VVGeomPath,
16
- _sfc_main$15 as VVGeomPoint,
17
- _sfc_main$16 as VVGeomPolygon,
18
- _sfc_main$17 as VVGeomRect,
19
- _sfc_main$18 as VVGeomSegment,
20
- _sfc_main$19 as VVGeomStick,
21
- _sfc_main$20 as VVGeomText,
22
- _sfc_main$21 as VVGeomTextsegment,
23
- _sfc_main$22 as VVGeomTile,
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 VVGeomCurve,
11
- _sfc_main$10 as VVGeomDensity,
12
- _sfc_main$11 as VVGeomHistogram,
13
- _sfc_main$12 as VVGeomLine,
14
- _sfc_main$13 as VVGeomLinerange,
15
- _sfc_main$14 as VVGeomPath,
16
- _sfc_main$15 as VVGeomPoint,
17
- _sfc_main$16 as VVGeomPolygon,
18
- _sfc_main$17 as VVGeomRect,
19
- _sfc_main$18 as VVGeomSegment,
20
- _sfc_main$19 as VVGeomStick,
21
- _sfc_main$20 as VVGeomText,
22
- _sfc_main$21 as VVGeomTextsegment,
23
- _sfc_main$22 as VVGeomTile,
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
@@ -2734,6 +2734,16 @@ function continuous_scale({
2734
2734
  };
2735
2735
  return Object.assign(fn, { title, limits, oob: oob2 }, etc);
2736
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
+ }
2737
2747
  function palette_scale_hue({
2738
2748
  h = [15, 375],
2739
2749
  c = 100,
@@ -2880,30 +2890,6 @@ function palette_scale_dynamic({
2880
2890
  };
2881
2891
  return Object.assign(fn, { title, limits, oob: oob2 }, etc);
2882
2892
  }
2883
- const palette_scales = {
2884
- identity: scale_identity_string,
2885
- discrete: palette_scale_hue,
2886
- hue: palette_scale_hue,
2887
- manual: palette_scale_manual,
2888
- continuous: palette_scale_gradient,
2889
- gradient: palette_scale_gradient,
2890
- gradient2: palette_scale_gradient2,
2891
- gradientn: palette_scale_gradientn,
2892
- dynamic: palette_scale_dynamic,
2893
- auto: palette_scale_auto,
2894
- custom: custom_scale,
2895
- default: palette_scale_auto
2896
- };
2897
- function scale_identity_number({ title, ...etc } = {}) {
2898
- return Object.assign(function(arr) {
2899
- return arr.map((v) => +v);
2900
- }, { title }, etc);
2901
- }
2902
- function scale_identity_string({ title, ...etc } = {}) {
2903
- return Object.assign(function(arr) {
2904
- return arr.map((v) => String(v ?? ""));
2905
- }, { title }, etc);
2906
- }
2907
2893
  function shape_scale_discrete({ title, ...etc } = {}) {
2908
2894
  let shapes = ["circle", "square", "triangle", "diamond", "plus"];
2909
2895
  let fn = function(arr) {
@@ -2932,6 +2918,20 @@ function linetype_scale_discrete({ title, ...etc } = {}) {
2932
2918
  };
2933
2919
  return Object.assign(fn, { title }, etc);
2934
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
+ };
2935
2935
  const vvscale = {
2936
2936
  color: palette_scales,
2937
2937
  stroke: palette_scales,
@@ -2942,26 +2942,26 @@ const vvscale = {
2942
2942
  default: ({ title, ...etc } = {}) => continuous_scale({ range: [0.1, 1], title, ...etc })
2943
2943
  },
2944
2944
  size: {
2945
- identity: scale_identity_number,
2945
+ identity: ({ title, ...etc } = {}) => identity_scale_number({ legend: false, title, ...etc }),
2946
2946
  continuous: continuous_scale,
2947
2947
  custom: custom_scale,
2948
2948
  default: ({ title, ...etc } = {}) => continuous_scale({ range: [1, 6], title, ...etc })
2949
2949
  },
2950
2950
  linewidth: {
2951
- identity: scale_identity_number,
2951
+ identity: ({ title, ...etc } = {}) => identity_scale_number({ legend: false, title, ...etc }),
2952
2952
  continuous: continuous_scale,
2953
2953
  manual: manual_scale,
2954
2954
  custom: custom_scale,
2955
2955
  default: ({ title, ...etc } = {}) => continuous_scale({ range: [1, 6], title, ...etc })
2956
2956
  },
2957
2957
  linetype: {
2958
- identity: scale_identity_string,
2958
+ identity: ({ title, ...etc } = {}) => identity_scale_string({ legend: false, title, ...etc }),
2959
2959
  discrete: linetype_scale_discrete,
2960
2960
  default: linetype_scale_discrete,
2961
2961
  custom: custom_scale
2962
2962
  },
2963
2963
  shape: {
2964
- identity: scale_identity_string,
2964
+ identity: ({ title, ...etc } = {}) => identity_scale_string({ legend: false, title, ...etc }),
2965
2965
  discrete: shape_scale_discrete,
2966
2966
  default: shape_scale_discrete,
2967
2967
  custom: custom_scale
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] = Object.assign(acc[k] || {}, t[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([axis_h, axis_y]);
157
- axis_v = obj_merge([axis_v, axis_x]);
158
- grid_h = obj_merge([grid_h, grid_x]);
159
- grid_v = obj_merge([grid_v, grid_y]);
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([axis_h, axis_x]);
166
- axis_v = obj_merge([axis_v, axis_y]);
167
- grid_h = obj_merge([grid_h, grid_y]);
168
- grid_v = obj_merge([grid_v, grid_x]);
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
@@ -134,14 +134,53 @@ 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) => Object.assign(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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vvplot",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "license": "MIT",
5
5
  "files": [
6
6
  "dist"