@sckyzo/cosmos-charts 0.0.2 → 0.2.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/index.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import * as apexcharts from 'apexcharts';
2
- import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import * as react from 'react';
3
3
 
4
+ /** Default brand color (the blue accent). Prefer `useChartTheme().brand`, which follows the accent. */
4
5
  declare const COSMOS_BRAND = "#465fff";
5
6
  declare const COSMOS_PALETTE: string[];
6
7
  /**
@@ -9,8 +10,10 @@ declare const COSMOS_PALETTE: string[];
9
10
  */
10
11
  declare const useDarkMode: () => boolean;
11
12
  /**
12
- * Returns ApexCharts grid + axis options matching the Cosmos design tokens
13
- * for the current color scheme.
13
+ * Returns ApexCharts grid + axis options and colors matching the Cosmos
14
+ * design tokens for the current theme and accent: `brandScale` is a
15
+ * sequential scale (five brand steps, low to high) and `surface` the card
16
+ * background.
14
17
  */
15
18
  declare const useChartTheme: () => {
16
19
  dark: boolean;
@@ -23,6 +26,8 @@ declare const useChartTheme: () => {
23
26
  };
24
27
  };
25
28
  brand: string;
29
+ brandScale: string[];
30
+ surface: string;
26
31
  palette: string[];
27
32
  };
28
33
 
@@ -42,7 +47,7 @@ type LineAreaChartProps = ChartSize & {
42
47
  }[];
43
48
  categories: (string | number)[];
44
49
  };
45
- declare const LineAreaChart: ({ series, categories, height, width, }: LineAreaChartProps) => react_jsx_runtime.JSX.Element;
50
+ declare const LineAreaChart: ({ series, categories, height, width, }: LineAreaChartProps) => react.JSX.Element;
46
51
 
