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

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 (222) 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 +49 -0
  5. package/dist/crossfilter/createCrossFilter.svelte.d.ts +13 -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 +114 -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 +23 -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 +38 -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 +215 -0
  59. package/src/Chart.svelte +98 -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 +181 -0
  75. package/src/PlotState.svelte.js +277 -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 +120 -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 +103 -0
  104. package/src/geoms/LabelPill.svelte +17 -0
  105. package/src/geoms/Line.svelte +99 -0
  106. package/src/geoms/Point.svelte +105 -0
  107. package/src/geoms/Violin.svelte +46 -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 +17 -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 +230 -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 +66 -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 +220 -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/index.js +4 -0
  156. package/src/patterns/patterns.js +208 -0
  157. package/src/patterns/scale.js +87 -0
  158. package/src/spec/chart-spec.js +29 -0
  159. package/src/symbols/RoundedSquare.svelte +33 -0
  160. package/src/symbols/Shape.svelte +37 -0
  161. package/src/symbols/constants/index.js +4 -0
  162. package/src/symbols/index.js +9 -0
  163. package/src/symbols/outline.svelte +60 -0
  164. package/src/symbols/solid.svelte +60 -0
  165. package/src/chart/FacetGrid.svelte +0 -51
  166. package/src/chart/Grid.svelte +0 -34
  167. package/src/chart/Legend.svelte +0 -16
  168. package/src/chart/PatternDefs.svelte +0 -13
  169. package/src/chart/Swatch.svelte +0 -93
  170. package/src/chart/SwatchButton.svelte +0 -29
  171. package/src/chart/SwatchGrid.svelte +0 -55
  172. package/src/chart/Symbol.svelte +0 -37
  173. package/src/chart/Texture.svelte +0 -16
  174. package/src/chart/TexturedShape.svelte +0 -27
  175. package/src/chart/TimelapseChart.svelte +0 -97
  176. package/src/chart/Timer.svelte +0 -27
  177. package/src/chart.js +0 -9
  178. package/src/components/charts/Axis.svelte +0 -66
  179. package/src/components/charts/Chart.svelte +0 -35
  180. package/src/components/index.js +0 -23
  181. package/src/components/lib/axis.js +0 -0
  182. package/src/components/lib/chart.js +0 -187
  183. package/src/components/lib/color.js +0 -327
  184. package/src/components/lib/funnel.js +0 -204
  185. package/src/components/lib/index.js +0 -19
  186. package/src/components/lib/pattern.js +0 -190
  187. package/src/components/lib/rollup.js +0 -55
  188. package/src/components/lib/shape.js +0 -199
  189. package/src/components/lib/summary.js +0 -145
  190. package/src/components/lib/theme.js +0 -23
  191. package/src/components/lib/timer.js +0 -41
  192. package/src/components/lib/utils.js +0 -165
  193. package/src/components/plots/BarPlot.svelte +0 -36
  194. package/src/components/plots/BoxPlot.svelte +0 -54
  195. package/src/components/plots/ScatterPlot.svelte +0 -30
  196. package/src/components/store.js +0 -70
  197. package/src/constants.js +0 -66
  198. package/src/elements/PatternDefs.svelte +0 -13
  199. package/src/elements/PatternMask.svelte +0 -20
  200. package/src/elements/Symbol.svelte +0 -38
  201. package/src/elements/Tooltip.svelte +0 -23
  202. package/src/funnel.svelte +0 -35
  203. package/src/geom.js +0 -105
  204. package/src/lib/axis.js +0 -75
  205. package/src/lib/colors.js +0 -32
  206. package/src/lib/geom.js +0 -4
  207. package/src/lib/shapes.js +0 -144
  208. package/src/lib/timer.js +0 -44
  209. package/src/lookup.js +0 -29
  210. package/src/plots/BarPlot.svelte +0 -55
  211. package/src/plots/BoxPlot.svelte +0 -0
  212. package/src/plots/FunnelPlot.svelte +0 -33
  213. package/src/plots/HeatMap.svelte +0 -5
  214. package/src/plots/HeatMapCalendar.svelte +0 -129
  215. package/src/plots/LinePlot.svelte +0 -55
  216. package/src/plots/Plot.svelte +0 -25
  217. package/src/plots/RankBarPlot.svelte +0 -38
  218. package/src/plots/ScatterPlot.svelte +0 -20
  219. package/src/plots/ViolinPlot.svelte +0 -11
  220. package/src/plots/heatmap.js +0 -70
  221. package/src/plots/index.js +0 -10
  222. package/src/swatch.js +0 -11
