@rokkit/chart 1.0.0-next.147 → 1.0.0-next.148

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.
Files changed (157) hide show
  1. package/dist/Plot/index.d.ts +4 -0
  2. package/dist/PlotState.svelte.d.ts +47 -0
  3. package/dist/crossfilter/createCrossFilter.svelte.d.ts +15 -0
  4. package/dist/geoms/lib/areas.d.ts +52 -0
  5. package/dist/geoms/lib/bars.d.ts +3 -0
  6. package/dist/index.d.ts +38 -1
  7. package/dist/lib/brewing/BoxBrewer.svelte.d.ts +10 -0
  8. package/dist/lib/brewing/CartesianBrewer.svelte.d.ts +8 -0
  9. package/dist/lib/brewing/PieBrewer.svelte.d.ts +8 -0
  10. package/dist/lib/brewing/ViolinBrewer.svelte.d.ts +9 -0
  11. package/dist/lib/brewing/brewer.svelte.d.ts +145 -0
  12. package/dist/lib/brewing/colors.d.ts +17 -0
  13. package/dist/lib/brewing/marks/arcs.d.ts +17 -0
  14. package/dist/lib/brewing/marks/areas.d.ts +31 -0
  15. package/dist/lib/brewing/marks/bars.d.ts +1 -0
  16. package/dist/lib/brewing/marks/boxes.d.ts +24 -0
  17. package/dist/lib/brewing/marks/lines.d.ts +24 -0
  18. package/dist/lib/brewing/marks/points.d.ts +40 -0
  19. package/dist/lib/brewing/marks/violins.d.ts +20 -0
  20. package/dist/lib/brewing/patterns.d.ts +14 -0
  21. package/dist/lib/brewing/scales.d.ts +28 -0
  22. package/dist/lib/brewing/stats.d.ts +31 -0
  23. package/dist/lib/brewing/symbols.d.ts +7 -0
  24. package/dist/lib/plot/chartProps.d.ts +177 -0
  25. package/dist/lib/plot/crossfilter.d.ts +13 -0
  26. package/dist/lib/plot/facet.d.ts +24 -0
  27. package/dist/lib/plot/frames.d.ts +45 -0
  28. package/dist/lib/plot/helpers.d.ts +3 -0
  29. package/dist/lib/plot/preset.d.ts +29 -0
  30. package/dist/lib/plot/scales.d.ts +5 -0
  31. package/dist/lib/plot/stat.d.ts +32 -0
  32. package/dist/lib/plot/types.d.ts +89 -0
  33. package/dist/lib/scales.svelte.d.ts +1 -1
  34. package/dist/lib/swatch.d.ts +12 -0
  35. package/dist/lib/utils.d.ts +1 -0
  36. package/dist/lib/xscale.d.ts +11 -0
  37. package/dist/patterns/index.d.ts +4 -9
  38. package/dist/patterns/patterns.d.ts +72 -0
  39. package/dist/patterns/scale.d.ts +30 -0
  40. package/package.json +9 -3
  41. package/src/AnimatedPlot.svelte +194 -0
  42. package/src/Chart.svelte +101 -0
  43. package/src/FacetPlot/Panel.svelte +23 -0
  44. package/src/FacetPlot.svelte +90 -0
  45. package/src/Plot/Arc.svelte +29 -0
  46. package/src/Plot/Area.svelte +25 -0
  47. package/src/Plot/Axis.svelte +62 -84
  48. package/src/Plot/Grid.svelte +20 -58
  49. package/src/Plot/Legend.svelte +160 -120
  50. package/src/Plot/Line.svelte +27 -0
  51. package/src/Plot/Point.svelte +27 -0
  52. package/src/Plot/Timeline.svelte +95 -0
  53. package/src/Plot/Tooltip.svelte +81 -0
  54. package/src/Plot/index.js +4 -0
  55. package/src/Plot.svelte +189 -0
  56. package/src/PlotState.svelte.js +278 -0
  57. package/src/Sparkline.svelte +69 -0
  58. package/src/charts/AreaChart.svelte +25 -0
  59. package/src/charts/BarChart.svelte +26 -0
  60. package/src/charts/BoxPlot.svelte +21 -0
  61. package/src/charts/BubbleChart.svelte +23 -0
  62. package/src/charts/LineChart.svelte +26 -0
  63. package/src/charts/PieChart.svelte +25 -0
  64. package/src/charts/ScatterPlot.svelte +25 -0
  65. package/src/charts/ViolinPlot.svelte +21 -0
  66. package/src/crossfilter/CrossFilter.svelte +38 -0
  67. package/src/crossfilter/FilterBar.svelte +32 -0
  68. package/src/crossfilter/FilterSlider.svelte +79 -0
  69. package/src/crossfilter/createCrossFilter.svelte.js +113 -0
  70. package/src/elements/SymbolGrid.svelte +6 -7
  71. package/src/geoms/Arc.svelte +81 -0
  72. package/src/geoms/Area.svelte +50 -0
  73. package/src/geoms/Bar.svelte +142 -0
  74. package/src/geoms/Box.svelte +101 -0
  75. package/src/geoms/LabelPill.svelte +17 -0
  76. package/src/geoms/Line.svelte +100 -0
  77. package/src/geoms/Point.svelte +100 -0
  78. package/src/geoms/Violin.svelte +44 -0
  79. package/src/geoms/lib/areas.js +131 -0
  80. package/src/geoms/lib/bars.js +172 -0
  81. package/src/index.js +52 -3
  82. package/src/lib/brewing/BoxBrewer.svelte.js +56 -0
  83. package/src/lib/brewing/CartesianBrewer.svelte.js +16 -0
  84. package/src/lib/brewing/PieBrewer.svelte.js +14 -0
  85. package/src/lib/brewing/ViolinBrewer.svelte.js +55 -0
  86. package/src/lib/brewing/brewer.svelte.js +229 -0
  87. package/src/lib/brewing/colors.js +22 -0
  88. package/src/lib/brewing/marks/arcs.js +43 -0
  89. package/src/lib/brewing/marks/areas.js +59 -0
  90. package/src/lib/brewing/marks/bars.js +49 -0
  91. package/src/lib/brewing/marks/boxes.js +75 -0
  92. package/src/lib/brewing/marks/lines.js +48 -0
  93. package/src/lib/brewing/marks/points.js +57 -0
  94. package/src/lib/brewing/marks/violins.js +90 -0
  95. package/src/lib/brewing/patterns.js +31 -0
  96. package/src/lib/brewing/scales.js +51 -0
  97. package/src/lib/brewing/scales.svelte.js +2 -26
  98. package/src/lib/brewing/stats.js +62 -0
  99. package/src/lib/brewing/symbols.js +10 -0
  100. package/src/lib/plot/chartProps.js +76 -0
  101. package/src/lib/plot/crossfilter.js +16 -0
  102. package/src/lib/plot/facet.js +58 -0
  103. package/src/lib/plot/frames.js +90 -0
  104. package/src/lib/plot/helpers.js +14 -0
  105. package/src/lib/plot/preset.js +53 -0
  106. package/src/lib/plot/scales.js +56 -0
  107. package/src/lib/plot/stat.js +92 -0
  108. package/src/lib/plot/types.js +65 -0
  109. package/src/lib/scales.svelte.js +2 -26
  110. package/src/lib/swatch.js +13 -0
  111. package/src/lib/utils.js +9 -0
  112. package/src/lib/xscale.js +31 -0
  113. package/src/patterns/DefinePatterns.svelte +32 -0
  114. package/src/patterns/PatternDef.svelte +27 -0
  115. package/src/patterns/index.js +4 -14
  116. package/src/patterns/patterns.js +208 -0
  117. package/src/patterns/scale.js +87 -0
  118. package/src/spec/chart-spec.js +29 -0
  119. package/src/symbols/Shape.svelte +1 -1
  120. package/src/symbols/constants/index.js +1 -1
  121. package/dist/old_lib/index.d.ts +0 -4
  122. package/dist/old_lib/plots.d.ts +0 -3
  123. package/dist/old_lib/swatch.d.ts +0 -285
  124. package/dist/old_lib/utils.d.ts +0 -1
  125. package/dist/patterns/paths/constants.d.ts +0 -1
  126. package/dist/template/constants.d.ts +0 -43
  127. package/dist/template/shapes/index.d.ts +0 -4
  128. package/src/old_lib/index.js +0 -4
  129. package/src/old_lib/plots.js +0 -27
  130. package/src/old_lib/swatch.js +0 -16
  131. package/src/old_lib/utils.js +0 -8
  132. package/src/patterns/Brick.svelte +0 -15
  133. package/src/patterns/Circles.svelte +0 -18
  134. package/src/patterns/CrossHatch.svelte +0 -12
  135. package/src/patterns/CurvedWave.svelte +0 -7
  136. package/src/patterns/Dots.svelte +0 -20
  137. package/src/patterns/OutlineCircles.svelte +0 -13
  138. package/src/patterns/Tile.svelte +0 -16
  139. package/src/patterns/Triangles.svelte +0 -13
  140. package/src/patterns/Waves.svelte +0 -9
  141. package/src/patterns/paths/NamedPattern.svelte +0 -9
  142. package/src/patterns/paths/constants.js +0 -4
  143. package/src/template/Texture.svelte +0 -13
  144. package/src/template/constants.js +0 -43
  145. package/src/template/shapes/Circles.svelte +0 -15
  146. package/src/template/shapes/Lines.svelte +0 -16
  147. package/src/template/shapes/Path.svelte +0 -9
  148. package/src/template/shapes/Polygons.svelte +0 -15
  149. package/src/template/shapes/index.js +0 -4
  150. /package/dist/{old_lib → lib}/brewer.d.ts +0 -0
  151. /package/dist/{old_lib → lib}/chart.d.ts +0 -0
  152. /package/dist/{old_lib → lib}/grid.d.ts +0 -0
  153. /package/dist/{old_lib → lib}/ticks.d.ts +0 -0
  154. /package/src/{old_lib → lib}/brewer.js +0 -0
  155. /package/src/{old_lib → lib}/chart.js +0 -0
  156. /package/src/{old_lib → lib}/grid.js +0 -0
  157. /package/src/{old_lib → lib}/ticks.js +0 -0
