@rokkit/chart 1.0.0-next.16 → 1.0.0-next.18

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rokkit/chart",
3
- "version": "1.0.0-next.16",
3
+ "version": "1.0.0-next.18",
4
4
  "description": "Components for making interactive charts.",
5
5
  "author": "Jerry Thomas <me@jerrythomas.name>",
6
6
  "license": "MIT",
@@ -13,28 +13,28 @@
13
13
  "access": "public"
14
14
  },
15
15
  "devDependencies": {
16
- "@sveltejs/vite-plugin-svelte": "^2.0.2",
16
+ "@sveltejs/vite-plugin-svelte": "^2.1.1",
17
17
  "@testing-library/svelte": "^3.2.2",
18
18
  "@vitest/ui": "~0.12.10",
19
- "eslint": "^8.33.0",
19
+ "eslint": "^8.39.0",
20
20
  "js-yaml": "^4.1.0",
21
21
  "jsdom": "^19.0.0",
22
- "svelte": "^3.55.1",
22
+ "svelte": "^3.58.0",
23
23
  "typescript": "^4.9.5",
24
- "vite": "^4.1.1",
24
+ "vite": "^4.3.2",
25
25
  "vitest": "~0.19.1",
26
- "shared-config": "1.0.0",
27
- "eslint-config-shared": "1.0.0"
26
+ "eslint-config-shared": "1.0.0",
27
+ "shared-config": "1.0.0"
28
28
  },
29
29
  "dependencies": {
30
- "d3-array": "^3.2.2",
30
+ "d3-array": "^3.2.3",
31
31
  "d3-collection": "^1.0.7",
32
32
  "d3-scale": "^4.0.2",
33
33
  "d3-shape": "^3.2.0",
34
34
  "date-fns": "^2.29.3",
35
35
  "ramda": "^0.28.0",
36
36
  "yootils": "^0.3.1",
37
- "@rokkit/core": "1.0.0-next.16"
37
+ "@rokkit/core": "1.0.0-next.18"
38
38
  },
39
39
  "files": [
40
40
  "src/**/*.js",
@@ -17,7 +17,7 @@
17
17
  export let rows
18
18
  export let limit
19
19
  export let start = 0
20
- export let autoscale = false
20
+ // export let autoscale = false
21
21
  export let interactive = false
22
22
  export let activeIndex = -1
23
23
 
@@ -7,7 +7,7 @@
7
7
  import Axis from './Axis.svelte'
8
8
  import BoxPlot from '../plots/BoxPlot.svelte'
9
9
  import ViolinPlot from '../plots/ViolinPlot.svelte'
10
- import ScatterPlot from '../plots/ScatterPlot.svelte'
10
+ import ScatterPlot from '../plots/old_ScatterPlot.svelte'
11
11
 
12
12
  let chart = writable({})
13
13
  let axis
@@ -31,8 +31,8 @@
31
31
  height: 350,
32
32
  values: {
33
33
  x: uniques(data, x),
34
- y: uniques(data, y),
35
- },
34
+ y: uniques(data, y)
35
+ }
36
36
  }
37
37
  }
38
38
 
@@ -42,7 +42,7 @@
42
42
  ...x,
43
43
  data: data.filter(
44
44
  (y) => y.Petal_Length >= x.lowerBound && y.Petal_Length < x.upperBound
45
- ),
45
+ )
46
46
  }))
47
47
 
48
48
  return groups
@@ -9,9 +9,9 @@ export { default as SwatchGrid } from './chart/SwatchGrid.svelte'
9
9
  export { default as Axis } from './chart/Axis.svelte'
10
10
  export { default as Grid } from './chart/Grid.svelte'
11
11
 
12
- export { default as BoxPlot } from './plots/BoxPlot.svelte'
12
+ export { default as BoxPlot } from '../plots/BoxPlot.svelte'
13
13
  export { default as ViolinPlot } from '../plots/ViolinPlot.svelte'
