@sckyzo/cosmos-charts 0.1.1 → 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
@@ -11,7 +11,9 @@ declare const COSMOS_PALETTE: string[];
11
11
  declare const useDarkMode: () => boolean;
12
12
  /**
13
13
  * Returns ApexCharts grid + axis options and colors matching the Cosmos
14
- * design tokens for the current theme and accent.
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.
15
17
  */
16
18
  declare const useChartTheme: () => {
17
19
  dark: boolean;
@@ -24,6 +26,8 @@ declare const useChartTheme: () => {
24
26
  };
25
27
  };
26
28
  brand: string;
29
+ brandScale: string[];
30
+ surface: string;
27
31
  palette: string[];
28
32
  };
29
33
 
@@ -141,4 +145,173 @@ type BarChartProps = ChartSize & {
141
145
  };
142
146
  declare const BarChart: ({ series, categories, orientation, stacked, colors, formatValue, showLegend, borderRadius, height, width, }: BarChartProps) => react.JSX.Element;
143
147
 
144
- 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 };