@pushwoosh/kit-charts 0.0.1

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 (119) hide show
  1. package/LICENSE +21 -0
  2. package/ai-documentation.md +378 -0
  3. package/core/Chart/Axes.d.ts +19 -0
  4. package/core/Chart/Axes.js +204 -0
  5. package/core/Chart/Chart.d.ts +33 -0
  6. package/core/Chart/Chart.js +616 -0
  7. package/core/Chart/Chart.styles.d.ts +109 -0
  8. package/core/Chart/Chart.styles.js +227 -0
  9. package/core/Chart/ChartErrorBoundary.d.ts +15 -0
  10. package/core/Chart/ChartErrorBoundary.js +27 -0
  11. package/core/Chart/Hinted.d.ts +11 -0
  12. package/core/Chart/Hinted.js +63 -0
  13. package/core/Chart/Legend.d.ts +15 -0
  14. package/core/Chart/Legend.js +92 -0
  15. package/core/Chart/PlotDecorations.d.ts +17 -0
  16. package/core/Chart/PlotDecorations.js +172 -0
  17. package/core/Chart/StackLabels.d.ts +6 -0
  18. package/core/Chart/StackLabels.js +85 -0
  19. package/core/Chart/Titles.d.ts +6 -0
  20. package/core/Chart/Titles.js +67 -0
  21. package/core/Chart/Tooltip.d.ts +13 -0
  22. package/core/Chart/Tooltip.js +87 -0
  23. package/core/Chart/useSize.d.ts +5 -0
  24. package/core/Chart/useSize.js +45 -0
  25. package/core/animation/motion.d.ts +20 -0
  26. package/core/animation/motion.js +20 -0
  27. package/core/animation/useTweenedNumbers.d.ts +1 -0
  28. package/core/animation/useTweenedNumbers.js +51 -0
  29. package/core/data/points.d.ts +14 -0
  30. package/core/data/points.js +73 -0
  31. package/core/format/time.d.ts +2 -0
  32. package/core/format/time.js +38 -0
  33. package/core/geometry/path.d.ts +19 -0
  34. package/core/geometry/path.js +76 -0
  35. package/core/layout/legend-layout.d.ts +21 -0
  36. package/core/layout/legend-layout.js +103 -0
  37. package/core/layout/measure-text.d.ts +9 -0
  38. package/core/layout/measure-text.js +57 -0
  39. package/core/layout/metrics.d.ts +63 -0
  40. package/core/layout/metrics.js +66 -0
  41. package/core/layout/point-width.d.ts +11 -0
  42. package/core/layout/point-width.js +86 -0
  43. package/core/layout/title-layout.d.ts +30 -0
  44. package/core/layout/title-layout.js +99 -0
  45. package/core/model/build-model.d.ts +69 -0
  46. package/core/model/build-model.js +556 -0
  47. package/core/model/palette.d.ts +15 -0
  48. package/core/model/palette.js +17 -0
  49. package/core/options/normalize.d.ts +8 -0
  50. package/core/options/normalize.js +44 -0
  51. package/core/registry/registry.d.ts +5 -0
  52. package/core/registry/registry.js +32 -0
  53. package/core/scale/band.d.ts +10 -0
  54. package/core/scale/band.js +33 -0
  55. package/core/scale/color.d.ts +9 -0
  56. package/core/scale/color.js +69 -0
  57. package/core/scale/linear.d.ts +17 -0
  58. package/core/scale/linear.js +64 -0
  59. package/core/scale/time.d.ts +19 -0
  60. package/core/scale/time.js +187 -0
  61. package/core/stack/stack.d.ts +9 -0
  62. package/core/stack/stack.js +76 -0
  63. package/core/types/formatter.d.ts +59 -0
  64. package/core/types/formatter.js +1 -0
  65. package/core/types/geometry.d.ts +16 -0
  66. package/core/types/geometry.js +1 -0
  67. package/core/types/options.d.ts +331 -0
  68. package/core/types/options.js +2 -0
  69. package/core/types/renderer.d.ts +101 -0
  70. package/core/types/renderer.js +1 -0
  71. package/core/types/scale.d.ts +34 -0
  72. package/core/types/scale.js +1 -0
  73. package/index.d.ts +16 -0
  74. package/index.js +10 -0
  75. package/package.json +64 -0
  76. package/presets/AreaChart.d.ts +3 -0
  77. package/presets/AreaChart.js +13 -0
  78. package/presets/ColumnChart.d.ts +3 -0
  79. package/presets/ColumnChart.js +13 -0
  80. package/presets/LineChart.d.ts +3 -0
  81. package/presets/LineChart.js +13 -0
  82. package/presets/PieChart.d.ts +3 -0
  83. package/presets/PieChart.js +13 -0
  84. package/presets/StackedColumnChart.d.ts +7 -0
  85. package/presets/StackedColumnChart.js +31 -0
  86. package/presets/index.d.ts +5 -0
  87. package/presets/index.js +5 -0
  88. package/series/area/area.d.ts +2 -0
  89. package/series/area/area.js +57 -0
  90. package/series/area/index.d.ts +1 -0
  91. package/series/area/index.js +1 -0
  92. package/series/column/column.d.ts +2 -0
  93. package/series/column/column.js +163 -0
  94. package/series/column/index.d.ts +1 -0
  95. package/series/column/index.js +1 -0
  96. package/series/heatmap/heatmap.d.ts +2 -0
  97. package/series/heatmap/heatmap.js +172 -0
  98. package/series/heatmap/index.d.ts +1 -0
  99. package/series/heatmap/index.js +1 -0
  100. package/series/line/index.d.ts +1 -0
  101. package/series/line/index.js +1 -0
  102. package/series/line/line.d.ts +2 -0
  103. package/series/line/line.js +49 -0
  104. package/series/pie/index.d.ts +1 -0
  105. package/series/pie/index.js +1 -0
  106. package/series/pie/pie.d.ts +2 -0
  107. package/series/pie/pie.js +224 -0
  108. package/series/shared/DataLabels.d.ts +14 -0
  109. package/series/shared/DataLabels.js +124 -0
  110. package/series/shared/Markers.d.ts +9 -0
  111. package/series/shared/Markers.js +34 -0
  112. package/series/shared/color.d.ts +1 -0
  113. package/series/shared/color.js +19 -0
  114. package/series/shared/domain.d.ts +3 -0
  115. package/series/shared/domain.js +14 -0
  116. package/series/shared/hit.d.ts +3 -0
  117. package/series/shared/hit.js +33 -0
  118. package/series/shared/legend.d.ts +3 -0
  119. package/series/shared/legend.js +12 -0
