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

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 +47 -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 +214 -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 +80 -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
@@ -0,0 +1,177 @@
1
+ /**
2
+ * Common props shared by all high-level chart wrappers.
3
+ */
4
+ export type ChartProps = {
5
+ /**
6
+ * - Data array to visualize
7
+ */
8
+ data?: Object[] | undefined;
9
+ /**
10
+ * - Field name for the X axis
11
+ */
12
+ x?: string | undefined;
13
+ /**
14
+ * - Field name for the Y axis
15
+ */
16
+ y?: string | undefined;
17
+ /**
18
+ * - Field name for fill color grouping (alias for color)
19
+ */
20
+ fill?: string | undefined;
21
+ /**
22
+ * - Field name for color grouping
23
+ */
24
+ color?: string | undefined;
25
+ /**
26
+ * - Field name for pattern fill grouping
27
+ */
28
+ pattern?: string | undefined;
29
+ /**
30
+ * - Aggregation stat: 'identity' | 'sum' | 'mean' | 'count' | 'min' | 'max' | 'median' | 'boxplot'
31
+ */
32
+ stat?: string | undefined;
33
+ /**
34
+ * - SVG width in pixels
35
+ */
36
+ width?: number | undefined;
37
+ /**
38
+ * - SVG height in pixels
39
+ */
40
+ height?: number | undefined;
41
+ /**
42
+ * - Color mode: 'light' | 'dark'
43
+ */
44
+ mode?: string | undefined;
45
+ /**
46
+ * - Whether to show grid lines
47
+ */
48
+ grid?: boolean | undefined;
49
+ /**
50
+ * - Whether to show the legend
51
+ */
52
+ legend?: boolean | undefined;
53
+ };
54
+ export type BarChartProps = Object;
55
+ export type PieChartProps = {
56
+ /**
57
+ * - Data array to visualize
58
+ */
59
+ data?: Object[] | undefined;
60
+ /**
61
+ * - Field name for slice labels (drives color key)
62
+ */
63
+ label?: string | undefined;
64
+ /**
65
+ * - Field name for slice values (theta)
66
+ */
67
+ y?: string | undefined;
68
+ /**
69
+ * - Alternative to label for color grouping
70
+ */
71
+ fill?: string | undefined;
72
+ /**
73
+ * - Inner radius as fraction of outer (0=pie, 0.5=donut)
74
+ */
75
+ innerRadius?: number | undefined;
76
+ /**
77
+ * - Aggregation stat (default sum for pie charts)
78
+ */
79
+ stat?: string | undefined;
80
+ /**
81
+ * - SVG width in pixels
82
+ */
83
+ width?: number | undefined;
84
+ /**
85
+ * - SVG height in pixels
86
+ */
87
+ height?: number | undefined;
88
+ /**
89
+ * - Color mode: 'light' | 'dark'
90
+ */
91
+ mode?: string | undefined;
92
+ /**
93
+ * - Whether to show the legend
94
+ */
95
+ legend?: boolean | undefined;
96
+ };
97
+ export type BoxViolinChartProps = {
98
+ /**
99
+ * - Data array to visualize
100
+ */
101
+ data?: Object[] | undefined;
102
+ /**
103
+ * - Field name for the category axis (groups)
104
+ */
105
+ x?: string | undefined;
106
+ /**
107
+ * - Field name for the value axis (raw observations)
108
+ */
109
+ y?: string | undefined;
110
+ /**
111
+ * - Field name for fill color; when different from x, sub-groups within each x-band (like grouped bars); lighter shade used for body, darker shade for whiskers/outline
112
+ */
113
+ fill?: string | undefined;
114
+ /**
115
+ * - SVG width in pixels
116
+ */
117
+ width?: number | undefined;
118
+ /**
119
+ * - SVG height in pixels
120
+ */
121
+ height?: number | undefined;
122
+ /**
123
+ * - Color mode: 'light' | 'dark'
124
+ */
125
+ mode?: string | undefined;
126
+ /**
127
+ * - Whether to show grid lines
128
+ */
129
+ grid?: boolean | undefined;
130
+ /**
131
+ * - Whether to show the legend
132
+ */
133
+ legend?: boolean | undefined;
134
+ };
135
+ export type ScatterBubbleChartProps = {
136
+ /**
137
+ * - Data array to visualize
138
+ */
139
+ data?: Object[] | undefined;
140
+ /**
141
+ * - Field name for X position
142
+ */
143
+ x?: string | undefined;
144
+ /**
145
+ * - Field name for Y position
146
+ */
147
+ y?: string | undefined;
148
+ /**
149
+ * - Field name for color grouping
150
+ */
151
+ color?: string | undefined;
152
+ /**
153
+ * - Field name for point radius (BubbleChart: required)
154
+ */
155
+ size?: string | undefined;
156
+ /**
157
+ * - SVG width in pixels
158
+ */
159
+ width?: number | undefined;
160
+ /**
161
+ * - SVG height in pixels
162
+ */
163
+ height?: number | undefined;
164
+ /**
165
+ * - Color mode: 'light' | 'dark'
166
+ */
167
+ mode?: string | undefined;
168
+ /**
169
+ * - Whether to show grid lines
170
+ */
171
+ grid?: boolean | undefined;
172
+ /**
173
+ * - Whether to show the legend
174
+ */
175
+ legend?: boolean | undefined;
176
+ };
177
+ export type LineAreaChartProps = Object;
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Applies dimming state to data rows using crossfilter instance.
3
+ * Maps each row to { data: row, dimmed: boolean }.
4
+ *
5
+ * @param {Object[]} data - raw data array
6
+ * @param {Object} cf - crossfilter instance (from createCrossFilter)
7
+ * @param {Object} channels - { x, y, color, ... } field name mapping
8
+ * @returns {{ data: Object, dimmed: boolean }[]}
9
+ */
10
+ export function applyDimming(data: Object[], cf: Object, channels: Object): {
11
+ data: Object;
12
+ dimmed: boolean;
13
+ }[];
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Splits data into a Map of panels keyed by facet field value.
3
+ * Preserves insertion order of first occurrence.
4
+ *
5
+ * @param {Object[]} data
6
+ * @param {string} field
7
+ * @returns {Map<unknown, Object[]>}
8
+ */
9
+ export function splitByField(data: Object[], field: string): Map<unknown, Object[]>;
10
+ /**
11
+ * Computes x/y domains for each panel.
12
+ *
13
+ * @param {Map<unknown, Object[]>} panels
14
+ * @param {{ x: string, y: string }} channels
15
+ * @param {'fixed'|'free'|'free_x'|'free_y'} scalesMode
16
+ * @returns {Map<unknown, { xDomain: unknown[], yDomain: [number, number] }>}
17
+ */
18
+ export function getFacetDomains(panels: Map<unknown, Object[]>, channels: {
19
+ x: string;
20
+ y: string;
21
+ }, scalesMode?: "fixed" | "free" | "free_x" | "free_y"): Map<unknown, {
22
+ xDomain: unknown[];
23
+ yDomain: [number, number];
24
+ }>;
@@ -0,0 +1,47 @@
1
+ /**
2
+ * Extracts animation frames from data, keyed by time field value.
3
+ * Preserves insertion order of time values.
4
+ *
5
+ * @param {Object[]} data
6
+ * @param {string} timeField
7
+ * @returns {Map<unknown, Object[]>}
8
+ */
9
+ export function extractFrames(data: Object[], timeField: string): Map<unknown, Object[]>;
10
+ /**
11
+ * Ensures all frame values (byField) appear for every (x, color?) combination.
12
+ * Uses dataset alignBy to fill missing frame-value combos with y=0 so bars
13
+ * animate smoothly rather than disappearing between frames.
14
+ *
15
+ * Call after pre-aggregation. The result can be split directly by extractFrames
16
+ * with no further per-frame normalization needed.
17
+ *
18
+ * @param {Object[]} data - pre-aggregated rows, one per (x, color?, byField)
19
+ * @param {{ x?: string, y: string, color?: string }} channels
20
+ * @param {string} byField - the frame field (e.g. 'year')
21
+ * @returns {Object[]}
22
+ */
23
+ export function completeFrames(data: Object[], channels: {
24
+ x?: string;
25
+ y: string;
26
+ color?: string;
27
+ }, byField: string): Object[];
28
+ /**
29
+ * Computes static x/y domains from the full (pre-split) data array.
30
+ * These domains stay constant throughout the animation so values are
31
+ * always comparable across frames.
32
+ *
33
+ * NOTE: y domain is pinned to [0, max] — assumes bar chart semantics.
34
+ * Pass an explicit yDomain override for scatter/line charts where y can
35
+ * be negative.
36
+ *
37
+ * @param {Object[]} data - full dataset (before frame extraction)
38
+ * @param {{ x: string, y: string }} channels
39
+ * @returns {{ xDomain: unknown[], yDomain: [number, number] }}
40
+ */
41
+ export function computeStaticDomains(data: Object[], channels: {
42
+ x: string;
43
+ y: string;
44
+ }): {
45
+ xDomain: unknown[];
46
+ yDomain: [number, number];
47
+ };
@@ -0,0 +1,3 @@
1
+ export function resolveFormat(field: any, helpers?: {}): any;
2
+ export function resolveTooltip(helpers?: {}): any;
3
+ export function resolveGeom(type: any, helpers?: {}): any;
@@ -0,0 +1,29 @@
1
+ export function resolvePreset(name: any, helpers?: {}): {
2
+ colors: any;
3
+ patterns: any;
4
+ symbols: any;
5
+ };
6
+ export namespace DEFAULT_PRESET {
7
+ export let colors: string[];
8
+ export { PATTERN_ORDER as patterns };
9
+ export { SYMBOL_ORDER as symbols };
10
+ }
11
+ export namespace ACCESSIBLE_PRESET {
12
+ let colors_1: string[];
13
+ export { colors_1 as colors };
14
+ export { PATTERN_ORDER as patterns };
15
+ export { SYMBOL_ORDER as symbols };
16
+ }
17
+ export namespace PRINT_PRESET {
18
+ let colors_2: string[];
19
+ export { colors_2 as colors };
20
+ export let patterns: string[];
21
+ export { SYMBOL_ORDER as symbols };
22
+ }
23
+ export type PlotPreset = {
24
+ colors: string[];
25
+ patterns: string[];
26
+ symbols: string[];
27
+ };
28
+ import { PATTERN_ORDER } from '../brewing/patterns.js';
29
+ import { SYMBOL_ORDER } from '../brewing/symbols.js';
@@ -0,0 +1,5 @@
1
+ export function inferFieldType(data: any, field: any): "continuous" | "band";
2
+ export function inferOrientation(xType: any, yType: any): "none" | "vertical" | "horizontal";
3
+ export function buildUnifiedXScale(datasets: any, field: any, width: any, opts?: {}): any;
4
+ export function buildUnifiedYScale(datasets: any, field: any, height: any, opts?: {}): any;
5
+ export function inferColorScaleType(data: any, field: any, spec?: {}): any;
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Resolves a stat name to an aggregation function.
3
+ * Checks built-ins first, then helpers.stats, then warns and falls back to identity.
4
+ *
5
+ * @param {string} name
6
+ * @param {Object} helpers
7
+ * @returns {Function}
8
+ */
9
+ export function resolveStat(name: string, helpers?: Object): Function;
10
+ /**
11
+ * Infers group-by fields from channels by excluding value fields.
12
+ * valueFields may contain channel keys (e.g. ['y', 'size']) OR field values (e.g. ['cty']).
13
+ * A channel's field is excluded if either the channel key OR the field value is in valueFields.
14
+ *
15
+ * @param {Record<string, string|undefined>} channels
16
+ * @param {string[]} valueFields
17
+ * @returns {string[]}
18
+ */
19
+ export function inferGroupByFields(channels: Record<string, string | undefined>, valueFields: string[]): string[];
20
+ /**
21
+ * Applies a stat aggregation to data based on a geom config.
22
+ * Returns data unchanged for identity stat.
23
+ *
24
+ * @param {Object[]} data
25
+ * @param {{ stat?: string, channels?: Record<string, string> }} geomConfig
26
+ * @param {Object} helpers
27
+ * @returns {Object[]}
28
+ */
29
+ export function applyGeomStat(data: Object[], geomConfig: {
30
+ stat?: string;
31
+ channels?: Record<string, string>;
32
+ }, helpers?: Object): Object[];
@@ -0,0 +1,89 @@
1
+ export type GeomSpec = {
2
+ /**
3
+ * - Geom type: 'bar'|'line'|'area'|'point'|'box'|'violin'|'arc' or custom
4
+ */
5
+ type: string;
6
+ x?: string | undefined;
7
+ y?: string | undefined;
8
+ color?: string | undefined;
9
+ fill?: string | undefined;
10
+ size?: string | undefined;
11
+ symbol?: string | undefined;
12
+ pattern?: string | undefined;
13
+ /**
14
+ * - Built-in or helpers.stats key
15
+ */
16
+ stat?: string | undefined;
17
+ options?: Record<string, unknown> | undefined;
18
+ };
19
+ export type PlotSpec = {
20
+ data: Record<string, unknown>[];
21
+ x?: string | undefined;
22
+ y?: string | undefined;
23
+ color?: string | undefined;
24
+ fill?: string | undefined;
25
+ size?: string | undefined;
26
+ symbol?: string | undefined;
27
+ pattern?: string | undefined;
28
+ theta?: string | undefined;
29
+ labels?: Record<string, string> | undefined;
30
+ xDomain?: unknown[] | undefined;
31
+ yDomain?: number[] | undefined;
32
+ xLabel?: string | undefined;
33
+ yLabel?: string | undefined;
34
+ axisOrigin?: [number, number] | undefined;
35
+ colorScale?: "diverging" | "sequential" | "categorical" | undefined;
36
+ colorScheme?: string | undefined;
37
+ colorMidpoint?: number | undefined;
38
+ colorDomain?: unknown[] | undefined;
39
+ geoms: GeomSpec[];
40
+ facet?: {
41
+ by: string;
42
+ cols?: number;
43
+ scales?: "fixed" | "free" | "free_x" | "free_y";
44
+ } | undefined;
45
+ animate?: {
46
+ by: string;
47
+ duration?: number;
48
+ loop?: boolean;
49
+ } | undefined;
50
+ grid?: boolean | undefined;
51
+ legend?: boolean | undefined;
52
+ tooltip?: boolean | undefined;
53
+ title?: string | undefined;
54
+ preset?: string | undefined;
55
+ width?: number | undefined;
56
+ height?: number | undefined;
57
+ mode?: "light" | "dark" | undefined;
58
+ };
59
+ export type PlotHelpers = {
60
+ stats?: Record<string, (values: unknown[]) => unknown> | undefined;
61
+ format?: Record<string, (v: unknown) => string> | undefined;
62
+ tooltip?: ((d: Record<string, unknown>) => string) | undefined;
63
+ /**
64
+ * Svelte components keyed by type name
65
+ */
66
+ geoms?: Record<string, unknown> | undefined;
67
+ /**
68
+ * d3 scale override
69
+ */
70
+ colorScale?: unknown;
71
+ preset?: {
72
+ colors: string[];
73
+ patterns: string[];
74
+ symbols: string[];
75
+ } | undefined;
76
+ presets?: Record<string, {
77
+ colors: string[];
78
+ patterns: string[];
79
+ symbols: string[];
80
+ }> | undefined;
81
+ /**
82
+ * custom SVG pattern components keyed by name
83
+ */
84
+ patterns?: Record<string, unknown> | undefined;
85
+ /**
86
+ * custom symbol shape components keyed by name
87
+ */
88
+ symbols?: Record<string, unknown> | undefined;
89
+ };
@@ -3,7 +3,7 @@ export function createScales(data: any, dimensions: any, options: any): {
3
3
  yScale?: undefined;
4
4
  colorScale?: undefined;
5
5
  } | {
6
- xScale: Object;
6
+ xScale: any;
7
7
  yScale: any;
8
8
  colorScale: Object | null;
9
9
  };
