@rokkit/chart 1.0.0-next.15 → 1.0.0-next.150

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 (223) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +150 -46
  3. package/dist/Plot/index.d.ts +9 -0
  4. package/dist/PlotState.svelte.d.ts +47 -0
  5. package/dist/crossfilter/createCrossFilter.svelte.d.ts +15 -0
  6. package/dist/elements/index.d.ts +6 -0
  7. package/dist/geoms/lib/areas.d.ts +52 -0
  8. package/dist/geoms/lib/bars.d.ts +3 -0
  9. package/dist/index.d.ts +51 -0
  10. package/dist/lib/brewer.d.ts +9 -0
  11. package/dist/lib/brewing/BoxBrewer.svelte.d.ts +10 -0
  12. package/dist/lib/brewing/CartesianBrewer.svelte.d.ts +8 -0
  13. package/dist/lib/brewing/PieBrewer.svelte.d.ts +8 -0
  14. package/dist/lib/brewing/ViolinBrewer.svelte.d.ts +9 -0
  15. package/dist/lib/brewing/axes.svelte.d.ts +66 -0
  16. package/dist/lib/brewing/bars.svelte.d.ts +56 -0
  17. package/dist/lib/brewing/brewer.svelte.d.ts +145 -0
  18. package/dist/lib/brewing/colors.d.ts +17 -0
  19. package/dist/lib/brewing/dimensions.svelte.d.ts +35 -0
  20. package/dist/lib/brewing/index.svelte.d.ts +118 -0
  21. package/dist/lib/brewing/legends.svelte.d.ts +48 -0
  22. package/dist/lib/brewing/marks/arcs.d.ts +17 -0
  23. package/dist/lib/brewing/marks/areas.d.ts +31 -0
  24. package/dist/lib/brewing/marks/bars.d.ts +1 -0
  25. package/dist/lib/brewing/marks/boxes.d.ts +24 -0
  26. package/dist/lib/brewing/marks/lines.d.ts +24 -0
  27. package/dist/lib/brewing/marks/points.d.ts +40 -0
  28. package/dist/lib/brewing/marks/violins.d.ts +20 -0
  29. package/dist/lib/brewing/patterns.d.ts +14 -0
  30. package/dist/lib/brewing/scales.d.ts +28 -0
  31. package/dist/lib/brewing/scales.svelte.d.ts +24 -0
  32. package/dist/lib/brewing/stats.d.ts +31 -0
  33. package/dist/lib/brewing/symbols.d.ts +7 -0
  34. package/dist/lib/brewing/types.d.ts +162 -0
  35. package/dist/lib/chart.d.ts +40 -0
  36. package/dist/lib/context.d.ts +13 -0
  37. package/dist/lib/grid.d.ts +72 -0
  38. package/dist/lib/plot/chartProps.d.ts +177 -0
  39. package/dist/lib/plot/crossfilter.d.ts +13 -0
  40. package/dist/lib/plot/facet.d.ts +24 -0
  41. package/dist/lib/plot/frames.d.ts +47 -0
  42. package/dist/lib/plot/helpers.d.ts +3 -0
  43. package/dist/lib/plot/preset.d.ts +29 -0
  44. package/dist/lib/plot/scales.d.ts +5 -0
  45. package/dist/lib/plot/stat.d.ts +32 -0
  46. package/dist/lib/plot/types.d.ts +89 -0
  47. package/dist/lib/scales.svelte.d.ts +35 -0
  48. package/dist/lib/swatch.d.ts +12 -0
  49. package/dist/lib/ticks.d.ts +36 -0
  50. package/dist/lib/utils.d.ts +61 -0
  51. package/dist/lib/xscale.d.ts +11 -0
  52. package/dist/patterns/index.d.ts +4 -0
  53. package/dist/patterns/patterns.d.ts +72 -0
  54. package/dist/patterns/scale.d.ts +30 -0
  55. package/dist/symbols/constants/index.d.ts +1 -0
  56. package/dist/symbols/index.d.ts +5 -0
  57. package/package.json +41 -45
  58. package/src/AnimatedPlot.svelte +214 -0
  59. package/src/Chart.svelte +101 -0
  60. package/src/FacetPlot/Panel.svelte +23 -0
  61. package/src/FacetPlot.svelte +90 -0
  62. package/src/Plot/Arc.svelte +29 -0
  63. package/src/Plot/Area.svelte +25 -0
  64. package/src/Plot/Axis.svelte +73 -0
  65. package/src/Plot/Bar.svelte +96 -0
  66. package/src/Plot/Grid.svelte +30 -0
  67. package/src/Plot/Legend.svelte +167 -0
  68. package/src/Plot/Line.svelte +27 -0
  69. package/src/Plot/Point.svelte +27 -0
  70. package/src/Plot/Root.svelte +107 -0
  71. package/src/Plot/Timeline.svelte +95 -0
  72. package/src/Plot/Tooltip.svelte +81 -0
  73. package/src/Plot/index.js +9 -0
  74. package/src/Plot.svelte +189 -0
  75. package/src/PlotState.svelte.js +278 -0
  76. package/src/Sparkline.svelte +69 -0
  77. package/src/Symbol.svelte +21 -0
  78. package/src/Texture.svelte +18 -0
  79. package/src/charts/AreaChart.svelte +25 -0
  80. package/src/charts/BarChart.svelte +26 -0
  81. package/src/charts/BoxPlot.svelte +21 -0
  82. package/src/charts/BubbleChart.svelte +23 -0
  83. package/src/charts/LineChart.svelte +26 -0
  84. package/src/charts/PieChart.svelte +25 -0
  85. package/src/charts/ScatterPlot.svelte +25 -0
  86. package/src/charts/ViolinPlot.svelte +21 -0
  87. package/src/crossfilter/CrossFilter.svelte +38 -0
  88. package/src/crossfilter/FilterBar.svelte +32 -0
  89. package/src/crossfilter/FilterSlider.svelte +79 -0
  90. package/src/crossfilter/createCrossFilter.svelte.js +113 -0
  91. package/src/elements/Bar.svelte +22 -24
  92. package/src/elements/ColorRamp.svelte +20 -22
  93. package/src/elements/ContinuousLegend.svelte +20 -17
  94. package/src/elements/DefinePatterns.svelte +24 -0
  95. package/src/elements/DiscreteLegend.svelte +15 -15
  96. package/src/elements/Label.svelte +4 -8
  97. package/src/elements/SymbolGrid.svelte +22 -0
  98. package/src/elements/index.js +6 -0
  99. package/src/examples/BarChartExample.svelte +81 -0
  100. package/src/geoms/Arc.svelte +81 -0
  101. package/src/geoms/Area.svelte +50 -0
  102. package/src/geoms/Bar.svelte +142 -0
  103. package/src/geoms/Box.svelte +101 -0
  104. package/src/geoms/LabelPill.svelte +17 -0
  105. package/src/geoms/Line.svelte +100 -0
  106. package/src/geoms/Point.svelte +100 -0
  107. package/src/geoms/Violin.svelte +44 -0
  108. package/src/geoms/lib/areas.js +131 -0
  109. package/src/geoms/lib/bars.js +172 -0
  110. package/src/index.js +67 -16
  111. package/src/lib/brewer.js +25 -0
  112. package/src/lib/brewing/BoxBrewer.svelte.js +56 -0
  113. package/src/lib/brewing/CartesianBrewer.svelte.js +16 -0
  114. package/src/lib/brewing/PieBrewer.svelte.js +14 -0
  115. package/src/lib/brewing/ViolinBrewer.svelte.js +55 -0
  116. package/src/lib/brewing/axes.svelte.js +270 -0
  117. package/src/lib/brewing/bars.svelte.js +201 -0
  118. package/src/lib/brewing/brewer.svelte.js +229 -0
  119. package/src/lib/brewing/colors.js +22 -0
  120. package/src/lib/brewing/dimensions.svelte.js +56 -0
  121. package/src/lib/brewing/index.svelte.js +205 -0
  122. package/src/lib/brewing/legends.svelte.js +137 -0
  123. package/src/lib/brewing/marks/arcs.js +43 -0
  124. package/src/lib/brewing/marks/areas.js +59 -0
  125. package/src/lib/brewing/marks/bars.js +49 -0
  126. package/src/lib/brewing/marks/boxes.js +75 -0
  127. package/src/lib/brewing/marks/lines.js +48 -0
  128. package/src/lib/brewing/marks/points.js +57 -0
  129. package/src/lib/brewing/marks/violins.js +90 -0
  130. package/src/lib/brewing/patterns.js +31 -0
  131. package/src/lib/brewing/scales.js +51 -0
  132. package/src/lib/brewing/scales.svelte.js +82 -0
  133. package/src/lib/brewing/stats.js +62 -0
  134. package/src/lib/brewing/symbols.js +10 -0
  135. package/src/lib/brewing/types.js +73 -0
  136. package/src/lib/chart.js +213 -0
  137. package/src/lib/context.js +131 -0
  138. package/src/lib/grid.js +85 -0
  139. package/src/lib/plot/chartProps.js +76 -0
  140. package/src/lib/plot/crossfilter.js +16 -0
  141. package/src/lib/plot/facet.js +58 -0
  142. package/src/lib/plot/frames.js +80 -0
  143. package/src/lib/plot/helpers.js +14 -0
  144. package/src/lib/plot/preset.js +53 -0
  145. package/src/lib/plot/scales.js +56 -0
  146. package/src/lib/plot/stat.js +92 -0
  147. package/src/lib/plot/types.js +65 -0
  148. package/src/lib/scales.svelte.js +151 -0
  149. package/src/lib/swatch.js +13 -0
  150. package/src/lib/ticks.js +46 -0
  151. package/src/lib/utils.js +111 -118
  152. package/src/lib/xscale.js +31 -0
  153. package/src/patterns/DefinePatterns.svelte +32 -0
  154. package/src/patterns/PatternDef.svelte +27 -0
  155. package/src/patterns/README.md +3 -0
  156. package/src/patterns/index.js +4 -0
  157. package/src/patterns/patterns.js +208 -0
  158. package/src/patterns/scale.js +87 -0
  159. package/src/spec/chart-spec.js +29 -0
  160. package/src/symbols/RoundedSquare.svelte +33 -0
  161. package/src/symbols/Shape.svelte +37 -0
  162. package/src/symbols/constants/index.js +4 -0
  163. package/src/symbols/index.js +9 -0
  164. package/src/symbols/outline.svelte +60 -0
  165. package/src/symbols/solid.svelte +60 -0
  166. package/src/chart/FacetGrid.svelte +0 -51
  167. package/src/chart/Grid.svelte +0 -34
  168. package/src/chart/Legend.svelte +0 -16
  169. package/src/chart/PatternDefs.svelte +0 -13
  170. package/src/chart/Swatch.svelte +0 -93
  171. package/src/chart/SwatchButton.svelte +0 -29
  172. package/src/chart/SwatchGrid.svelte +0 -55
  173. package/src/chart/Symbol.svelte +0 -37
  174. package/src/chart/Texture.svelte +0 -16
  175. package/src/chart/TexturedShape.svelte +0 -27
  176. package/src/chart/TimelapseChart.svelte +0 -97
  177. package/src/chart/Timer.svelte +0 -27
  178. package/src/chart.js +0 -9
  179. package/src/components/charts/Axis.svelte +0 -66
  180. package/src/components/charts/Chart.svelte +0 -35
  181. package/src/components/index.js +0 -23
  182. package/src/components/lib/axis.js +0 -0
  183. package/src/components/lib/chart.js +0 -187
  184. package/src/components/lib/color.js +0 -327
  185. package/src/components/lib/funnel.js +0 -204
  186. package/src/components/lib/index.js +0 -19
  187. package/src/components/lib/pattern.js +0 -190
  188. package/src/components/lib/rollup.js +0 -55
  189. package/src/components/lib/shape.js +0 -199
  190. package/src/components/lib/summary.js +0 -145
  191. package/src/components/lib/theme.js +0 -23
  192. package/src/components/lib/timer.js +0 -41
  193. package/src/components/lib/utils.js +0 -165
  194. package/src/components/plots/BarPlot.svelte +0 -36
  195. package/src/components/plots/BoxPlot.svelte +0 -54
  196. package/src/components/plots/ScatterPlot.svelte +0 -30
  197. package/src/components/store.js +0 -70
  198. package/src/constants.js +0 -66
  199. package/src/elements/PatternDefs.svelte +0 -13
  200. package/src/elements/PatternMask.svelte +0 -20
  201. package/src/elements/Symbol.svelte +0 -38
  202. package/src/elements/Tooltip.svelte +0 -23
  203. package/src/funnel.svelte +0 -35
  204. package/src/geom.js +0 -105
  205. package/src/lib/axis.js +0 -75
  206. package/src/lib/colors.js +0 -32
  207. package/src/lib/geom.js +0 -4
  208. package/src/lib/shapes.js +0 -144
  209. package/src/lib/timer.js +0 -44
  210. package/src/lookup.js +0 -29
  211. package/src/plots/BarPlot.svelte +0 -55
  212. package/src/plots/BoxPlot.svelte +0 -0
  213. package/src/plots/FunnelPlot.svelte +0 -33
  214. package/src/plots/HeatMap.svelte +0 -5
  215. package/src/plots/HeatMapCalendar.svelte +0 -129
  216. package/src/plots/LinePlot.svelte +0 -55
  217. package/src/plots/Plot.svelte +0 -25
  218. package/src/plots/RankBarPlot.svelte +0 -38
  219. package/src/plots/ScatterPlot.svelte +0 -20
  220. package/src/plots/ViolinPlot.svelte +0 -11
  221. package/src/plots/heatmap.js +0 -70
  222. package/src/plots/index.js +0 -10
  223. package/src/swatch.js +0 -11
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2022 Jerry Thomas
3
+ Copyright (c) 2025 Jerry Thomas
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -1,55 +1,159 @@
1
- # Charts for Svelte
1
+ # @rokkit/chart
2
2
 
