@rokkit/chart 1.1.17 → 1.1.19

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 (156) hide show
  1. package/dist/AnimatedPlot.svelte.d.ts +35 -0
  2. package/dist/Chart.svelte.d.ts +21 -0
  3. package/dist/ChartExporter.svelte.d.ts +22 -0
  4. package/dist/ChartLegend.svelte.d.ts +30 -0
  5. package/dist/ChartProvider.svelte.d.ts +10 -0
  6. package/dist/FacetPlot/Panel.svelte.d.ts +22 -0
  7. package/dist/FacetPlot.svelte.d.ts +32 -0
  8. package/dist/Plot/Arc.svelte.d.ts +18 -0
  9. package/dist/Plot/Area.svelte.d.ts +14 -0
  10. package/dist/Plot/Axis.svelte.d.ts +13 -0
  11. package/dist/Plot/Bar.svelte.d.ts +11 -0
  12. package/dist/Plot/Grid.svelte.d.ts +3 -0
  13. package/dist/Plot/Legend.svelte.d.ts +6 -0
  14. package/dist/Plot/Line.svelte.d.ts +13 -0
  15. package/dist/Plot/Point.svelte.d.ts +13 -0
  16. package/dist/Plot/Root.svelte.d.ts +21 -0
  17. package/dist/Plot/Timeline.svelte.d.ts +13 -0
  18. package/dist/Plot/Tooltip.svelte.d.ts +7 -0
  19. package/dist/Plot.svelte.d.ts +34 -0
  20. package/dist/PlotState.svelte.d.ts +0 -3
  21. package/dist/Sparkline.svelte.d.ts +16 -0
  22. package/dist/Symbol.svelte.d.ts +12 -0
  23. package/dist/Texture.svelte.d.ts +12 -0
  24. package/dist/charts/AreaChart.svelte.d.ts +25 -0
  25. package/dist/charts/BarChart.svelte.d.ts +26 -0
  26. package/dist/charts/BoxPlot.svelte.d.ts +18 -0
  27. package/dist/charts/BubbleChart.svelte.d.ts +23 -0
  28. package/dist/charts/LineChart.svelte.d.ts +26 -0
  29. package/dist/charts/PieChart.svelte.d.ts +19 -0
  30. package/dist/charts/ScatterPlot.svelte.d.ts +29 -0
  31. package/dist/charts/ViolinPlot.svelte.d.ts +18 -0
  32. package/dist/crossfilter/CrossFilter.svelte.d.ts +12 -0
  33. package/dist/crossfilter/FilterBar.svelte.d.ts +12 -0
  34. package/dist/crossfilter/FilterHistogram.svelte.d.ts +19 -0
  35. package/dist/crossfilter/FilterSlider.svelte.d.ts +15 -0
  36. package/dist/elements/Bar.svelte.d.ts +17 -0
  37. package/dist/elements/ColorRamp.svelte.d.ts +17 -0
  38. package/dist/elements/ContinuousLegend.svelte.d.ts +18 -0
  39. package/dist/elements/DefinePatterns.svelte.d.ts +21 -0
  40. package/dist/elements/DiscreteLegend.svelte.d.ts +17 -0
  41. package/dist/elements/Label.svelte.d.ts +11 -0
  42. package/dist/elements/SymbolGrid.svelte.d.ts +8 -0
  43. package/dist/examples/BarChartExample.svelte.d.ts +18 -0
  44. package/dist/geoms/Arc.svelte.d.ts +20 -0
  45. package/dist/geoms/Area.svelte.d.ts +16 -0
  46. package/dist/geoms/Bar.svelte.d.ts +23 -0
  47. package/dist/geoms/Box.svelte.d.ts +12 -0
  48. package/dist/geoms/Candlestick.svelte.d.ts +20 -0
  49. package/dist/geoms/Heatmap.svelte.d.ts +13 -0
  50. package/dist/geoms/Hexbin.svelte.d.ts +13 -0
  51. package/dist/geoms/LabelPill.svelte.d.ts +9 -0
  52. package/dist/geoms/Line.svelte.d.ts +24 -0
  53. package/dist/geoms/Point.svelte.d.ts +30 -0
  54. package/dist/geoms/Ribbon.svelte.d.ts +16 -0
  55. package/dist/geoms/Violin.svelte.d.ts +12 -0
  56. package/dist/geoms/Waterfall.svelte.d.ts +18 -0
  57. package/dist/geoms/lib/areas.d.ts +5 -3
  58. package/dist/lib/brewing/brewer.svelte.d.ts +24 -15
  59. package/dist/lib/brewing/marks/arcs.d.ts +16 -6
  60. package/dist/lib/brewing/marks/areas.d.ts +2 -2
  61. package/dist/lib/brewing/marks/boxes.d.ts +3 -3
  62. package/dist/lib/brewing/marks/lines.d.ts +6 -6
  63. package/dist/lib/brewing/marks/points.d.ts +13 -12
  64. package/dist/lib/brewing/marks/violins.d.ts +3 -3
  65. package/dist/lib/brewing/scales.d.ts +3 -3
  66. package/dist/lib/chart.d.ts +2 -2
  67. package/dist/lib/keyboard-nav.d.ts +1 -1
  68. package/dist/lib/plot/facet.d.ts +2 -2
  69. package/dist/lib/plot/frames.d.ts +9 -9
  70. package/dist/lib/plot/scales.d.ts +3 -3
  71. package/dist/lib/plot/types.d.ts +7 -4
  72. package/dist/lib/scales.svelte.d.ts +2 -2
  73. package/dist/lib/utils.d.ts +7 -1
  74. package/dist/lib/xscale.d.ts +1 -1
  75. package/dist/patterns/DefinePatterns.svelte.d.ts +7 -0
  76. package/dist/patterns/PatternDef.svelte.d.ts +11 -0
  77. package/dist/spec/chart-spec.d.ts +22 -0
  78. package/dist/symbols/RoundedSquare.svelte.d.ts +11 -0
  79. package/dist/symbols/Shape.svelte.d.ts +18 -0
  80. package/dist/symbols/constants/index.d.ts +1 -1
  81. package/dist/symbols/index.d.ts +2 -2
  82. package/dist/symbols/outline.svelte.d.ts +18 -0
  83. package/dist/symbols/solid.svelte.d.ts +18 -0
  84. package/package.json +22 -3
  85. package/src/AnimatedPlot.svelte +49 -43
  86. package/src/Chart.svelte +34 -22
  87. package/src/ChartExporter.svelte +19 -16
  88. package/src/ChartLegend.svelte +24 -20
  89. package/src/ChartProvider.svelte +10 -2
  90. package/src/FacetPlot/Panel.svelte +23 -3
  91. package/src/FacetPlot.svelte +29 -26
  92. package/src/Plot/Arc.svelte +3 -2
  93. package/src/Plot/Area.svelte +30 -8
  94. package/src/Plot/Axis.svelte +26 -45
  95. package/src/Plot/Bar.svelte +20 -5
  96. package/src/Plot/Grid.svelte +5 -4
  97. package/src/Plot/Legend.svelte +8 -4
  98. package/src/Plot/Line.svelte +24 -7
  99. package/src/Plot/Point.svelte +24 -6
  100. package/src/Plot/Root.svelte +17 -2
  101. package/src/Plot/Timeline.svelte +13 -14
  102. package/src/Plot/Tooltip.svelte +12 -6
  103. package/src/Plot.svelte +58 -40
  104. package/src/PlotState.svelte.js +6 -2
  105. package/src/Sparkline.svelte +22 -8
  106. package/src/Symbol.svelte +15 -5
  107. package/src/Texture.svelte +12 -2
  108. package/src/charts/AreaChart.svelte +26 -3
  109. package/src/charts/BarChart.svelte +27 -3
  110. package/src/charts/BoxPlot.svelte +19 -3
  111. package/src/charts/BubbleChart.svelte +24 -3
  112. package/src/charts/LineChart.svelte +27 -3
  113. package/src/charts/PieChart.svelte +20 -3
  114. package/src/charts/ScatterPlot.svelte +27 -3
  115. package/src/charts/ViolinPlot.svelte +19 -3
  116. package/src/crossfilter/CrossFilter.svelte +13 -10
  117. package/src/crossfilter/FilterBar.svelte +14 -3
  118. package/src/crossfilter/FilterHistogram.svelte +49 -24
  119. package/src/crossfilter/FilterSlider.svelte +16 -5
  120. package/src/elements/Bar.svelte +16 -2
  121. package/src/elements/ColorRamp.svelte +28 -4
  122. package/src/elements/ContinuousLegend.svelte +20 -3
  123. package/src/elements/DefinePatterns.svelte +23 -7
  124. package/src/elements/DiscreteLegend.svelte +18 -2
  125. package/src/elements/Label.svelte +11 -2
  126. package/src/elements/SymbolGrid.svelte +13 -4
  127. package/src/examples/BarChartExample.svelte +12 -15
  128. package/src/geoms/Arc.svelte +18 -5
  129. package/src/geoms/Area.svelte +38 -20
  130. package/src/geoms/Bar.svelte +40 -23
  131. package/src/geoms/Box.svelte +13 -4
  132. package/src/geoms/Candlestick.svelte +27 -7
  133. package/src/geoms/Heatmap.svelte +20 -9
  134. package/src/geoms/Hexbin.svelte +35 -13
  135. package/src/geoms/LabelPill.svelte +9 -3
  136. package/src/geoms/Line.svelte +27 -10
  137. package/src/geoms/Point.svelte +33 -13
  138. package/src/geoms/Ribbon.svelte +26 -8
  139. package/src/geoms/Violin.svelte +13 -4
  140. package/src/geoms/Waterfall.svelte +32 -12
  141. package/src/geoms/lib/areas.js +2 -2
  142. package/src/lib/brewing/marks/arcs.js +3 -2
  143. package/src/lib/brewing/marks/boxes.js +1 -1
  144. package/src/lib/brewing/marks/lines.js +2 -2
  145. package/src/lib/brewing/marks/points.js +3 -2
  146. package/src/lib/brewing/marks/violins.js +1 -1
  147. package/src/lib/plot/facet.js +1 -1
  148. package/src/lib/plot/frames.js +4 -4
  149. package/src/lib/plot/types.js +6 -3
  150. package/src/lib/utils.js +7 -1
  151. package/src/patterns/DefinePatterns.svelte +9 -4
  152. package/src/patterns/PatternDef.svelte +11 -3
  153. package/src/symbols/RoundedSquare.svelte +15 -4
  154. package/src/symbols/Shape.svelte +21 -3
  155. package/src/symbols/outline.svelte +2 -0
  156. package/src/symbols/solid.svelte +2 -0
