@sproutsocial/seeds-react-data-viz 0.3.1 → 0.4.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.
- package/README.md +2 -0
- package/dist/esm/index.js +511 -85
- package/dist/esm/index.js.map +1 -1
- package/dist/index.d.mts +146 -19
- package/dist/index.d.ts +146 -19
- package/dist/index.js +518 -85
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
2
|
import { ReactNode } from 'react';
|
|
3
|
-
import { TimeTicksInfoObject, AxisLabelsFormatterContextObject, Chart, Annotation, TooltipFormatterContextObject, Options, SeriesSplineOptions, SeriesAreasplineOptions, AxisTickPositionsArray } from 'highcharts';
|
|
3
|
+
import { TimeTicksInfoObject, AxisLabelsFormatterContextObject, Chart, Annotation, TooltipFormatterContextObject, Options, SeriesSplineOptions, SeriesAreasplineOptions, SeriesColumnOptions, AxisTickPositionsArray } from 'highcharts';
|
|
4
4
|
import * as _sproutsocial_seeds_react_box from '@sproutsocial/seeds-react-box';
|
|
5
5
|
import { TypeBoxProps } from '@sproutsocial/seeds-react-box';
|
|
6
6
|
import { Table } from '@sproutsocial/seeds-react-table';
|
|
7
7
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
8
8
|
import * as styled_components from 'styled-components';
|
|
9
9
|
|
|
10
|
+
/**
|
|
11
|
+
* Type of series to render. See {@link https://api.highcharts.com/highcharts/series} for detailed series configuration options.
|
|
12
|
+
*/
|
|
13
|
+
type TypeSeriesType = "areaspline" | "spline" | "column";
|
|
10
14
|
interface ExtendedTimeTicksInfoObject extends TimeTicksInfoObject {
|
|
11
15
|
unitName: "hour" | "day" | "week" | "month" | "year";
|
|
12
16
|
}
|
|
@@ -14,7 +18,7 @@ interface ExtendedAxisLabelsFormatterContextObject extends AxisLabelsFormatterCo
|
|
|
14
18
|
tickPositionInfo: ExtendedTimeTicksInfoObject;
|
|
15
19
|
}
|
|
16
20
|
type TypeChartDataPoint = Readonly<{
|
|
17
|
-
x: number;
|
|
21
|
+
x: number | string;
|
|
18
22
|
y: number | null;
|
|
19
23
|
}>;
|
|
20
24
|
type TypeChartDataStyles = Readonly<{
|
|
@@ -22,8 +26,8 @@ type TypeChartDataStyles = Readonly<{
|
|
|
22
26
|
}>;
|
|
23
27
|
type TypeChartNumberFormat = "decimal" | "percent" | "currency" | "duration";
|
|
24
28
|
type TypeChartTimeFormat = "12" | "24";
|
|
25
|
-
type TypeChartTooltipDateFormatter = ({ x }: {
|
|
26
|
-
x: number;
|
|
29
|
+
type TypeChartTooltipDateFormatter = ({ x, }: {
|
|
30
|
+
x: number | string;
|
|
27
31
|
}) => ReactNode;
|
|
28
32
|
type TypeChartTooltipProps = Readonly<{
|
|
29
33
|
data: ReadonlyArray<Readonly<{
|
|
@@ -32,7 +36,7 @@ type TypeChartTooltipProps = Readonly<{
|
|
|
32
36
|
value: number | null;
|
|
33
37
|
icon?: ReactNode;
|
|
34
38
|
}>>;
|
|
35
|
-
x: number;
|
|
39
|
+
x: number | string;
|
|
36
40
|
}>;
|
|
37
41
|
type TypeChartYAxisLabelFormatter = ({ y, yValues, }: Readonly<{
|
|
38
42
|
y: number;
|
|
@@ -48,6 +52,48 @@ type TypeChartXAnnotations = Readonly<{
|
|
|
48
52
|
type TypeChartStyleColor = string;
|
|
49
53
|
type TypeChartStylePattern = "solid" | "dashed";
|
|
50
54
|
type TypeChartStyleHasOnClick = boolean;
|
|
55
|
+
type TypeVerticalBarChartProps = Readonly<{
|
|
56
|
+
data: ReadonlyArray<Readonly<{
|
|
57
|
+
name: string;
|
|
58
|
+
points: ReadonlyArray<TypeChartDataPoint>;
|
|
59
|
+
icon?: ReactNode;
|
|
60
|
+
styles?: TypeChartDataStyles & Readonly<{
|
|
61
|
+
pattern?: TypeChartStylePattern;
|
|
62
|
+
}>;
|
|
63
|
+
}>>;
|
|
64
|
+
invalidNumberLabel: ReactNode;
|
|
65
|
+
numberLocale: Intl.LocalesArgument;
|
|
66
|
+
textLocale: Intl.LocalesArgument;
|
|
67
|
+
tooltipDateFormatter: TypeChartTooltipDateFormatter;
|
|
68
|
+
currency?: string;
|
|
69
|
+
numberFormat?: TypeChartNumberFormat;
|
|
70
|
+
/**
|
|
71
|
+
* The maximum number of series to display.
|
|
72
|
+
* @default 10
|
|
73
|
+
* @description We recommend limiting the number of series to 10 to maintain chart readability and accessibility.
|
|
74
|
+
*/
|
|
75
|
+
seriesLimit?: number;
|
|
76
|
+
/**
|
|
77
|
+
* If false, disables the warning when the number of series exceeds the seriesLimit.
|
|
78
|
+
* @default true
|
|
79
|
+
*/
|
|
80
|
+
showSeriesLimitWarning?: boolean;
|
|
81
|
+
tooltip?: ({ data, x }: TypeChartTooltipProps) => ReactNode;
|
|
82
|
+
yAxisLabelFormatter?: TypeChartYAxisLabelFormatter;
|
|
83
|
+
onClick?: ({ x }: Readonly<{
|
|
84
|
+
x: number;
|
|
85
|
+
}>) => void;
|
|
86
|
+
tooltipClickLabel?: ReactNode;
|
|
87
|
+
timeFormat?: TypeChartTimeFormat;
|
|
88
|
+
xAnnotations?: TypeChartXAnnotations;
|
|
89
|
+
xAxisLabelFormatter?: (params: {
|
|
90
|
+
textLocale: Intl.LocalesArgument;
|
|
91
|
+
tickPositions: number[];
|
|
92
|
+
unitName: string;
|
|
93
|
+
value: string | number;
|
|
94
|
+
timeFormat?: string;
|
|
95
|
+
}) => string;
|
|
96
|
+
}>;
|
|
51
97
|
interface TypeExtendedChart extends Chart {
|
|
52
98
|
annotations?: Annotation[];
|
|
53
99
|
}
|
|
@@ -237,6 +283,10 @@ type TypeDonutChartProps = Readonly<{
|
|
|
237
283
|
hideLegend?: boolean;
|
|
238
284
|
numberFormat?: TypeChartNumberFormat;
|
|
239
285
|
tooltip?: ({ color, name, percent, value, }: TypeDonutChartTooltipProps) => ReactNode;
|
|
286
|
+
onClick?: ({ x }: Readonly<{
|
|
287
|
+
x: string;
|
|
288
|
+
}>) => void;
|
|
289
|
+
tooltipClickLabel?: ReactNode;
|
|
240
290
|
}>;
|
|
241
291
|
declare const DonutChart: react.NamedExoticComponent<Readonly<{
|
|
242
292
|
data: ReadonlyArray<Readonly<{
|
|
@@ -252,6 +302,10 @@ declare const DonutChart: react.NamedExoticComponent<Readonly<{
|
|
|
252
302
|
hideLegend?: boolean;
|
|
253
303
|
numberFormat?: TypeChartNumberFormat;
|
|
254
304
|
tooltip?: ({ color, name, percent, value, }: TypeDonutChartTooltipProps) => ReactNode;
|
|
305
|
+
onClick?: ({ x }: Readonly<{
|
|
306
|
+
x: string;
|
|
307
|
+
}>) => void;
|
|
308
|
+
tooltipClickLabel?: ReactNode;
|
|
255
309
|
}>>;
|
|
256
310
|
|
|
257
311
|
type TypeDonutChartLegendTableProps = Readonly<{
|
|
@@ -324,17 +378,25 @@ declare const LineChart: react.NamedExoticComponent<Readonly<{
|
|
|
324
378
|
|
|
325
379
|
declare const baseChartOptions: Options;
|
|
326
380
|
declare const TIME_SERIES_CHART_HEIGHT = 275;
|
|
381
|
+
declare const timeSeriesChartOptions: Options;
|
|
327
382
|
declare const lineChartOptions: Options;
|
|
328
383
|
declare const areaChartOptions: Options;
|
|
384
|
+
declare const columnChartOptions: Options;
|
|
385
|
+
/**
|
|
386
|
+
* The default series limit for VerticalBarChart.
|
|
387
|
+
* This limit is recommended to maintain chart readability and accessibility.
|
|
388
|
+
* @see {VerticalBarChart}
|
|
389
|
+
*/
|
|
390
|
+
declare const VERTICAL_BAR_CHART_DEFAULT_SERIES_LIMIT = 10;
|
|
329
391
|
declare const DONUT_CHART_HALO_SIZE = 10;
|
|
330
392
|
declare const DONUT_CHART_HEIGHT: number;
|
|
331
393
|
declare const DONUT_CHART_WIDTH: number;
|
|
332
394
|
declare const donutChartOptions: Options;
|
|
333
395
|
|
|
334
|
-
type TypeTimeSeriesOptions = SeriesSplineOptions | SeriesAreasplineOptions;
|
|
335
|
-
declare const transformDataToSeries: ({ data }: {
|
|
336
|
-
data: TypeAreaChartProps["data"] | TypeLineChartProps["data"];
|
|
337
|
-
}, type:
|
|
396
|
+
type TypeTimeSeriesOptions = SeriesSplineOptions | SeriesAreasplineOptions | SeriesColumnOptions;
|
|
397
|
+
declare const transformDataToSeries: ({ data, }: {
|
|
398
|
+
data: TypeAreaChartProps["data"] | TypeLineChartProps["data"] | TypeVerticalBarChartProps["data"];
|
|
399
|
+
}, type: TypeSeriesType) => TypeTimeSeriesOptions[];
|
|
338
400
|
|
|
339
401
|
type TypeTransformTimeSeriesTooltipDataProps = Readonly<{
|
|
340
402
|
context: TooltipFormatterContextObject;
|
|
@@ -343,15 +405,6 @@ type TypeTransformTimeSeriesTooltipDataProps = Readonly<{
|
|
|
343
405
|
type TypeTransformTimeSeriesTooltipDataReturn = TypeChartTooltipProps["data"];
|
|
344
406
|
declare const transformTimeSeriesTooltipData: ({ context, data, }: TypeTransformTimeSeriesTooltipDataProps) => TypeTransformTimeSeriesTooltipDataReturn;
|
|
345
407
|
|
|
346
|
-
type TypeXAxisLabelFormatterProps = Readonly<{
|
|
347
|
-
textLocale: Intl.LocalesArgument;
|
|
348
|
-
tickPositions: AxisTickPositionsArray;
|
|
349
|
-
unitName: ExtendedTimeTicksInfoObject["unitName"];
|
|
350
|
-
value: AxisLabelsFormatterContextObject["value"];
|
|
351
|
-
timeFormat?: TypeChartTimeFormat;
|
|
352
|
-
}>;
|
|
353
|
-
declare const xAxisLabelFormatter: ({ textLocale, tickPositions, unitName, value, timeFormat, }: TypeXAxisLabelFormatterProps) => string;
|
|
354
|
-
|
|
355
408
|
type TypeYAxisLabelFormatterProps = Readonly<{
|
|
356
409
|
numberLocale: Intl.LocalesArgument;
|
|
357
410
|
textLocale: Intl.LocalesArgument;
|
|
@@ -362,6 +415,79 @@ type TypeYAxisLabelFormatterProps = Readonly<{
|
|
|
362
415
|
}>;
|
|
363
416
|
declare const yAxisLabelFormatter: ({ numberLocale, textLocale, tickPositions, value, currency, numberFormat, }: TypeYAxisLabelFormatterProps) => string;
|
|
364
417
|
|
|
418
|
+
type TypeXAxisLabelFormatterProps = Readonly<{
|
|
419
|
+
textLocale: Intl.LocalesArgument;
|
|
420
|
+
tickPositions: AxisTickPositionsArray;
|
|
421
|
+
unitName: ExtendedTimeTicksInfoObject["unitName"];
|
|
422
|
+
value: AxisLabelsFormatterContextObject["value"];
|
|
423
|
+
timeFormat?: TypeChartTimeFormat;
|
|
424
|
+
}>;
|
|
425
|
+
declare const xAxisLabelFormatter: ({ textLocale, tickPositions, unitName, value, timeFormat, }: TypeXAxisLabelFormatterProps) => string;
|
|
426
|
+
|
|
427
|
+
/**
|
|
428
|
+
* Helper to detect if data is hourly time data (all x values are hours of the same day)
|
|
429
|
+
* @param data - Array of series data with points containing x values
|
|
430
|
+
* @returns boolean indicating if all x values are hours of the same day
|
|
431
|
+
*/
|
|
432
|
+
declare function isHourlyTimeData(data: ReadonlyArray<Readonly<{
|
|
433
|
+
points: ReadonlyArray<{
|
|
434
|
+
x: number | string;
|
|
435
|
+
}>;
|
|
436
|
+
}>>): boolean;
|
|
437
|
+
|
|
438
|
+
/**
|
|
439
|
+
* Helper to detect if data is categorical hour data (all x values are hour strings)
|
|
440
|
+
* Supports both 12-hour format ("12 AM", "1 PM") and 24-hour format ("00:00", "13:00", "23:00")
|
|
441
|
+
* @param data - Array of series data with points containing x values
|
|
442
|
+
* @returns boolean indicating if all x values are hour strings
|
|
443
|
+
*/
|
|
444
|
+
declare function isCategoricalHourData(data: ReadonlyArray<Readonly<{
|
|
445
|
+
points: ReadonlyArray<{
|
|
446
|
+
x: number | string;
|
|
447
|
+
}>;
|
|
448
|
+
}>>): boolean;
|
|
449
|
+
|
|
450
|
+
declare const getStorybookCategoricalData: ({ showNulls, showNegativeValues, numberOfSeries, yAxisMax, showCustomColors, showDashedLines, categoryType, }: {
|
|
451
|
+
showNulls: boolean;
|
|
452
|
+
showNegativeValues: boolean;
|
|
453
|
+
numberOfSeries: number;
|
|
454
|
+
yAxisMax: number;
|
|
455
|
+
showCustomColors: boolean;
|
|
456
|
+
showDashedLines: boolean;
|
|
457
|
+
categoryType: "hours" | "hours24" | "days" | "months" | "custom";
|
|
458
|
+
}) => {
|
|
459
|
+
points: {
|
|
460
|
+
x: string;
|
|
461
|
+
y: number | null;
|
|
462
|
+
}[];
|
|
463
|
+
name: string;
|
|
464
|
+
styles: {
|
|
465
|
+
color: string | undefined;
|
|
466
|
+
pattern: string;
|
|
467
|
+
};
|
|
468
|
+
}[];
|
|
469
|
+
|
|
470
|
+
declare const getStorybookSparseTimelineData: ({ showNulls, showNegativeValues, numberOfSeries, yAxisMax, showCustomColors, showDashedLines, numberOfPoints, timeSpanHours, }: {
|
|
471
|
+
showNulls: boolean;
|
|
472
|
+
showNegativeValues: boolean;
|
|
473
|
+
numberOfSeries: number;
|
|
474
|
+
yAxisMax: number;
|
|
475
|
+
showCustomColors: boolean;
|
|
476
|
+
showDashedLines: boolean;
|
|
477
|
+
numberOfPoints?: number;
|
|
478
|
+
timeSpanHours?: number;
|
|
479
|
+
}) => {
|
|
480
|
+
points: {
|
|
481
|
+
x: number;
|
|
482
|
+
y: number | null;
|
|
483
|
+
}[];
|
|
484
|
+
name: string;
|
|
485
|
+
styles: {
|
|
486
|
+
color: string | undefined;
|
|
487
|
+
pattern: string;
|
|
488
|
+
};
|
|
489
|
+
}[];
|
|
490
|
+
|
|
365
491
|
declare const GlobalChartStyleOverrides: styled_components.GlobalStyleComponent<{}, styled_components.DefaultTheme>;
|
|
366
492
|
declare const baseChartStyles: styled_components.FlattenInterpolation<styled_components.ThemedStyledProps<Readonly<{
|
|
367
493
|
$colors: ReadonlyArray<TypeChartStyleColor>;
|
|
@@ -381,6 +507,7 @@ declare const areaChartStyles: styled_components.FlattenInterpolation<styled_com
|
|
|
381
507
|
}>, any>>;
|
|
382
508
|
declare const donutChartStyles: styled_components.FlattenInterpolation<styled_components.ThemedStyledProps<Readonly<{
|
|
383
509
|
$colors: ReadonlyArray<TypeChartStyleColor>;
|
|
510
|
+
$hasOnClick: TypeChartStyleHasOnClick;
|
|
384
511
|
}>, any>>;
|
|
385
512
|
|
|
386
|
-
export { AreaChart, ChartLegend, ChartLegendLabel, ChartTable, ChartTooltip, ChartTooltipFooter, ChartTooltipHeader, ChartTooltipPortal, ChartTooltipTable, ChartTooltipTitle, ColorBox, DONUT_CHART_HALO_SIZE, DONUT_CHART_HEIGHT, DONUT_CHART_WIDTH, DatavizColorBox, DonutChart, DonutChartLegendTable, type ExtendedAxisLabelsFormatterContextObject, type ExtendedTimeTicksInfoObject, GlobalChartStyleOverrides, LineChart, NetworkColorBox, TIME_SERIES_CHART_HEIGHT, type TypeAreaChartProps, type TypeChartDataPoint, type TypeChartDataStyles, type TypeChartLegendLabelProps, type TypeChartLegendProps, type TypeChartNumberFormat, type TypeChartStyleColor, type TypeChartStyleHasOnClick, type TypeChartStylePattern, type TypeChartTableProps, type TypeChartTimeFormat, type TypeChartTooltipDateFormatter, type TypeChartTooltipProps, type TypeChartTooltipTableProps, type TypeChartXAnnotations, type TypeChartXAnnotationsDetails, type TypeChartYAxisLabelFormatter, type TypeColorBoxProps, type TypeDatavizColorBox, type TypeDatavizColorBoxProps, type TypeDonutChartLegendTableProps, type TypeDonutChartProps, type TypeDonutChartTooltipProps, type TypeExtendedChart, type TypeLegendLabel, type TypeLineChartProps, areaChartOptions, areaChartStyles, baseChartOptions, baseChartStyles, donutChartOptions, donutChartStyles, generateChartTooltipPortalId, getDatavizColor, getDatavizColorWithAlpha, getDatavizOpacity, lineChartOptions, lineChartStyles, timeSeriesChartStyles, transformDataToSeries, transformTimeSeriesTooltipData, xAxisLabelFormatter, yAxisLabelFormatter };
|
|
513
|
+
export { AreaChart, ChartLegend, ChartLegendLabel, ChartTable, ChartTooltip, ChartTooltipFooter, ChartTooltipHeader, ChartTooltipPortal, ChartTooltipTable, ChartTooltipTitle, ColorBox, DONUT_CHART_HALO_SIZE, DONUT_CHART_HEIGHT, DONUT_CHART_WIDTH, DatavizColorBox, DonutChart, DonutChartLegendTable, type ExtendedAxisLabelsFormatterContextObject, type ExtendedTimeTicksInfoObject, GlobalChartStyleOverrides, LineChart, NetworkColorBox, TIME_SERIES_CHART_HEIGHT, type TypeAreaChartProps, type TypeChartDataPoint, type TypeChartDataStyles, type TypeChartLegendLabelProps, type TypeChartLegendProps, type TypeChartNumberFormat, type TypeChartStyleColor, type TypeChartStyleHasOnClick, type TypeChartStylePattern, type TypeChartTableProps, type TypeChartTimeFormat, type TypeChartTooltipDateFormatter, type TypeChartTooltipProps, type TypeChartTooltipTableProps, type TypeChartXAnnotations, type TypeChartXAnnotationsDetails, type TypeChartYAxisLabelFormatter, type TypeColorBoxProps, type TypeDatavizColorBox, type TypeDatavizColorBoxProps, type TypeDonutChartLegendTableProps, type TypeDonutChartProps, type TypeDonutChartTooltipProps, type TypeExtendedChart, type TypeLegendLabel, type TypeLineChartProps, type TypeSeriesType, type TypeVerticalBarChartProps, VERTICAL_BAR_CHART_DEFAULT_SERIES_LIMIT, areaChartOptions, areaChartStyles, baseChartOptions, baseChartStyles, columnChartOptions, donutChartOptions, donutChartStyles, generateChartTooltipPortalId, getDatavizColor, getDatavizColorWithAlpha, getDatavizOpacity, getStorybookCategoricalData, getStorybookSparseTimelineData, isCategoricalHourData, isHourlyTimeData, lineChartOptions, lineChartStyles, timeSeriesChartOptions, timeSeriesChartStyles, transformDataToSeries, transformTimeSeriesTooltipData, xAxisLabelFormatter, yAxisLabelFormatter };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
2
|
import { ReactNode } from 'react';
|
|
3
|
-
import { TimeTicksInfoObject, AxisLabelsFormatterContextObject, Chart, Annotation, TooltipFormatterContextObject, Options, SeriesSplineOptions, SeriesAreasplineOptions, AxisTickPositionsArray } from 'highcharts';
|
|
3
|
+
import { TimeTicksInfoObject, AxisLabelsFormatterContextObject, Chart, Annotation, TooltipFormatterContextObject, Options, SeriesSplineOptions, SeriesAreasplineOptions, SeriesColumnOptions, AxisTickPositionsArray } from 'highcharts';
|
|
4
4
|
import * as _sproutsocial_seeds_react_box from '@sproutsocial/seeds-react-box';
|
|
5
5
|
import { TypeBoxProps } from '@sproutsocial/seeds-react-box';
|
|
6
6
|
import { Table } from '@sproutsocial/seeds-react-table';
|
|
7
7
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
8
8
|
import * as styled_components from 'styled-components';
|
|
9
9
|
|
|
10
|
+
/**
|
|
11
|
+
* Type of series to render. See {@link https://api.highcharts.com/highcharts/series} for detailed series configuration options.
|
|
12
|
+
*/
|
|
13
|
+
type TypeSeriesType = "areaspline" | "spline" | "column";
|
|
10
14
|
interface ExtendedTimeTicksInfoObject extends TimeTicksInfoObject {
|
|
11
15
|
unitName: "hour" | "day" | "week" | "month" | "year";
|
|
12
16
|
}
|
|
@@ -14,7 +18,7 @@ interface ExtendedAxisLabelsFormatterContextObject extends AxisLabelsFormatterCo
|
|
|
14
18
|
tickPositionInfo: ExtendedTimeTicksInfoObject;
|
|
15
19
|
}
|
|
16
20
|
type TypeChartDataPoint = Readonly<{
|
|
17
|
-
x: number;
|
|
21
|
+
x: number | string;
|
|
18
22
|
y: number | null;
|
|
19
23
|
}>;
|
|
20
24
|
type TypeChartDataStyles = Readonly<{
|
|
@@ -22,8 +26,8 @@ type TypeChartDataStyles = Readonly<{
|
|
|
22
26
|
}>;
|
|
23
27
|
type TypeChartNumberFormat = "decimal" | "percent" | "currency" | "duration";
|
|
24
28
|
type TypeChartTimeFormat = "12" | "24";
|
|
25
|
-
type TypeChartTooltipDateFormatter = ({ x }: {
|
|
26
|
-
x: number;
|
|
29
|
+
type TypeChartTooltipDateFormatter = ({ x, }: {
|
|
30
|
+
x: number | string;
|
|
27
31
|
}) => ReactNode;
|
|
28
32
|
type TypeChartTooltipProps = Readonly<{
|
|
29
33
|
data: ReadonlyArray<Readonly<{
|
|
@@ -32,7 +36,7 @@ type TypeChartTooltipProps = Readonly<{
|
|
|
32
36
|
value: number | null;
|
|
33
37
|
icon?: ReactNode;
|
|
34
38
|
}>>;
|
|
35
|
-
x: number;
|
|
39
|
+
x: number | string;
|
|
36
40
|
}>;
|
|
37
41
|
type TypeChartYAxisLabelFormatter = ({ y, yValues, }: Readonly<{
|
|
38
42
|
y: number;
|
|
@@ -48,6 +52,48 @@ type TypeChartXAnnotations = Readonly<{
|
|
|
48
52
|
type TypeChartStyleColor = string;
|
|
49
53
|
type TypeChartStylePattern = "solid" | "dashed";
|
|
50
54
|
type TypeChartStyleHasOnClick = boolean;
|
|
55
|
+
type TypeVerticalBarChartProps = Readonly<{
|
|
56
|
+
data: ReadonlyArray<Readonly<{
|
|
57
|
+
name: string;
|
|
58
|
+
points: ReadonlyArray<TypeChartDataPoint>;
|
|
59
|
+
icon?: ReactNode;
|
|
60
|
+
styles?: TypeChartDataStyles & Readonly<{
|
|
61
|
+
pattern?: TypeChartStylePattern;
|
|
62
|
+
}>;
|
|
63
|
+
}>>;
|
|
64
|
+
invalidNumberLabel: ReactNode;
|
|
65
|
+
numberLocale: Intl.LocalesArgument;
|
|
66
|
+
textLocale: Intl.LocalesArgument;
|
|
67
|
+
tooltipDateFormatter: TypeChartTooltipDateFormatter;
|
|
68
|
+
currency?: string;
|
|
69
|
+
numberFormat?: TypeChartNumberFormat;
|
|
70
|
+
/**
|
|
71
|
+
* The maximum number of series to display.
|
|
72
|
+
* @default 10
|
|
73
|
+
* @description We recommend limiting the number of series to 10 to maintain chart readability and accessibility.
|
|
74
|
+
*/
|
|
75
|
+
seriesLimit?: number;
|
|
76
|
+
/**
|
|
77
|
+
* If false, disables the warning when the number of series exceeds the seriesLimit.
|
|
78
|
+
* @default true
|
|
79
|
+
*/
|
|
80
|
+
showSeriesLimitWarning?: boolean;
|
|
81
|
+
tooltip?: ({ data, x }: TypeChartTooltipProps) => ReactNode;
|
|
82
|
+
yAxisLabelFormatter?: TypeChartYAxisLabelFormatter;
|
|
83
|
+
onClick?: ({ x }: Readonly<{
|
|
84
|
+
x: number;
|
|
85
|
+
}>) => void;
|
|
86
|
+
tooltipClickLabel?: ReactNode;
|
|
87
|
+
timeFormat?: TypeChartTimeFormat;
|
|
88
|
+
xAnnotations?: TypeChartXAnnotations;
|
|
89
|
+
xAxisLabelFormatter?: (params: {
|
|
90
|
+
textLocale: Intl.LocalesArgument;
|
|
91
|
+
tickPositions: number[];
|
|
92
|
+
unitName: string;
|
|
93
|
+
value: string | number;
|
|
94
|
+
timeFormat?: string;
|
|
95
|
+
}) => string;
|
|
96
|
+
}>;
|
|
51
97
|
interface TypeExtendedChart extends Chart {
|
|
52
98
|
annotations?: Annotation[];
|
|
53
99
|
}
|
|
@@ -237,6 +283,10 @@ type TypeDonutChartProps = Readonly<{
|
|
|
237
283
|
hideLegend?: boolean;
|
|
238
284
|
numberFormat?: TypeChartNumberFormat;
|
|
239
285
|
tooltip?: ({ color, name, percent, value, }: TypeDonutChartTooltipProps) => ReactNode;
|
|
286
|
+
onClick?: ({ x }: Readonly<{
|
|
287
|
+
x: string;
|
|
288
|
+
}>) => void;
|
|
289
|
+
tooltipClickLabel?: ReactNode;
|
|
240
290
|
}>;
|
|
241
291
|
declare const DonutChart: react.NamedExoticComponent<Readonly<{
|
|
242
292
|
data: ReadonlyArray<Readonly<{
|
|
@@ -252,6 +302,10 @@ declare const DonutChart: react.NamedExoticComponent<Readonly<{
|
|
|
252
302
|
hideLegend?: boolean;
|
|
253
303
|
numberFormat?: TypeChartNumberFormat;
|
|
254
304
|
tooltip?: ({ color, name, percent, value, }: TypeDonutChartTooltipProps) => ReactNode;
|
|
305
|
+
onClick?: ({ x }: Readonly<{
|
|
306
|
+
x: string;
|
|
307
|
+
}>) => void;
|
|
308
|
+
tooltipClickLabel?: ReactNode;
|
|
255
309
|
}>>;
|
|
256
310
|
|
|
257
311
|
type TypeDonutChartLegendTableProps = Readonly<{
|
|
@@ -324,17 +378,25 @@ declare const LineChart: react.NamedExoticComponent<Readonly<{
|
|
|
324
378
|
|
|
325
379
|
declare const baseChartOptions: Options;
|
|
326
380
|
declare const TIME_SERIES_CHART_HEIGHT = 275;
|
|
381
|
+
declare const timeSeriesChartOptions: Options;
|
|
327
382
|
declare const lineChartOptions: Options;
|
|
328
383
|
declare const areaChartOptions: Options;
|
|
384
|
+
declare const columnChartOptions: Options;
|
|
385
|
+
/**
|
|
386
|
+
* The default series limit for VerticalBarChart.
|
|
387
|
+
* This limit is recommended to maintain chart readability and accessibility.
|
|
388
|
+
* @see {VerticalBarChart}
|
|
389
|
+
*/
|
|
390
|
+
declare const VERTICAL_BAR_CHART_DEFAULT_SERIES_LIMIT = 10;
|
|
329
391
|
declare const DONUT_CHART_HALO_SIZE = 10;
|
|
330
392
|
declare const DONUT_CHART_HEIGHT: number;
|
|
331
393
|
declare const DONUT_CHART_WIDTH: number;
|
|
332
394
|
declare const donutChartOptions: Options;
|
|
333
395
|
|
|
334
|
-
type TypeTimeSeriesOptions = SeriesSplineOptions | SeriesAreasplineOptions;
|
|
335
|
-
declare const transformDataToSeries: ({ data }: {
|
|
336
|
-
data: TypeAreaChartProps["data"] | TypeLineChartProps["data"];
|
|
337
|
-
}, type:
|
|
396
|
+
type TypeTimeSeriesOptions = SeriesSplineOptions | SeriesAreasplineOptions | SeriesColumnOptions;
|
|
397
|
+
declare const transformDataToSeries: ({ data, }: {
|
|
398
|
+
data: TypeAreaChartProps["data"] | TypeLineChartProps["data"] | TypeVerticalBarChartProps["data"];
|
|
399
|
+
}, type: TypeSeriesType) => TypeTimeSeriesOptions[];
|
|
338
400
|
|
|
339
401
|
type TypeTransformTimeSeriesTooltipDataProps = Readonly<{
|
|
340
402
|
context: TooltipFormatterContextObject;
|
|
@@ -343,15 +405,6 @@ type TypeTransformTimeSeriesTooltipDataProps = Readonly<{
|
|
|
343
405
|
type TypeTransformTimeSeriesTooltipDataReturn = TypeChartTooltipProps["data"];
|
|
344
406
|
declare const transformTimeSeriesTooltipData: ({ context, data, }: TypeTransformTimeSeriesTooltipDataProps) => TypeTransformTimeSeriesTooltipDataReturn;
|
|
345
407
|
|
|
346
|
-
type TypeXAxisLabelFormatterProps = Readonly<{
|
|
347
|
-
textLocale: Intl.LocalesArgument;
|
|
348
|
-
tickPositions: AxisTickPositionsArray;
|
|
349
|
-
unitName: ExtendedTimeTicksInfoObject["unitName"];
|
|
350
|
-
value: AxisLabelsFormatterContextObject["value"];
|
|
351
|
-
timeFormat?: TypeChartTimeFormat;
|
|
352
|
-
}>;
|
|
353
|
-
declare const xAxisLabelFormatter: ({ textLocale, tickPositions, unitName, value, timeFormat, }: TypeXAxisLabelFormatterProps) => string;
|
|
354
|
-
|
|
355
408
|
type TypeYAxisLabelFormatterProps = Readonly<{
|
|
356
409
|
numberLocale: Intl.LocalesArgument;
|
|
357
410
|
textLocale: Intl.LocalesArgument;
|
|
@@ -362,6 +415,79 @@ type TypeYAxisLabelFormatterProps = Readonly<{
|
|
|
362
415
|
}>;
|
|
363
416
|
declare const yAxisLabelFormatter: ({ numberLocale, textLocale, tickPositions, value, currency, numberFormat, }: TypeYAxisLabelFormatterProps) => string;
|
|
364
417
|
|
|
418
|
+
type TypeXAxisLabelFormatterProps = Readonly<{
|
|
419
|
+
textLocale: Intl.LocalesArgument;
|
|
420
|
+
tickPositions: AxisTickPositionsArray;
|
|
421
|
+
unitName: ExtendedTimeTicksInfoObject["unitName"];
|
|
422
|
+
value: AxisLabelsFormatterContextObject["value"];
|
|
423
|
+
timeFormat?: TypeChartTimeFormat;
|
|
424
|
+
}>;
|
|
425
|
+
declare const xAxisLabelFormatter: ({ textLocale, tickPositions, unitName, value, timeFormat, }: TypeXAxisLabelFormatterProps) => string;
|
|
426
|
+
|
|
427
|
+
/**
|
|
428
|
+
* Helper to detect if data is hourly time data (all x values are hours of the same day)
|
|
429
|
+
* @param data - Array of series data with points containing x values
|
|
430
|
+
* @returns boolean indicating if all x values are hours of the same day
|
|
431
|
+
*/
|
|
432
|
+
declare function isHourlyTimeData(data: ReadonlyArray<Readonly<{
|
|
433
|
+
points: ReadonlyArray<{
|
|
434
|
+
x: number | string;
|
|
435
|
+
}>;
|
|
436
|
+
}>>): boolean;
|
|
437
|
+
|
|
438
|
+
/**
|
|
439
|
+
* Helper to detect if data is categorical hour data (all x values are hour strings)
|
|
440
|
+
* Supports both 12-hour format ("12 AM", "1 PM") and 24-hour format ("00:00", "13:00", "23:00")
|
|
441
|
+
* @param data - Array of series data with points containing x values
|
|
442
|
+
* @returns boolean indicating if all x values are hour strings
|
|
443
|
+
*/
|
|
444
|
+
declare function isCategoricalHourData(data: ReadonlyArray<Readonly<{
|
|
445
|
+
points: ReadonlyArray<{
|
|
446
|
+
x: number | string;
|
|
447
|
+
}>;
|
|
448
|
+
}>>): boolean;
|
|
449
|
+
|
|
450
|
+
declare const getStorybookCategoricalData: ({ showNulls, showNegativeValues, numberOfSeries, yAxisMax, showCustomColors, showDashedLines, categoryType, }: {
|
|
451
|
+
showNulls: boolean;
|
|
452
|
+
showNegativeValues: boolean;
|
|
453
|
+
numberOfSeries: number;
|
|
454
|
+
yAxisMax: number;
|
|
455
|
+
showCustomColors: boolean;
|
|
456
|
+
showDashedLines: boolean;
|
|
457
|
+
categoryType: "hours" | "hours24" | "days" | "months" | "custom";
|
|
458
|
+
}) => {
|
|
459
|
+
points: {
|
|
460
|
+
x: string;
|
|
461
|
+
y: number | null;
|
|
462
|
+
}[];
|
|
463
|
+
name: string;
|
|
464
|
+
styles: {
|
|
465
|
+
color: string | undefined;
|
|
466
|
+
pattern: string;
|
|
467
|
+
};
|
|
468
|
+
}[];
|
|
469
|
+
|
|
470
|
+
declare const getStorybookSparseTimelineData: ({ showNulls, showNegativeValues, numberOfSeries, yAxisMax, showCustomColors, showDashedLines, numberOfPoints, timeSpanHours, }: {
|
|
471
|
+
showNulls: boolean;
|
|
472
|
+
showNegativeValues: boolean;
|
|
473
|
+
numberOfSeries: number;
|
|
474
|
+
yAxisMax: number;
|
|
475
|
+
showCustomColors: boolean;
|
|
476
|
+
showDashedLines: boolean;
|
|
477
|
+
numberOfPoints?: number;
|
|
478
|
+
timeSpanHours?: number;
|
|
479
|
+
}) => {
|
|
480
|
+
points: {
|
|
481
|
+
x: number;
|
|
482
|
+
y: number | null;
|
|
483
|
+
}[];
|
|
484
|
+
name: string;
|
|
485
|
+
styles: {
|
|
486
|
+
color: string | undefined;
|
|
487
|
+
pattern: string;
|
|
488
|
+
};
|
|
489
|
+
}[];
|
|
490
|
+
|
|
365
491
|
declare const GlobalChartStyleOverrides: styled_components.GlobalStyleComponent<{}, styled_components.DefaultTheme>;
|
|
366
492
|
declare const baseChartStyles: styled_components.FlattenInterpolation<styled_components.ThemedStyledProps<Readonly<{
|
|
367
493
|
$colors: ReadonlyArray<TypeChartStyleColor>;
|
|
@@ -381,6 +507,7 @@ declare const areaChartStyles: styled_components.FlattenInterpolation<styled_com
|
|
|
381
507
|
}>, any>>;
|
|
382
508
|
declare const donutChartStyles: styled_components.FlattenInterpolation<styled_components.ThemedStyledProps<Readonly<{
|
|
383
509
|
$colors: ReadonlyArray<TypeChartStyleColor>;
|
|
510
|
+
$hasOnClick: TypeChartStyleHasOnClick;
|
|
384
511
|
}>, any>>;
|
|
385
512
|
|
|
386
|
-
export { AreaChart, ChartLegend, ChartLegendLabel, ChartTable, ChartTooltip, ChartTooltipFooter, ChartTooltipHeader, ChartTooltipPortal, ChartTooltipTable, ChartTooltipTitle, ColorBox, DONUT_CHART_HALO_SIZE, DONUT_CHART_HEIGHT, DONUT_CHART_WIDTH, DatavizColorBox, DonutChart, DonutChartLegendTable, type ExtendedAxisLabelsFormatterContextObject, type ExtendedTimeTicksInfoObject, GlobalChartStyleOverrides, LineChart, NetworkColorBox, TIME_SERIES_CHART_HEIGHT, type TypeAreaChartProps, type TypeChartDataPoint, type TypeChartDataStyles, type TypeChartLegendLabelProps, type TypeChartLegendProps, type TypeChartNumberFormat, type TypeChartStyleColor, type TypeChartStyleHasOnClick, type TypeChartStylePattern, type TypeChartTableProps, type TypeChartTimeFormat, type TypeChartTooltipDateFormatter, type TypeChartTooltipProps, type TypeChartTooltipTableProps, type TypeChartXAnnotations, type TypeChartXAnnotationsDetails, type TypeChartYAxisLabelFormatter, type TypeColorBoxProps, type TypeDatavizColorBox, type TypeDatavizColorBoxProps, type TypeDonutChartLegendTableProps, type TypeDonutChartProps, type TypeDonutChartTooltipProps, type TypeExtendedChart, type TypeLegendLabel, type TypeLineChartProps, areaChartOptions, areaChartStyles, baseChartOptions, baseChartStyles, donutChartOptions, donutChartStyles, generateChartTooltipPortalId, getDatavizColor, getDatavizColorWithAlpha, getDatavizOpacity, lineChartOptions, lineChartStyles, timeSeriesChartStyles, transformDataToSeries, transformTimeSeriesTooltipData, xAxisLabelFormatter, yAxisLabelFormatter };
|
|
513
|
+
export { AreaChart, ChartLegend, ChartLegendLabel, ChartTable, ChartTooltip, ChartTooltipFooter, ChartTooltipHeader, ChartTooltipPortal, ChartTooltipTable, ChartTooltipTitle, ColorBox, DONUT_CHART_HALO_SIZE, DONUT_CHART_HEIGHT, DONUT_CHART_WIDTH, DatavizColorBox, DonutChart, DonutChartLegendTable, type ExtendedAxisLabelsFormatterContextObject, type ExtendedTimeTicksInfoObject, GlobalChartStyleOverrides, LineChart, NetworkColorBox, TIME_SERIES_CHART_HEIGHT, type TypeAreaChartProps, type TypeChartDataPoint, type TypeChartDataStyles, type TypeChartLegendLabelProps, type TypeChartLegendProps, type TypeChartNumberFormat, type TypeChartStyleColor, type TypeChartStyleHasOnClick, type TypeChartStylePattern, type TypeChartTableProps, type TypeChartTimeFormat, type TypeChartTooltipDateFormatter, type TypeChartTooltipProps, type TypeChartTooltipTableProps, type TypeChartXAnnotations, type TypeChartXAnnotationsDetails, type TypeChartYAxisLabelFormatter, type TypeColorBoxProps, type TypeDatavizColorBox, type TypeDatavizColorBoxProps, type TypeDonutChartLegendTableProps, type TypeDonutChartProps, type TypeDonutChartTooltipProps, type TypeExtendedChart, type TypeLegendLabel, type TypeLineChartProps, type TypeSeriesType, type TypeVerticalBarChartProps, VERTICAL_BAR_CHART_DEFAULT_SERIES_LIMIT, areaChartOptions, areaChartStyles, baseChartOptions, baseChartStyles, columnChartOptions, donutChartOptions, donutChartStyles, generateChartTooltipPortalId, getDatavizColor, getDatavizColorWithAlpha, getDatavizOpacity, getStorybookCategoricalData, getStorybookSparseTimelineData, isCategoricalHourData, isHourlyTimeData, lineChartOptions, lineChartStyles, timeSeriesChartOptions, timeSeriesChartStyles, transformDataToSeries, transformTimeSeriesTooltipData, xAxisLabelFormatter, yAxisLabelFormatter };
|