3
- The core idea behind the implementation is to use the respective strengths of both D3 and Svelte to build Themable, Composable, Animated, Responsive, Accessible, and Reactive Data Visualization components.
3
+ Data-driven D3 chart components for Svelte 5, inspired by the composable approach of [dc.js](https://dc-js.github.io/dc.js/).
4
4
 
5
- - [D3](https://d3js.org/) makes working with SVG a breeze. It provides a large set of utility functions for graph visualization that includes the computation of scales, interpolation, shapes, and more.
6
- - [Svelte](https://svelte.dev/) makes UI development fun again. It provides modularization, interactivity, reactivity, and responsiveness.
5
+ ## Install
7
6
 
8
- This component library borrows concepts from the following articles, products, and repositories.
7
+ ```bash
8
+ bun add @rokkit/chart
9
+ # or
10
+ npm install @rokkit/chart
11
+ ```
9
12
 
10
- - [Introduction to Accessible Contrast and Color for Data Visualization](https://observablehq.com/@frankelavsky/chartability-contrast-series) by [Frank Elavsky](https://observablehq.com/@frankelavsky)
11
- - [Animated, Responsive, and Reactive Data Visualization with Svelte](https://www.infoq.com/news/2020/10/svelte-d3-animation-data-vis/)
12
- - [Barchart Race using Svelte & D3](https://t.co/iIoJw4f7Jc?amp=1) by [Amelia Wattenberger](https://mobile.twitter.com/Wattenberger) & [Russell Goldenberg](https://mobile.twitter.com/codenberg)
13
- - [The D3.js Graph Gallery](https://www.d3-graph-gallery.com/index.html)
14
- - [DC.js](https://dc-js.github.io/dc.js/) is an awesome implementation of interactive animated charts using D3.
13
+ ## Overview
15
14
 
16
- ## Getting Started
15
+ `@rokkit/chart` provides composable SVG chart components built on D3. All components are placed inside `Plot.Root`, which manages shared state (scales, dimensions, color mapping) via Svelte context. Child components read from that context — you do not wire them together manually.
17
16
 
18
- Get started quickly using [degit](https://github.com/Rich-Harris/degit).
17
+ ## Usage
19
18
 
20
- ```bash
21
- degit jerrythomas/sparsh-ui/sites/playground my-app
19
+ ### Basic bar chart
20
+
21
+ ```svelte
22
+ <script>
23
+ import { Plot } from '@rokkit/chart'
24
+
25
+ const data = [
26
+ { month: 'Jan', sales: 120, returns: 30 },
27
+ { month: 'Feb', sales: 150, returns: 20 },
28
+ { month: 'Mar', sales: 90, returns: 40 }
29
+ ]
30
+ </script>
31
+
32
+ <Plot.Root {data} width={600} height={400} fill="month">
33
+ <Plot.Grid />
34
+ <Plot.Axis type="x" field="month" label="Month" />
35
+ <Plot.Axis type="y" field="sales" label="Sales" />
36
+ <Plot.Bar x="month" y="sales" />
37
+ <Plot.Legend />
38
+ </Plot.Root>
22
39
  ```
23
40
 
24
- ## Features
25
-
26
- - [x] Fill patterns
27
- - [x] Symbols
28
- - [x] Colors
29
- - [ ] Themes
30
-
31
- ### Plots
32
-
33
- - [x] Box
34
- - [ ] Violin
35
- - [x] Scatter
36
- - [ ] Line
37
- - [ ] Histogram
38
- - [ ] StackedBar
39
- - [ ] Funnel
40
-
41
- ### Chart
42
-
43
- - [x] Axis
44
- - [x] Labels
45
- - [x] Grid
46
- - [x] Ticks
47
- - [ ] Margins
48
- - [ ] Legend
49
- - [ ] Composable
50
- - [ ] Facet Grid
51
- - [ ] Combine multiple plots
52
- - [ ] Animation
53
- - [ ] Time lapse
54
- - [ ] Sliding window
55
- - [ ] Rolling window
41
+ ### Using `@rokkit/data` for preprocessing
42
+
43
+ ```svelte
44
+ <script>
45
+ import { Plot } from '@rokkit/chart'
46
+ import { dataset } from '@rokkit/data'
47
+
48
+ const raw = [
49
+ { category: 'Electronics', name: 'A', revenue: 450 },
50
+ { category: 'Clothing', name: 'B', revenue: 320 },
51
+ { category: 'Electronics', name: 'C', revenue: 620 }
52
+ ]
53
+
54
+ const data = dataset(raw)
55
+ .groupBy('category')
56
+ .summarize('name', { total: (vals) => vals.reduce((s, v) => s + v.revenue, 0) })
57
+ .rollup()
58
+ </script>
59
+
60
+ <Plot.Root {data} fill="category" width={500} height={350}>
61
+ <Plot.Axis type="x" field="category" />
62
+ <Plot.Axis type="y" field="total" />
63
+ <Plot.Bar x="category" y="total" />
64
+ <Plot.Legend />
65
+ </Plot.Root>
66
+ ```
67
+
68
+ ### Using `ChartBrewer` for advanced control
69
+
70
+ `ChartBrewer` is the reactive state manager that `Plot.Root` uses internally. Use it directly when you need programmatic access to scales, axes, or legend state outside of the component tree.
71
+
72
+ ```js
73
+ import { ChartBrewer, createScales, createBars } from '@rokkit/chart'
74
+
75
+ const brewer = new ChartBrewer({
76
+ width: 600,
77
+ height: 400,
78
+ margin: { top: 20, right: 30, bottom: 40, left: 50 },
79
+ padding: 0.2,
80
+ animationDuration: 300
81
+ })
82
+
83
+ brewer.setData(data)
84
+ brewer.setFields({ x: 'month', y: 'sales', color: 'month' })
85
+ brewer.createScales()
86
+
87
+ const scales = brewer.getScales()
88
+ const dimensions = brewer.getDimensions()
89
+ ```
90
+
91
+ ## API
92
+
93
+ ### Components (`Plot` namespace)
94
+
95
+ | Component | Description |
96
+ | ------------- | --------------------------------------------------------- |
97
+ | `Plot.Root` | Chart container. Manages dimensions, scales, and context. |
98
+ | `Plot.Bar` | Bar series. Reads x/y fields and renders SVG rects. |
99
+ | `Plot.Axis` | X or Y axis with optional label and tick formatting. |
100
+ | `Plot.Grid` | Background grid lines derived from axis scales. |
101
+ | `Plot.Legend` | Color legend; clicking items filters the visible series. |
102
+
103
+ ### `Plot.Root` props
104
+
105
+ | Prop | Type | Default | Description |
106
+ | ------------------- | ------------------ | ------------------------------------- | --------------------------------------------------------------------- |
107
+ | `data` | `array \| dataset` | `[]` | Chart data. Accepts a plain array or a `@rokkit/data` dataset object. |
108
+ | `width` | `number` | `600` | SVG width in pixels. |
109
+ | `height` | `number` | `400` | SVG height in pixels. |
110
+ | `margin` | `object` | `{top:20,right:30,bottom:40,left:50}` | Chart margins. |
111
+ | `fill` | `string` | `null` | Field name used for color mapping. |
112
+ | `responsive` | `boolean` | `true` | Resize with the container. |
113
+ | `animationDuration` | `number` | `300` | Transition duration in ms. |
114
+
115
+ ### `Plot.Bar` props
116
+
117
+ | Prop | Type | Default | Description |
118
+ | ------------------- | ---------- | ----------- | --------------------------------------------- |
119
+ | `x` | `string` | — | Field for x-axis values. |
120
+ | `y` | `string` | — | Field for y-axis values. |
121
+ | `fill` | `string` | — | Field for color mapping (overrides root). |
122
+ | `color` | `string` | `'#4682b4'` | Fallback bar color when no fill field is set. |
123
+ | `opacity` | `number` | `1` | Bar opacity. |
124
+ | `animationDuration` | `number` | `300` | Per-bar transition duration in ms. |
125
+ | `onClick` | `function` | `null` | Click handler; receives the data row. |
126
+
127
+ ### `Plot.Axis` props
128
+
129
+ | Prop | Type | Default | Description |
130
+ | ------------ | ------------ | ------- | --------------------------------- |
131
+ | `type` | `'x' \| 'y'` | `'x'` | Axis orientation. |
132
+ | `field` | `string` | — | Data field this axis represents. |
133
+ | `label` | `string` | `''` | Axis label. |
134
+ | `ticks` | `number` | — | Suggested tick count. |
135
+ | `tickFormat` | `function` | — | D3 tick formatter. |
136
+ | `grid` | `boolean` | `false` | Render grid lines from this axis. |
137
+
138
+ ### Utility functions
139
+
140
+ | Export | Description |
141
+ | ----------------------------------------- | ------------------------------------------- |
142
+ | `createDimensions(width, height, margin)` | Compute chart area dimensions with margins |
143
+ | `createScales(data, fields, dimensions)` | Generate D3 band/linear scales |
144
+ | `createBars(data, scales, fields)` | Compute bar x/y/width/height attributes |
145
+ | `createGroupedBars(data, scales, fields)` | Compute grouped bar layout |
146
+ | `createLegend(data, colorScale)` | Build legend item array |
147
+ | `filterByLegend(data, activeItems)` | Filter data rows by active legend selection |
148
+ | `createXAxis(scale, options)` | Build D3 x-axis descriptor |
149
+ | `createYAxis(scale, options)` | Build D3 y-axis descriptor |
150
+ | `createGrid(scales, dimensions)` | Build grid line descriptors |
151
+
152
+ ## Dependencies
153
+
154
+ - `d3-scale`, `d3-axis`, `d3-format`, `d3-selection`, `d3-array`, `d3-transition`, `d3-scale-chromatic`
155
+ - `@rokkit/core`, `@rokkit/data`, `@rokkit/states`
156
+
157
+ ---
158
+
159
+ Part of [Rokkit](https://github.com/jerrythomas/rokkit) — a Svelte 5 component library and design system.
@@ -0,0 +1,9 @@
1
+ export { default as Root } from "./Root.svelte";
2
+ export { default as Axis } from "./Axis.svelte";
3
+ export { default as Bar } from "./Bar.svelte";
4
+ export { default as Legend } from "./Legend.svelte";
5
+ export { default as Grid } from "./Grid.svelte";
6
+ export { default as Line } from "./Line.svelte";
7
+ export { default as Area } from "./Area.svelte";
8
+ export { default as Point } from "./Point.svelte";
9
+ export { default as Arc } from "./Arc.svelte";
@@ -0,0 +1,47 @@
1
+ export class PlotState {
2
+ constructor(config?: {});
3
+ axisOrigin: undefined[];
4
+ orientation: string;
5
+ colorScaleType: any;
6
+ xScale: any;
7
+ yScale: any;
8
+ colors: Map<unknown, {
9
+ fill: string;
10
+ stroke: string;
11
+ }>;
12
+ patterns: Map<any, any>;
13
+ symbols: Map<any, any>;
14
+ colorField: any;
15
+ patternField: any;
16
+ symbolField: any;
17
+ geomTypes: Set<any>;
18
+ xAxisY: any;
19
+ yAxisX: any;
20
+ update(config: any): void;
21
+ registerGeom(config: any): string;
22
+ updateGeom(id: any, config: any): void;
23
+ unregisterGeom(id: any): void;
24
+ geomData(id: any): any[];
25
+ label(field: any): any;
26
+ format(field: any): any;
27
+ tooltip(): any;
28
+ geomComponent(type: any): any;
29
+ preset(): {
30
+ colors: any;
31
+ patterns: any;
32
+ symbols: any;
33
+ };
34
+ get margin(): {
35
+ top: number;
36
+ right: number;
37
+ bottom: number;
38
+ left: number;
39
+ };
40
+ get innerWidth(): number;
41
+ get innerHeight(): number;
42
+ get mode(): string;
43
+ get hovered(): null;
44
+ setHovered(data: any): void;
45
+ clearHovered(): void;
46
+ #private;
47
+ }
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Creates a reactive cross-filter state object.
3
+ *
4
+ * Filter values follow the spec type:
5
+ * FilterState = Map<string, Set<unknown> | [number, number]>
6
+ * - categorical: raw Set of selected values
7
+ * - continuous: [min, max] tuple
8
+ *
9
+ * Exposes a `filters` getter so CrossFilter.svelte can bind to current state.
10
+ * Exposes a `version` counter that increments on every mutation, giving
11
+ * components a simple reactive signal to watch for filter changes.
12
+ *
13
+ * @returns {CrossFilter}
14
+ */
15
+ export function createCrossFilter(): CrossFilter;
@@ -0,0 +1,6 @@
1
+ export { default as Bar } from "./Bar.svelte";
2
+ export { default as ColorRamp } from "./ColorRamp.svelte";
3
+ export { default as ContinuousLegend } from "./ContinuousLegend.svelte";
4
+ export { default as Label } from "./Label.svelte";
5
+ export { default as DefinePatterns } from "./DefinePatterns.svelte";
6
+ export { default as SymbolGrid } from "./SymbolGrid.svelte";
@@ -0,0 +1,52 @@
1
+ /**
2
+ * Builds area path geometry for multi-series area charts.
3
+ *
4
+ * @param {Object[]} data
5
+ * @param {{ x: string, y: string, color?: string }} channels
6
+ * @param {Function} xScale
7
+ * @param {Function} yScale
8
+ * @param {Map<unknown, {fill: string, stroke: string}>} colors
9
+ * @param {'linear'|'smooth'|'step'} [curve]
10
+ * @param {Map<unknown, string>} [patterns]
11
+ * @returns {{ d: string, fill: string, stroke: string, key: unknown, patternId: string|null }[]}
12
+ */
13
+ export function buildAreas(data: Object[], channels: {
14
+ x: string;
15
+ y: string;
16
+ color?: string;
17
+ }, xScale: Function, yScale: Function, colors: Map<unknown, {
18
+ fill: string;
19
+ stroke: string;
20
+ }>, curve?: "linear" | "smooth" | "step", patterns?: Map<unknown, string>): {
21
+ d: string;
22
+ fill: string;
23
+ stroke: string;
24
+ key: unknown;
25
+ patternId: string | null;
26
+ }[];
27
+ /**
28
+ * Builds stacked area paths using d3 stack layout.
29
+ *
30
+ * @param {Object[]} data
31
+ * @param {{ x: string, y: string, color: string }} channels
32
+ * @param {Function} xScale
33
+ * @param {Function} yScale
34
+ * @param {Map<unknown, {fill: string, stroke: string}>} colors
35
+ * @param {'linear'|'smooth'|'step'} [curve]
36
+ * @param {Map<unknown, string>} [patterns]
37
+ * @returns {{ d: string, fill: string, stroke: string, key: unknown, patternId: string|null }[]}
38
+ */
39
+ export function buildStackedAreas(data: Object[], channels: {
40
+ x: string;
41
+ y: string;
42
+ color: string;
43
+ }, xScale: Function, yScale: Function, colors: Map<unknown, {
44
+ fill: string;
45
+ stroke: string;
46
+ }>, curve?: "linear" | "smooth" | "step", patterns?: Map<unknown, string>): {
47
+ d: string;
48
+ fill: string;
49
+ stroke: string;
50
+ key: unknown;
51
+ patternId: string | null;
52
+ }[];
@@ -0,0 +1,3 @@
1
+ export function buildGroupedBars(data: any, channels: any, xScale: any, yScale: any, colors: any, innerHeight: any, patterns: any): any;
2
+ export function buildStackedBars(data: any, channels: any, xScale: any, yScale: any, colors: any, innerHeight: any, patterns: any): any;
3
+ export function buildHorizontalBars(data: any, channels: any, xScale: any, yScale: any, colors: any, _innerHeight: any): any;
@@ -0,0 +1,51 @@
1
+ export namespace PlotLayers {
2
+ export { Root };
3
+ export { Axis };
4
+ export { Bar };
5
+ export { Grid };
6
+ export { Legend };
7
+ export { Line };
8
+ export { Area };
9
+ export { Point };
10
+ export { Arc };
11
+ }
12
+ export { default as PlotChart } from "./Plot.svelte";
13
+ export { default as FacetPlot } from "./FacetPlot.svelte";
14
+ export { default as AnimatedPlot } from "./AnimatedPlot.svelte";
15
+ export { default as GeomBar } from "./geoms/Bar.svelte";
16
+ export { default as GeomLine } from "./geoms/Line.svelte";
17
+ export { default as GeomArea } from "./geoms/Area.svelte";
18
+ export { default as GeomPoint } from "./geoms/Point.svelte";
19
+ export { default as GeomArc } from "./geoms/Arc.svelte";
20
+ export { default as GeomBox } from "./geoms/Box.svelte";
21
+ export { default as GeomViolin } from "./geoms/Violin.svelte";
22
+ export { default as Chart } from "./Chart.svelte";
23
+ export { default as Sparkline } from "./Sparkline.svelte";
24
+ export { default as BarChart } from "./charts/BarChart.svelte";
25
+ export { default as LineChart } from "./charts/LineChart.svelte";
26
+ export { default as AreaChart } from "./charts/AreaChart.svelte";
27
+ export { default as PieChart } from "./charts/PieChart.svelte";
28
+ export { default as ScatterPlot } from "./charts/ScatterPlot.svelte";
29
+ export { default as BoxPlot } from "./charts/BoxPlot.svelte";
30
+ export { default as ViolinPlot } from "./charts/ViolinPlot.svelte";
31
+ export { default as BubbleChart } from "./charts/BubbleChart.svelte";
32
+ export { PlotState } from "./PlotState.svelte.js";
33
+ export { ChartBrewer } from "./lib/brewing/index.svelte.js";
34
+ export * from "./lib/brewing/index.svelte.js";
35
+ export { CartesianBrewer } from "./lib/brewing/CartesianBrewer.svelte.js";
36
+ export { PieBrewer } from "./lib/brewing/PieBrewer.svelte.js";
37
+ export { BoxBrewer } from "./lib/brewing/BoxBrewer.svelte.js";
38
+ export { ViolinBrewer } from "./lib/brewing/ViolinBrewer.svelte.js";
39
+ export { createCrossFilter } from "./crossfilter/createCrossFilter.svelte.js";
40
+ export { default as CrossFilter } from "./crossfilter/CrossFilter.svelte";
41
+ export { default as FilterBar } from "./crossfilter/FilterBar.svelte";
42
+ export { default as FilterSlider } from "./crossfilter/FilterSlider.svelte";
43
+ import Root from './Plot/Root.svelte';
44
+ import Axis from './Plot/Axis.svelte';
45
+ import Bar from './Plot/Bar.svelte';
46
+ import Grid from './Plot/Grid.svelte';
47
+ import Legend from './Plot/Legend.svelte';
48
+ import Line from './Plot/Line.svelte';
49
+ import Area from './Plot/Area.svelte';
50
+ import Point from './Plot/Point.svelte';
51
+ import Arc from './Plot/Arc.svelte';
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Get fill patterns for a set of values
3
+ *
4
+ * @param {Array} values - Array of values
5
+ * @param {Object} swatch - Object with keys for color, gray, and pattern
6
+ * @param {Boolean} gray - Boolean to determine if gray or color
7
+ * @returns {Object} - Object with keys for pattern and color
8
+ */
9
+ export function getFillPatterns(values: any[], swatch: Object, gray?: boolean): Object;
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Brewer for box plots. Always computes quartile statistics regardless of the stat prop.
3
+ * Groups by x + fill (primary) or x + color (fallback).
4
+ * fill = box interior color, color = whisker/outline stroke.
5
+ */
6
+ export class BoxBrewer extends ChartBrewer {
7
+ transform(data: any, channels: any): any;
8
+ boxes: any[];
9
+ }
10
+ import { ChartBrewer } from './brewer.svelte.js';
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Brewer for cartesian charts (Bar, Line, Area).
3
+ * Groups by x (and fill/color if set) and applies the given stat.
4
+ */
5
+ export class CartesianBrewer extends ChartBrewer {
6
+ transform(data: any, channels: any, stat: any): any;
7
+ }
8
+ import { ChartBrewer } from './brewer.svelte.js';
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Brewer for pie charts. Always aggregates by the label field.
3
+ * 'identity' is not meaningful for pie charts — falls back to 'sum'.
4
+ */
5
+ export class PieBrewer extends ChartBrewer {
6
+ transform(data: any, channels: any, stat: any): any;
7
+ }
8
+ import { ChartBrewer } from './brewer.svelte.js';
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Brewer for violin plots. Computes the same quartile statistics as BoxBrewer.
3
+ * fill = violin body color, color = outline stroke.
4
+ */
5
+ export class ViolinBrewer extends ChartBrewer {
6
+ transform(data: any, channels: any): any;
7
+ violins: any[];
8
+ }
9
+ import { ChartBrewer } from './brewer.svelte.js';
@@ -0,0 +1,66 @@
1
+ /**
2
+ * Creates x-axis tick data for rendering
3
+ *
4
+ * @param {Object} scales - Chart scales
5
+ * @param {Function} scales.x - X-axis scale
6
+ * @param {Object} dimensions - Chart dimensions
7
+ * @param {Object} options - Axis options
8
+ * @param {number} [options.tickCount] - Number of ticks to show
9
+ * @param {Function} [options.tickFormat] - Tick formatting function
10
+ * @param {string} [options.label] - Axis label
11
+ * @returns {AxisData} Axis rendering data
12
+ */
13
+ export function createXAxis(scales: {
14
+ x: Function;
15
+ }, dimensions: Object, options: {
16
+ tickCount?: number | undefined;
17
+ tickFormat?: Function | undefined;
18
+ label?: string | undefined;
19
+ }): AxisData;
20
+ /**
21
+ * Creates y-axis tick data for rendering
22
+ *
23
+ * @param {Object} scales - Chart scales
24
+ * @param {Function} scales.y - Y-axis scale
25
+ * @param {Object} dimensions - Chart dimensions
26
+ * @param {Object} options - Axis options
27
+ * @param {number} [options.tickCount] - Number of ticks to show
28
+ * @param {Function} [options.tickFormat] - Tick formatting function
29
+ * @param {string} [options.label] - Axis label
30
+ * @returns {AxisData} Axis rendering data
31
+ */
32
+ export function createYAxis(scales: {
33
+ y: Function;
34
+ }, dimensions: Object, options: {
35
+ tickCount?: number | undefined;
36
+ tickFormat?: Function | undefined;
37
+ label?: string | undefined;
38
+ }): AxisData;
39
+ /**
40
+ * Creates grid line data for rendering
41
+ *
42
+ * @param {Object} scales - Chart scales
43
+ * @param {Object} dimensions - Chart dimensions
44
+ * @param {Object} options - Grid options
45
+ * @param {string} [options.direction='both'] - Grid direction ('x', 'y', or 'both')
46
+ * @param {number} [options.xTickCount] - Number of x-axis ticks
47
+ * @param {number} [options.yTickCount] - Number of y-axis ticks
48
+ * @returns {Object} Grid rendering data
49
+ */
50
+ export function createGrid(scales: Object, dimensions: Object, options: {
51
+ direction?: string | undefined;
52
+ xTickCount?: number | undefined;
53
+ yTickCount?: number | undefined;
54
+ }): Object;
55
+ /**
56
+ * Creates DOM attributes for a tick element
57
+ *
58
+ * @param {TickData} tick - Tick data
59
+ * @param {string} axis - Axis type ('x' or 'y')
60
+ * @returns {Object} Attributes for the tick
61
+ */
62
+ export function createTickAttributes(tick: TickData, axis: string): Object;
63
+ export type TickData = import("./types").TickData;
64
+ export type AxisData = import("./types").AxisData;
65
+ export type ChartScales = import("./types").ChartScales;
66
+ export type ChartDimensions = import("./types").ChartDimensions;
@@ -0,0 +1,56 @@
1
+ /**
2
+ * Creates bar data for rendering
3
+ *
4
+ * @param {Array} data - Chart data
5
+ * @param {Object} fields - Field mappings
6
+ * @param {string} fields.x - X-axis field
7
+ * @param {string} fields.y - Y-axis field
8
+ * @param {string} fields.color - Color field (optional)
9
+ * @param {Object} scales - Chart scales
10
+ * @param {Function} scales.x - X-axis scale
11
+ * @param {Function} scales.y - Y-axis scale
12
+ * @param {Function} scales.color - Color scale
13
+ * @param {Object} options - Options including dimensions and defaultColor
14
+ * @param {Object} options.dimensions - Chart dimensions
15
+ * @param {string} [options.defaultColor='#4682b4'] - Default color if no color scale
16
+ * @returns {BarData[]} Bar data for rendering
17
+ */
18
+ export function createBars(data: any[], fields: {
19
+ x: string;
20
+ y: string;
21
+ color: string;
22
+ }, scales: {
23
+ x: Function;
24
+ y: Function;
25
+ color: Function;
26
+ }, options: {
27
+ dimensions: Object;
28
+ defaultColor?: string | undefined;
29
+ }): BarData[];
30
+ /**
31
+ * Filter bars based on a selection criteria
32
+ *
33
+ * @param {BarData[]} bars - Bar data array
34
+ * @param {Object} selection - Selection criteria
35
+ * @returns {BarData[]} Filtered bars
36
+ */
37
+ export function filterBars(bars: BarData[], selection: Object): BarData[];
38
+ /**
39
+ * Creates a grouped bars layout
40
+ *
41
+ * @param {Array} data - Chart data
42
+ * @param {Object} fields - Field mappings
43
+ * @param {Object} scales - Chart scales
44
+ * @param {Object} options - Options including dimensions and padding
45
+ * @param {Object} options.dimensions - Chart dimensions
46
+ * @param {number} [options.padding=0.1] - Padding between bars in a group
47
+ * @returns {Object} Grouped bar data
48
+ */
49
+ export function createGroupedBars(data: any[], fields: Object, scales: Object, options: {
50
+ dimensions: Object;
51
+ padding?: number | undefined;
52
+ }): Object;
53
+ export type BarData = import("./types").BarData;
54
+ export type ScaleFields = import("./types").ScaleFields;
55
+ export type ChartScales = import("./types").ChartScales;
56
+ export type ChartDimensions = import("./types").ChartDimensions;