@@ -7,7 +7,7 @@
7
7
  * Violin body uses the lighter fill shade; outline uses the darker stroke shade.
8
8
  *
9
9
  * @param {Object[]} data
10
- * @param {{ x: string, fill?: string }} channels
10
+ * @param {{ x?: string, fill?: string }} channels
11
11
  * `fill` drives violin interior and outline (defaults to x-field).
12
12
  * @param {import('d3-scale').ScaleBand} xScale
13
13
  * @param {import('d3-scale').ScaleLinear} yScale
@@ -15,6 +15,6 @@
15
15
  * @returns {Array}
16
16
  */
17
17
  export function buildViolins(data: Object[], channels: {
18
- x: string;
18
+ x?: string;
19
19
  fill?: string;
20
- }, xScale: any, yScale: any, colors: Map<any, any>): any[];
20
+ }, xScale: import("d3-scale").ScaleBand<any>, yScale: import("d3-scale").ScaleLinear<any, any, never>, colors: Map<any, any>): any[];
@@ -7,7 +7,7 @@
7
7
  */
8
8
  export function buildXScale(data: Object[], field: string, width: number, opts?: {
9
9
  padding?: number;
10
- }): any;
10
+ }): import("d3-scale").ScaleBand<string> | (number[] & import("d3-scale").ScaleLinear<number, number, never>);
11
11
  /**
12
12
  * Builds a y linear scale from 0 to max, extended by any layer overrides.
13
13
  * @param {Object[]} data
@@ -18,11 +18,11 @@ export function buildXScale(data: Object[], field: string, width: number, opts?:
18
18
  export function buildYScale(data: Object[], field: string, height: number, layers?: Array<{
19
19
  data?: Object[];
20
20
  y?: string;
21
- }>): any;
21
+ }>): import("d3-scale").ScaleLinear<number, number, never>;
22
22
  /**
23
23
  * Builds a sqrt scale for bubble/point size.
24
24
  * @param {Object[]} data
25
25
  * @param {string} field
26
26
  * @param {number} maxRadius
27
27
  */