47
52
  type RealtimeChartProps = ChartSize & {
48
53
  /** Sample generator — defaults to a noisy walk between 30 and 80. */
@@ -53,32 +58,32 @@ type RealtimeChartProps = ChartSize & {
53
58
  warnThreshold?: number;
54
59
  critThreshold?: number;
55
60
  };
56
- declare const RealtimeChart: ({ generator, intervalMs, windowSize, warnThreshold, critThreshold, height, width, }: RealtimeChartProps) => react_jsx_runtime.JSX.Element;
61
+ declare const RealtimeChart: ({ generator, intervalMs, windowSize, warnThreshold, critThreshold, height, width, }: RealtimeChartProps) => react.JSX.Element;
57
62
 
58
63
  type RadialBarChartProps = ChartSize & {
59
64
  series: number[];
60
65
  labels: string[];
61
66
  };
62
- declare const RadialBarChart: ({ series, labels, height, width, }: RadialBarChartProps) => react_jsx_runtime.JSX.Element;
67
+ declare const RadialBarChart: ({ series, labels, height, width, }: RadialBarChartProps) => react.JSX.Element;
63
68
 
64
69
  type GradientRadialProps = ChartSize & {
65
70
  value: number;
66
71
  label?: string;
67
72
  };
68
- declare const GradientRadial: ({ value, label, height, width, }: GradientRadialProps) => react_jsx_runtime.JSX.Element;
73
+ declare const GradientRadial: ({ value, label, height, width, }: GradientRadialProps) => react.JSX.Element;
69
74
 
70
75
  type SemiCircleGaugeProps = ChartSize & {
71
76
  value: number;
72
77
  label?: string;
73
78
  color?: string;
74
79
  };
75
- declare const SemiCircleGauge: ({ value, label, color, height, width, }: SemiCircleGaugeProps) => react_jsx_runtime.JSX.Element;
80
+ declare const SemiCircleGauge: ({ value, label, color, height, width, }: SemiCircleGaugeProps) => react.JSX.Element;
76
81
 
77
82
  type StrokedGaugeProps = ChartSize & {
78
83
  value: number;
79
84
  label?: string;
80
85
  };
81
- declare const StrokedGauge: ({ value, label, height, width, }: StrokedGaugeProps) => react_jsx_runtime.JSX.Element;
86
+ declare const StrokedGauge: ({ value, label, height, width, }: StrokedGaugeProps) => react.JSX.Element;
82
87
 
83
88
  type DonutChartProps = ChartSize & {
84
89
  series: number[];
@@ -86,15 +91,15 @@ type DonutChartProps = ChartSize & {
86
91
  /** Whether to show the right-side legend (default: bottom). */
87
92
  rightLegend?: boolean;
88
93
  };
89
- declare const DonutChart: ({ series, labels, rightLegend, height, width, }: DonutChartProps) => react_jsx_runtime.JSX.Element;
90
- declare const DonutRightLegend: (props: Omit<DonutChartProps, "rightLegend">) => react_jsx_runtime.JSX.Element;
94
+ declare const DonutChart: ({ series, labels, rightLegend, height, width, }: DonutChartProps) => react.JSX.Element;
95
+ declare const DonutRightLegend: (props: Omit<DonutChartProps, "rightLegend">) => react.JSX.Element;
91
96
 
92
97
  type SparklineProps = ChartSize & {
93
98
  data: number[];
94
99
  color?: string;
95
100
  variant?: 'line' | 'area';
96
101
  };
97
- declare const Sparkline: ({ data, color, variant, height, width, }: SparklineProps) => react_jsx_runtime.JSX.Element;
102
+ declare const Sparkline: ({ data, color, variant, height, width, }: SparklineProps) => react.JSX.Element;
98
103
  type SparklineGroupItem = {
99
104
  label: string;
100
105
  value: number | string;
@@ -104,7 +109,7 @@ type SparklineGroupItem = {
104
109
  declare const SparklineGroup: ({ items, className, }: {
105
110
  items: SparklineGroupItem[];
106
111
  className?: string;
107
- }) => react_jsx_runtime.JSX.Element;
112
+ }) => react.JSX.Element;
108
113
 
109
114
  type TreemapDatum = {
110
115
  x: string;
@@ -116,7 +121,7 @@ type TreemapChartProps = ChartSize & {
116
121
  data: TreemapDatum[];
117
122
  }[];
118
123
  };
119
- declare const TreemapChart: ({ series, height, width }: TreemapChartProps) => react_jsx_runtime.JSX.Element;
124
+ declare const TreemapChart: ({ series, height, width }: TreemapChartProps) => react.JSX.Element;
120
125
 
121
126
  type BarChartOrientation = 'vertical' | 'horizontal';
122
127
  type BarChartProps = ChartSize & {
@@ -138,6 +143,175 @@ type BarChartProps = ChartSize & {
138
143
  /** Tailwind border-radius applied to bar tops. Default 4. */
139
144
  borderRadius?: number;
140
145
  };
141
- declare const BarChart: ({ series, categories, orientation, stacked, colors, formatValue, showLegend, borderRadius, height, width, }: BarChartProps) => react_jsx_runtime.JSX.Element;
146
+ declare const BarChart: ({ series, categories, orientation, stacked, colors, formatValue, showLegend, borderRadius, height, width, }: BarChartProps) => react.JSX.Element;
142
147
 
143
- export { BarChart, type BarChartOrientation, type BarChartProps, COSMOS_BRAND, COSMOS_PALETTE, type ChartSeriesPoint, type ChartSize, DonutChart, type DonutChartProps, DonutRightLegend, GradientRadial, type GradientRadialProps, LineAreaChart, type LineAreaChartProps, RadialBarChart, type RadialBarChartProps, RealtimeChart, type RealtimeChartProps, SemiCircleGauge, type SemiCircleGaugeProps, Sparkline, SparklineGroup, type SparklineGroupItem, type SparklineProps, StrokedGauge, type StrokedGaugeProps, TreemapChart, type TreemapChartProps, type TreemapDatum, useChartTheme, useDarkMode };
148
+ type HeatmapColorRange = {
149
+ /** Lowest value of the range, inclusive. */
150
+ from: number;
151
+ /** Highest value of the range, inclusive. A value on a shared bound takes the later range. */
152
+ to: number;
153
+ color: string;
154
+ /** Legend label. Default: `from – to`, formatted with `formatValue`. */
155
+ name?: string;
156
+ };
157
+ type HeatmapChartProps = ChartSize & {
158
+ /** One row per series, drawn top to bottom; one value per category. */
159
+ series: {
160
+ name: string;
161
+ data: number[];
162
+ }[];
163
+ categories: (string | number)[];
164
+ /**
165
+ * Color steps, low to high, spread over the data range in buckets with
166
+ * round bounds. Default: five brand steps of the current theme and accent.
167
+ */
168
+ colors?: string[];
169
+ /**
170
+ * Explicit color ranges (thresholds such as OK / WARN / CRIT), which take
171
+ * precedence over `colors`. Cover every value: a cell outside all ranges
172
+ * falls back to a series color.
173
+ */
174
+ ranges?: HeatmapColorRange[];
175
+ /** Format the values in the tooltip, the legend and the cells. */
176
+ formatValue?: (value: number) => string;
177
+ /** Print each value inside its cell. */
178
+ showValues?: boolean;
179
+ /** Show the color legend. Default true. */
180
+ showLegend?: boolean;
181
+ };
182
+ declare const HeatmapChart: ({ series, categories, colors, ranges, formatValue, showValues, showLegend, height, width, }: HeatmapChartProps) => react.JSX.Element;
183
+
184
+ type RadarChartProps = ChartSize & {
185
+ /** One polygon per series; one value per category, in the same order. */
186
+ series: {
187
+ name: string;
188
+ data: number[];
189
+ }[];
190
+ /** The axes, clockwise from the top. */
191
+ categories: string[];
192
+ /** Override the default Cosmos palette. */
193
+ colors?: string[];
194
+ /** Format the scale labels and the tooltip values. */
195
+ formatValue?: (value: number) => string;
196
+ /** Show the legend (auto-true when 2+ series). */
197
+ showLegend?: boolean;
198
+ /** Top of the scale, e.g. 100 for scores. Default: rounded up from the data. */
199
+ max?: number;
200
+ };
201
+ declare const RadarChart: ({ series, categories, colors, formatValue, showLegend, max, height, width, }: RadarChartProps) => react.JSX.Element;
202
+
203
+ type ScatterPoint = {
204
+ x: number;
205
+ y: number;
206
+ /** Names the point in the tooltip title: a node, a host, a rack. */
207
+ label?: string;
208
+ };
209
+ type BubblePoint = ScatterPoint & {
210
+ /** Third measure, drawn as the bubble size. */
211
+ z: number;
212
+ };
213
+ type XYChartProps = ChartSize & {
214
+ /** Title under the x-axis. Also labels the x value in the tooltip (default `x`). */
215
+ xTitle?: string;
216
+ /** Title beside the y-axis. Also labels the y value in the tooltip (default `y`). */
217
+ yTitle?: string;
218
+ /** Override the default Cosmos palette, one color per series. */
219
+ colors?: string[];
220
+ /** Format the x-axis labels and the tooltip's x value (default: at most two decimals). */
221
+ formatX?: (value: number) => string;
222
+ /** Format the y-axis labels and the tooltip's y value (default: at most two decimals). */
223
+ formatY?: (value: number) => string;
224
+ /** Show the legend (auto-true when 2+ series). */
225
+ showLegend?: boolean;
226
+ };
227
+ type ScatterChartProps = XYChartProps & {
228
+ series: {
229
+ name: string;
230
+ data: ScatterPoint[];
231
+ }[];
232
+ };
233
+ type BubbleChartProps = XYChartProps & {
234
+ series: {
235
+ name: string;
236
+ data: BubblePoint[];
237
+ }[];
238
+ /** Labels the size in the tooltip. Default `Size`. */
239
+ sizeTitle?: string;
240
+ /** Format the size in the tooltip (default: at most two decimals). */
241
+ formatSize?: (value: number) => string;
242
+ };
243
+ /** Points on two numeric axes, e.g. latency against load, one point per node. */
244
+ declare const ScatterChart: ({ height, width, ...props }: ScatterChartProps) => react.JSX.Element;
245
+ /** A scatter chart whose bubble size carries a third measure (`z`), e.g. request volume. */
246
+ declare const BubbleChart: ({ sizeTitle, formatSize, height, width, ...props }: BubbleChartProps) => react.JSX.Element;
247
+
248
+ type BoxPlotChartOrientation = 'vertical' | 'horizontal';
249
+ /** One box, the five-number summary of a distribution. */
250
+ type BoxPlotSummary = [min: number, q1: number, median: number, q3: number, max: number];
251
+ type BoxPlotChartProps = ChartSize & {
252
+ /** One summary per category, in the order of `categories`. */
253
+ series: {
254
+ name: string;
255
+ data: BoxPlotSummary[];
256
+ }[];
257
+ categories: string[];
258
+ /** `vertical` (default) draws boxes upward; `horizontal` draws them rightward. */
259
+ orientation?: BoxPlotChartOrientation;
260
+ /** Override the default Cosmos palette, one color per series. */
261
+ colors?: string[];
262
+ /** Format the value axis labels and the tooltip values. */
263
+ formatValue?: (value: number) => string;
264
+ /** Show the legend (auto-true when 2+ series). */
265
+ showLegend?: boolean;
266
+ };
267
+ /** Distributions per category (min, quartiles, median, max), e.g. response times per service. */
268
+ declare const BoxPlotChart: ({ series, categories, orientation, colors, formatValue, showLegend, height, width, }: BoxPlotChartProps) => react.JSX.Element;
269
+
270
+ type RangeBarPoint = {
271
+ /** Row label: the service, rack or host the range belongs to. */
272
+ x: string;
273
+ /** Start and end, as timestamps in milliseconds. */
274
+ y: [number, number];
275
+ };
276
+ type RangeBarChartProps = ChartSize & {
277
+ /** One series per kind of range (maintenance, deploy, incident…), drawn on a datetime axis. */
278
+ series: {
279
+ name: string;
280
+ data: RangeBarPoint[];
281
+ }[];
282
+ /** Draw every series of a row on one lane, instead of one lane per series. */
283
+ groupRows?: boolean;
284
+ /** Override the default Cosmos palette. */
285
+ colors?: string[];
286
+ /** Format the start and end times in the tooltip. Default: `14 Oct, 02:00`, in UTC like the axis. */
287
+ formatDate?: (timestamp: number) => string;
288
+ /** Show the legend (auto-true when 2+ series). */
289
+ showLegend?: boolean;
290
+ };
291
+ declare const RangeBarChart: ({ series, groupRows, colors, formatDate, showLegend, height, width, }: RangeBarChartProps) => react.JSX.Element;
292
+
293
+ type MixedChartAxis = 'left' | 'right';
294
+ type MixedChartSeries = {
295
+ name: string;
296
+ /** `column` draws bars, `line` draws a line over them. */
297
+ type: 'line' | 'column';
298
+ data: number[];
299
+ /** The y axis the series is read on. Any `right` series adds a second axis. Default `left`. */
300
+ axis?: MixedChartAxis;
301
+ };
302
+ type MixedChartProps = ChartSize & {
303
+ /** Lines and columns on one category axis. Names must be unique: each y axis finds its series by name. */
304
+ series: MixedChartSeries[];
305
+ categories: (string | number)[];
306
+ /** Override the default Cosmos palette. */
307
+ colors?: string[];
308
+ /** Format the left axis labels and the tooltip values of its series. */
309
+ formatValue?: (value: number) => string;
310
+ /** Format the right axis labels and the tooltip values of its series. */
311
+ formatRightValue?: (value: number) => string;
312
+ /** Show the legend (auto-true when 2+ series). */
313
+ showLegend?: boolean;
314
+ };
315
+ declare const MixedChart: ({ series, categories, colors, formatValue, formatRightValue, showLegend, height, width, }: MixedChartProps) => react.JSX.Element;
316
+
317
+ export { BarChart, type BarChartOrientation, type BarChartProps, BoxPlotChart, type BoxPlotChartOrientation, type BoxPlotChartProps, type BoxPlotSummary, BubbleChart, type BubbleChartProps, type BubblePoint, COSMOS_BRAND, COSMOS_PALETTE, type ChartSeriesPoint, type ChartSize, DonutChart, type DonutChartProps, DonutRightLegend, GradientRadial, type GradientRadialProps, HeatmapChart, type HeatmapChartProps, type HeatmapColorRange, LineAreaChart, type LineAreaChartProps, MixedChart, type MixedChartAxis, type MixedChartProps, type MixedChartSeries, RadarChart, type RadarChartProps, RadialBarChart, type RadialBarChartProps, RangeBarChart, type RangeBarChartProps, type RangeBarPoint, RealtimeChart, type RealtimeChartProps, ScatterChart, type ScatterChartProps, type ScatterPoint, SemiCircleGauge, type SemiCircleGaugeProps, Sparkline, SparklineGroup, type SparklineGroupItem, type SparklineProps, StrokedGauge, type StrokedGaugeProps, TreemapChart, type TreemapChartProps, type TreemapDatum, useChartTheme, useDarkMode };