@rokkit/chart 1.3.7 → 1.3.8

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 (76) hide show
  1. package/dist/AnimatedPlot.svelte +26 -8
  2. package/dist/AnimatedPlot.svelte.d.ts +5 -0
  3. package/dist/Chart.svelte +1 -1
  4. package/dist/FacetPlot.svelte +1 -1
  5. package/dist/Plot/Axis.svelte +19 -10
  6. package/dist/Plot/Root.svelte +64 -46
  7. package/dist/Plot/Root.svelte.d.ts +27 -2
  8. package/dist/Plot/Timeline.svelte +39 -13
  9. package/dist/Plot/index.d.ts +4 -4
  10. package/dist/Plot/index.js +4 -4
  11. package/dist/Plot.svelte +95 -178
  12. package/dist/Plot.svelte.d.ts +4 -0
  13. package/dist/PlotState.svelte.d.ts +16 -0
  14. package/dist/PlotState.svelte.js +118 -16
  15. package/dist/PlotSurface.svelte +162 -0
  16. package/dist/PlotSurface.svelte.d.ts +25 -0
  17. package/dist/charts/AreaChart.svelte +4 -1
  18. package/dist/charts/AreaChart.svelte.d.ts +1 -0
  19. package/dist/charts/BarChart.svelte +32 -3
  20. package/dist/charts/BarChart.svelte.d.ts +10 -1
  21. package/dist/charts/BoxPlot.svelte +4 -2
  22. package/dist/charts/BoxPlot.svelte.d.ts +1 -0
  23. package/dist/charts/BubbleChart.svelte +34 -3
  24. package/dist/charts/BubbleChart.svelte.d.ts +11 -1
  25. package/dist/charts/LineChart.svelte +1 -1
  26. package/dist/charts/PieChart.svelte +1 -1
  27. package/dist/charts/ScatterPlot.svelte +32 -3
  28. package/dist/charts/ScatterPlot.svelte.d.ts +10 -1
  29. package/dist/charts/ViolinPlot.svelte +4 -2
  30. package/dist/charts/ViolinPlot.svelte.d.ts +1 -0
  31. package/dist/examples/BarChartExample.svelte +1 -1
  32. package/dist/geoms/Arc.svelte +3 -2
  33. package/dist/geoms/Area.svelte +2 -2
  34. package/dist/geoms/Bar.svelte +17 -6
  35. package/dist/geoms/Box.svelte +131 -76
  36. package/dist/geoms/Box.svelte.d.ts +7 -0
  37. package/dist/geoms/Candlestick.svelte +17 -11
  38. package/dist/geoms/Jitter.svelte +82 -0
  39. package/dist/geoms/Jitter.svelte.d.ts +15 -0
  40. package/dist/geoms/Line.svelte +1 -1
  41. package/dist/geoms/Point.svelte +7 -1
  42. package/dist/geoms/Rule.svelte +113 -0
  43. package/dist/geoms/Rule.svelte.d.ts +16 -0
  44. package/dist/geoms/Violin.svelte +30 -6
  45. package/dist/geoms/Violin.svelte.d.ts +5 -0
  46. package/dist/geoms/Waterfall.svelte +16 -9
  47. package/dist/geoms/lib/areas.d.ts +6 -2
  48. package/dist/geoms/lib/areas.js +17 -11
  49. package/dist/geoms/lib/bars.d.ts +18 -3
  50. package/dist/geoms/lib/bars.js +70 -96
  51. package/dist/index.d.ts +24 -4
  52. package/dist/index.js +25 -5
  53. package/dist/lib/brewing/ViolinBrewer.svelte.d.ts +1 -1
  54. package/dist/lib/brewing/marks/arcs.js +7 -1
  55. package/dist/lib/brewing/marks/boxes.d.ts +11 -2
  56. package/dist/lib/brewing/marks/boxes.js +32 -11
  57. package/dist/lib/brewing/marks/lines.d.ts +4 -1
  58. package/dist/lib/brewing/marks/lines.js +18 -15
  59. package/dist/lib/brewing/marks/swarm.d.ts +32 -0
  60. package/dist/lib/brewing/marks/swarm.js +125 -0
  61. package/dist/lib/brewing/marks/violins.d.ts +4 -20
  62. package/dist/lib/brewing/marks/violins.js +41 -25
  63. package/dist/lib/brewing/stats.d.ts +3 -1
  64. package/dist/lib/brewing/stats.js +28 -11
  65. package/dist/lib/plot/scales.js +12 -7
  66. package/dist/lib/plot/types.d.ts +9 -1
  67. package/dist/lib/plot/types.js +3 -1
  68. package/package.json +1 -1
  69. package/dist/Plot/Area.svelte +0 -54
  70. package/dist/Plot/Area.svelte.d.ts +0 -14
  71. package/dist/Plot/Bar.svelte +0 -69
  72. package/dist/Plot/Bar.svelte.d.ts +0 -11
  73. package/dist/Plot/Line.svelte +0 -54
  74. package/dist/Plot/Line.svelte.d.ts +0 -13
  75. package/dist/Plot/Point.svelte +0 -58
  76. package/dist/Plot/Point.svelte.d.ts +0 -13