28
- export function buildSizeScale(data: Object[], field: string, maxRadius?: number): any;
28
+ export function buildSizeScale(data: Object[], field: string, maxRadius?: number): import("d3-scale").ScalePower<number, number, never>;
@@ -28,8 +28,8 @@ declare class Chart {
28
28
  y: any;
29
29
  } | undefined;
30
30
  scale: {
31
- x: any;
32
- y: any;
31
+ x: import("d3-scale").ScaleLinear<number, number, never> | import("d3-scale").ScaleBand<string> | (Date[] & import("d3-scale").ScaleTime<number, number, never>);
32
+ y: import("d3-scale").ScaleLinear<number, number, never> | import("d3-scale").ScaleBand<string> | (Date[] & import("d3-scale").ScaleTime<number, number, never>);
33
33
  } | undefined;
34
34
  aggregate(value: any, stat: any): void;
35
35
  ticks(axis: any, count: any, fontSize?: number): any;
@@ -11,5 +11,5 @@
11
11
  */
12
12
  export function keyboardNav(node: Element, enabled: boolean): {
13
13
  update(newEnabled: any): void;
14
- destroy: () => any;
14
+ destroy: () => void;
15
15
  };
@@ -4,9 +4,9 @@
4
4
  *
5
5
  * @param {Object[]} data
6
6
  * @param {string} field
7
- * @returns {Map<unknown, Object[]>}
7
+ * @returns {Map<unknown, Record<string, unknown>[]>}
8
8
  */