@@ -0,0 +1,12 @@
1
+ export namespace swatch {
2
+ export { palette };
3
+ export namespace keys {
4
+ export let gray: string[];
5
+ export let color: string[];
6
+ export { shapes as symbol };
7
+ export { PATTERN_ORDER as pattern };
8
+ }
9
+ }
10
+ import palette from './palette.json';
11
+ import { shapes } from '../symbols';
12
+ import { PATTERN_ORDER } from './brewing/patterns.js';
@@ -58,3 +58,4 @@ export function createTooltipFormatter(options?: Object): Function;
58
58
  * @returns {string} Transform attribute value
59
59
  */
60
60
  export function transform(x: number, y: number): string;
61
+ export function scaledPathCollection(paths: any): {};
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Builds an appropriate D3 x-axis scale based on value types.
3
+ * Returns scaleTime for Date values, scaleLinear for numeric values,
4
+ * or scaleBand for categorical values.
5
+ *
6
+ * @param {Array} xValues
7
+ * @param {Object} dimensions
8
+ * @param {number} padding
9
+ * @returns {import('d3-scale').ScaleContinuousNumeric|import('d3-scale').ScaleBand}
10
+ */
11
+ export function buildXScale(xValues: any[], dimensions: Object, padding: number): any | any;
@@ -1,9 +1,4 @@
1
- export { default as Brick } from "./Brick.svelte";
2
- export { default as Circles } from "./Circles.svelte";
3
- export { default as Dots } from "./Dots.svelte";
4
- export { default as CrossHatch } from "./CrossHatch.svelte";
5
- export { default as Waves } from "./Waves.svelte";
6
- export { default as Tile } from "./Tile.svelte";
7
- export { default as Triangles } from "./Triangles.svelte";
8
- export { default as CurvedWave } from "./CurvedWave.svelte";
9
- export { default as OutlineCircles } from "./OutlineCircles.svelte";
1
+ export { default as PatternDef } from "./PatternDef.svelte";
2
+ export { default as DefinePatterns } from "./DefinePatterns.svelte";
3
+ export { PATTERNS } from "./patterns.js";
4
+ export { scaleMark, resolveMarkAttrs } from "./scale.js";
@@ -0,0 +1,72 @@
1
+ /**
2
+ * Unified pattern library.
3
+ *
4
+ * Each entry is an array of mark descriptors. All geometry is in normalized
5
+ * 0–1 coordinates; the renderer scales by `size` at paint time.
6
+ *
7
+ * Mark types
8
+ * ----------
9
+ * circle { cx, cy, r }
10
+ * line { x1, y1, x2, y2 } coordinates may exceed 0–1 for seamless tiling
11
+ * polygon { points: [x,y][] }
12
+ * rect { x, y, w, h }
13
+ * path { d: [cmd, ...args][] } SVG path commands as nested arrays (H/V take one arg)
14
+ *
15
+ * Appearance
16
+ * ----------
17
+ * fill: true → element uses fill color (stroke: none)
18
+ * fill: false → element uses stroke color (fill: none) ← default
19
+ * fillOpacity: n → applied as fill-opacity on filled marks
20
+ * opacity: n → applied as opacity on any mark
21
+ */
22
+ /** @typedef {{ type: 'circle', cx: number, cy: number, r: number, fill?: boolean, fillOpacity?: number, opacity?: number }} CircleMark */
23
+ /** @typedef {{ type: 'line', x1: number, y1: number, x2: number, y2: number, fill?: false, strokeWidth?: number }} LineMark */
24
+ /** @typedef {{ type: 'polygon', points: [number,number][], fill?: boolean, fillOpacity?: number, opacity?: number }} PolygonMark */
25
+ /** @typedef {{ type: 'rect', x: number, y: number, w: number, h: number, fill?: boolean, fillOpacity?: number, opacity?: number }} RectMark */
26
+ /** @typedef {{ type: 'path', d: (string|number)[][], fill?: boolean, fillOpacity?: number, opacity?: number }} PathMark */
27
+ /** @typedef {CircleMark | LineMark | PolygonMark | RectMark | PathMark} PatternMark */
28
+ /** @type {Record<string, PatternMark[]>} */
29
+ export const PATTERNS: Record<string, PatternMark[]>;
30
+ export type CircleMark = {
31
+ type: "circle";
32
+ cx: number;
33
+ cy: number;
34
+ r: number;
35
+ fill?: boolean;
36
+ fillOpacity?: number;
37
+ opacity?: number;
38
+ };
39
+ export type LineMark = {
40
+ type: "line";
41
+ x1: number;
42
+ y1: number;
43
+ x2: number;
44
+ y2: number;
45
+ fill?: false;
46
+ strokeWidth?: number;
47
+ };
48
+ export type PolygonMark = {
49
+ type: "polygon";
50
+ points: [number, number][];
51
+ fill?: boolean;
52
+ fillOpacity?: number;
53
+ opacity?: number;
54
+ };
55
+ export type RectMark = {
56
+ type: "rect";
57
+ x: number;
58
+ y: number;
59
+ w: number;
60
+ h: number;
61
+ fill?: boolean;
62
+ fillOpacity?: number;
63
+ opacity?: number;
64
+ };
65
+ export type PathMark = {
66
+ type: "path";
67
+ d: (string | number)[][];
68
+ fill?: boolean;
69
+ fillOpacity?: number;
70
+ opacity?: number;
71
+ };
72
+ export type PatternMark = CircleMark | LineMark | PolygonMark | RectMark | PathMark;
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Scale all geometric coordinates in a mark by `size`.
3
+ * Renames rect `w`/`h` to `width`/`height` and converts polygon/path to strings.
4
+ * @param {PatternMark} mark
5
+ * @param {number} size
6
+ * @returns {object}
7
+ */
8
+ export function scaleMark(mark: PatternMark, size: number): object;
9
+ /**
10
+ * Resolve a scaled mark into SVG-ready `{ type, attrs }`.
11
+ * `attrs` can be spread directly onto the SVG element.
12
+ *
13
+ * Per-mark overrides respected:
14
+ * mark.strokeWidth → `stroke-width` (takes precedence over `thickness`)
15
+ * mark.fillOpacity → `fill-opacity`
16
+ * mark.opacity → `opacity`
17
+ *
18
+ * @param {object} scaledMark Output of scaleMark
19
+ * @param {{ fill: string, stroke: string, thickness: number }} appearance
20
+ * @returns {{ type: string, attrs: object }}
21
+ */
22
+ export function resolveMarkAttrs(scaledMark: object, { fill, stroke, thickness }: {
23
+ fill: string;
24
+ stroke: string;
25
+ thickness: number;
26
+ }): {
27
+ type: string;
28
+ attrs: object;
29
+ };
30
+ import type { PatternMark } from './patterns.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rokkit/chart",
3
- "version": "1.0.0-next.147",
3
+ "version": "1.0.0-next.149",
4
4
  "type": "module",
