@barefootjs/chart 0.1.0
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/chart-container.d.ts +10 -0
- package/dist/chart-container.d.ts.map +1 -0
- package/dist/context.d.ts +10 -0
- package/dist/context.d.ts.map +1 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2254 -0
- package/dist/types.d.ts +235 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/utils/arcs.d.ts +44 -0
- package/dist/utils/arcs.d.ts.map +1 -0
- package/dist/utils/areas.d.ts +23 -0
- package/dist/utils/areas.d.ts.map +1 -0
- package/dist/utils/classes.d.ts +24 -0
- package/dist/utils/classes.d.ts.map +1 -0
- package/dist/utils/lines.d.ts +18 -0
- package/dist/utils/lines.d.ts.map +1 -0
- package/dist/utils/radar.d.ts +25 -0
- package/dist/utils/radar.d.ts.map +1 -0
- package/dist/utils/scales.d.ts +12 -0
- package/dist/utils/scales.d.ts.map +1 -0
- package/package.json +55 -0
- package/src/chart-container.ts +17 -0
- package/src/context.ts +14 -0
- package/src/index.ts +75 -0
- package/src/types.ts +270 -0
- package/src/utils/arcs.ts +149 -0
- package/src/utils/areas.ts +69 -0
- package/src/utils/classes.ts +24 -0
- package/src/utils/lines.ts +61 -0
- package/src/utils/radar.ts +53 -0
- package/src/utils/scales.ts +64 -0
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
import type { ScaleBand, ScaleLinear, ScalePoint } from 'd3-scale';
|
|
2
|
+
/** Color and label configuration for chart data series */
|
|
3
|
+
export type ChartConfig = Record<string, {
|
|
4
|
+
label: string;
|
|
5
|
+
color: string;
|
|
6
|
+
}>;
|
|
7
|
+
/** Registration info for a bar series */
|
|
8
|
+
export interface BarRegistration {
|
|
9
|
+
dataKey: string;
|
|
10
|
+
fill: string;
|
|
11
|
+
radius: number;
|
|
12
|
+
}
|
|
13
|
+
/** Props for ChartContainer */
|
|
14
|
+
export interface ChartContainerProps {
|
|
15
|
+
config: ChartConfig;
|
|
16
|
+
className?: string;
|
|
17
|
+
children?: unknown;
|
|
18
|
+
}
|
|
19
|
+
/** Props for BarChart */
|
|
20
|
+
export interface BarChartProps {
|
|
21
|
+
data: Record<string, unknown>[];
|
|
22
|
+
children?: unknown;
|
|
23
|
+
}
|
|
24
|
+
/** Props for Bar */
|
|
25
|
+
export interface BarProps {
|
|
26
|
+
dataKey: string;
|
|
27
|
+
fill?: string;
|
|
28
|
+
radius?: number;
|
|
29
|
+
}
|
|
30
|
+
/** Props for CartesianGrid */
|
|
31
|
+
export interface CartesianGridProps {
|
|
32
|
+
vertical?: boolean;
|
|
33
|
+
horizontal?: boolean;
|
|
34
|
+
}
|
|
35
|
+
/** Props for XAxis */
|
|
36
|
+
export interface XAxisProps {
|
|
37
|
+
dataKey: string;
|
|
38
|
+
tickFormatter?: (value: string) => string;
|
|
39
|
+
hide?: boolean;
|
|
40
|
+
}
|
|
41
|
+
/** Props for YAxis */
|
|
42
|
+
export interface YAxisProps {
|
|
43
|
+
hide?: boolean;
|
|
44
|
+
tickFormatter?: (value: number) => string;
|
|
45
|
+
}
|
|
46
|
+
/** Props for LineChart */
|
|
47
|
+
export interface LineChartProps {
|
|
48
|
+
data: Record<string, unknown>[];
|
|
49
|
+
children?: unknown;
|
|
50
|
+
}
|
|
51
|
+
/** Props for Line */
|
|
52
|
+
export interface LineProps {
|
|
53
|
+
dataKey: string;
|
|
54
|
+
stroke?: string;
|
|
55
|
+
strokeWidth?: number;
|
|
56
|
+
type?: 'linear' | 'monotone';
|
|
57
|
+
dot?: boolean;
|
|
58
|
+
}
|
|
59
|
+
/** Props for ChartTooltip */
|
|
60
|
+
export interface ChartTooltipProps {
|
|
61
|
+
labelFormatter?: (label: string) => string;
|
|
62
|
+
}
|
|
63
|
+
/** Registration info for a radial bar series */
|
|
64
|
+
export interface RadialBarRegistration {
|
|
65
|
+
dataKey: string;
|
|
66
|
+
fill: string;
|
|
67
|
+
}
|
|
68
|
+
/** Registration info for a pie slice */
|
|
69
|
+
export interface PieRegistration {
|
|
70
|
+
dataKey: string;
|
|
71
|
+
fill: string;
|
|
72
|
+
}
|
|
73
|
+
/** Props for RadialChart */
|
|
74
|
+
export interface RadialChartProps {
|
|
75
|
+
data: Record<string, unknown>[];
|
|
76
|
+
innerRadius?: number;
|
|
77
|
+
outerRadius?: number;
|
|
78
|
+
startAngle?: number;
|
|
79
|
+
endAngle?: number;
|
|
80
|
+
children?: unknown;
|
|
81
|
+
}
|
|
82
|
+
/** Props for RadialBar */
|
|
83
|
+
export interface RadialBarProps {
|
|
84
|
+
dataKey: string;
|
|
85
|
+
fill?: string;
|
|
86
|
+
stackId?: string;
|
|
87
|
+
}
|
|
88
|
+
/** Props for RadialChartLabel */
|
|
89
|
+
export interface RadialChartLabelProps {
|
|
90
|
+
children?: unknown;
|
|
91
|
+
}
|
|
92
|
+
/** Context value shared between RadialChart and its children */
|
|
93
|
+
export interface RadialChartContextValue {
|
|
94
|
+
svgGroup: () => SVGGElement | null;
|
|
95
|
+
container: () => HTMLElement | null;
|
|
96
|
+
data: () => Record<string, unknown>[];
|
|
97
|
+
innerRadius: () => number;
|
|
98
|
+
outerRadius: () => number;
|
|
99
|
+
startAngle: () => number;
|
|
100
|
+
endAngle: () => number;
|
|
101
|
+
config: () => ChartConfig;
|
|
102
|
+
centerX: () => number;
|
|
103
|
+
centerY: () => number;
|
|
104
|
+
radialBars: () => RadialBarRegistration[];
|
|
105
|
+
registerRadialBar: (bar: RadialBarRegistration) => void;
|
|
106
|
+
unregisterRadialBar: (dataKey: string) => void;
|
|
107
|
+
}
|
|
108
|
+
/** Props for PieChart */
|
|
109
|
+
export interface PieChartProps {
|
|
110
|
+
data: Record<string, unknown>[];
|
|
111
|
+
children?: unknown;
|
|
112
|
+
}
|
|
113
|
+
/** Props for Pie */
|
|
114
|
+
export interface PieProps {
|
|
115
|
+
dataKey: string;
|
|
116
|
+
nameKey: string;
|
|
117
|
+
fill?: string;
|
|
118
|
+
innerRadius?: number;
|
|
119
|
+
outerRadius?: number;
|
|
120
|
+
paddingAngle?: number;
|
|
121
|
+
}
|
|
122
|
+
/** Props for PieTooltip */
|
|
123
|
+
export interface PieTooltipProps {
|
|
124
|
+
labelFormatter?: (label: string) => string;
|
|
125
|
+
}
|
|
126
|
+
/** Context value shared between PieChart and its children */
|
|
127
|
+
export interface PieChartContextValue {
|
|
128
|
+
svgGroup: () => SVGGElement | null;
|
|
129
|
+
container: () => HTMLElement | null;
|
|
130
|
+
data: () => Record<string, unknown>[];
|
|
131
|
+
width: () => number;
|
|
132
|
+
height: () => number;
|
|
133
|
+
config: () => ChartConfig;
|
|
134
|
+
pies: () => PieRegistration[];
|
|
135
|
+
registerPie: (pie: PieRegistration) => void;
|
|
136
|
+
unregisterPie: (dataKey: string) => void;
|
|
137
|
+
}
|
|
138
|
+
/** Context value shared between BarChart and its children */
|
|
139
|
+
export interface BarChartContextValue {
|
|
140
|
+
svgGroup: () => SVGGElement | null;
|
|
141
|
+
container: () => HTMLElement | null;
|
|
142
|
+
data: () => Record<string, unknown>[];
|
|
143
|
+
xDataKey: () => string;
|
|
144
|
+
xScale: () => ScaleBand<string> | null;
|
|
145
|
+
yScale: () => ScaleLinear<number, number> | null;
|
|
146
|
+
innerWidth: () => number;
|
|
147
|
+
innerHeight: () => number;
|
|
148
|
+
config: () => ChartConfig;
|
|
149
|
+
bars: () => BarRegistration[];
|
|
150
|
+
registerBar: (bar: BarRegistration) => void;
|
|
151
|
+
unregisterBar: (dataKey: string) => void;
|
|
152
|
+
setXDataKey: (key: string) => void;
|
|
153
|
+
}
|
|
154
|
+
/** Registration info for a radar series */
|
|
155
|
+
export interface RadarRegistration {
|
|
156
|
+
dataKey: string;
|
|
157
|
+
fill: string;
|
|
158
|
+
fillOpacity: number;
|
|
159
|
+
}
|
|
160
|
+
/** Registration info for an area series */
|
|
161
|
+
export interface AreaRegistration {
|
|
162
|
+
dataKey: string;
|
|
163
|
+
fill: string;
|
|
164
|
+
stroke: string;
|
|
165
|
+
fillOpacity: number;
|
|
166
|
+
}
|
|
167
|
+
/** Props for RadarChart */
|
|
168
|
+
export interface RadarChartProps {
|
|
169
|
+
data: Record<string, unknown>[];
|
|
170
|
+
children?: unknown;
|
|
171
|
+
}
|
|
172
|
+
/** Props for AreaChart */
|
|
173
|
+
export interface AreaChartProps {
|
|
174
|
+
data: Record<string, unknown>[];
|
|
175
|
+
children?: unknown;
|
|
176
|
+
}
|
|
177
|
+
/** Props for Radar */
|
|
178
|
+
export interface RadarProps {
|
|
179
|
+
dataKey: string;
|
|
180
|
+
fill?: string;
|
|
181
|
+
fillOpacity?: number;
|
|
182
|
+
}
|
|
183
|
+
/** Props for PolarGrid */
|
|
184
|
+
export interface PolarGridProps {
|
|
185
|
+
gridType?: 'polygon' | 'circle';
|
|
186
|
+
show?: boolean;
|
|
187
|
+
}
|
|
188
|
+
/** Props for PolarAngleAxis */
|
|
189
|
+
export interface PolarAngleAxisProps {
|
|
190
|
+
dataKey: string;
|
|
191
|
+
tickFormatter?: (value: string) => string;
|
|
192
|
+
hide?: boolean;
|
|
193
|
+
}
|
|
194
|
+
/** Props for RadarTooltip */
|
|
195
|
+
export interface RadarTooltipProps {
|
|
196
|
+
labelFormatter?: (label: string) => string;
|
|
197
|
+
}
|
|
198
|
+
/** Context value shared between RadarChart and its children */
|
|
199
|
+
export interface RadarChartContextValue {
|
|
200
|
+
svgGroup: () => SVGGElement | null;
|
|
201
|
+
container: () => HTMLElement | null;
|
|
202
|
+
data: () => Record<string, unknown>[];
|
|
203
|
+
dataKey: () => string;
|
|
204
|
+
radius: () => number;
|
|
205
|
+
radialScale: () => ScaleLinear<number, number> | null;
|
|
206
|
+
config: () => ChartConfig;
|
|
207
|
+
radars: () => RadarRegistration[];
|
|
208
|
+
registerRadar: (radar: RadarRegistration) => void;
|
|
209
|
+
unregisterRadar: (dataKey: string) => void;
|
|
210
|
+
setDataKey: (key: string) => void;
|
|
211
|
+
}
|
|
212
|
+
/** Props for Area */
|
|
213
|
+
export interface AreaProps {
|
|
214
|
+
dataKey: string;
|
|
215
|
+
fill?: string;
|
|
216
|
+
stroke?: string;
|
|
217
|
+
fillOpacity?: number;
|
|
218
|
+
}
|
|
219
|
+
/** Context value shared between AreaChart and its children */
|
|
220
|
+
export interface AreaChartContextValue {
|
|
221
|
+
svgGroup: () => SVGGElement | null;
|
|
222
|
+
container: () => HTMLElement | null;
|
|
223
|
+
data: () => Record<string, unknown>[];
|
|
224
|
+
xDataKey: () => string;
|
|
225
|
+
xScale: () => ScalePoint<string> | null;
|
|
226
|
+
yScale: () => ScaleLinear<number, number> | null;
|
|
227
|
+
innerWidth: () => number;
|
|
228
|
+
innerHeight: () => number;
|
|
229
|
+
config: () => ChartConfig;
|
|
230
|
+
areas: () => AreaRegistration[];
|
|
231
|
+
registerArea: (area: AreaRegistration) => void;
|
|
232
|
+
unregisterArea: (dataKey: string) => void;
|
|
233
|
+
setXDataKey: (key: string) => void;
|
|
234
|
+
}
|
|
235
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AAElE,0DAA0D;AAC1D,MAAM,MAAM,WAAW,GAAG,MAAM,CAC9B,MAAM,EACN;IACE,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,EAAE,MAAM,CAAA;CACd,CACF,CAAA;AAED,yCAAyC;AACzC,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,MAAM,CAAA;IACf,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,MAAM,CAAA;CACf;AAED,+BAA+B;AAC/B,MAAM,WAAW,mBAAmB;IAClC,MAAM,EAAE,WAAW,CAAA;IACnB,SAAS,CAAC,EAAE,MAAM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AK,IAAI,CAAA;CAClC;AAED,qBAAqB;AACrB,MAAM,WAAW,SAAS;IACxB,OAAO,EAAE,MAAM,CAAA;IACf,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB;AAED,8DAA8D;AAC9D,MAAM,WAAW,qBAAqB;IACpC,QAAQ,EAAE,MAAM,WAAW,GAAG,IAAI,CAAA;IAClC,SAAS,EAAE,MAAM,WAAW,GAAG,IAAI,CAAA;IACnC,IAAI,EAAE,MAAM,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAA;IACrC,QAAQ,EAAE,MAAM,MAAM,CAAA;IACtB,MAAM,EAAE,MAAM,UAAU,CAAC,MAAM,CAAC,GAAG,IAAI,CAAA;IACvC,MAAM,EAAE,MAAM,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,CAAA;IAChD,UAAU,EAAE,MAAM,MAAM,CAAA;IACxB,WAAW,EAAE,MAAM,MAAM,CAAA;IACzB,MAAM,EAAE,MAAM,WAAW,CAAA;IACzB,KAAK,EAAE,MAAM,gBAAgB,EAAE,CAAA;IAC/B,YAAY,EAAE,CAAC,IAAI,EAAE,gBAAgB,KAAK,IAAI,CAAA;IAC9C,cAAc,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAA;IACzC,WAAW,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAA;CACnC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
export interface PieSliceSpec {
|
|
2
|
+
/** Slice path generated by `d3-shape`'s `arc()`. */
|
|
3
|
+
d: string;
|
|
4
|
+
/** Resolved fill — datum override, then ChartConfig color, then fallback. */
|
|
5
|
+
fill: string;
|
|
6
|
+
/** Datum's name used for tooltip lookup and as the stable map key. */
|
|
7
|
+
name: string;
|
|
8
|
+
/** Numeric value used to size the slice. */
|
|
9
|
+
value: number;
|
|
10
|
+
}
|
|
11
|
+
export interface RadialBarArcSpec {
|
|
12
|
+
/** Background-track path (full sweep, dim). */
|
|
13
|
+
trackD: string | null;
|
|
14
|
+
/** Foreground value path (proportional to data value). */
|
|
15
|
+
arcD: string | null;
|
|
16
|
+
/** Numeric value used to size the arc. */
|
|
17
|
+
value: number;
|
|
18
|
+
/** Optional per-datum fill override (when datum.fill is set). */
|
|
19
|
+
itemFill?: string;
|
|
20
|
+
/** Index in the input data, used as a stable identifier for SVG. */
|
|
21
|
+
index: number;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Build the arc geometry for a single radial-bar series. Each input datum
|
|
25
|
+
* becomes a concentric ring within `[innerR, outerR]`, with the value arc
|
|
26
|
+
* sweeping from `startDeg` (top) to a fraction of the dataset max.
|
|
27
|
+
*
|
|
28
|
+
* Pure data — caller renders one `<path d={track.trackD}>` plus one
|
|
29
|
+
* `<path d={track.arcD}>` per spec, keeping the d3-shape dependency inside
|
|
30
|
+
* `@barefootjs/chart` and out of consumer bundles.
|
|
31
|
+
*/
|
|
32
|
+
export declare function buildRadialBarArcs(data: Record<string, unknown>[], dataKey: string, innerR: number, outerR: number, startDeg: number, endDeg: number): RadialBarArcSpec[];
|
|
33
|
+
/**
|
|
34
|
+
* Build the slice geometry for a single pie/donut series. Each input datum
|
|
35
|
+
* becomes one path with its `d` string generated from `d3-shape`'s `arc()`.
|
|
36
|
+
*
|
|
37
|
+
* Pure data — caller renders one `<path d={slice.d}>` per spec, keeping the
|
|
38
|
+
* d3-shape dependency inside `@barefootjs/chart` and out of consumer bundles.
|
|
39
|
+
*/
|
|
40
|
+
export declare function buildPieSlices(data: Record<string, unknown>[], dataKey: string, nameKey: string, config: Record<string, {
|
|
41
|
+
label: string;
|
|
42
|
+
color: string;
|
|
43
|
+
}>, width: number, height: number, innerRadiusRatio: number, outerRadiusRatio: number, paddingAngleDeg: number): PieSliceSpec[];
|
|
44
|
+
//# sourceMappingURL=arcs.d.ts.map
|
|
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,YAAY,EAAE,CA4BhB"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { ScalePoint, ScaleLinear } from 'd3-scale';
|
|
2
|
+
export interface AreaPaths {
|
|
3
|
+
/** Filled area path from the bottom of the chart up to each y value. */
|
|
4
|
+
area: string;
|
|
5
|
+
/** Stroke-only path along the top of the area (degenerate area where y0 === y1). */
|
|
6
|
+
line: string;
|
|
7
|
+
}
|
|
8
|
+
export interface AreaDot {
|
|
9
|
+
key: string;
|
|
10
|
+
cx: number;
|
|
11
|
+
cy: number;
|
|
12
|
+
xValue: string;
|
|
13
|
+
yValue: number;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Build the SVG `d` attributes for an area series. Pure helper — d3-shape
|
|
17
|
+
* stays inside `@barefootjs/chart` so consumer bundles avoid pulling in bare
|
|
18
|
+
* specifiers the browser import map does not resolve.
|
|
19
|
+
*/
|
|
20
|
+
export declare function buildAreaPaths(data: Record<string, unknown>[], xKey: string, yKey: string, xs: ScalePoint<string>, ys: ScaleLinear<number, number>, innerHeight: number): AreaPaths;
|
|
21
|
+
/** Build the per-point geometry used to render invisible hover-target dots. */
|
|
22
|
+
export declare function buildAreaDots(data: Record<string, unknown>[], xKey: string, yKey: string, xs: ScalePoint<string>, ys: ScaleLinear<number, number>): AreaDot[];
|
|
23
|
+
//# sourceMappingURL=areas.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"areas.d.ts","sourceRoot":"","sources":["../../src/utils/areas.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AAEvD,MAAM,WAAW,SAAS;IACxB,wEAAwE;IACxE,IAAI,EAAE,MAAM,CAAA;IACZ,oFAAoF;IACpF,IAAI,EAAE,MAAM,CAAA;CACb;AAED,MAAM,WAAW,OAAO;IACtB,GAAG,EAAE,MAAM,CAAA;IACX,EAAE,EAAE,MAAM,CAAA;IACV,EAAE,EAAE,MAAM,CAAA;IACV,MAAM,EAAE,MAAM,CAAA;IACd,MAAM,EAAE,MAAM,CAAA;CACf;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAC5B,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,EAC/B,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,EAAE,EAAE,UAAU,CAAC,MAAM,CAAC,EACtB,EAAE,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,EAC/B,WAAW,EAAE,MAAM,GAClB,SAAS,CAiBX;AAED,+EAA+E;AAC/E,wBAAgB,aAAa,CAC3B,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,EAC/B,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,EAAE,EAAE,UAAU,CAAC,MAAM,CAAC,EACtB,EAAE,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,GAC9B,OAAO,EAAE,CAYX"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Stable CSS class names for chart primitives.
|
|
3
|
+
*
|
|
4
|
+
* Exported as constants so consumers can reference them via
|
|
5
|
+
* `<g className={CHART_CLASS_X_AXIS}>` in `"use client"` files. The compiler's
|
|
6
|
+
* `cssLayerPrefixer` only rewrites locally-declared constants and static
|
|
7
|
+
* className literals; imported identifiers are left alone, which keeps the
|
|
8
|
+
* names un-prefixed for the e2e test selectors (`.chart-x-axis text`, ...).
|
|
9
|
+
*/
|
|
10
|
+
export declare const CHART_CLASS_GRID = "chart-grid";
|
|
11
|
+
export declare const CHART_CLASS_X_AXIS = "chart-x-axis";
|
|
12
|
+
export declare const CHART_CLASS_Y_AXIS = "chart-y-axis";
|
|
13
|
+
export declare const CHART_CLASS_POLAR_GRID = "chart-polar-grid";
|
|
14
|
+
export declare const CHART_CLASS_POLAR_ANGLE_AXIS = "chart-polar-angle-axis";
|
|
15
|
+
export declare const CHART_CLASS_RADIAL_BAR = "chart-radial-bar";
|
|
16
|
+
export declare const CHART_CLASS_RADIAL_LABEL = "chart-radial-label";
|
|
17
|
+
export declare const CHART_CLASS_BAR = "chart-bar";
|
|
18
|
+
export declare const CHART_CLASS_LINE = "chart-line";
|
|
19
|
+
export declare const CHART_CLASS_AREA = "chart-area";
|
|
20
|
+
export declare const CHART_CLASS_AREA_DOT = "chart-area-dot";
|
|
21
|
+
export declare const CHART_CLASS_RADAR = "chart-radar";
|
|
22
|
+
export declare const CHART_CLASS_PIE = "chart-pie";
|
|
23
|
+
export declare const CHART_CLASS_TOOLTIP = "chart-tooltip";
|
|
24
|
+
//# sourceMappingURL=classes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"classes.d.ts","sourceRoot":"","sources":["../../src/utils/classes.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,eAAO,MAAM,gBAAgB,eAAe,CAAA;AAC5C,eAAO,MAAM,kBAAkB,iBAAiB,CAAA;AAChD,eAAO,MAAM,kBAAkB,iBAAiB,CAAA;AAChD,eAAO,MAAM,sBAAsB,qBAAqB,CAAA;AACxD,eAAO,MAAM,4BAA4B,2BAA2B,CAAA;AACpE,eAAO,MAAM,sBAAsB,qBAAqB,CAAA;AACxD,eAAO,MAAM,wBAAwB,uBAAuB,CAAA;AAC5D,eAAO,MAAM,eAAe,cAAc,CAAA;AAC1C,eAAO,MAAM,gBAAgB,eAAe,CAAA;AAC5C,eAAO,MAAM,gBAAgB,eAAe,CAAA;AAC5C,eAAO,MAAM,oBAAoB,mBAAmB,CAAA;AACpD,eAAO,MAAM,iBAAiB,gBAAgB,CAAA;AAC9C,eAAO,MAAM,eAAe,cAAc,CAAA;AAC1C,eAAO,MAAM,mBAAmB,kBAAkB,CAAA"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { ScaleBand } from 'd3-scale';
|
|
2
|
+
import type { ScaleLinear } from 'd3-scale';
|
|
3
|
+
export interface LinePoint {
|
|
4
|
+
key: string;
|
|
5
|
+
cx: number;
|
|
6
|
+
cy: number;
|
|
7
|
+
xValue: string;
|
|
8
|
+
yValue: number;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Build the SVG `d` attribute for a line series. Pure helper — d3-shape stays
|
|
12
|
+
* inside `@barefootjs/chart` so consumer bundles avoid pulling in bare
|
|
13
|
+
* specifiers the browser import map does not resolve.
|
|
14
|
+
*/
|
|
15
|
+
export declare function buildLinePath(data: Record<string, unknown>[], xKey: string, yKey: string, xs: ScaleBand<string>, ys: ScaleLinear<number, number>, type: 'linear' | 'monotone'): string;
|
|
16
|
+
/** Build the per-point geometry used to render hover/visual dots. */
|
|
17
|
+
export declare function buildLinePoints(data: Record<string, unknown>[], xKey: string, yKey: string, xs: ScaleBand<string>, ys: ScaleLinear<number, number>): LinePoint[];
|
|
18
|
+
//# sourceMappingURL=lines.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lines.d.ts","sourceRoot":"","sources":["../../src/utils/lines.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;AACzC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AAE3C,MAAM,WAAW,SAAS;IACxB,GAAG,EAAE,MAAM,CAAA;IACX,EAAE,EAAE,MAAM,CAAA;IACV,EAAE,EAAE,MAAM,CAAA;IACV,MAAM,EAAE,MAAM,CAAA;IACd,MAAM,EAAE,MAAM,CAAA;CACf;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAC3B,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,EAC/B,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,EAAE,EAAE,SAAS,CAAC,MAAM,CAAC,EACrB,EAAE,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,EAC/B,IAAI,EAAE,QAAQ,GAAG,UAAU,GAC1B,MAAM,CAcR;AAED,qEAAqE;AACrE,wBAAgB,eAAe,CAC7B,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,EAC/B,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,EAAE,EAAE,SAAS,CAAC,MAAM,CAAC,EACrB,EAAE,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,GAC9B,SAAS,EAAE,CAab"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { ScaleLinear } from 'd3-scale';
|
|
2
|
+
export interface RadarVertex {
|
|
3
|
+
/** Stable identifier — combines axis index and label for keyed mapArray. */
|
|
4
|
+
key: string;
|
|
5
|
+
/** Polar angle in radians; 0 points up, increases clockwise. */
|
|
6
|
+
angle: number;
|
|
7
|
+
/** Polar radius from the chart centre. */
|
|
8
|
+
r: number;
|
|
9
|
+
/** Cartesian x coordinate (radius * cos(angle)). */
|
|
10
|
+
x: number;
|
|
11
|
+
/** Cartesian y coordinate (radius * sin(angle)). */
|
|
12
|
+
y: number;
|
|
13
|
+
/** Axis label drawn from `data[i][axisKey]`. */
|
|
14
|
+
label: string;
|
|
15
|
+
/** Numeric series value drawn from `data[i][dataKey]`. */
|
|
16
|
+
value: number;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Compute the per-axis vertices for a radar series. Each input datum becomes
|
|
20
|
+
* one vertex placed at angle = `(2π / n) * i - π/2` and radius = `radialScale(value)`.
|
|
21
|
+
*/
|
|
22
|
+
export declare function buildRadarVertices(data: Record<string, unknown>[], dataKey: string, axisKey: string, radialScale: ScaleLinear<number, number>): RadarVertex[];
|
|
23
|
+
/** Convert vertices into the `points` attribute of a `<polygon>`. */
|
|
24
|
+
export declare function buildRadarPolygonPoints(vertices: RadarVertex[]): string;
|
|
25
|
+
//# sourceMappingURL=radar.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"radar.d.ts","sourceRoot":"","sources":["../../src/utils/radar.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AAE3C,MAAM,WAAW,WAAW;IAC1B,4EAA4E;IAC5E,GAAG,EAAE,MAAM,CAAA;IACX,gEAAgE;IAChE,KAAK,EAAE,MAAM,CAAA;IACb,0CAA0C;IAC1C,CAAC,EAAE,MAAM,CAAA;IACT,oDAAoD;IACpD,CAAC,EAAE,MAAM,CAAA;IACT,oDAAoD;IACpD,CAAC,EAAE,MAAM,CAAA;IACT,gDAAgD;IAChD,KAAK,EAAE,MAAM,CAAA;IACb,0DAA0D;IAC1D,KAAK,EAAE,MAAM,CAAA;CACd;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,EAC/B,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM,EACf,WAAW,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,GACvC,WAAW,EAAE,CAmBf;AAED,qEAAqE;AACrE,wBAAgB,uBAAuB,CAAC,QAAQ,EAAE,WAAW,EAAE,GAAG,MAAM,CAEvE"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type ScaleBand, type ScaleLinear, type ScalePoint } from 'd3-scale';
|
|
2
|
+
export declare function createBandScale(data: Record<string, unknown>[], dataKey: string, width: number): ScaleBand<string>;
|
|
3
|
+
export declare function createLinearScale(data: Record<string, unknown>[], dataKeys: string[], height: number): ScaleLinear<number, number>;
|
|
4
|
+
export declare function createPointScale(data: Record<string, unknown>[], dataKey: string, width: number): ScalePoint<string>;
|
|
5
|
+
/**
|
|
6
|
+
* Linear scale spanning `[0, max(data values across dataKeys)]`, mapped to
|
|
7
|
+
* `[0, radius]`. Used by RadarChart to convert numeric series values into
|
|
8
|
+
* polar radii. Returns null when no dataKeys are supplied so callers can
|
|
9
|
+
* cheaply gate downstream rendering on registration completing.
|
|
10
|
+
*/
|
|
11
|
+
export declare function createRadarRadialScale(data: Record<string, unknown>[], dataKeys: string[], radius: number): ScaleLinear<number, number> | null;
|
|
12
|
+
//# sourceMappingURL=scales.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scales.d.ts","sourceRoot":"","sources":["../../src/utils/scales.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsC,KAAK,SAAS,EAAE,KAAK,WAAW,EAAE,KAAK,UAAU,EAAE,MAAM,UAAU,CAAA;AAGhH,wBAAgB,eAAe,CAC7B,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,EAC/B,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,MAAM,GACZ,SAAS,CAAC,MAAM,CAAC,CAKnB;AAED,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,EAC/B,QAAQ,EAAE,MAAM,EAAE,EAClB,MAAM,EAAE,MAAM,GACb,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAY7B;AAED,wBAAgB,gBAAgB,CAC9B,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,EAC/B,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,MAAM,GACZ,UAAU,CAAC,MAAM,CAAC,CAKpB;AAED;;;;;GAKG;AACH,wBAAgB,sBAAsB,CACpC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,EAC/B,QAAQ,EAAE,MAAM,EAAE,EAClB,MAAM,EAAE,MAAM,GACb,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,CAUpC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@barefootjs/chart",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "SVG chart components for BarefootJS with signal-based reactivity",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.js"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"dist",
|
|
16
|
+
"src"
|
|
17
|
+
],
|
|
18
|
+
"scripts": {
|
|
19
|
+
"build": "bun run build:js && bun run build:types",
|
|
20
|
+
"build:js": "bun build ./src/index.ts --outdir ./dist --format esm",
|
|
21
|
+
"build:types": "tsgo --emitDeclarationOnly --outDir ./dist",
|
|
22
|
+
"test": "bun test",
|
|
23
|
+
"clean": "rm -rf dist"
|
|
24
|
+
},
|
|
25
|
+
"keywords": [
|
|
26
|
+
"chart",
|
|
27
|
+
"area-chart",
|
|
28
|
+
"bar-chart",
|
|
29
|
+
"svg",
|
|
30
|
+
"signals",
|
|
31
|
+
"reactive",
|
|
32
|
+
"barefoot"
|
|
33
|
+
],
|
|
34
|
+
"author": "kobaken <kentafly88@gmail.com>",
|
|
35
|
+
"license": "MIT",
|
|
36
|
+
"repository": {
|
|
37
|
+
"type": "git",
|
|
38
|
+
"url": "https://github.com/piconic-ai/barefootjs",
|
|
39
|
+
"directory": "packages/chart"
|
|
40
|
+
},
|
|
41
|
+
"peerDependencies": {
|
|
42
|
+
"@barefootjs/client": ">=0.0.1"
|
|
43
|
+
},
|
|
44
|
+
"dependencies": {
|
|
45
|
+
"d3-array": "^3.2.4",
|
|
46
|
+
"d3-scale": "^4.0.2",
|
|
47
|
+
"d3-shape": "^3.2.0"
|
|
48
|
+
},
|
|
49
|
+
"devDependencies": {
|
|
50
|
+
"@types/d3-array": "^3.2.1",
|
|
51
|
+
"@types/d3-scale": "^4.0.8",
|
|
52
|
+
"@types/d3-shape": "^3.1.8",
|
|
53
|
+
"typescript": "^5.0.0"
|
|
54
|
+
}
|
|
55
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { ChartConfig } from './types'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Apply CSS variables from ChartConfig to a container element.
|
|
5
|
+
* Sets --color-{key} for each config entry.
|
|
6
|
+
*
|
|
7
|
+
* Reused by the JSX-native `ChartContainer` ref callback in
|
|
8
|
+
* `ui/components/ui/chart/index.tsx`.
|
|
9
|
+
*/
|
|
10
|
+
export function applyChartCSSVariables(
|
|
11
|
+
container: HTMLElement,
|
|
12
|
+
config: ChartConfig,
|
|
13
|
+
): void {
|
|
14
|
+
for (const [key, value] of Object.entries(config)) {
|
|
15
|
+
container.style.setProperty(`--color-${key}`, value.color)
|
|
16
|
+
}
|
|
17
|
+
}
|
package/src/context.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { createContext } from '@barefootjs/client/runtime'
|
|
2
|
+
import type { BarChartContextValue, RadialChartContextValue, RadarChartContextValue, PieChartContextValue, AreaChartContextValue, ChartConfig } from './types'
|
|
3
|
+
|
|
4
|
+
export const BarChartContext = createContext<BarChartContextValue>()
|
|
5
|
+
|
|
6
|
+
export const RadialChartContext = createContext<RadialChartContextValue>()
|
|
7
|
+
|
|
8
|
+
export const RadarChartContext = createContext<RadarChartContextValue>()
|
|
9
|
+
|
|
10
|
+
export const PieChartContext = createContext<PieChartContextValue>()
|
|
11
|
+
|
|
12
|
+
export const AreaChartContext = createContext<AreaChartContextValue>()
|
|
13
|
+
|
|
14
|
+
export const ChartConfigContext = createContext<{ config: ChartConfig }>()
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
// Context types consumed by JSX-native chart containers and primitives.
|
|
2
|
+
export { BarChartContext, RadialChartContext, RadarChartContext, PieChartContext, AreaChartContext, ChartConfigContext } from './context'
|
|
3
|
+
|
|
4
|
+
// Scale utilities used by JSX-native chart containers.
|
|
5
|
+
export { createBandScale, createLinearScale, createPointScale, createRadarRadialScale } from './utils/scales'
|
|
6
|
+
|
|
7
|
+
// Arc geometry helpers for JSX-native radial primitives. d3-shape stays
|
|
8
|
+
// inside this package so consumer bundles avoid pulling in bare specifiers
|
|
9
|
+
// the browser import map does not resolve.
|
|
10
|
+
export { buildRadialBarArcs, buildPieSlices, type RadialBarArcSpec, type PieSliceSpec } from './utils/arcs'
|
|
11
|
+
|
|
12
|
+
// Line geometry helpers for the JSX-native `Line` primitive (#1080 step 3).
|
|
13
|
+
export { buildLinePath, buildLinePoints, type LinePoint } from './utils/lines'
|
|
14
|
+
|
|
15
|
+
// Area geometry helpers for the JSX-native `Area` primitive (#1080 step 3).
|
|
16
|
+
export { buildAreaPaths, buildAreaDots, type AreaPaths, type AreaDot } from './utils/areas'
|
|
17
|
+
|
|
18
|
+
// Radar geometry helpers for the JSX-native `Radar` primitive (#1080 step 3).
|
|
19
|
+
export { buildRadarVertices, buildRadarPolygonPoints, type RadarVertex } from './utils/radar'
|
|
20
|
+
|
|
21
|
+
// Stable CSS class names for chart primitives. Imported (rather than
|
|
22
|
+
// declared inline) so the JSX compiler's cssLayerPrefixer leaves them alone
|
|
23
|
+
// — the e2e selectors target the un-prefixed forms.
|
|
24
|
+
export {
|
|
25
|
+
CHART_CLASS_GRID,
|
|
26
|
+
CHART_CLASS_X_AXIS,
|
|
27
|
+
CHART_CLASS_Y_AXIS,
|
|
28
|
+
CHART_CLASS_POLAR_GRID,
|
|
29
|
+
CHART_CLASS_POLAR_ANGLE_AXIS,
|
|
30
|
+
CHART_CLASS_RADIAL_BAR,
|
|
31
|
+
CHART_CLASS_RADIAL_LABEL,
|
|
32
|
+
CHART_CLASS_BAR,
|
|
33
|
+
CHART_CLASS_LINE,
|
|
34
|
+
CHART_CLASS_AREA,
|
|
35
|
+
CHART_CLASS_AREA_DOT,
|
|
36
|
+
CHART_CLASS_RADAR,
|
|
37
|
+
CHART_CLASS_PIE,
|
|
38
|
+
CHART_CLASS_TOOLTIP,
|
|
39
|
+
} from './utils/classes'
|
|
40
|
+
|
|
41
|
+
// Helper used by the JSX-native ChartContainer ref to project ChartConfig
|
|
42
|
+
// entries onto CSS custom properties.
|
|
43
|
+
export { applyChartCSSVariables } from './chart-container'
|
|
44
|
+
|
|
45
|
+
// Type exports
|
|
46
|
+
export type {
|
|
47
|
+
ChartConfig,
|
|
48
|
+
BarRegistration,
|
|
49
|
+
RadialBarRegistration,
|
|
50
|
+
RadarRegistration,
|
|
51
|
+
PieRegistration,
|
|
52
|
+
AreaRegistration,
|
|
53
|
+
ChartContainerProps,
|
|
54
|
+
BarChartProps,
|
|
55
|
+
BarProps,
|
|
56
|
+
PieChartProps,
|
|
57
|
+
PieProps,
|
|
58
|
+
PieTooltipProps,
|
|
59
|
+
AreaChartProps,
|
|
60
|
+
AreaProps,
|
|
61
|
+
LineChartProps,
|
|
62
|
+
LineProps,
|
|
63
|
+
CartesianGridProps,
|
|
64
|
+
XAxisProps,
|
|
65
|
+
YAxisProps,
|
|
66
|
+
ChartTooltipProps,
|
|
67
|
+
RadialChartProps,
|
|
68
|
+
RadialBarProps,
|
|
69
|
+
RadialChartLabelProps,
|
|
70
|
+
RadarChartProps,
|
|
71
|
+
RadarProps,
|
|
72
|
+
PolarGridProps,
|
|
73
|
+
PolarAngleAxisProps,
|
|
74
|
+
RadarTooltipProps,
|
|
75
|
+
} from './types'
|