9
- export function splitByField(data: Object[], field: string): Map<unknown, Object[]>;
9
+ export function splitByField(data: Object[], field: string): Map<unknown, Record<string, unknown>[]>;
10
10
  /**
11
11
  * Computes x/y domains for each panel.
12
12
  *
@@ -4,9 +4,9 @@
4
4
  *
5
5
  * @param {Object[]} data
6
6
  * @param {string} timeField
7
- * @returns {Map<unknown, Object[]>}
7
+ * @returns {Map<unknown, Record<string, unknown>[]>}
8
8
  */
9
- export function extractFrames(data: Object[], timeField: string): Map<unknown, Object[]>;
9
+ export function extractFrames(data: Object[], timeField: string): Map<unknown, Record<string, unknown>[]>;
10
10
  /**
11
11
  * Ensures all frame values (byField) appear for every (x, color?) combination.
12
12
  * Uses dataset alignBy to fill missing frame-value combos with y=0 so bars
@@ -16,15 +16,15 @@ export function extractFrames(data: Object[], timeField: string): Map<unknown, O
16
16
  * with no further per-frame normalization needed.
17
17
  *
18
18
  * @param {Object[]} data - pre-aggregated rows, one per (x, color?, byField)
19
- * @param {{ x?: string, y: string, color?: string }} channels
19
+ * @param {{ x?: string, y?: string, color?: string }} channels
20
20
  * @param {string} byField - the frame field (e.g. 'year')
21
- * @returns {Object[]}
21
+ * @returns {Record<string, unknown>[]}
22
22
  */
23
23
  export function completeFrames(data: Object[], channels: {
24
24
  x?: string;
25
- y: string;
25
+ y?: string;
26
26
  color?: string;
27
- }, byField: string): Object[];
27
+ }, byField: string): Record<string, unknown>[];
28
28
  /**
29
29
  * Computes static x/y domains from the full (pre-split) data array.
30
30
  * These domains stay constant throughout the animation so values are
@@ -35,12 +35,12 @@ export function completeFrames(data: Object[], channels: {
35
35
  * be negative.
36
36
  *
37
37
  * @param {Object[]} data - full dataset (before frame extraction)
38
- * @param {{ x: string, y: string }} channels
38
+ * @param {{ x?: string, y?: string }} channels
39
39
  * @returns {{ xDomain: unknown[], yDomain: [number, number] }}
40
40
  */