5
5
  "description": "Data-driven chart components",
6
6
  "repository": {
@@ -35,18 +35,24 @@
35
35
  "types": "./dist/index.d.ts",
36
36
  "import": "./src/index.js",
37
37
  "svelte": "./src/index.js"
38
- }
38
+ },
39
+ "./patterns": "./src/patterns/index.js",
40
+ "./symbols": "./src/symbols/index.js",
41
+ "./symbols/*": "./src/symbols/*",
42
+ "./patterns/*": "./src/patterns/*",
43
+ "./charts/*": "./src/charts/*"
39
44
  },
40
45
  "dependencies": {
41
46
  "@rokkit/core": "latest",
42
47
  "@rokkit/data": "latest",
43
48
  "@rokkit/states": "latest",
44
49
  "d3-array": "^3.2.4",
45
- "d3-format": "^3.1.2",
46
50
  "d3-axis": "^3.0.0",
51
+ "d3-format": "^3.1.2",
47
52
  "d3-scale": "^4.0.2",
48
53
  "d3-scale-chromatic": "^3.1.0",
49
54
  "d3-selection": "^3.0.0",
55
+ "d3-shape": "^3.2.0",
50
56
  "d3-transition": "^3.0.1",
51
57
  "ramda": "^0.32.0"
52
58
  }