14
- export { default as ScatterPlot } from './plots/ScatterPlot.svelte'
14
+ export { default as ScatterPlot } from '../plots/ScatterPlot.svelte'
15
15
  export { default as FunnelPlot } from '../plots/FunnelPlot.svelte'
16
16
 
17
17
  export { default as Chart } from './chart/Chart.svelte'
@@ -1,5 +1,5 @@
1
1
  import { nest } from 'd3-collection'
2
- import { max, quantile, ascending, histogram } from 'd3-array'
2
+ import { max, quantile, ascending } from 'd3-array'
3
3
  import { scaleLinear } from 'd3-scale'
4
4
  import { area, curveCatmullRom } from 'd3-shape'
5
5
  import { getScale } from './utils'
package/src/index.js CHANGED
@@ -12,5 +12,5 @@ export { default as BarPlot } from './plots/BarPlot.svelte'
12
12
  export { default as LinePlot } from './plots/LinePlot.svelte'
13
13
  export { default as BoxPlot } from './plots/BoxPlot.svelte'
14
14
  export { default as ViolinPlot } from './plots/ViolinPlot.svelte'
15
- export { default as ScatterPlot } from './plots/ScatterPlot.svelte'
15
+ export { default as ScatterPlot } from './plots/old_ScatterPlot.svelte'
16
16
  export * from './components/lib'
