svelteplot 0.0.1-alpha.23 → 0.0.1-alpha.25

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/Plot.svelte CHANGED
@@ -74,7 +74,13 @@ const onMouseMove = (evt) => {
74
74
  let hasLegend = $derived(color?.legend || symbol?.legend);
75
75
  </script>
76
76
 
77
- <figure data-testid={testid} class="svelteplot" bind:clientWidth={width} style:max-width={maxWidth}>
77
+ <figure
78
+ data-testid={testid} class="svelteplot"
79
+ data-reactive-hack-x={plot.x.dataValues.length}
80
+ data-reactive-hack-y={plot.y.dataValues.length}
81
+ data-reactive-hack-color={plot.color.dataValues.length}
82
+ data-reactive-hack-symbol={plot.symbol.dataValues.length}
83
+ bind:clientWidth={width} style:max-width={maxWidth}>
78
84
  <div
79
85
  role="document"
80
86
  class="plot-body"
@@ -50,21 +50,6 @@ export class Scale {
50
50
  isColor = $derived(this.name === 'color');
51
51
  scaleType = $derived(this.scaleOptions.type ||
52
52
  inferScaleType(this.dataValues, { isPosition: this.isPosition, isColor: this.isColor }));
53
- // readonly valueType = $derived(
54
- // this.dataValues.every((v) => v == null)
55
- // ? 'null'
56
- // : this.dataValues.every(isColorOrNull)
57
- // ? 'color'
58
- // : this.dataValues.every(isBooleanOrNull)
59
- // ? 'boolean'
60
- // : this.dataValues.every(isStringOrNull)
61
- // ? 'text'
62
- // : this.dataValues.every(isNumberOrNull)
63
- // ? 'number'
64
- // : this.dataValues.every(isDateOrNull)
65
- // ? 'date'
66
- // : 'mixed'
67
- // );
68
53
  domain = $derived(this.scaleOptions.domain || inferScaleDomain(this.dataValues, this.scaleType));
69
54
  }
70
55
  // opacity: typeof === 'number' && between [0,1]
@@ -14,8 +14,10 @@ let {
14
14
  data,
15
15
  curve,
16
16
  tension,
17
+ x = null,
17
18
  x1 = null,
18
19
  x2 = null,
20
+ y = null,
19
21
  y1 = null,
20
22
  y2 = null,
21
23
  z = null,
@@ -25,9 +27,9 @@ let {
25
27
  ...styleProps
26
28
  } = $props();
27
29
  let channels = $derived({
28
- x1,
30
+ x1: x1 == null ? x : x1,
29
31
  x2,
30
- y1,
32
+ y1: y1 == null ? y : y1,
31
33
  y2,
32
34
  fill,
33
35
  stroke,
@@ -45,7 +47,7 @@ let sortedGroups = $derived(
45
47
  let areaPath = $derived(
46
48
  callWithProps(area, [], {
47
49
  curve: maybeCurve(curve, tension),
48
- ...x1 != null && x2 != null ? {
50
+ ...channels.x1 != null && channels.x2 != null ? {
49
51
  // "vertical" area
50
52
  x0: (d) => plot.xScale(resolveChannel("x1", d, channels)),
51
53
  x1: (d) => plot.xScale(resolveChannel("x2", d, channels)),
@@ -58,15 +60,16 @@ let areaPath = $derived(
58
60
  }
59
61
  })
60
62
  );
63
+ $inspect({ channels, x });
61
64
  </script>
62
65
 
63
66
  <BaseMark_Area
64
67
  type="area"
65
68
  {data}
66
69
  channels={['x1', 'x2', 'y1', 'y2', 'fill', 'stroke']}
67
- {x1}
70
+ x1={x1 != null ? x1 : x}
68
71
  {x2}
69
- {y1}
72
+ y1={y1 != null ? y1 : y}
70
73
  {y2}
71
74
  {fill}
72
75
  {stroke}
@@ -1,8 +1,10 @@
1
1
  import { SvelteComponentTyped } from "svelte";
2
2
  import type { MarkProps, BaseMarkStyleProps, ChannelAccessor, Curve } from '../types.js';
3
3
  export type AreaMarkProps = MarkProps & BaseMarkStyleProps & {
4
+ x?: ChannelAccessor;
4
5
  x1?: ChannelAccessor;
5
6
  x2?: ChannelAccessor;
7
+ y?: ChannelAccessor;
6
8
  y1?: ChannelAccessor;
7
9
  y2?: ChannelAccessor;
8
10
  z?: ChannelAccessor;
@@ -1,10 +1,10 @@
1
1
  <script context="module"></script>
2
2
 
3
3
  <script>import Area from "./Area.svelte";
4
- import { stackX, recordizeX, renameChannels } from "..";
4
+ import { stackX, recordizeX } from "..";
5
5
  let { data: rawData, stack, ...rawChannels } = $props();
6
6
  let { data, ...channels } = $derived(
7
- renameChannels(stackX(recordizeX({ data: rawData, ...rawChannels }), stack), { y: "y1" })
7
+ stackX(recordizeX({ data: rawData, ...rawChannels }), stack)
8
8
  );
9
9
  </script>
10
10
 
@@ -1,10 +1,10 @@
1
1
  <script context="module"></script>
2
2
 
3
3
  <script>import Area from "./Area.svelte";
4
- import { stackY, recordizeY, renameChannels } from "..";
4
+ import { stackY, recordizeY } from "..";
5
5
  let { data: rawData, stack, ...rawChannels } = $props();
6
6
  let { data, ...channels } = $derived(
7
- renameChannels(stackY(recordizeY({ data: rawData, ...rawChannels }), stack), { x: "x1" })
7
+ stackY(recordizeY({ data: rawData, ...rawChannels }), stack)
8
8
  );
9
9
  $inspect({ data, channels });
10
10
  </script>
@@ -56,7 +56,6 @@ function stackXY(byDim, data, channels, options) {
56
56
  });
57
57
  })
58
58
  .flat(1);
59
- console.log({ newData });
60
59
  return {
61
60
  data: newData,
62
61
  ...channels,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "svelteplot",
3
- "version": "0.0.1-alpha.23",
3
+ "version": "0.0.1-alpha.25",
4
4
  "scripts": {
5
5
  "dev": "vite dev",
6
6
  "build": "vite build",
@@ -29,6 +29,7 @@
29
29
  "devDependencies": {
30
30
  "@playwright/test": "^1.40.1",
31
31
  "@sveltejs/adapter-auto": "^3.1.0",
32
+ "@sveltejs/adapter-static": "^3.0.1",
32
33
  "@sveltejs/kit": "^2.3.2",
33
34
  "@sveltejs/package": "^2.2.5",
34
35
  "@sveltejs/vite-plugin-svelte": "^3.0.1",