@@ -0,0 +1,114 @@
1
+ export function buildLegendGroups(channels: any, colorMap: any, patternMap: any, symbolMap: any): {
2
+ field: any;
3
+ items: any;
4
+ }[];
5
+ export class ChartBrewer {
6
+ /**
7
+ * Override in subclasses to apply stat aggregation.
8
+ * @param {Object[]} data
9
+ * @param {Object} channels
10
+ * @param {string|Function} stat
11
+ * @returns {Object[]}
12
+ */
13
+ transform(data: Object[], _channels: any, _stat: any): Object[];
14
+ /** Aggregated data — all derived marks read this, not #rawData */
15
+ processedData: Object[];
16
+ /** Exposes channels to subclasses for use in their own $derived properties */
17
+ get channels(): {};
18
+ /** @type {Map<unknown, {fill:string,stroke:string}>} */
19
+ colorMap: Map<unknown, {
20
+ fill: string;
21
+ stroke: string;
22
+ }>;
23
+ /** @type {Map<unknown, string>} */
24
+ patternMap: Map<unknown, string>;
25
+ /**
26
+ * Unified pattern defs for ChartPatternDefs.
27
+ * When fill and pattern map the same field, pattern key = color key (simple case).
28
+ * When they differ, each unique (fillKey, patternKey) pair gets its own pattern def
29
+ * so bars/areas can have distinct colors per region AND distinct textures per category.
30
+ * @type {Array<{ id: string, name: string, fill: string, stroke: string }>}
31
+ */
32
+ patternDefs: Array<{
33
+ id: string;
34
+ name: string;
35
+ fill: string;
36
+ stroke: string;
37
+ }>;
38
+ /** @type {Map<unknown, string>} */
39
+ symbolMap: Map<unknown, string>;
40
+ get innerWidth(): number;
41
+ get innerHeight(): number;
42
+ xScale: any;
43
+ yScale: any;
44
+ sizeScale: any;
45
+ bars: any;
46
+ lines: {
47
+ d: string;
48
+ fill: string;
49
+ stroke: string;
50
+ points: {
51
+ x: number;
52
+ y: number;
53
+ data: Object;
54
+ }[];
55
+ key?: unknown;
56
+ }[];
57
+ areas: {
58
+ d: any;
59
+ fill: any;
60
+ stroke: string;
61
+ key: any;
62
+ colorKey: any;
63
+ patternKey: any;
64
+ patternId: string | null;
65
+ }[] | {
66
+ d: any;
67
+ fill: any;
68
+ stroke: string;
69
+ colorKey: null;
70
+ patternKey: null;
71
+ patternId: null;
72
+ }[];
73
+ arcs: any;
74
+ points: {
75
+ data: Object;
76
+ cx: any;
77
+ cy: any;
78
+ r: any;
79
+ fill: any;
80
+ stroke: any;
81
+ symbolPath: string | null;
82
+ key: any;
83
+ }[];
84
+ legendGroups: {
85
+ field: any;
86
+ items: any;
87
+ }[];
88
+ get margin(): {
89
+ top: number;
90
+ right: number;
91
+ bottom: number;
92
+ left: number;
93
+ };
94
+ get width(): number;
95
+ get height(): number;
96
+ get mode(): string;
97
+ /**
98
+ * @param {{ data?: Object[], channels?: Object, width?: number, height?: number, mode?: string, margin?: Object, layers?: Object[], curve?: string, stat?: string|Function }} opts
99
+ * Supported channel keys: `x`, `y`, `fill`, `color`, `pattern`, `symbol`, `size`, `label`.
100
+ * `frame` is reserved for future animation use (no-op).
101
+ */
102
+ update(opts?: {
103
+ data?: Object[];
104
+ channels?: Object;
105
+ width?: number;
106
+ height?: number;
107
+ mode?: string;
108
+ margin?: Object;
109
+ layers?: Object[];
110
+ curve?: string;
111
+ stat?: string | Function;
112
+ }): void;
113
+ #private;
114
+ }
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Extracts distinct values for a given field from the data array.
3
+ * @param {Object[]} data
4
+ * @param {string|null} field
5
+ * @returns {unknown[]}
6
+ */
7
+ export function distinct(data: Object[], field: string | null): unknown[];
8
+ /**
9
+ * Assigns palette colors to an array of distinct values.
10
+ * @param {unknown[]} values
11
+ * @param {'light'|'dark'} mode
12
+ * @returns {Map<unknown, {fill: string, stroke: string}>}
13
+ */
14
+ export function assignColors(values: unknown[], mode?: "light" | "dark"): Map<unknown, {
15
+ fill: string;
16
+ stroke: string;
17
+ }>;
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Creates chart dimensions based on width, height and margins
3
+ *
4
+ * @param {number} width - Total chart width
5
+ * @param {number} height - Total chart height
6
+ * @param {ChartMargin} margin - Chart margins
7
+ * @returns {ChartDimensions} Chart dimensions
8
+ */
9
+ export function createDimensions(width?: number, height?: number, margin?: ChartMargin): ChartDimensions;
10
+ /**
11
+ * Updates existing dimensions with new values
12
+ *
13
+ * @param {ChartDimensions} dimensions - Current dimensions
14
+ * @param {Object} updates - Values to update
15
+ * @param {number} [updates.width] - New width
16
+ * @param {number} [updates.height] - New height
17
+ * @param {ChartMargin} [updates.margin] - New margin
18
+ * @returns {ChartDimensions} Updated dimensions
19
+ */
20
+ export function updateDimensions(dimensions: ChartDimensions, updates?: {
21
+ width?: number | undefined;
22
+ height?: number | undefined;
23
+ margin?: import("./types.js").ChartMargin | undefined;
24
+ }): ChartDimensions;
25
+ /**
26
+ * @typedef {import('./types').ChartMargin} ChartMargin
27
+ * @typedef {import('./types').ChartDimensions} ChartDimensions
28
+ */
29
+ /**
30
+ * Default chart margin
31
+ * @type {ChartMargin}
32
+ */
33
+ export const DEFAULT_MARGIN: ChartMargin;
34
+ export type ChartMargin = import("./types").ChartMargin;
35
+ export type ChartDimensions = import("./types").ChartDimensions;
@@ -0,0 +1,118 @@
1
+ /**
2
+ * Main class that manages chart state and provides access to all brewing functions
3
+ */
4
+ export class ChartBrewer {
5
+ /**
6
+ * Creates a new ChartBrewer instance
7
+ *
8
+ * @param {Object} options Configuration options
9
+ */
10
+ constructor(options?: Object);
11
+ /**
12
+ * Sets the data for the chart
13
+ *
14
+ * @param {Array} data Data array
15
+ * @returns {ChartBrewer} this for method chaining
16
+ */
17
+ setData(data: any[]): ChartBrewer;
18
+ /**
19
+ * Sets the field mappings for axes and color
20
+ *
21
+ * @param {Object} fields Field mappings
22
+ * @returns {ChartBrewer} this for method chaining
23
+ */
24
+ setFields({ x, y, color }: Object): ChartBrewer;
25
+ /**
26
+ * Sets the dimensions of the chart
27
+ *
28
+ * @param {Object} dimensions Chart dimensions
29
+ * @returns {ChartBrewer} this for method chaining
30
+ */
31
+ setDimensions({ width, height, margin }: Object): ChartBrewer;
32
+ /**
33
+ * Creates scales based on data and dimensions
34
+ *
35
+ * @returns {ChartBrewer} this for method chaining
36
+ */
37
+ createScales(): ChartBrewer;
38
+ /**
39
+ * Creates bar data for rendering
40
+ *
41
+ * @returns {Array} Data for rendering bars
42
+ */
43
+ createBars(): any[];
44
+ /**
45
+ * Creates x-axis tick data for rendering
46
+ *
47
+ * @param {Object} options Axis options
48
+ * @returns {Object} Axis rendering data
49
+ */
50
+ createXAxis(options?: Object): Object;
51
+ /**
52
+ * Creates y-axis tick data for rendering
53
+ *
54
+ * @param {Object} options Axis options
55
+ * @returns {Object} Axis rendering data
56
+ */
57
+ createYAxis(options?: Object): Object;
58
+ /**
59
+ * Creates grid line data for rendering
60
+ *
61
+ * @param {Object} options Grid options
62
+ * @returns {Object} Grid rendering data
63
+ */
64
+ createGrid(options?: Object): Object;
65
+ /**
66
+ * Creates legend data for rendering
67
+ *
68
+ * @param {Object} options Legend options
69
+ * @returns {Object} Legend rendering data
70
+ */
71
+ createLegend(options?: Object): Object;
72
+ /**
73
+ * Gets all chart dimensions
74
+ *
75
+ * @returns {Object} Chart dimensions
76
+ */
77
+ getDimensions(): Object;
78
+ /**
79
+ * Gets all chart scales
80
+ *
81
+ * @returns {Object} Chart scales
82
+ */
83
+ getScales(): Object;
84
+ /**
85
+ * Gets the animation duration
86
+ *
87
+ * @returns {number} Animation duration in ms
88
+ */
89
+ getAnimationDuration(): number;
90
+ /**
91
+ * Gets the data being used
92
+ *
93
+ * @returns {Array} Chart data
94
+ */
95
+ getData(): any[];
96
+ /**
97
+ * Gets the fields configuration
98
+ *
99
+ * @returns {Object} Fields configuration
100
+ */
101
+ getFields(): Object;
102
+ #private;
103
+ }
104
+ import { createDimensions } from './dimensions.svelte.js';
105
+ import { updateDimensions } from './dimensions.svelte.js';
106
+ import { createScales } from './scales.svelte.js';
107
+ import { getOrigin } from './scales.svelte.js';
108
+ import { createBars } from './bars.svelte.js';
109
+ import { filterBars } from './bars.svelte.js';
110
+ import { createGroupedBars } from './bars.svelte.js';
111
+ import { createXAxis } from './axes.svelte.js';
112
+ import { createYAxis } from './axes.svelte.js';
113
+ import { createGrid } from './axes.svelte.js';
114
+ import { createTickAttributes } from './axes.svelte.js';
115
+ import { createLegend } from './legends.svelte.js';
116
+ import { filterByLegend } from './legends.svelte.js';
117
+ import { createLegendItemAttributes } from './legends.svelte.js';
118
+ export { createDimensions, updateDimensions, createScales, getOrigin, createBars, filterBars, createGroupedBars, createXAxis, createYAxis, createGrid, createTickAttributes, createLegend, filterByLegend, createLegendItemAttributes };
@@ -0,0 +1,48 @@
1
+ /**
2
+ * Creates legend data for rendering
3
+ *
4
+ * @param {Array} data - Chart data
5
+ * @param {Object} fields - Field mappings
6
+ * @param {string} fields.color - Color field
7
+ * @param {Object} scales - Chart scales
8
+ * @param {Function} scales.color - Color scale
9
+ * @param {Object} options - Legend options including dimensions
10
+ * @param {Object} options.dimensions - Chart dimensions
11
+ * @param {string} [options.title=''] - Legend title
12
+ * @param {string} [options.align='right'] - Legend alignment ('left', 'center', or 'right')
13
+ * @param {string} [options.shape='rect'] - Legend marker shape ('rect' or 'circle')
14
+ * @param {number} [options.markerSize=10] - Size of legend markers
15
+ * @returns {LegendData} Legend rendering data
16
+ */
17
+ export function createLegend(data: any[], fields: {
18
+ color: string;
19
+ }, scales: {
20
+ color: Function;
21
+ }, options: {
22
+ dimensions: Object;
23
+ title?: string | undefined;
24
+ align?: string | undefined;
25
+ shape?: string | undefined;
26
+ markerSize?: number | undefined;
27
+ }): LegendData;
28
+ /**
29
+ * Filter data based on legend selection
30
+ *
31
+ * @param {Array} data - Chart data
32
+ * @param {string} colorField - Field used for color mapping
33
+ * @param {Array} selectedValues - Selected legend values
34
+ * @returns {Array} Filtered data
35
+ */
36
+ export function filterByLegend(data: any[], colorField: string, selectedValues: any[]): any[];
37
+ /**
38
+ * Create attributes for legend items
39
+ *
40
+ * @param {LegendItem} item - Legend item
41
+ * @returns {Object} Attributes for the legend item
42
+ */
43
+ export function createLegendItemAttributes(item: LegendItem): Object;
44
+ export type LegendItem = import("./types").LegendItem;
45
+ export type LegendData = import("./types").LegendData;
46
+ export type ScaleFields = import("./types").ScaleFields;
47
+ export type ChartScales = import("./types").ChartScales;
48
+ export type ChartDimensions = import("./types").ChartDimensions;
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Builds arc geometry for pie/donut charts.
3
+ * @param {Object[]} data
4
+ * @param {{ color: string, y: string, pattern?: string }} channels
5
+ * @param {Map} colors
6
+ * @param {number} width
7
+ * @param {number} height
8
+ * @param {{ innerRadius?: number }} opts
9
+ * @param {Map<unknown, string>} [patterns]
10
+ */
11
+ export function buildArcs(data: Object[], channels: {
12
+ color: string;
13
+ y: string;
14
+ pattern?: string;
15
+ }, colors: Map<any, any>, width: number, height: number, opts?: {
16
+ innerRadius?: number;
17
+ }, patterns?: Map<unknown, string>): any;
@@ -0,0 +1,31 @@
1
+ /**
2
+ * @param {Object[]} data
3
+ * @param {{ x: string, y: string, fill?: string, pattern?: string }} channels
4
+ * `fill` is the primary aesthetic — drives grouping and interior color.
5
+ * @param {Function} xScale
6
+ * @param {Function} yScale
7
+ * @param {Map} colors
8
+ * @param {'linear'|'smooth'|'step'} [curve]
9
+ * @param {Map} [patternMap]
10
+ */
11
+ export function buildAreas(data: Object[], channels: {
12
+ x: string;
13
+ y: string;
14
+ fill?: string;
15
+ pattern?: string;
16
+ }, xScale: Function, yScale: Function, colors: Map<any, any>, curve?: "linear" | "smooth" | "step", patternMap?: Map<any, any>): {
17
+ d: any;
18
+ fill: any;
19
+ stroke: string;
20
+ key: any;
21
+ colorKey: any;
22
+ patternKey: any;
23
+ patternId: string | null;
24
+ }[] | {
25
+ d: any;
26
+ fill: any;
27
+ stroke: string;
28
+ colorKey: null;
29
+ patternKey: null;
30
+ patternId: null;
31
+ }[];
@@ -0,0 +1 @@
1
+ export function buildBars(data: any, channels: any, xScale: any, yScale: any, colors: any, patternMap: any): any;
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Builds box geometry for box plot charts.
3
+ * Input data rows must already contain { q1, median, q3, iqr_min, iqr_max } —
4
+ * computed by applyBoxStat before reaching this function.
5
+ *
6
+ * When `fill` differs from `x`, boxes are sub-grouped within each x-band
7
+ * (one narrower box per fill value per x category, like grouped bars).
8
+ * Box body uses the lighter fill shade; whiskers and median use the darker stroke shade.
9
+ *
10
+ * @param {Object[]} data - Pre-aggregated rows with quartile fields
11
+ * @param {{ x: string, fill?: string }} channels
12
+ * `fill` drives the box and whisker color (defaults to x-field).
13
+ * @param {import('d3-scale').ScaleBand} xScale
14
+ * @param {import('d3-scale').ScaleLinear} yScale
15
+ * @param {Map<unknown, {fill:string, stroke:string}>} colors
16
+ * @returns {Array}
17
+ */
18
+ export function buildBoxes(data: Object[], channels: {
19
+ x: string;
20
+ fill?: string;
21
+ }, xScale: any, yScale: any, colors: Map<unknown, {
22
+ fill: string;
23
+ stroke: string;
24
+ }>): any[];
@@ -0,0 +1,24 @@
1
+ /**
2
+ * @param {Object[]} data
3
+ * @param {{ x: string, y: string, color?: string }} channels
4
+ * @param {Function} xScale
5
+ * @param {Function} yScale
6
+ * @param {Map} colors
7
+ * @param {'linear'|'smooth'|'step'} [curve]
8
+ * @returns {{ d: string, fill: string, stroke: string, points: {x:number, y:number, data:Object}[], key?: unknown }[]}
9
+ */
10
+ export function buildLines(data: Object[], channels: {
11
+ x: string;
12
+ y: string;
13
+ color?: string;
14
+ }, xScale: Function, yScale: Function, colors: Map<any, any>, curve?: "linear" | "smooth" | "step"): {
15
+ d: string;
16
+ fill: string;
17
+ stroke: string;
18
+ points: {
19
+ x: number;
20
+ y: number;
21
+ data: Object;
22
+ }[];
23
+ key?: unknown;
24
+ }[];
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Returns a Map assigning shape names to distinct values, cycling through available shapes.
3
+ * @param {unknown[]} values
4
+ * @returns {Map<unknown, string>}
5
+ */
6
+ export function assignSymbols(values: unknown[]): Map<unknown, string>;
7
+ /**
8
+ * Builds an SVG path string for a given shape name and radius.
9
+ * @param {string} shapeName
10
+ * @param {number} r
11
+ * @returns {string}
12
+ */
13
+ export function buildSymbolPath(shapeName: string, r: number): string;
14
+ /**
15
+ * Builds point geometry for scatter/bubble charts.
16
+ * @param {Object[]} data
17
+ * @param {{ x: string, y: string, color?: string, size?: string, symbol?: string }} channels
18
+ * @param {Function} xScale
19
+ * @param {Function} yScale
20
+ * @param {Map} colors
21
+ * @param {Function|null} sizeScale
22
+ * @param {Map<unknown, string>|null} symbolMap — maps symbol field value → shape name
23
+ * @param {number} defaultRadius
24
+ */
25
+ export function buildPoints(data: Object[], channels: {
26
+ x: string;
27
+ y: string;
28
+ color?: string;
29
+ size?: string;
30
+ symbol?: string;
31
+ }, xScale: Function, yScale: Function, colors: Map<any, any>, sizeScale: Function | null, symbolMap: Map<unknown, string> | null, defaultRadius?: number): {
32
+ data: Object;
33
+ cx: any;
34
+ cy: any;
35
+ r: any;
36
+ fill: any;
37
+ stroke: any;
38
+ symbolPath: string | null;
39
+ key: any;
40
+ }[];
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Builds a closed violin shape path for each group.
3
+ * Input rows must have { q1, median, q3, iqr_min, iqr_max } from applyBoxStat.
4
+ *
5
+ * When `fill` differs from `x`, violins are sub-grouped within each x-band
6
+ * (one narrower violin per fill value per x category, like grouped bars).
7
+ * Violin body uses the lighter fill shade; outline uses the darker stroke shade.
8
+ *
9
+ * @param {Object[]} data
10
+ * @param {{ x: string, fill?: string }} channels
11
+ * `fill` drives violin interior and outline (defaults to x-field).
12
+ * @param {import('d3-scale').ScaleBand} xScale
13
+ * @param {import('d3-scale').ScaleLinear} yScale
14
+ * @param {Map} colors
15
+ * @returns {Array}
16
+ */
17
+ export function buildViolins(data: Object[], channels: {
18
+ x: string;
19
+ fill?: string;
20
+ }, xScale: any, yScale: any, colors: Map<any, any>): any[];
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Converts a data key to a safe SVG element ID for pattern references.
3
+ * Spaces and non-word characters are replaced to avoid broken url(#...) refs.
4
+ * @param {unknown} key
5
+ * @returns {string}
6
+ */
7
+ export function toPatternId(key: unknown): string;
8
+ /**
9
+ * Assigns patterns from PATTERN_ORDER to an array of distinct values.
10
+ * @param {unknown[]} values
11
+ * @returns {Map<unknown, string>}
12
+ */
13
+ export function assignPatterns(values: unknown[]): Map<unknown, string>;
14
+ export const PATTERN_ORDER: string[];
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Builds an x scale (band for categorical, linear for numeric).
3
+ * @param {Object[]} data
4
+ * @param {string} field
5
+ * @param {number} width - inner width (pixels)
6
+ * @param {{ padding?: number }} opts
7
+ */
8
+ export function buildXScale(data: Object[], field: string, width: number, opts?: {
9
+ padding?: number;
10
+ }): any;
11
+ /**
12
+ * Builds a y linear scale from 0 to max, extended by any layer overrides.
13
+ * @param {Object[]} data
14
+ * @param {string} field
15
+ * @param {number} height - inner height (pixels)
16
+ * @param {Array<{data?: Object[], y?: string}>} layers
17
+ */
18
+ export function buildYScale(data: Object[], field: string, height: number, layers?: Array<{
19
+ data?: Object[];
20
+ y?: string;
21
+ }>): any;
22
+ /**
23
+ * Builds a sqrt scale for bubble/point size.
24
+ * @param {Object[]} data
25
+ * @param {string} field
26
+ * @param {number} maxRadius
27
+ */
28
+ export function buildSizeScale(data: Object[], field: string, maxRadius?: number): any;
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Creates scales based on data, fields, and dimensions
3
+ *
4
+ * @param {Array} data - Chart data
5
+ * @param {ScaleFields} fields - Field mappings
6
+ * @param {Object} dimensions - Chart dimensions
7
+ * @param {Object} options - Scale options
8
+ * @param {number} [options.padding=0.2] - Padding for band scales
9
+ * @returns {ChartScales} Chart scales
10
+ */
11
+ export function createScales(data: any[], fields: ScaleFields, dimensions: Object, options?: {
12
+ padding?: number | undefined;
13
+ }): ChartScales;
14
+ /**
15
+ * Gets the origin coordinates for the axes
16
+ *
17
+ * @param {ChartScales} scales - Chart scales
18
+ * @param {Object} dimensions - Chart dimensions
19
+ * @returns {Object} Origin coordinates
20
+ */
21
+ export function getOrigin(scales: ChartScales, dimensions: Object): Object;
22
+ export type ChartScales = import("./types").ChartScales;
23
+ export type ScaleFields = import("./types").ScaleFields;
24
+ export type ChartDimensions = import("./types").ChartDimensions;
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Computes box plot quartile statistics grouped by x (and optionally color).
3
+ * Output rows have { q1, median, q3, iqr_min, iqr_max } replacing the raw y values.
4
+ *
5
+ * @param {Object[]} data
6
+ * @param {{ x?: string, y?: string, color?: string }} channels
7
+ * @returns {Object[]}
8
+ */
9
+ export function applyBoxStat(data: Object[], channels: {
10
+ x?: string;
11
+ y?: string;
12
+ color?: string;
13
+ }): Object[];
14
+ export function applyAggregate(data: any, { by, value, stat }: {
15
+ by: any;
16
+ value: any;
17
+ stat: any;
18
+ }): any;
19
+ /**
20
+ * Built-in reduction functions. Each receives an array of numeric values.
21
+ * @type {Record<string, (values: number[]) => number>}
22
+ */
23
+ export const STAT_FNS: Record<string, (values: number[]) => number>;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Assigns shapes from SYMBOL_ORDER to an array of distinct values.
3
+ * @param {unknown[]} values
4
+ * @returns {Map<unknown, string>}
5
+ */
6
+ export function assignSymbols(values: unknown[]): Map<unknown, string>;
7
+ export const SYMBOL_ORDER: string[];