41
41
  export function computeStaticDomains(data: Object[], channels: {
42
- x: string;
43
- y: string;
42
+ x?: string;
43
+ y?: string;
44
44
  }): {
45
45
  xDomain: unknown[];
46
46
  yDomain: [number, number];
@@ -1,5 +1,5 @@
1
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;
2
+ export function inferOrientation(xType: any, yType: any): "none" | "horizontal" | "vertical";
3
+ export function buildUnifiedXScale(datasets: any, field: any, width: any, opts?: {}): import("d3-scale").ScaleLinear<number, number, never> | import("d3-scale").ScaleBand<string>;
4
+ export function buildUnifiedYScale(datasets: any, field: any, height: any, opts?: {}): import("d3-scale").ScaleLinear<number, number, never> | import("d3-scale").ScaleBand<string>;
5
5
  export function inferColorScaleType(data: any, field: any, spec?: {}): any;
@@ -14,10 +14,11 @@ export type GeomSpec = {
14
14
  * - Built-in or helpers.stats key
15
15
  */
16
16
  stat?: string | undefined;
17
+ label?: string | boolean | undefined;
17
18
  options?: Record<string, unknown> | undefined;
18
19
  };
19
20
  export type PlotSpec = {
20
- data: Record<string, unknown>[];
21
+ data?: Record<string, unknown>[] | undefined;
21
22
  x?: string | undefined;
22
23
  y?: string | undefined;
23
24
  color?: string | undefined;
@@ -32,11 +33,11 @@ export type PlotSpec = {
32
33
  xLabel?: string | undefined;
33
34
  yLabel?: string | undefined;
34
35
  axisOrigin?: [number, number] | undefined;
35
- colorScale?: "diverging" | "sequential" | "categorical" | undefined;
36
+ colorScale?: "categorical" | "sequential" | "diverging" | undefined;
36
37
  colorScheme?: string | undefined;
37
38
  colorMidpoint?: number | undefined;
38
39
  colorDomain?: unknown[] | undefined;
39
- geoms: GeomSpec[];
40
+ geoms?: GeomSpec[] | undefined;
40
41
  facet?: {
41
42
  by: string;
42
43
  cols?: number;
@@ -51,6 +52,8 @@ export type PlotSpec = {
51
52
  legend?: boolean | undefined;
52
53
  tooltip?: boolean | undefined;
53
54
  title?: string | undefined;
55
+ summary?: string | undefined;
56
+ orientation?: "horizontal" | "vertical" | undefined;
54
57
  preset?: string | undefined;
55
58
  width?: number | undefined;
56
59
  height?: number | undefined;
@@ -63,7 +66,7 @@ export type PlotHelpers = {
63
66
  /**
64
67
  * Svelte components keyed by type name
65
68
  */
66
- geoms?: Record<string, unknown> | undefined;
69
+ geoms?: Record<string, import("svelte").Component<any, any, string>> | undefined;
67
70
  /**
68
71
  * d3 scale override
69
72
  */
@@ -3,8 +3,8 @@ export function createScales(data: any, dimensions: any, options: any): {
3
3
  yScale?: undefined;
4
4
  colorScale?: undefined;
5
5
  } | {
6
- xScale: any;
7
- yScale: any;
6
+ xScale: import("d3-scale").ScaleBand<any> | import("d3-scale").ScaleContinuousNumeric<any, any, never>;
7
+ yScale: import("d3-scale").ScaleLinear<number, number, never>;
8
8
  colorScale: Object | null;
9
9
  };
10
10
  /**
@@ -58,4 +58,10 @@ 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): {};
61
+ /**
62
+ * Builds a collection of size-scaling path generators keyed by shape name.
63
+ *
64
+ * @param {Record<string, string|number|(string|number)[]>} paths
65
+ * @returns {Record<string, (size: number) => string|number>}
66
+ */
67
+ export function scaledPathCollection(paths: Record<string, string | number | (string | number)[]>): Record<string, (size: number) => string | number>;
@@ -8,4 +8,4 @@
8
8
  * @param {number} padding
9
9
  * @returns {import('d3-scale').ScaleContinuousNumeric|import('d3-scale').ScaleBand}
10
10
  */
11
- export function buildXScale(xValues: any[], dimensions: Object, padding: number): any | any;
11
+ export function buildXScale(xValues: any[], dimensions: Object, padding: number): import("d3-scale").ScaleContinuousNumeric<any, any, never> | import("d3-scale").ScaleBand<any>;
@@ -0,0 +1,7 @@
1
+ import type { PatternMark } from './patterns.js';
2
+ type Props = {
3
+ patterns?: Record<string, PatternMark[]>;
4
+ };
5
+ declare const DefinePatterns: import("svelte").Component<Props, {}, "">;
6
+ type DefinePatterns = ReturnType<typeof DefinePatterns>;
7
+ export default DefinePatterns;
@@ -0,0 +1,11 @@
1
+ import type { PatternMark } from './patterns.js';
2
+ type Props = {
3
+ id: string;
4
+ marks?: PatternMark[];
5
+ size?: number;
6
+ stroke?: string;
7
+ thickness?: number;
8
+ };
9
+ declare const PatternDef: import("svelte").Component<Props, {}, "">;
10
+ type PatternDef = ReturnType<typeof PatternDef>;
11
+ export default PatternDef;
@@ -0,0 +1,22 @@
1
+ export function chart(data: any, channels?: {}): ChartSpec;
2
+ export class ChartSpec {
3
+ constructor(data: any);
4
+ data: any;
5
+ channels: {};
6
+ layers: any[];
7
+ options: {};
8
+ x(f: any): this;
9
+ y(f: any): this;
10
+ color(f: any): this;
11
+ pattern(f: any): this;
12
+ aes(ch: any): this;
13
+ bar(opts?: {}): this;
14
+ line(opts?: {}): this;
15
+ area(opts?: {}): this;
16
+ arc(opts?: {}): this;
17
+ point(opts?: {}): this;
18
+ grid(opts?: {}): this;
19
+ legend(opts?: {}): this;
20
+ axis(type: any, opts?: {}): this;
21
+ size(w: any, h: any): this;
22
+ }
@@ -0,0 +1,11 @@
1
+ import type { SVGAttributes } from 'svelte/elements';
2
+ export interface Props extends Omit<SVGAttributes<SVGRectElement>, 'x' | 'y' | 'fill' | 'stroke'> {
3
+ x?: number;
4
+ y?: number;
5
+ size?: number;
6
+ fill?: string;
7
+ stroke?: string;
8
+ }
9
+ declare const RoundedSquare: import("svelte").Component<Props, {}, "">;
10
+ type RoundedSquare = ReturnType<typeof RoundedSquare>;
11
+ export default RoundedSquare;
@@ -0,0 +1,18 @@
1
+ import type { SVGAttributes } from 'svelte/elements';
2
+ export type Props = {
3
+ x?: number;
4
+ y?: number;
5
+ size?: number;
6
+ fill?: string;
7
+ stroke?: string;
8
+ thickness?: number;
9
+ name?: string;
10
+ onclick?: SVGAttributes<SVGPathElement>['onclick'];
11
+ onmouseover?: SVGAttributes<SVGPathElement>['onmouseover'];
12
+ onmouseleave?: SVGAttributes<SVGPathElement>['onmouseleave'];
13
+ onfocus?: SVGAttributes<SVGPathElement>['onfocus'];
14
+ onblur?: SVGAttributes<SVGPathElement>['onblur'];
15
+ };
16
+ declare const Shape: import("svelte").Component<Props, {}, "">;
17
+ type Shape = ReturnType<typeof Shape>;
18
+ export default Shape;
@@ -1 +1 @@
1
- export const namedShapes: {};
1
+ export const namedShapes: Record<string, (size: number) => string | number>;
@@ -1,5 +1,5 @@
1
1
  export const shapes: string[];
2
2
  export const components: {
3
- default: import("svelte/legacy").LegacyComponentType;
4
- 'rounded-square': import("svelte/legacy").LegacyComponentType;
3
+ default: import("svelte").Component<import("./Shape.svelte").Props, {}, "">;
4
+ 'rounded-square': import("svelte").Component<import("./RoundedSquare.svelte").Props, {}, "">;
5
5
  };
@@ -0,0 +1,18 @@
1
+ interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
2
+ new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
3
+ $$bindings?: Bindings;
4
+ } & Exports;
5
+ (internal: unknown, props: {
6
+ $$events?: Events;
7
+ $$slots?: Slots;
8
+ }): Exports & {
9
+ $set?: any;
10
+ $on?: any;
11
+ };
12
+ z_$$bindings?: Bindings;
13
+ }
14
+ declare const Outline: $$__sveltets_2_IsomorphicComponent<Record<string, never>, {
15
+ [evt: string]: CustomEvent<any>;
16
+ }, {}, {}, string>;
17
+ type Outline = InstanceType<typeof Outline>;
18
+ export default Outline;
@@ -0,0 +1,18 @@
1
+ interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
2
+ new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
3
+ $$bindings?: Bindings;
4
+ } & Exports;
5
+ (internal: unknown, props: {
6
+ $$events?: Events;
7
+ $$slots?: Slots;
8
+ }): Exports & {
9
+ $set?: any;
10
+ $on?: any;
11
+ };
12
+ z_$$bindings?: Bindings;
13
+ }
14
+ declare const Solid: $$__sveltets_2_IsomorphicComponent<Record<string, never>, {
15
+ [evt: string]: CustomEvent<any>;
16
+ }, {}, {}, string>;
17
+ type Solid = InstanceType<typeof Solid>;
18
+ export default Solid;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rokkit/chart",
3
- "version": "1.1.17",
3
+ "version": "1.1.19",
4
4
  "type": "module",
5
5
  "description": "Data-driven chart components",
6
6
  "repository": {
@@ -16,10 +16,11 @@
16
16
  "access": "public"
17
17
  },
18
18
  "scripts": {
19
- "prepublishOnly": "cp ../../LICENSE . && bun clean && bun tsc --project tsconfig.build.json",
19
+ "prepublishOnly": "cp ../../LICENSE . && bun run clean && bun run build",
20
20
  "postpublish": "rm -f LICENSE",
21
21
  "clean": "rm -rf dist",
22
- "build": "bun prepublishOnly"
22
+ "build": "svelte-package -i src -o dist",
23
+ "check": "svelte-check --tsconfig ./tsconfig.json"
23
24
  },
24
25
  "files": [
25
26
  "src/**/*.js",
@@ -56,5 +57,23 @@
56
57
  "d3-transition": "^3.0.1",
57
58
  "d3-zoom": "^3.0.0",
58
59
  "ramda": "^0.32.0"
60
+ },
61
+ "peerDependencies": {
62
+ "svelte": "^5.0.0"
63
+ },
64
+ "devDependencies": {
65
+ "@sveltejs/package": "^2.5.8",
66
+ "@sveltejs/vite-plugin-svelte": "^6.2.4",
67
+ "@types/d3-array": "^3.2.2",
68
+ "@types/d3-axis": "^3.0.6",
69
+ "@types/d3-format": "^3.0.4",
70
+ "@types/d3-scale": "^4.0.9",
71
+ "@types/d3-scale-chromatic": "^3.1.0",
72
+ "@types/d3-selection": "^3.0.11",
73
+ "@types/d3-shape": "^3.1.8",
74
+ "@types/d3-transition": "^3.0.9",
75
+ "@types/d3-zoom": "^3.0.8",
76
+ "@types/ramda": "^0.31.1",
77
+ "svelte-check": "^4.4.3"
59
78
  }
60
79
  }
@@ -1,38 +1,43 @@
1
- <script>
1
+ <script lang="ts">
2
2
  import { onMount, onDestroy } from 'svelte'
3
+ import type { Snippet } from 'svelte'
3
4
  import { tweened } from 'svelte/motion'
4
5
  import { sineInOut } from 'svelte/easing'
5
6
  import { extractFrames, completeFrames, computeStaticDomains } from './lib/plot/frames.js'
6
7
  import { applyGeomStat } from './lib/plot/stat.js'
8
+ import type { GeomSpec, PlotHelpers, PlotSpec } from './lib/plot/types.js'
7
9
  import Timeline from './Plot/Timeline.svelte'
8
10
  import PlotChart from './Plot.svelte'
9
11
 
10
- /**
11
- * @type {{
12
- * data: Object[],
13
- * animate: { by: string, duration?: number, loop?: boolean },
14
- * x?: string,
15
- * y?: string,
16
- * color?: string,
17
- * fill?: string,
18
- * pattern?: string,
19
- * symbol?: string,
20
- * geom?: string,
21
- * stat?: string,
22
- * geoms?: import('./lib/plot/types.js').GeomSpec[],
23
- * helpers?: import('./lib/plot/types.js').PlotHelpers,
24
- * width?: number,
25
- * height?: number,
26
- * mode?: 'light' | 'dark',
27
- * grid?: boolean,
28
- * legend?: boolean,
29
- * tween?: boolean,
30
- * sorted?: boolean,
31
- * dynamicDomain?: boolean,
32
- * label?: boolean | string | ((data: Record<string, unknown>) => string),
33
- * children?: import('svelte').Snippet
34
- * }}
35
- */
12
+ type Row = Record<string, unknown>
13
+ type Animate = { by: string; duration?: number; loop?: boolean }
14
+ type AggChannels = { x?: string; y?: string; color?: string; frame?: string }
15
+
16
+ type Props = {
17
+ data?: Row[]
18
+ animate: Animate
19
+ x?: string
20
+ y?: string
21
+ color?: string
22
+ fill?: string
23
+ pattern?: string
24
+ symbol?: string
25
+ geom?: string
26
+ stat?: string
27
+ geoms?: GeomSpec[]
28
+ helpers?: PlotHelpers
29
+ width?: number
30
+ height?: number
31
+ mode?: 'light' | 'dark'
32
+ grid?: boolean
33
+ legend?: boolean
34
+ tween?: boolean
35
+ sorted?: boolean
36
+ dynamicDomain?: boolean
37
+ label?: boolean | string | ((data: Row) => string)
38
+ children?: Snippet
39
+ }
40
+
36
41
  let {
37
42
  data = [],
38
43
  animate,
@@ -56,7 +61,7 @@
56
61
  dynamicDomain = false,
57
62
  label = false,
58
63
  children
59
- } = $props()
64
+ }: Props = $props()
60
65
 