@@ -1,4 +0,0 @@
1
- export { default as Circles } from "./Circles.svelte";
2
- export { default as Lines } from "./Lines.svelte";
3
- export { default as Path } from "./Path.svelte";
4
- export { default as Polygons } from "./Polygons.svelte";
@@ -1,4 +0,0 @@
1
- export { swatch } from './swatch'
2
- export { swatchGrid } from './grid'
3
- export * from './chart'
4
- export * from './brewer'
@@ -1,27 +0,0 @@
1
- // skipcq: JS-C1003 - Importing all plots from observablehq/plot
2
- import * as Plot from '@observablehq/plot'
3
-
4
- export function plotter(node, options) {
5
- let { data, aes, type, opts } = options
6
- // let chart = Plot.lineY(options.data).plot({ grid: true })
7
-
8
- function render() {
9
- const chart = Plot[type](data, aes).plot({
10
- color: { scheme: 'turbo', range: [0.1, 0.9] },
11
- ...opts
12
- })
13
- node.firstChild?.remove() // remove old chart, if any
14
- node.append(chart)
15
- }
16
- render()
17
-
18
- return {
19
- update: (input) => {
20
- data = input.data
21
- aes = input.aes
22
- type = input.type
23
- opts = input.opts
24
- render()
25
- }
26
- }
27
- }
@@ -1,16 +0,0 @@
1
- import { writable } from 'svelte/store'
2
- import palette from './palette.json'
3
- // skipcq: JS-C1003 - Importing all patterns
4
- import * as patterns from '../patterns'
5
- import { shapes } from '../symbols'
6
-
7
- export const swatch = writable({
8
- palette,
9
- patterns,
10
- keys: {
11
- gray: ['gray'],
12
- color: Object.keys(palette).filter((name) => name !== 'gray'),
13
- symbol: shapes,
14
- pattern: Object.keys(patterns)
15
- }
16
- })
@@ -1,8 +0,0 @@
1
- import { scaledPath } from '@rokkit/core'
2
-
3
- export function scaledPathCollection(paths) {
4
- return Object.entries(paths).reduce(
5
- (acc, [key, value]) => ({ ...acc, [key]: (s) => scaledPath(s, value) }),
6
- {}
7
- )
8
- }
@@ -1,15 +0,0 @@
1
- <script>
2
- let { size = 10, thickness = 0.5, stroke = 'currentColor' } = $props()
3
-
4
- let lines = $derived([
5
- { x1: 0, y1: 0.25 * size, x2: 0.5 * size, y2: 0.25 * size },
6
- { x1: 0.5 * size, y1: 0.75 * size, x2: size, y2: 0.75 * size },
7
- { x1: 0, y1: 0, x2: 0, y2: size },
8
- { x1: size, y1: 0, x2: size, y2: size },
9
- { x1: 0.5 * size, y1: 0, x2: 0.5 * size, y2: size }
10
- ])
11
- </script>
12
-
13
- {#each lines as line, index (index)}
14
- <line {...line} {stroke} stroke-width={thickness} stroke-linecap="round" />
15
- {/each}
@@ -1,18 +0,0 @@
1
- <script>
2
- let { size = 10, fill = 'currentColor', stroke = 'currentColor' } = $props()
3
-
4
- let data = $derived(
5
- [
6
- { cx: 0, cy: 0, r: 0.5 },
7
- { cx: 1, cy: 1, r: 0.5 }
8
- ].map(({ cx, cy, r }) => ({
9
- cx: cx * size,
10
- cy: cy * size,
11
- r: r * size
12
- }))
13
- )
14
- </script>
15
-
16
- {#each data as { cx, cy, r }, index (index)}
17
- <circle {cx} {cy} {r} {fill} {stroke} />
18
- {/each}
@@ -1,12 +0,0 @@
1
- <script>
2
- let { size = 10, thickness = 0.5, stroke = 'currentColor' } = $props()
3
-
4
- let lines = $derived([
5
- { x1: 0, y1: 0, x2: size, y2: size },
6
- { x1: 0, y1: size, x2: size, y2: 0 }
7
- ])
8
- </script>
9
-
10
- {#each lines as line, index (index)}
11
- <line {...line} {stroke} stroke-width={thickness} stroke-linecap="round" />
12
- {/each}
@@ -1,7 +0,0 @@
1
- <script>
2
- import NamedPattern from './paths/NamedPattern.svelte'
3
-
4
- let { size = 10, thickness = 0.5, stroke = 'currentColor' } = $props()
5
- </script>
6
-
7
- <NamedPattern {size} {thickness} {stroke} name="curvedWave" />
@@ -1,20 +0,0 @@
1
- <script>
2
- let { size = 10, fill = 'currentColor' } = $props()
3
-
4
- let data = $derived(
5
- [
6
- { cx: 0.2 * size, cy: 0.2 * size },
7
- { cx: 0.4 * size, cy: 0.4 * size },
8
- { cx: 0.6 * size, cy: 0.6 * size },
9
- { cx: 0.8 * size, cy: 0.8 * size },
10
- { cx: 0.8 * size, cy: 0.2 * size },
11
- { cx: 0.6 * size, cy: 0.4 * size },
12
- { cx: 0.4 * size, cy: 0.6 * size },
13
- { cx: 0.2 * size, cy: 0.8 * size }
14
- ].map((x) => ({ ...x, r: 0.08 * size }))
15
- )
16
- </script>
17
-
18
- {#each data as { cx, cy, r }, index (index)}
19
- <circle {cx} {cy} {r} {fill} />
20
- {/each}
@@ -1,13 +0,0 @@
1
- <script>
2
- let { size = 10, fill = 'currentColor', stroke = 'currentColor' } = $props()
3
-
4
- let centres = $derived([
5
- { cx: 0, cy: 0 },
6
- { cx: size, cy: size }
7
- ])
8
- let r = $derived(0.5 * size)
9
- </script>
10
-
11
- {#each centres as { cx, cy }, index (index)}
12
- <circle {cx} {cy} {r} {fill} {stroke} />
13
- {/each}
@@ -1,16 +0,0 @@
1
- <script>
2
- const thickness = 0.5
3
- let { size = 10, stroke = 'currentColor' } = $props()
4
-
5
- let lines = $derived([
6
- { x1: 0, y1: 0.25 * size, x2: 0.5 * size, y2: 0.25 * size },
7
- { x1: 0.5 * size, y1: 0.75 * size, x2: size, y2: 0.75 * size },
8
- { x1: 0, y1: 0, x2: 0, y2: size },
9
- { x1: size, y1: 0, x2: size, y2: size },
10
- { x1: 0.5 * size, y1: 0, x2: 0.5 * size, y2: size }
11
- ])
12
- </script>
13
-
14
- {#each lines as line, index (index)}
15
- <line {...line} {stroke} stroke-width={thickness} stroke-linecap="round" />
16
- {/each}
@@ -1,13 +0,0 @@
1
- <script>
2
- let { size = 10, fill = 'currentColor', stroke = 'currentColor' } = $props()
3
-
4
- let polygons = $derived([
5
- [0, 0.5 * size, 0.5 * size, size, 0, size],
6
- [0.5 * size, 0, 0, 0, 0, 0.5 * size],
7
- [size, 0, 0.5 * size, 0.5 * size, size, size]
8
- ])
9
- </script>
10
-
11
- {#each polygons as points, index (index)}
12
- <polygon points={points.join(', ')} {fill} {stroke} stroke-width="0" />
13
- {/each}
@@ -1,9 +0,0 @@
1
- <script>
2
- import { scaledPath } from '@rokkit/core'
3
-
4
- let { size = 10, thickness = 0.5, stroke = 'currentColor', fill = 'none', data = [] } = $props()
5
-
6
- let d = $derived(scaledPath(size, data))
7
- </script>
8
-
9
- <path {d} {stroke} stroke-width={thickness} {fill} />
@@ -1,9 +0,0 @@
1
- <script>
2
- import { patterns } from './constants'
3
-
4
- let { size = 10, thickness = 0.5, stroke = 'currentColor', name = 'cross-hatch' } = $props()
5
-
6
- let d = $derived(patterns[name](size))
7
- </script>
8
-
9
- <path {d} {stroke} stroke-width={thickness} fill="none" />
@@ -1,4 +0,0 @@
1
- import { scaledPathCollection } from '../../old_lib/utils'
2
- import paths from './patterns.json'
3
-
4
- export const patterns = scaledPathCollection(paths)
@@ -1,13 +0,0 @@
1
- <script>
2
- import { library } from './constants'
3
- import * as templates from './shapes'
4
- import { pick } from 'ramda'
5
-
6
- let { size = 10, fill = 'none', stroke = 'none', thickness = 0.5, name = 'Waves' } = $props()
7
-
8
- let pattern = $derived(library[name])
9
- let props = $derived(pick(pattern.allowed ?? [], { fill, stroke, thickness }))
10
- let Component = $derived(templates[pattern.component])
11
- </script>
12
-
13
- <Component {size} {...props} data={pattern.data} />
@@ -1,43 +0,0 @@
1
- export const library = {
2
- Brick: {
3
- component: 'Lines',
4
- allowed: ['stroke'],
5
- data: [
6
- { x1: 0, y1: 0.25, x2: 0.5, y2: 0.25 },
7
- { x1: 0.5, y1: 0.75, x2: 1, y2: 0.75 },
8
- { x1: 0, y1: 0, x2: 0, y2: 1 },
9
- { x1: 1, y1: 0, x2: 1, y2: 1 },
10
- { x1: 0.5, y1: 0, x2: 0.5, y2: 1 }
11
- ]
12
- },
13
- Circles: {
14
- component: 'Circles',
15
- allowed: ['fill', 'stroke'],
16
- data: [
17
- { cx: 0, cy: 0, r: 0.5 },
18
- { cx: 1, cy: 1, r: 0.5 }
19
- ]
20
- },
21
- Dominoes: {
22
- component: 'Circles',
23
- allowed: ['fill'],
24
- data: [
25
- { cx: 0.2, cy: 0.2, r: 0.8 },
26
- { cx: 0.4, cy: 0.4, r: 0.8 },
27
- { cx: 0.6, cy: 0.6, r: 0.8 },
28
- { cx: 0.8, cy: 0.8, r: 0.8 },
29
- { cx: 0.8, cy: 0.2, r: 0.8 },
30
- { cx: 0.6, cy: 0.4, r: 0.8 },
31
- { cx: 0.4, cy: 0.6, r: 0.8 },
32
- { cx: 0.2, cy: 0.8, r: 0.8 }
33
- ]
34
- },
35
- Waves: {
36
- component: 'Path',
37
- stroke: true,
38
- data: [
39
- ['M', 0, 0.25],
40
- ['A', 0.6, 0.5, 0, 0, 0, 1, 0.25]
41
- ]
42
- }
43
- }
@@ -1,15 +0,0 @@
1
- <script>
2
- let { size = 10, fill = 'currentColor', stroke = 'currentColor', data } = $props()
3
-
4
- let circles = $derived(
5
- data.map(({ cx, cy, r }) => ({
6
- cx: cx * size,
7
- cy: cy * size,
8
- r: r * size
9
- }))
10
- )
11
- </script>
12
-
13
- {#each circles as { cx, cy, r }, index (index)}
14
- <circle {cx} {cy} {r} {fill} {stroke} />
15
- {/each}
@@ -1,16 +0,0 @@
1
- <script>
2
- let { size = 10, thickness = 0.5, stroke = 'currentColor', data = [] } = $props()
3
-
4
- let lines = $derived(
5
- data.map(({ x1, y1, x2, y2 }) => ({
6
- x1: x1 * size,
7
- y1: y1 * size,
8
- x2: x2 * size,
9
- y2: y2 * size
10
- }))
11
- )
12
- </script>
13
-
14
- {#each lines as line, index (index)}
15
- <line {...line} {stroke} stroke-width={thickness} stroke-linecap="round" />
16
- {/each}
@@ -1,9 +0,0 @@
1
- <script>
2
- import { scaledPath } from '@rokkit/core'
3
-
4
- let { size = 10, thickness = 0.5, stroke = 'currentColor', data = [] } = $props()
5
-
6
- let d = $derived(scaledPath(size, data))
7
- </script>
8
-
9
- <path {d} {stroke} stroke-width={thickness} fill="none" />
@@ -1,15 +0,0 @@
1
- <script>
2
- let {
3
- size = 10,
4
- thickness = 0.5,
5
- fill = 'currentColor',
6
- stroke = 'currentColor',
7
- data = []
8
- } = $props()
9
-
10
- let polygons = $derived(data.map((points) => points.map((point) => point * size).join(', ')))
11
- </script>
12
-
13
- {#each polygons as points, index (index)}
14
- <polygon {points} {fill} {stroke} stroke-width={thickness} />
15
- {/each}
@@ -1,4 +0,0 @@
1
- export { default as Circles } from './Circles.svelte'
2
- export { default as Lines } from './Lines.svelte'
3
- export { default as Path } from './Path.svelte'
4
- export { default as Polygons } from './Polygons.svelte'
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes