@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.
- package/dist/Plot/index.d.ts +4 -0
- package/dist/PlotState.svelte.d.ts +47 -0
- package/dist/crossfilter/createCrossFilter.svelte.d.ts +15 -0
- package/dist/geoms/lib/areas.d.ts +52 -0
- package/dist/geoms/lib/bars.d.ts +3 -0
- package/dist/index.d.ts +38 -1
- package/dist/lib/brewing/BoxBrewer.svelte.d.ts +10 -0
- package/dist/lib/brewing/CartesianBrewer.svelte.d.ts +8 -0
- package/dist/lib/brewing/PieBrewer.svelte.d.ts +8 -0
- package/dist/lib/brewing/ViolinBrewer.svelte.d.ts +9 -0
- package/dist/lib/brewing/brewer.svelte.d.ts +145 -0
- package/dist/lib/brewing/colors.d.ts +17 -0
- package/dist/lib/brewing/marks/arcs.d.ts +17 -0
- package/dist/lib/brewing/marks/areas.d.ts +31 -0
- package/dist/lib/brewing/marks/bars.d.ts +1 -0
- package/dist/lib/brewing/marks/boxes.d.ts +24 -0
- package/dist/lib/brewing/marks/lines.d.ts +24 -0
- package/dist/lib/brewing/marks/points.d.ts +40 -0
- package/dist/lib/brewing/marks/violins.d.ts +20 -0
- package/dist/lib/brewing/patterns.d.ts +14 -0
- package/dist/lib/brewing/scales.d.ts +28 -0
- package/dist/lib/brewing/stats.d.ts +31 -0
- package/dist/lib/brewing/symbols.d.ts +7 -0
- package/dist/lib/plot/chartProps.d.ts +177 -0
- package/dist/lib/plot/crossfilter.d.ts +13 -0
- package/dist/lib/plot/facet.d.ts +24 -0
- package/dist/lib/plot/frames.d.ts +47 -0
- package/dist/lib/plot/helpers.d.ts +3 -0
- package/dist/lib/plot/preset.d.ts +29 -0
- package/dist/lib/plot/scales.d.ts +5 -0
- package/dist/lib/plot/stat.d.ts +32 -0
- package/dist/lib/plot/types.d.ts +89 -0
- package/dist/lib/scales.svelte.d.ts +1 -1
- package/dist/lib/swatch.d.ts +12 -0
- package/dist/lib/utils.d.ts +1 -0
- package/dist/lib/xscale.d.ts +11 -0
- package/dist/patterns/index.d.ts +4 -9
- package/dist/patterns/patterns.d.ts +72 -0
- package/dist/patterns/scale.d.ts +30 -0
- package/package.json +9 -3
- package/src/AnimatedPlot.svelte +214 -0
- package/src/Chart.svelte +101 -0
- package/src/FacetPlot/Panel.svelte +23 -0
- package/src/FacetPlot.svelte +90 -0
- package/src/Plot/Arc.svelte +29 -0
- package/src/Plot/Area.svelte +25 -0
- package/src/Plot/Axis.svelte +62 -84
- package/src/Plot/Grid.svelte +20 -58
- package/src/Plot/Legend.svelte +160 -120
- package/src/Plot/Line.svelte +27 -0
- package/src/Plot/Point.svelte +27 -0
- package/src/Plot/Timeline.svelte +95 -0
- package/src/Plot/Tooltip.svelte +81 -0
- package/src/Plot/index.js +4 -0
- package/src/Plot.svelte +189 -0
- package/src/PlotState.svelte.js +278 -0
- package/src/Sparkline.svelte +69 -0
- package/src/charts/AreaChart.svelte +25 -0
- package/src/charts/BarChart.svelte +26 -0
- package/src/charts/BoxPlot.svelte +21 -0
- package/src/charts/BubbleChart.svelte +23 -0
- package/src/charts/LineChart.svelte +26 -0
- package/src/charts/PieChart.svelte +25 -0
- package/src/charts/ScatterPlot.svelte +25 -0
- package/src/charts/ViolinPlot.svelte +21 -0
- package/src/crossfilter/CrossFilter.svelte +38 -0
- package/src/crossfilter/FilterBar.svelte +32 -0
- package/src/crossfilter/FilterSlider.svelte +79 -0
- package/src/crossfilter/createCrossFilter.svelte.js +113 -0
- package/src/elements/SymbolGrid.svelte +6 -7
- package/src/geoms/Arc.svelte +81 -0
- package/src/geoms/Area.svelte +50 -0
- package/src/geoms/Bar.svelte +142 -0
- package/src/geoms/Box.svelte +101 -0
- package/src/geoms/LabelPill.svelte +17 -0
- package/src/geoms/Line.svelte +100 -0
- package/src/geoms/Point.svelte +100 -0
- package/src/geoms/Violin.svelte +44 -0
- package/src/geoms/lib/areas.js +131 -0
- package/src/geoms/lib/bars.js +172 -0
- package/src/index.js +52 -3
- package/src/lib/brewing/BoxBrewer.svelte.js +56 -0
- package/src/lib/brewing/CartesianBrewer.svelte.js +16 -0
- package/src/lib/brewing/PieBrewer.svelte.js +14 -0
- package/src/lib/brewing/ViolinBrewer.svelte.js +55 -0
- package/src/lib/brewing/brewer.svelte.js +229 -0
- package/src/lib/brewing/colors.js +22 -0
- package/src/lib/brewing/marks/arcs.js +43 -0
- package/src/lib/brewing/marks/areas.js +59 -0
- package/src/lib/brewing/marks/bars.js +49 -0
- package/src/lib/brewing/marks/boxes.js +75 -0
- package/src/lib/brewing/marks/lines.js +48 -0
- package/src/lib/brewing/marks/points.js +57 -0
- package/src/lib/brewing/marks/violins.js +90 -0
- package/src/lib/brewing/patterns.js +31 -0
- package/src/lib/brewing/scales.js +51 -0
- package/src/lib/brewing/scales.svelte.js +2 -26
- package/src/lib/brewing/stats.js +62 -0
- package/src/lib/brewing/symbols.js +10 -0
- package/src/lib/plot/chartProps.js +76 -0
- package/src/lib/plot/crossfilter.js +16 -0
- package/src/lib/plot/facet.js +58 -0
- package/src/lib/plot/frames.js +80 -0
- package/src/lib/plot/helpers.js +14 -0
- package/src/lib/plot/preset.js +53 -0
- package/src/lib/plot/scales.js +56 -0
- package/src/lib/plot/stat.js +92 -0
- package/src/lib/plot/types.js +65 -0
- package/src/lib/scales.svelte.js +2 -26
- package/src/lib/swatch.js +13 -0
- package/src/lib/utils.js +9 -0
- package/src/lib/xscale.js +31 -0
- package/src/patterns/DefinePatterns.svelte +32 -0
- package/src/patterns/PatternDef.svelte +27 -0
- package/src/patterns/index.js +4 -14
- package/src/patterns/patterns.js +208 -0
- package/src/patterns/scale.js +87 -0
- package/src/spec/chart-spec.js +29 -0
- package/src/symbols/Shape.svelte +1 -1
- package/src/symbols/constants/index.js +1 -1
- package/dist/old_lib/index.d.ts +0 -4
- package/dist/old_lib/plots.d.ts +0 -3
- package/dist/old_lib/swatch.d.ts +0 -285
- package/dist/old_lib/utils.d.ts +0 -1
- package/dist/patterns/paths/constants.d.ts +0 -1
- package/dist/template/constants.d.ts +0 -43
- package/dist/template/shapes/index.d.ts +0 -4
- package/src/old_lib/index.js +0 -4
- package/src/old_lib/plots.js +0 -27
- package/src/old_lib/swatch.js +0 -16
- package/src/old_lib/utils.js +0 -8
- package/src/patterns/Brick.svelte +0 -15
- package/src/patterns/Circles.svelte +0 -18
- package/src/patterns/CrossHatch.svelte +0 -12
- package/src/patterns/CurvedWave.svelte +0 -7
- package/src/patterns/Dots.svelte +0 -20
- package/src/patterns/OutlineCircles.svelte +0 -13
- package/src/patterns/Tile.svelte +0 -16
- package/src/patterns/Triangles.svelte +0 -13
- package/src/patterns/Waves.svelte +0 -9
- package/src/patterns/paths/NamedPattern.svelte +0 -9
- package/src/patterns/paths/constants.js +0 -4
- package/src/template/Texture.svelte +0 -13
- package/src/template/constants.js +0 -43
- package/src/template/shapes/Circles.svelte +0 -15
- package/src/template/shapes/Lines.svelte +0 -16
- package/src/template/shapes/Path.svelte +0 -9
- package/src/template/shapes/Polygons.svelte +0 -15
- package/src/template/shapes/index.js +0 -4
- /package/dist/{old_lib → lib}/brewer.d.ts +0 -0
- /package/dist/{old_lib → lib}/chart.d.ts +0 -0
- /package/dist/{old_lib → lib}/grid.d.ts +0 -0
- /package/dist/{old_lib → lib}/ticks.d.ts +0 -0
- /package/src/{old_lib → lib}/brewer.js +0 -0
- /package/src/{old_lib → lib}/chart.js +0 -0
- /package/src/{old_lib → lib}/grid.js +0 -0
- /package/src/{old_lib → lib}/ticks.js +0 -0
package/dist/Plot/index.d.ts
CHANGED
|
@@ -3,3 +3,7 @@ export { default as Axis } from "./Axis.svelte";
|
|
|
3
3
|
export { default as Bar } from "./Bar.svelte";
|
|
4
4
|
export { default as Legend } from "./Legend.svelte";
|
|
5
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,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;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,14 +1,51 @@
|
|
|
1
|
-
export namespace
|
|
1
|
+
export namespace PlotLayers {
|
|
2
2
|
export { Root };
|
|
3
3
|
export { Axis };
|
|
4
4
|
export { Bar };
|
|
5
5
|
export { Grid };
|
|
6
6
|
export { Legend };
|
|
7
|
+
export { Line };
|
|
8
|
+
export { Area };
|
|
9
|
+
export { Point };
|
|
10
|
+
export { Arc };
|
|
7
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";
|
|
8
33
|
export { ChartBrewer } from "./lib/brewing/index.svelte.js";
|
|
9
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";
|
|
10
43
|
import Root from './Plot/Root.svelte';
|
|
11
44
|
import Axis from './Plot/Axis.svelte';
|
|
12
45
|
import Bar from './Plot/Bar.svelte';
|
|
13
46
|
import Grid from './Plot/Grid.svelte';
|
|
14
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,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,145 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Groups aesthetic channel mappings by field name, merging aesthetics that
|
|
3
|
+
* share the same field into one legend section.
|
|
4
|
+
*
|
|
5
|
+
* @param {{ fill?: string, color?: string, pattern?: string, symbol?: string }} channels
|
|
6
|
+
* `fill` takes precedence over `color` for polygon charts (bars, areas, pie slices).
|
|
7
|
+
* @param {Map<unknown, {fill:string, stroke:string}>} colorMap
|
|
8
|
+
* @param {Map<unknown, string>} patternMap
|
|
9
|
+
* @param {Map<unknown, string>} symbolMap
|
|
10
|
+
* @returns {{ field: string, items: { label: string, fill: string|null, stroke: string|null, patternId: string|null, shape: string|null }[] }[]}
|
|
11
|
+
*/
|
|
12
|
+
export function buildLegendGroups(channels: {
|
|
13
|
+
fill?: string;
|
|
14
|
+
color?: string;
|
|
15
|
+
pattern?: string;
|
|
16
|
+
symbol?: string;
|
|
17
|
+
}, colorMap: Map<unknown, {
|
|
18
|
+
fill: string;
|
|
19
|
+
stroke: string;
|
|
20
|
+
}>, patternMap: Map<unknown, string>, symbolMap: Map<unknown, string>): {
|
|
21
|
+
field: string;
|
|
22
|
+
items: {
|
|
23
|
+
label: string;
|
|
24
|
+
fill: string | null;
|
|
25
|
+
stroke: string | null;
|
|
26
|
+
patternId: string | null;
|
|
27
|
+
shape: string | null;
|
|
28
|
+
}[];
|
|
29
|
+
}[];
|
|
30
|
+
export class ChartBrewer {
|
|
31
|
+
/**
|
|
32
|
+
* Override in subclasses to apply stat aggregation.
|
|
33
|
+
* @param {Object[]} data
|
|
34
|
+
* @param {Object} channels
|
|
35
|
+
* @param {string|Function} stat
|
|
36
|
+
* @returns {Object[]}
|
|
37
|
+
*/
|
|
38
|
+
transform(data: Object[], _channels: any, _stat: any): Object[];
|
|
39
|
+
/** Aggregated data — all derived marks read this, not #rawData */
|
|
40
|
+
processedData: Object[];
|
|
41
|
+
/** Exposes channels to subclasses for use in their own $derived properties */
|
|
42
|
+
get channels(): {};
|
|
43
|
+
/** @type {Map<unknown, {fill:string,stroke:string}>} */
|
|
44
|
+
colorMap: Map<unknown, {
|
|
45
|
+
fill: string;
|
|
46
|
+
stroke: string;
|
|
47
|
+
}>;
|
|
48
|
+
/** @type {Map<unknown, string>} */
|
|
49
|
+
patternMap: Map<unknown, string>;
|
|
50
|
+
/**
|
|
51
|
+
* Unified pattern defs for ChartPatternDefs.
|
|
52
|
+
* When fill and pattern map the same field, pattern key = color key (simple case).
|
|
53
|
+
* When they differ, each unique (fillKey, patternKey) pair gets its own pattern def
|
|
54
|
+
* so bars/areas can have distinct colors per region AND distinct textures per category.
|
|
55
|
+
* @type {Array<{ id: string, name: string, fill: string, stroke: string }>}
|
|
56
|
+
*/
|
|
57
|
+
patternDefs: Array<{
|
|
58
|
+
id: string;
|
|
59
|
+
name: string;
|
|
60
|
+
fill: string;
|
|
61
|
+
stroke: string;
|
|
62
|
+
}>;
|
|
63
|
+
/** @type {Map<unknown, string>} */
|
|
64
|
+
symbolMap: Map<unknown, string>;
|
|
65
|
+
get innerWidth(): number;
|
|
66
|
+
get innerHeight(): number;
|
|
67
|
+
xScale: any;
|
|
68
|
+
yScale: any;
|
|
69
|
+
sizeScale: any;
|
|
70
|
+
bars: any;
|
|
71
|
+
lines: {
|
|
72
|
+
d: string;
|
|
73
|
+
fill: string;
|
|
74
|
+
stroke: string;
|
|
75
|
+
points: {
|
|
76
|
+
x: number;
|
|
77
|
+
y: number;
|
|
78
|
+
data: Object;
|
|
79
|
+
}[];
|
|
80
|
+
key?: unknown;
|
|
81
|
+
}[];
|
|
82
|
+
areas: {
|
|
83
|
+
d: any;
|
|
84
|
+
fill: any;
|
|
85
|
+
stroke: string;
|
|
86
|
+
key: any;
|
|
87
|
+
colorKey: any;
|
|
88
|
+
patternKey: any;
|
|
89
|
+
patternId: string | null;
|
|
90
|
+
}[] | {
|
|
91
|
+
d: any;
|
|
92
|
+
fill: any;
|
|
93
|
+
stroke: string;
|
|
94
|
+
colorKey: null;
|
|
95
|
+
patternKey: null;
|
|
96
|
+
patternId: null;
|
|
97
|
+
}[];
|
|
98
|
+
arcs: any;
|
|
99
|
+
points: {
|
|
100
|
+
data: Object;
|
|
101
|
+
cx: any;
|
|
102
|
+
cy: any;
|
|
103
|
+
r: any;
|
|
104
|
+
fill: any;
|
|
105
|
+
stroke: any;
|
|
106
|
+
symbolPath: string | null;
|
|
107
|
+
key: any;
|
|
108
|
+
}[];
|
|
109
|
+
legendGroups: {
|
|
110
|
+
field: string;
|
|
111
|
+
items: {
|
|
112
|
+
label: string;
|
|
113
|
+
fill: string | null;
|
|
114
|
+
stroke: string | null;
|
|
115
|
+
patternId: string | null;
|
|
116
|
+
shape: string | null;
|
|
117
|
+
}[];
|
|
118
|
+
}[];
|
|
119
|
+
get margin(): {
|
|
120
|
+
top: number;
|
|
121
|
+
right: number;
|
|
122
|
+
bottom: number;
|
|
123
|
+
left: number;
|
|
124
|
+
};
|
|
125
|
+
get width(): number;
|
|
126
|
+
get height(): number;
|
|
127
|
+
get mode(): string;
|
|
128
|
+
/**
|
|
129
|
+
* @param {{ data?: Object[], channels?: Object, width?: number, height?: number, mode?: string, margin?: Object, layers?: Object[], curve?: string, stat?: string|Function }} opts
|
|
130
|
+
* Supported channel keys: `x`, `y`, `fill`, `color`, `pattern`, `symbol`, `size`, `label`.
|
|
131
|
+
* `frame` is reserved for future animation use (no-op).
|
|
132
|
+
*/
|
|
133
|
+
update(opts?: {
|
|
134
|
+
data?: Object[];
|
|
135
|
+
channels?: Object;
|
|
136
|
+
width?: number;
|
|
137
|
+
height?: number;
|
|
138
|
+
mode?: string;
|
|
139
|
+
margin?: Object;
|
|
140
|
+
layers?: Object[];
|
|
141
|
+
curve?: string;
|
|
142
|
+
stat?: string | Function;
|
|
143
|
+
}): void;
|
|
144
|
+
#private;
|
|
145
|
+
}
|
|
@@ -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,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,31 @@
|
|
|
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
|
+
/**
|
|
15
|
+
* Aggregates data by one or more grouping fields, reducing the value field
|
|
16
|
+
* using the given stat. Accepts a built-in name or a custom function.
|
|
17
|
+
*
|
|
18
|
+
* @param {Object[]} data
|
|
19
|
+
* @param {{ by: string[], value: string, stat: string|Function }} opts
|
|
20
|
+
* @returns {Object[]}
|
|
21
|
+
*/
|
|
22
|
+
export function applyAggregate(data: Object[], { by, value, stat }: {
|
|
23
|
+
by: string[];
|
|
24
|
+
value: string;
|
|
25
|
+
stat: string | Function;
|
|
26
|
+
}): Object[];
|
|
27
|
+
/**
|
|
28
|
+
* Built-in reduction functions. Each receives an array of numeric values.
|
|
29
|
+
* @type {Record<string, (values: number[]) => number>}
|
|
30
|
+
*/
|
|
31
|
+
export const STAT_FNS: Record<string, (values: number[]) => number>;
|