61
66
  // Effective geom list: explicit array takes precedence; otherwise build from shorthand props
62
67
  const effectiveGeoms = $derived(
@@ -78,7 +83,7 @@
78
83
  const firstNonIdentity = effectiveGeoms.find((g) => g.stat && g.stat !== 'identity')
79
84
  if (!firstNonIdentity) return { data, geoms: effectiveGeoms }
80
85
 
81
- const aggChannels = { y }
86
+ const aggChannels: AggChannels = { y }
82
87
  if (x) aggChannels.x = x
83
88
  if (color) aggChannels.color = color
84
89
  aggChannels.frame = animate.by
@@ -124,7 +129,7 @@
124
129
  if (typeof window.matchMedia !== 'function') return
125
130
  const mq = window.matchMedia('(prefers-reduced-motion: reduce)')
126
131
  prefersReducedMotion = mq.matches
127
- const handler = (e) => { prefersReducedMotion = e.matches }
132
+ const handler = (e: MediaQueryListEvent) => { prefersReducedMotion = e.matches }
128
133
  mq.addEventListener('change', handler)
129
134
  return () => mq.removeEventListener('change', handler)
130
135
  })
@@ -146,7 +151,7 @@
146
151
  }
147
152
  }
148
153
 
149
- function tick(time) {
154
+ function tick(time: number) {
150
155
  if (!playing) return
151
156
  if (time - lastTime >= msPerFrame) {
152
157
  lastTime = time
@@ -169,7 +174,7 @@
169
174
  })
170
175
 
171
176
  // Reduced motion: step frames on interval instead of rAF
172
- let reducedInterval = 0
177
+ let reducedInterval: ReturnType<typeof setInterval> | undefined
173
178
  $effect(() => {
174
179
  if (!playing || !prefersReducedMotion) {
175
180
  clearInterval(reducedInterval)
@@ -203,35 +208,36 @@
203
208
 
204
209
  function handlePlay() { playing = true }
205
210
  function handlePause() { playing = false }
206
- function handleScrub(index) { playing = false; currentIndex = index }
207
- function handleSpeed(s) { speed = s }
211
+ function handleScrub(index: number) { playing = false; currentIndex = index }
212
+ function handleSpeed(s: number) { speed = s }
208
213
 
209
214
  // Detect horizontal bar chart race: sorted=true AND y is a categorical string field
210
215
  const isHorizontalRace = $derived.by(() => {
211
- if (!sorted || !prepared.data.length) return false
216
+ if (!sorted || !prepared.data.length || !y) return false
212
217
  const sample = prepared.data[0]
213
- return y && typeof sample[y] === 'string'
218
+ return typeof sample[y] === 'string'
214
219
  })
215
220
 
216
221
  // Number of unique entities (y categories) for horizontal race yDomain
217
222
  const entityCount = $derived.by(() => {
218
- if (!isHorizontalRace) return 0
219
- return new Set(prepared.data.map((d) => d[y])).size
223
+ if (!isHorizontalRace || !y) return 0
224
+ const field = y
225
+ return new Set(prepared.data.map((d) => d[field])).size
220
226
  })
221
227
 
222
228
  // Tweened display data — smoothly interpolates values between frames.
223
229
  // Tween duration is 1.1× the frame interval so tweens always overlap:
224
230
  // when the next frame fires, the previous tween is ~91% complete.
225
231
  // displayTween.set() starts from the current in-flight value → seamless continuous motion.
226
- const displayTween = tweened([], { duration: 0 })
232
+ const displayTween = tweened<Row[]>([], { duration: 0 })
227
233
 
228
234
  $effect(() => {
229
235
  const raw = currentFrameData
230
- const xField = x
231
- const yField = y
236
+ const xField = x ?? ''
237
+ const yField = y ?? ''
232
238
 
233
239
  // Build display target for this frame
234
- let target
240
+ let target: Row[]
235
241
  if (isHorizontalRace) {
236
242
  const ranked = raw.slice().sort((a, b) => Number(b[xField]) - Number(a[xField]))
237
243
  const n = ranked.length
@@ -345,7 +351,7 @@
345
351
  const xDomainForFrame = $derived(
346
352
  isHorizontalRace && dynamicDomain ? $xDomainTween : staticDomains.xDomain
347
353
  )
348
- const frameSpec = $derived({
354
+ const frameSpec = $derived<PlotSpec>({
349
355
  data: $displayTween,
350
356
  x,
351
357
  y: isHorizontalRace ? '_rank' : y,
package/src/Chart.svelte CHANGED
@@ -1,25 +1,37 @@
1
- <script>
1
+ <script lang="ts">
2
2
  import { setContext } from 'svelte'
3
+ import type { Snippet } from 'svelte'
3
4
  import { ChartBrewer } from './lib/brewing/brewer.svelte.js'
5
+ import type { ChartSpec } from './spec/chart-spec.js'
6
+
7
+ type Channels = {
8
+ x?: string
9
+ y?: string
10
+ color?: string
11
+ pattern?: string
12
+ fill?: string
13
+ size?: string
14
+ label?: string
15
+ symbol?: string
16
+ }
17
+
18
+ type Props = {
19
+ spec?: ChartSpec
20
+ data?: Record<string, unknown>[]
21
+ x?: string
22
+ y?: string
23
+ color?: string
24
+ pattern?: string
25
+ fill?: string
26
+ size?: string
27
+ label?: string
28
+ symbol?: string
29
+ width?: number
30
+ height?: number
31
+ mode?: 'light' | 'dark'
32
+ children?: Snippet
33
+ }
4
34
 
5
- /**
6
- * @type {{
7
- * spec?: import('./spec/chart-spec.js').ChartSpec,
8
- * data?: Object[],
9
- * x?: string,
10
- * y?: string,
11
- * color?: string,
12
- * pattern?: string,
13
- * fill?: string,
14
- * size?: string,
15
- * label?: string,
16
- * symbol?: string,
17
- * width?: number,
18
- * height?: number,
19
- * mode?: 'light' | 'dark',
20
- * children?: import('svelte').Snippet
21
- * }}
22
- */
23
35
  let {
24
36
  spec = undefined,
25
37
  data = [],
@@ -35,13 +47,13 @@
35
47
  height = 400,
36
48
  mode = 'light',
37
49
  children
38
- } = $props()
50
+ }: Props = $props()
39
51
 
40
52
  const brewer = new ChartBrewer()
41
53
  setContext('chart-brewer', brewer)
42
54
 
43
- function buildChannels() {
44
- const channels = {}
55
+ function buildChannels(): Channels {
56
+ const channels: Channels = {}
45
57
  if (x) channels.x = x
46
58
  if (y) channels.y = y
47
59
  if (color) channels.color = color