@@ -1,54 +0,0 @@
1
- <script lang="ts">
2
- import { getContext } from 'svelte'
3
- import { area as d3Area, type CurveFactory } from 'd3-shape'
4
- import type { PlotState } from '../PlotState.svelte.js'
5
-
6
- type Datum = Record<string, unknown> | number
7
-
8
- type Props = {
9
- data?: Datum[]
10
- x?: string
11
- y?: string
12
- y0?: string
13
- fill?: string
14
- opacity?: number
15
- curve?: CurveFactory
16
- }
17
-
18
- let {
19
- data = [],
20
- x = undefined,
21
- y = undefined,
22
- y0 = undefined,
23
- fill = 'steelblue',
24
- opacity = 0.7,
25
- curve = undefined
26
- }: Props = $props()
27
-
28
- const state = getContext<PlotState>('plot-state')
29
-
30
- const accessor = (d: Datum, field: string | undefined): unknown =>
31
- field && typeof d === 'object' ? d[field] : d
32
-
33
- const path = $derived.by(() => {
34
- if (!state?.xScale || !state?.yScale || !data?.length) return null
35
- const xScale = state.xScale
36
- const yScale = state.yScale
37
- const innerHeight = state.innerHeight
38
- const areaGen = d3Area<Datum>()
39
- .x((d) => xScale(accessor(d, x)) ?? 0)
40
- .y1((d) => yScale(accessor(d, y)) ?? 0)
41
- .y0((d) =>
42
- y0 !== undefined
43
- ? (yScale((typeof d === 'object' ? d[y0] : undefined) ?? y0) ?? innerHeight)
44
- : innerHeight
45
- )
46
- .defined((d) => d != null)
47
- if (curve) areaGen.curve(curve)
48
- return areaGen(data)
49
- })
50
- </script>
51
-
52
- {#if path}
53
- <path d={path} {fill} {opacity} stroke="none" data-plot-element="area" />
54
- {/if}
@@ -1,14 +0,0 @@
1
- import { type CurveFactory } from 'd3-shape';
2
- type Datum = Record<string, unknown> | number;
3
- type Props = {
4
- data?: Datum[];
5
- x?: string;
6
- y?: string;
7
- y0?: string;
8
- fill?: string;
9
- opacity?: number;
10
- curve?: CurveFactory;
11
- };
12
- declare const Area: import("svelte").Component<Props, {}, "">;
13
- type Area = ReturnType<typeof Area>;
14
- export default Area;
@@ -1,69 +0,0 @@
1
- <script lang="ts">
2
- import { getContext } from 'svelte'
3
- import type { PlotState } from '../PlotState.svelte.js'
4
-
5
- type Datum = Record<string, unknown> | number
6
-
7
- type Props = {
8
- data?: Datum[]
9
- x?: string
10
- y?: string
11
- fill?: string
12
- opacity?: number
13
- }
14
-
15
- let { data = undefined, x = undefined, y = undefined, fill = 'steelblue', opacity = 1 }: Props =
16
- $props()
17
-
18
- const state = getContext<PlotState>('plot-state')
19
-
20
- const accessor = (d: Datum, field: string | undefined): unknown =>
21
- field && typeof d === 'object' ? d[field] : d
22
-
23
- const bars = $derived.by(() => {
24
- if (!state?.xScale || !state?.yScale) return []
25
- const xScale = state.xScale
26
- const yScale = state.yScale
27
- const innerHeight = state.innerHeight
28
- const src = data ?? []
29
- if (!src.length) return []
30
-
31
- const bw = typeof xScale.bandwidth === 'function' ? xScale.bandwidth() : 20
32
- const padding = typeof xScale.bandwidth === 'function' ? bw * 0.05 : 0
33
-
34
- // Baseline at y=0 when domain spans zero (supports negative bars)
35
- const yDomain = typeof yScale.bandwidth !== 'function' ? yScale.domain?.() : null
36
- const baseline =
37
- yDomain && yDomain[0] <= 0 && yDomain[yDomain.length - 1] >= 0
38
- ? (yScale(0) ?? innerHeight)
39
- : innerHeight
40
-
41
- return src.map((d) => {
42
- const xVal = accessor(d, x)
43
- const yVal = accessor(d, y)
44
- const xPos = (xScale(xVal) ?? 0) + padding
45
- const yPos = yScale(yVal) ?? baseline
46
- return {
47
- x: xPos,
48
- y: Math.min(yPos, baseline),
49
- width: bw * 0.9,
50
- height: Math.abs(baseline - yPos),
51
- label: `${xVal}: ${yVal}`
52
- }
53
- })
54
- })
55
- </script>
56
-
57
- {#each bars as bar, i (i)}
58
- <rect
59
- x={bar.x}
60
- y={bar.y}
61
- width={bar.width}
62
- height={bar.height}
63
- {fill}
64
- {opacity}
65
- data-plot-element="bar"
66
- role="graphics-symbol"
67
- aria-label={bar.label}
68
- />
69
- {/each}
@@ -1,11 +0,0 @@
1
- type Datum = Record<string, unknown> | number;
2
- type Props = {
3
- data?: Datum[];
4
- x?: string;
5
- y?: string;
6
- fill?: string;
7
- opacity?: number;
8
- };
9
- declare const Bar: import("svelte").Component<Props, {}, "">;
10
- type Bar = ReturnType<typeof Bar>;
11
- export default Bar;
@@ -1,54 +0,0 @@
1
- <script lang="ts">
2
- import { getContext } from 'svelte'
3
- import { line as d3Line, type CurveFactory } from 'd3-shape'
4
- import type { PlotState } from '../PlotState.svelte.js'
5
-
6
- type Datum = Record<string, unknown> | number
7
-
8
- type Props = {
9
- data?: Datum[]
10
- x?: string
11
- y?: string
12
- stroke?: string
13
- strokeWidth?: number
14
- curve?: CurveFactory
15
- }
16
-
17
- let {
18
- data = [],
19
- x = undefined,
20
- y = undefined,
21
- stroke = 'steelblue',
22
- strokeWidth = 2,
23
- curve = undefined
24
- }: Props = $props()
25
-
26
- const state = getContext<PlotState>('plot-state')
27
-
28
- const accessor = (d: Datum, field: string | undefined): unknown =>
29
- field && typeof d === 'object' ? d[field] : d
30
-
31
- const path = $derived.by(() => {
32
- if (!state?.xScale || !state?.yScale || !data?.length) return null
33
- const xScale = state.xScale
34
- const yScale = state.yScale
35
- const lineGen = d3Line<Datum>()
36
- .x((d) => xScale(accessor(d, x)) ?? 0)
37
- .y((d) => yScale(accessor(d, y)) ?? 0)
38
- .defined((d) => d != null)
39
- if (curve) lineGen.curve(curve)
40
- return lineGen(data)
41
- })
42
- </script>
43
-
44
- {#if path}
45
- <path
46
- d={path}
47
- fill="none"
48
- {stroke}
49
- stroke-width={strokeWidth}
50
- stroke-linejoin="round"
51
- stroke-linecap="round"
52
- data-plot-element="line"
53
- />
54
- {/if}
@@ -1,13 +0,0 @@
1
- import { type CurveFactory } from 'd3-shape';
2
- type Datum = Record<string, unknown> | number;
3
- type Props = {
4
- data?: Datum[];
5
- x?: string;
6
- y?: string;
7
- stroke?: string;
8
- strokeWidth?: number;
9
- curve?: CurveFactory;
10
- };
11
- declare const Line: import("svelte").Component<Props, {}, "">;
12
- type Line = ReturnType<typeof Line>;
13
- export default Line;
@@ -1,58 +0,0 @@
1
- <script lang="ts">
2
- import { getContext } from 'svelte'
3
- import type { PlotState } from '../PlotState.svelte.js'
4
-
5
- type Datum = Record<string, unknown> | number
6
-
7
- type Props = {
8
- data?: Datum[]
9
- x?: string
10
- y?: string
11
- r?: number
12
- fill?: string
13
- stroke?: string
14
- strokeWidth?: number
15
- }
16
-
17
- let {
18
- data = [],
19
- x = undefined,
20
- y = undefined,
21
- r = 4,
22
- fill = 'steelblue',
23
- stroke = 'white',
24
- strokeWidth = 1
25
- }: Props = $props()
26
-
27
- const state = getContext<PlotState>('plot-state')
28
-
29
- const accessor = (d: Datum, field: string | undefined): unknown =>
30
- field && typeof d === 'object' ? d[field] : d
31
-
32
- const points = $derived.by(() => {
33
- if (!state?.xScale || !state?.yScale || !data?.length) return []
34
- const xScale = state.xScale
35
- const yScale = state.yScale
36
- return data
37
- .map((d) => ({
38
- cx: xScale(accessor(d, x)) ?? null,
39
- cy: yScale(accessor(d, y)) ?? null,
40
- label: `(${accessor(d, x)}, ${accessor(d, y)})`
41
- }))
42
- .filter((p) => p.cx !== null && p.cy !== null)
43
- })
44
- </script>
45
-
46
- {#each points as pt, i (i)}
47
- <circle
48
- cx={pt.cx}
49
- cy={pt.cy}
50
- {r}
51
- {fill}
52
- {stroke}
53
- stroke-width={strokeWidth}
54
- data-plot-element="point"
55
- role="graphics-symbol"
56
- aria-label={pt.label}
57
- />
58
- {/each}
@@ -1,13 +0,0 @@
1
- type Datum = Record<string, unknown> | number;
2
- type Props = {
3
- data?: Datum[];
4
- x?: string;
5
- y?: string;
6
- r?: number;
7
- fill?: string;
8
- stroke?: string;
9
- strokeWidth?: number;
10
- };
11
- declare const Point: import("svelte").Component<Props, {}, "">;
12
- type Point = ReturnType<typeof Point>;
13
- export default Point;