@@ -0,0 +1,54 @@
1
+ <script>
2
+ import { getContext } from 'svelte'
3
+
4
+ let chart = getContext('chart')
5
+
6
+ export let whisker = true
7
+ export let boxWidth = 150
8
+ export let stroke = 'green'
9
+ export let fill = '#69b3a2' // fixed color or attribute to be used for color
10
+ export let scaleFill = () => fill // defaults to fill color
11
+
12
+ $: data = $chart.summary()
13
+ </script>
14
+
15
+ {#each data as { key, value }}
16
+ <rect
17
+ width={boxWidth}
18
+ height={$chart.axis.y.scale(value.q1) - $chart.axis.y.scale(value.q3)}
19
+ x={$chart.axis.x.scale(key) - boxWidth / 2}
20
+ y={$chart.axis.y.scale(value.q3)}
21
+ fill={scaleFill(value[fill])}
22
+ {stroke}
23
+ />
24
+ <line
25
+ x1={$chart.axis.x.scale(key) - boxWidth / 2}
26
+ x2={$chart.axis.x.scale(key) + boxWidth / 2}
27
+ y1={$chart.axis.y.scale(value.median)}
28
+ y2={$chart.axis.y.scale(value.median)}
29
+ {stroke}
30
+ />
31
+ <line
32
+ x1={$chart.axis.x.scale(key)}
33
+ x2={$chart.axis.x.scale(key)}
34
+ y1={$chart.axis.y.scale(value.min)}
35
+ y2={$chart.axis.y.scale(value.max)}
36
+ {stroke}
37
+ />
38
+ {#if whisker}
39
+ <line
40
+ x1={$chart.axis.x.scale(key) - boxWidth / 8}
41
+ x2={$chart.axis.x.scale(key) + boxWidth / 8}
42
+ y1={$chart.axis.y.scale(value.min)}
43
+ y2={$chart.axis.y.scale(value.min)}
44
+ {stroke}
45
+ />
46
+ <line
47
+ x1={$chart.axis.x.scale(key) - boxWidth / 8}
48
+ x2={$chart.axis.x.scale(key) + boxWidth / 8}
49
+ y1={$chart.axis.y.scale(value.max)}
50
+ y2={$chart.axis.y.scale(value.max)}
51
+ {stroke}
52
+ />
53
+ {/if}
54
+ {/each}
@@ -1,25 +1,25 @@
1
1
  <script>
2
- import { aggregate, getScales } from '../lib/utils'
2
+ import { aggregate, getScales } from '../lib/utils'
3
3
 
4
- import BoxPlot from './BoxPlot.svelte'
5
- import ScatterPlot from './ScatterPlot.svelte'
4
+ import BoxPlot from './BoxPlot.svelte'
5
+ import ScatterPlot from './old_ScatterPlot.svelte'
6
6
 
7
- export let data
8
- export let width
9
- export let height
10
- export let x
11
- export let y
12
- export let plots = []
7
+ export let data
8
+ export let width
9
+ export let height
10
+ export let x
11
+ export let y
12
+ export let plots = []
13
13
 
14
- $: nested = aggregate(data, x, y)
15
- $: scales = getScales(data, x, y, width, height)
14
+ $: nested = aggregate(data, x, y)
15
+ $: scales = getScales(data, x, y, width, height)
16
16
  </script>
17
17
 
18
18
  <svg viewBox="0 0 {width} {height}">
19
- {#if plots.includes('box')}
20
- <BoxPlot data={nested} {...scales} />
21
- {/if}
22
- {#if plots.includes('scatter')}
23
- <ScatterPlot {data} {x} {y} {...scales} />
24
- {/if}
19
+ {#if plots.includes('box')}
20
+ <BoxPlot data={nested} {...scales} />
21
+ {/if}
22
+ {#if plots.includes('scatter')}
23
+ <ScatterPlot {data} {x} {y} {...scales} />
24
+ {/if}
25
25
  </svg>
@@ -1,20 +1,30 @@
1
1
  <script>
2
- import { getContext } from 'svelte'
3
- import { colorBrewer } from '../lib/colors'
2
+ import { clamp } from 'yootils'
3
+ import Symbol from '../chart/Symbol.svelte'
4
+ import { getContext } from 'svelte'
4
5
 
5
- let chart = getContext('chart')
6
+ const chart = getContext('chart')
6
7
 
7
- export let size = $chart.height / 128
8
+ export let size = 8
9
+ export let fill = '#c0c0c0'
10
+ export let stroke = '#3c3c3c'
11
+ export let jitterWidth = 50
12
+ export let offset
8
13
 
9
- $: colors = colorBrewer($chart.data.map((d) => d.fill))
10
- $: points = $chart.data.map((d) => ({
11
- cx: $chart.scale.x(d.x),
12
- cy: $chart.scale.y(d.y),
13
- fill: colors[d.fill]
14
- }))
15
- // support shapes and sizes for scatter
14
+ $: jitterWidth = clamp(jitterWidth, 0, 100 / 2)
15
+ $: offset = clamp(offset | (jitterWidth / 2), 0, 100)
16
16
  </script>
17
17
 
18
- {#each points as { cx, cy, fill }}
19
- <circle {cx} {cy} r={size} {fill} fill-opacity="0.5" />
20
- {/each}
18
+ {#if $chart.data}
19
+ {#each $chart.data as d}
20
+ <Symbol
21
+ x={$chart.axis.x.scale(d[$chart.x]) -
22
+ offset +
23
+ Math.random() * jitterWidth}
24
+ y={$chart.axis.y.scale(d[$chart.y])}
25
+ {fill}
26
+ {stroke}
27
+ {size}
28
+ />
29
+ {/each}
30
+ {/if}
@@ -6,5 +6,5 @@ export { default as Line } from './LinePlot.svelte'
6
6
  export { default as LinePlot } from './LinePlot.svelte'
7
7
  export { default as Violin } from './ViolinPlot.svelte'
8
8
  export { default as ViolinPlot } from './ViolinPlot.svelte'
9
- export { default as Scatter } from './ScatterPlot.svelte'
10
- export { default as ScatterPlot } from './ScatterPlot.svelte'
9
+ export { default as Scatter } from './old_ScatterPlot.svelte'
10
+ export { default as ScatterPlot } from './old_ScatterPlot.svelte'
@@ -0,0 +1,20 @@
1
+ <script>
2
+ import { getContext } from 'svelte'
3
+ import { colorBrewer } from '../lib/colors'
4
+
5
+ let chart = getContext('chart')
6
+
7
+ export let size = $chart.height / 128
8
+
9
+ $: colors = colorBrewer($chart.data.map((d) => d.fill))
10
+ $: points = $chart.data.map((d) => ({
11
+ cx: $chart.scale.x(d.x),
12
+ cy: $chart.scale.y(d.y),
13
+ fill: colors[d.fill]
14
+ }))
15
+ // support shapes and sizes for scatter
16
+ </script>
17
+
18
+ {#each points as { cx, cy, fill }}
19
+ <circle {cx} {cy} r={size} {fill} fill-opacity="0.5" />
20
+ {/each}
File without changes
@@ -1,54 +0,0 @@
1
- <script>
2
- import { getContext } from 'svelte'
3
-
4
- let chart = getContext('chart')
5
-
6
- export let whisker = true
7
- export let boxWidth = 150
8
- export let stroke = 'green'
9
- export let fill = '#69b3a2' // fixed color or attribute to be used for color
10
- export let scaleFill = () => fill // defaults to fill color
11
-
12
- $: data = $chart.summary()
13
- </script>
14
-
15
- {#each data as { key, value }}
16
- <rect
17
- width={boxWidth}
18
- height={$chart.axis.y.scale(value.q1) - $chart.axis.y.scale(value.q3)}
19
- x={$chart.axis.x.scale(key) - boxWidth / 2}
20
- y={$chart.axis.y.scale(value.q3)}
21
- fill={scaleFill(value[fill])}
22
- {stroke}
23
- />
24
- <line
25
- x1={$chart.axis.x.scale(key) - boxWidth / 2}
26
- x2={$chart.axis.x.scale(key) + boxWidth / 2}
27
- y1={$chart.axis.y.scale(value.median)}
28
- y2={$chart.axis.y.scale(value.median)}
29
- {stroke}
30
- />
31
- <line
32
- x1={$chart.axis.x.scale(key)}
33
- x2={$chart.axis.x.scale(key)}
34
- y1={$chart.axis.y.scale(value.min)}
35
- y2={$chart.axis.y.scale(value.max)}
36
- {stroke}
37
- />
38
- {#if whisker}
39
- <line
40
- x1={$chart.axis.x.scale(key) - boxWidth / 8}
41
- x2={$chart.axis.x.scale(key) + boxWidth / 8}
42
- y1={$chart.axis.y.scale(value.min)}
43
- y2={$chart.axis.y.scale(value.min)}
44
- {stroke}
45
- />
46
- <line
47
- x1={$chart.axis.x.scale(key) - boxWidth / 8}
48
- x2={$chart.axis.x.scale(key) + boxWidth / 8}
49
- y1={$chart.axis.y.scale(value.max)}
50
- y2={$chart.axis.y.scale(value.max)}
51
- {stroke}
52
- />
53
- {/if}
54
- {/each}
@@ -1,30 +0,0 @@
1
- <script>
2
- import { clamp } from 'yootils'
3
- import Symbol from '../chart/Symbol.svelte'
4
- import { getContext } from 'svelte'
5
-
6
- const chart = getContext('chart')
7
-
8
- export let size = 8
9
- export let fill = '#c0c0c0'
10
- export let stroke = '#3c3c3c'
11
- export let jitterWidth = 50
12
- export let offset
13
-
14
- $: jitterWidth = clamp(jitterWidth, 0, 100 / 2)
15
- $: offset = clamp(offset | (jitterWidth / 2), 0, 100)
16
- </script>
17
-
18
- {#if $chart.data}
19
- {#each $chart.data as d}
20
- <Symbol
21
- x={$chart.axis.x.scale(d[$chart.x]) -
22
- offset +
23
- Math.random() * jitterWidth}
24
- y={$chart.axis.y.scale(d[$chart.y])}
25
- {fill}
26
- {stroke}
27
- {size}
28
- />
29
- {/each}
30
- {/if}
File without changes
File without changes