@@ -0,0 +1,331 @@
1
+ import { type AxisLabelContext, type AxisLabelFormatter, type DataLabelFormatter, type LegendLabelFormatter, type TooltipCellFormatter, type TooltipFormatter } from './formatter';
2
+ import { type Spacing } from './geometry';
3
+ import { type ColorStop, type TimeUnit } from './scale';
4
+ export type Stacking = 'normal' | 'percent';
5
+ export interface TextStyle {
6
+ color?: string;
7
+ fontFamily?: string;
8
+ fontSize?: string;
9
+ fontWeight?: string;
10
+ fontStyle?: string;
11
+ textOutline?: string;
12
+ textAlign?: 'left' | 'center' | 'right';
13
+ whiteSpace?: 'normal' | 'nowrap';
14
+ display?: 'none';
15
+ }
16
+ export interface ShadowOptions {
17
+ color?: string;
18
+ offsetX?: number;
19
+ offsetY?: number;
20
+ width?: number;
21
+ opacity?: number;
22
+ }
23
+ export interface AnimationOptions {
24
+ duration: number;
25
+ }
26
+ export interface ChartRootOptions {
27
+ type?: string;
28
+ height?: number | string | null;
29
+ width?: number | string | null;
30
+ backgroundColor?: string;
31
+ spacing?: Spacing;
32
+ marginTop?: number;
33
+ marginRight?: number;
34
+ marginBottom?: number;
35
+ marginLeft?: number;
36
+ style?: TextStyle;
37
+ plotBorderWidth?: number;
38
+ plotBorderColor?: string;
39
+ /**
40
+ * Drag across the plot to narrow the x axis to what was dragged over, with a
41
+ * button to undo it. Only a continuous x axis zooms; there is nothing between
42
+ * two categories to zoom to.
43
+ */
44
+ zoomType?: 'x';
45
+ resetZoomText?: string;
46
+ scrollablePlotArea?: {
47
+ minWidth?: number;
48
+ minHeight?: number;
49
+ };
50
+ }
51
+ export interface TitleOptions {
52
+ text?: string | null;
53
+ align?: 'left' | 'center' | 'right';
54
+ /** Explains the chart behind an info icon beside the title, on hover or focus. */
55
+ hint?: string;
56
+ /**
57
+ * A muted note on the far end of the title's own row — what period the figures
58
+ * cover, when they were counted. Only the main title draws one.
59
+ */
60
+ caption?: string;
61
+ captionStyle?: TextStyle;
62
+ style?: TextStyle;
63
+ }
64
+ export interface AxisTitleOptions {
65
+ text?: string | null;
66
+ align?: 'low' | 'middle' | 'high';
67
+ rotation?: number;
68
+ offset?: number;
69
+ x?: number;
70
+ y?: number;
71
+ style?: TextStyle;
72
+ }
73
+ export interface AxisLabelsOptions {
74
+ enabled?: boolean;
75
+ format?: string;
76
+ formatter?: AxisLabelFormatter;
77
+ /**
78
+ * Explains one tick on hover or focus, in the same callout a title hint uses.
79
+ * Return nothing for a tick that needs no explanation.
80
+ */
81
+ hint?: (ctx: AxisLabelContext) => string | undefined;
82
+ allowOverlap?: boolean;
83
+ align?: 'left' | 'center' | 'right';
84
+ rotation?: number;
85
+ x?: number;
86
+ y?: number;
87
+ padding?: number;
88
+ style?: TextStyle;
89
+ }
90
+ /** `zIndex` at or above this draws over the series instead of under it. */
91
+ export declare const ABOVE_SERIES_Z_INDEX = 5;
92
+ export interface PlotLineOptions {
93
+ value: number | string;
94
+ color?: string;
95
+ width?: number;
96
+ dashStyle?: 'solid' | 'dash' | 'dot';
97
+ zIndex?: number;
98
+ label?: PlotLabelOptions;
99
+ }
100
+ export interface PlotBandOptions {
101
+ from: number | string;
102
+ to: number | string;
103
+ color?: string;
104
+ borderColor?: string;
105
+ borderWidth?: number;
106
+ zIndex?: number;
107
+ label?: PlotLabelOptions;
108
+ }
109
+ export interface PlotLabelOptions {
110
+ text?: string;
111
+ align?: 'left' | 'center' | 'right';
112
+ verticalAlign?: 'top' | 'middle' | 'bottom';
113
+ x?: number;
114
+ y?: number;
115
+ rotation?: number;
116
+ style?: TextStyle;
117
+ }
118
+ export interface StackLabelsOptions {
119
+ enabled?: boolean;
120
+ formatter?: DataLabelFormatter;
121
+ style?: TextStyle;
122
+ }
123
+ export interface AxisOptions {
124
+ type?: 'linear' | 'datetime' | 'category';
125
+ categories?: readonly string[];
126
+ min?: number;
127
+ max?: number;
128
+ visible?: boolean;
129
+ opposite?: boolean;
130
+ reversed?: boolean;
131
+ linkedTo?: number;
132
+ offset?: number;
133
+ allowDecimals?: boolean;
134
+ lineColor?: string;
135
+ lineWidth?: number;
136
+ tickColor?: string;
137
+ tickWidth?: number;
138
+ tickLength?: number;
139
+ tickAmount?: number;
140
+ tickInterval?: number | TimeUnit;
141
+ tickPixelInterval?: number;
142
+ tickPositions?: readonly number[];
143
+ gridLineWidth?: number;
144
+ gridLineColor?: string;
145
+ plotLines?: readonly PlotLineOptions[];
146
+ plotBands?: readonly PlotBandOptions[];
147
+ stackLabels?: StackLabelsOptions;
148
+ labels?: AxisLabelsOptions;
149
+ title?: AxisTitleOptions;
150
+ }
151
+ export interface ColorAxisOptions {
152
+ min?: number;
153
+ max?: number;
154
+ visible?: boolean;
155
+ stops?: readonly ColorStop[];
156
+ }
157
+ export interface LegendOptions<TSeriesMeta = unknown> {
158
+ enabled?: boolean;
159
+ align?: 'left' | 'center' | 'right';
160
+ verticalAlign?: 'top' | 'middle' | 'bottom';
161
+ layout?: 'horizontal' | 'vertical';
162
+ margin?: number;
163
+ x?: number;
164
+ y?: number;
165
+ itemStyle?: TextStyle;
166
+ itemHoverStyle?: TextStyle;
167
+ itemDistance?: number;
168
+ symbolHeight?: number;
169
+ symbolWidth?: number;
170
+ symbolRadius?: number;
171
+ symbolPadding?: number;
172
+ labelFormatter?: LegendLabelFormatter<TSeriesMeta>;
173
+ }
174
+ export interface TooltipTableColumn<TChartMeta = unknown, TSeriesMeta = unknown> {
175
+ /**
176
+ * A function is resolved per hover, and one that returns `null` drops the whole
177
+ * column: that is how a "vs the previous point" column names the date it
178
+ * compares against and disappears on the first point, where there is none.
179
+ */
180
+ title?: string | TooltipFormatter<TChartMeta, TSeriesMeta>;
181
+ align?: 'left' | 'right';
182
+ cell: TooltipCellFormatter<TSeriesMeta>;
183
+ }
184
+ /**
185
+ * Lays the tooltip out as a table: a header line, a heading row, and one row per
186
+ * series with its swatch. Use it when a point carries more than one figure —
187
+ * a count and its share of the whole — and a single line would run them together.
188
+ */
189
+ export interface TooltipTableOptions<TChartMeta = unknown, TSeriesMeta = unknown> {
190
+ /** The line above the table. Defaults to the formatted x. */
191
+ header?: TooltipFormatter<TChartMeta, TSeriesMeta>;
192
+ /** Heading over the series-name column. */
193
+ seriesTitle?: string;
194
+ columns: readonly TooltipTableColumn<TChartMeta, TSeriesMeta>[];
195
+ }
196
+ export interface TooltipOptions<TChartMeta = unknown, TSeriesMeta = unknown> {
197
+ enabled?: boolean;
198
+ shared?: boolean;
199
+ table?: TooltipTableOptions<TChartMeta, TSeriesMeta>;
200
+ /** `callout` anchors a beaked bubble to the point; `box` floats near the cursor. */
201
+ shape?: 'callout' | 'box';
202
+ followPointer?: boolean;
203
+ formatter?: TooltipFormatter<TChartMeta, TSeriesMeta>;
204
+ dateFormat?: string;
205
+ valuePrefix?: string;
206
+ valueSuffix?: string;
207
+ backgroundColor?: string;
208
+ borderColor?: string;
209
+ borderRadius?: number;
210
+ padding?: number;
211
+ shadow?: ShadowOptions | false;
212
+ style?: TextStyle;
213
+ }
214
+ export interface MarkerStateOptions {
215
+ enabled?: boolean;
216
+ radius?: number;
217
+ lineWidth?: number;
218
+ }
219
+ export interface MarkerOptions {
220
+ enabled?: boolean;
221
+ symbol?: 'circle' | 'square' | 'none';
222
+ radius?: number;
223
+ width?: number;
224
+ height?: number;
225
+ lineWidth?: number;
226
+ lineColor?: string;
227
+ fillColor?: string;
228
+ states?: {
229
+ hover?: MarkerStateOptions;
230
+ };
231
+ }
232
+ export interface DataLabelsOptions<TSeriesMeta = unknown> {
233
+ enabled?: boolean;
234
+ format?: string;
235
+ formatter?: DataLabelFormatter<TSeriesMeta>;
236
+ align?: 'left' | 'center' | 'right';
237
+ color?: string;
238
+ padding?: number;
239
+ allowOverlap?: boolean;
240
+ style?: TextStyle;
241
+ /**
242
+ * Style for every line after the first, when the label text carries newlines —
243
+ * the muted share printed under a headline figure.
244
+ */
245
+ secondaryStyle?: TextStyle;
246
+ }
247
+ export interface SeriesStatesOptions {
248
+ hover?: {
249
+ enabled?: boolean;
250
+ lineWidth?: number;
251
+ brightness?: number;
252
+ /** Deepens a translucent body on hover, where brightening a pale fill does nothing. */
253
+ fillOpacity?: number;
254
+ };
255
+ inactive?: {
256
+ opacity?: number;
257
+ };
258
+ }
259
+ export type PointTuple = readonly [x: number, y: number] | readonly [category: string, y: number] | readonly [x: number, y: number, value: number];
260
+ export interface PointObject<TPointMeta = unknown> {
261
+ x?: number | string;
262
+ y?: number | null;
263
+ value?: number | null;
264
+ name?: string;
265
+ color?: string;
266
+ meta?: TPointMeta;
267
+ }
268
+ export type SeriesPoint<TPointMeta = unknown> = number | null | PointTuple | PointObject<TPointMeta>;
269
+ export type SeriesData<TPointMeta = unknown> = readonly SeriesPoint<TPointMeta>[];
270
+ export interface SeriesOptionsBase<TSeriesMeta = unknown, TPointMeta = unknown> {
271
+ type: string;
272
+ name?: string;
273
+ data?: SeriesData<TPointMeta>;
274
+ color?: string;
275
+ visible?: boolean;
276
+ showInLegend?: boolean;
277
+ /**
278
+ * Overrides the shape the legend uses for this series. A line series keys with
279
+ * a dash by default; a dot reads better when the legend is a plain key above
280
+ * the plot rather than a swatch column beside it.
281
+ */
282
+ legendSymbol?: 'circle' | 'square' | 'line';
283
+ yAxis?: number;
284
+ stacking?: Stacking;
285
+ meta?: TSeriesMeta;
286
+ lineWidth?: number;
287
+ borderWidth?: number;
288
+ borderColor?: string;
289
+ borderRadius?: number;
290
+ /**
291
+ * `top` strokes only the edge the value reaches — the top of a bar counting up,
292
+ * the bottom of one counting down — which is the funnel look: pale body, one
293
+ * bright rule along the value. `all` (the default) is the Highcharts box.
294
+ */
295
+ borderPosition?: 'all' | 'top';
296
+ fillOpacity?: number;
297
+ pointPadding?: number;
298
+ groupPadding?: number;
299
+ minPointLength?: number;
300
+ innerSize?: number | string;
301
+ marker?: MarkerOptions;
302
+ dataLabels?: DataLabelsOptions<TSeriesMeta>;
303
+ states?: SeriesStatesOptions;
304
+ animation?: AnimationOptions | false;
305
+ cursor?: 'pointer' | 'default';
306
+ turboThreshold?: number;
307
+ }
308
+ export interface PlotOptions<TSeriesMeta = unknown, TPointMeta = unknown> {
309
+ series?: Partial<SeriesOptionsBase<TSeriesMeta, TPointMeta>>;
310
+ [seriesType: string]: Partial<SeriesOptionsBase<TSeriesMeta, TPointMeta>> | undefined;
311
+ }
312
+ export interface ChartOptions<TChartMeta = unknown, TSeriesMeta = unknown, TPointMeta = unknown> {
313
+ chart?: ChartRootOptions;
314
+ title?: TitleOptions;
315
+ subtitle?: TitleOptions;
316
+ xAxis?: AxisOptions | readonly AxisOptions[];
317
+ yAxis?: AxisOptions | readonly AxisOptions[];
318
+ colorAxis?: ColorAxisOptions;
319
+ legend?: LegendOptions<TSeriesMeta>;
320
+ tooltip?: TooltipOptions<TChartMeta, TSeriesMeta>;
321
+ plotOptions?: PlotOptions<TSeriesMeta, TPointMeta>;
322
+ series?: readonly SeriesOptionsBase<TSeriesMeta, TPointMeta>[];
323
+ colors?: readonly string[];
324
+ meta?: TChartMeta;
325
+ /**
326
+ * Turns a bare number into text everywhere the chart prints one without a
327
+ * formatter of its own: axis labels, data labels, stack labels and the default
328
+ * tooltip. Replaces repeating the same thousands separator in four callbacks.
329
+ */
330
+ numberFormat?: (value: number) => string;
331
+ }
@@ -0,0 +1,2 @@
1
+ /** `zIndex` at or above this draws over the series instead of under it. */
2
+ export const ABOVE_SERIES_Z_INDEX = 5;
@@ -0,0 +1,101 @@
1
+ import { type ReactNode } from 'react';
2
+ import { type Point, type Rect, type SlotGeometry } from './geometry';
3
+ import { type SeriesOptionsBase } from './options';
4
+ import { type AnyScale, type ColorScale, type DomainRange, type ScaleKind, type ValueScale } from './scale';
5
+ import { type NormalizedPoint } from '../data/points';
6
+ export interface DomainAcc {
7
+ readonly x: DomainRange;
8
+ readonly y: readonly DomainRange[];
9
+ readonly color: DomainRange;
10
+ readonly categories: readonly string[];
11
+ }
12
+ export interface StackedValue {
13
+ from: number;
14
+ to: number;
15
+ total: number;
16
+ }
17
+ export interface HoverState {
18
+ seriesIndex: number;
19
+ pointIndex: number;
20
+ }
21
+ export interface RenderContext<TSeries extends SeriesOptionsBase = SeriesOptionsBase> {
22
+ series: TSeries;
23
+ seriesIndex: number;
24
+ points: readonly NormalizedPoint[];
25
+ plot: Rect;
26
+ scales: {
27
+ x: AnyScale;
28
+ y: ValueScale;
29
+ color: ColorScale | undefined;
30
+ };
31
+ color: string;
32
+ colors: readonly string[];
33
+ stacked: readonly (StackedValue | undefined)[] | undefined;
34
+ slot: SlotGeometry | undefined;
35
+ hovered: HoverState | undefined;
36
+ /**
37
+ * The series is switched off. A renderer whose `exit` is `collapse` draws its
38
+ * shapes flattened onto their own baseline so the CSS transition on the geometry
39
+ * carries them there; the rest can ignore it and let the layer fade.
40
+ */
41
+ hidden: boolean;
42
+ /**
43
+ * Points switched off one by one, by `point.index` — a pie's legend does this.
44
+ * They are still handed over so their shape can shrink away rather than vanish;
45
+ * they must not be drawn at full size, counted in a total, or hit-tested.
46
+ */
47
+ hiddenPoints: ReadonlySet<number>;
48
+ animate: boolean;
49
+ /**
50
+ * How the chart turns a bare number into text. A renderer reaches for it
51
+ * wherever it prints a value the caller gave no formatter for.
52
+ */
53
+ numberFormat: NumberFormatter;
54
+ }
55
+ /** Chart-wide number-to-text rule; the default is `String`. */
56
+ export type NumberFormatter = (value: number) => string;
57
+ export interface PointHit {
58
+ seriesIndex: number;
59
+ pointIndex: number;
60
+ x: number | string;
61
+ y: number | null;
62
+ value: number | null;
63
+ anchor: Point;
64
+ distance: number;
65
+ }
66
+ export interface LegendItem {
67
+ seriesIndex: number;
68
+ /**
69
+ * Set when the item stands for a single point rather than the whole series — a
70
+ * pie slice. Toggling it takes that point out of the chart, not the series.
71
+ */
72
+ pointIndex?: number;
73
+ label: string;
74
+ color: string;
75
+ symbol: 'circle' | 'square' | 'line';
76
+ visible: boolean;
77
+ }
78
+ /**
79
+ * How a series leaves the plot when it is switched off. Bars read as growing out
80
+ * of the axis, so they collapse back into it; a line has no baseline to collapse
81
+ * to and simply fades.
82
+ */
83
+ export type ExitMotion = 'collapse' | 'fade';
84
+ export interface SeriesRenderer<TSeries extends SeriesOptionsBase = SeriesOptionsBase> {
85
+ readonly type: string;
86
+ readonly scales: {
87
+ x: ScaleKind;
88
+ y: ScaleKind;
89
+ };
90
+ readonly exit?: ExitMotion;
91
+ /**
92
+ * The renderer tweens its own geometry frame by frame — the chart then leaves its
93
+ * shapes alone rather than putting a CSS transition on top, which would fight it.
94
+ */
95
+ readonly animatesGeometry?: boolean;
96
+ extendDomain(series: TSeries, acc: DomainAcc): DomainAcc;
97
+ render(ctx: RenderContext<TSeries>): ReactNode;
98
+ hitTest(ctx: RenderContext<TSeries>, pointer: Point): PointHit[] | null;
99
+ legendItems(series: TSeries, seriesIndex: number, colors: readonly string[]): LegendItem[];
100
+ }
101
+ export type AnySeriesRenderer = SeriesRenderer<SeriesOptionsBase>;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,34 @@
1
+ export type ScaleKind = 'linear' | 'time' | 'band' | 'color' | 'none';
2
+ export type TimeUnit = 'second' | 'minute' | 'hour' | 'day' | 'week' | 'month' | 'year';
3
+ export interface ContinuousScale {
4
+ readonly kind: 'linear' | 'time';
5
+ map(value: number): number;
6
+ invert(px: number): number;
7
+ ticks(hint?: number): number[];
8
+ domain(): readonly [number, number];
9
+ range(): readonly [number, number];
10
+ }
11
+ export interface BandScale {
12
+ readonly kind: 'band';
13
+ map(value: string): number;
14
+ invert(px: number): string | undefined;
15
+ ticks(): string[];
16
+ domain(): readonly string[];
17
+ range(): readonly [number, number];
18
+ bandwidth(): number;
19
+ step(): number;
20
+ }
21
+ export type ColorStop = readonly [position: number, color: string];
22
+ export interface ColorScale {
23
+ readonly kind: 'color';
24
+ map(value: number): string;
25
+ domain(): readonly [number, number];
26
+ stops(): readonly ColorStop[];
27
+ }
28
+ export type AnyScale = ContinuousScale | BandScale | ColorScale;
29
+ /** What a renderer can be handed as its value axis: numbers or categories. */
30
+ export type ValueScale = ContinuousScale | BandScale;
31
+ export interface DomainRange {
32
+ min: number;
33
+ max: number;
34
+ }
@@ -0,0 +1 @@
1
+ export {};
package/index.d.ts ADDED
@@ -0,0 +1,16 @@
1
+ export { Chart, type ChartProps } from './core/Chart/Chart';
2
+ export { AreaChart, ColumnChart, LineChart, PieChart, StackedColumnChart, type StackedColumnChartProps, } from './presets';
3
+ export { area } from './series/area';
4
+ export { column } from './series/column';
5
+ export { heatmap } from './series/heatmap';
6
+ export { line } from './series/line';
7
+ export { pie } from './series/pie';
8
+ export { registerSeries, resolveRenderers, getRenderer } from './core/registry/registry';
9
+ export { DEFAULT_COLORS, DEFAULT_GRID_COLOR, DEFAULT_AXIS_COLOR, DEFAULT_TEXT_COLOR, DEFAULT_MUTED_TEXT_COLOR, DEFAULT_SURFACE_COLOR, } from './core/model/palette';
10
+ export { formatTime } from './core/format/time';
11
+ export { type NormalizedPoint } from './core/data/points';
12
+ export type { Point, Rect, Size, SlotGeometry, Spacing, } from './core/types/geometry';
13
+ export type { AnyScale, BandScale, ColorScale, ColorStop, ContinuousScale, DomainRange, ScaleKind, TimeUnit, ValueScale, } from './core/types/scale';
14
+ export type { AxisLabelContext, AxisLabelFormatter, DataLabelContext, DataLabelFormatter, LegendLabelContext, LegendLabelFormatter, TooltipCellFormatter, TooltipContext, TooltipFormatter, TooltipNeighbour, TooltipPoint, } from './core/types/formatter';
15
+ export type { AnimationOptions, AxisLabelsOptions, AxisOptions, AxisTitleOptions, ChartOptions, ChartRootOptions, ColorAxisOptions, DataLabelsOptions, LegendOptions, MarkerOptions, MarkerStateOptions, PlotBandOptions, PlotLabelOptions, PlotLineOptions, PlotOptions, PointObject, PointTuple, SeriesData, SeriesOptionsBase, SeriesPoint, SeriesStatesOptions, ShadowOptions, Stacking, StackLabelsOptions, TextStyle, TitleOptions, TooltipOptions, TooltipTableColumn, TooltipTableOptions, } from './core/types/options';
16
+ export type { AnySeriesRenderer, DomainAcc, ExitMotion, HoverState, LegendItem, PointHit, RenderContext, SeriesRenderer, StackedValue, } from './core/types/renderer';
package/index.js ADDED
@@ -0,0 +1,10 @@
1
+ export { Chart } from './core/Chart/Chart';
2
+ export { AreaChart, ColumnChart, LineChart, PieChart, StackedColumnChart } from './presets';
3
+ export { area } from './series/area';
4
+ export { column } from './series/column';
5
+ export { heatmap } from './series/heatmap';
6
+ export { line } from './series/line';
7
+ export { pie } from './series/pie';
8
+ export { registerSeries, resolveRenderers, getRenderer } from './core/registry/registry';
9
+ export { DEFAULT_COLORS, DEFAULT_GRID_COLOR, DEFAULT_AXIS_COLOR, DEFAULT_TEXT_COLOR, DEFAULT_MUTED_TEXT_COLOR, DEFAULT_SURFACE_COLOR } from './core/model/palette';
10
+ export { formatTime } from './core/format/time';
package/package.json ADDED
@@ -0,0 +1,64 @@
1
+ {
2
+ "name": "@pushwoosh/kit-charts",
3
+ "version": "0.0.1",
4
+ "description": "Small React chart library on SVG, with a Highcharts-shaped configuration model",
5
+ "license": "MIT",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://gitlab.corp.pushwoosh.com/frontend/development-kit/charts.git"
9
+ },
10
+ "keywords": [
11
+ "chart",
12
+ "charts",
13
+ "react",
14
+ "svg",
15
+ "dataviz",
16
+ "visualization",
17
+ "highcharts-alternative"
18
+ ],
19
+ "main": "index.js",
20
+ "module": "index.js",
21
+ "types": "index.d.ts",
22
+ "sideEffects": false,
23
+ "publishConfig": {
24
+ "access": "public"
25
+ },
26
+ "scripts": {
27
+ "start": "npm run playground",
28
+ "build": "pushwoosh-engine lib:build && cp ai-documentation.md LICENSE dist/",
29
+ "playground": "webpack serve --config ./node_modules/@pushwoosh/frontend-builder-engine/lib/webpack.playground.config.js --stats-error-details",
30
+ "check": "npm run check:lint && npm run check:types",
31
+ "check:lint": "echo \"Run check:lint\" && NODE_ENV=production eslint ./src ./playground ./tests",
32
+ "check:lint-fix": "echo \"Run check:lint\" && NODE_ENV=production eslint ./src ./playground ./tests --fix",
33
+ "check:types": "echo \"Run check:types\" && pushwoosh-engine lib:check-types && tsc --noEmit -p tsconfig.json",
34
+ "test": "jest"
35
+ },
36
+ "pre-commit": "check",
37
+ "dependencies": {
38
+ "@pushwoosh/kit-constants": "^1.8.0"
39
+ },
40
+ "devDependencies": {
41
+ "@pushwoosh/frontend-builder-engine": "^3.0.0",
42
+ "@testing-library/jest-dom": "^6.9.1",
43
+ "@testing-library/react": "^16.3.0",
44
+ "@types/jest": "^30.0.0",
45
+ "@types/react": "^18.3.2",
46
+ "@types/react-dom": "^18.3.0",
47
+ "@types/styled-components": "^5.1.34",
48
+ "cross-env": "^7.0.3",
49
+ "jest": "^30.2.0",
50
+ "jest-environment-jsdom": "^30.2.0",
51
+ "pre-commit": "^1.2.2",
52
+ "react": "^18.3.1",
53
+ "react-dom": "^18.3.1",
54
+ "styled-components": "^5.3.11",
55
+ "ts-jest": "^29.4.6"
56
+ },
57
+ "peerDependencies": {
58
+ "react": ">=18.0.0",
59
+ "styled-components": ">=5.3.3"
60
+ },
61
+ "engines": {
62
+ "node": ">= 18"
63
+ }
64
+ }
@@ -0,0 +1,3 @@
1
+ import { type ReactElement } from 'react';
2
+ import { type ChartProps } from '../core/Chart/Chart';
3
+ export declare function AreaChart<TChartMeta = unknown, TSeriesMeta = unknown>(props: ChartProps<TChartMeta, TSeriesMeta>): ReactElement;
@@ -0,0 +1,13 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { Chart } from '../core/Chart/Chart';
3
+ import { area } from '../series/area';
4
+ export function AreaChart(props) {
5
+ const {
6
+ renderers,
7
+ ...rest
8
+ } = props;
9
+ return _jsx(Chart, {
10
+ ...rest,
11
+ renderers: renderers ? [area, ...renderers] : [area]
12
+ });
13
+ }
@@ -0,0 +1,3 @@
1
+ import { type ReactElement } from 'react';
2
+ import { type ChartProps } from '../core/Chart/Chart';
3
+ export declare function ColumnChart<TChartMeta = unknown, TSeriesMeta = unknown>(props: ChartProps<TChartMeta, TSeriesMeta>): ReactElement;
@@ -0,0 +1,13 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { Chart } from '../core/Chart/Chart';
3
+ import { column } from '../series/column';
4
+ export function ColumnChart(props) {
5
+ const {
6
+ renderers,
7
+ ...rest
8
+ } = props;
9
+ return _jsx(Chart, {
10
+ ...rest,
11
+ renderers: renderers ? [column, ...renderers] : [column]
12
+ });
13
+ }
@@ -0,0 +1,3 @@
1
+ import { type ReactElement } from 'react';
2
+ import { type ChartProps } from '../core/Chart/Chart';
3
+ export declare function LineChart<TChartMeta = unknown, TSeriesMeta = unknown>(props: ChartProps<TChartMeta, TSeriesMeta>): ReactElement;
@@ -0,0 +1,13 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { Chart } from '../core/Chart/Chart';
3
+ import { line } from '../series/line';
4
+ export function LineChart(props) {
5
+ const {
6
+ renderers,
7
+ ...rest
8
+ } = props;
9
+ return _jsx(Chart, {
10
+ ...rest,
11
+ renderers: renderers ? [line, ...renderers] : [line]
12
+ });
13
+ }
@@ -0,0 +1,3 @@
1
+ import { type ReactElement } from 'react';
2
+ import { type ChartProps } from '../core/Chart/Chart';
3
+ export declare function PieChart<TChartMeta = unknown, TSeriesMeta = unknown>(props: ChartProps<TChartMeta, TSeriesMeta>): ReactElement;
@@ -0,0 +1,13 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { Chart } from '../core/Chart/Chart';
3
+ import { pie } from '../series/pie';
4
+ export function PieChart(props) {
5
+ const {
6
+ renderers,
7
+ ...rest
8
+ } = props;
9
+ return _jsx(Chart, {
10
+ ...rest,
11
+ renderers: renderers ? [pie, ...renderers] : [pie]
12
+ });
13
+ }
@@ -0,0 +1,7 @@
1
+ import { type ReactElement } from 'react';
2
+ import { type ChartProps } from '../core/Chart/Chart';
3
+ import { type Stacking } from '../core/types/options';
4
+ export interface StackedColumnChartProps<TChartMeta = unknown, TSeriesMeta = unknown> extends ChartProps<TChartMeta, TSeriesMeta> {
5
+ stacking?: Stacking;
6
+ }
7
+ export declare function StackedColumnChart<TChartMeta = unknown, TSeriesMeta = unknown>(props: StackedColumnChartProps<TChartMeta, TSeriesMeta>): ReactElement;