@redsift/charts 9.3.3 → 9.4.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/index.d.ts +159 -21
- package/index.js +635 -105
- package/index.js.map +1 -1
- package/package.json +2 -2
package/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BrushBehavior, ScaleLinear as ScaleLinear$1, ScaleOrdinal, Arc as Arc$1 } from 'd3';
|
|
1
|
+
import { BrushBehavior, ScaleLinear as ScaleLinear$1, ScaleOrdinal, Arc as Arc$1, ScaleTime as ScaleTime$2, ScalePoint as ScalePoint$2, Line as Line$1 } from 'd3';
|
|
2
2
|
import * as _redsift_design_system from '@redsift/design-system';
|
|
3
3
|
import { ValueOf, Comp, ContainerProps } from '@redsift/design-system';
|
|
4
4
|
import { MutableRefObject, ComponentProps, ReactElement, RefObject, ReactNode } from 'react';
|
|
@@ -21,7 +21,7 @@ interface UseBrushProps {
|
|
|
21
21
|
}
|
|
22
22
|
declare const useBrush: ({ brushRef: propsBrushRef, svgRef, extent, scaleX, scaleY, isBrushable, isGridded, onBrush, onBrushEnd, }: UseBrushProps) => void;
|
|
23
23
|
|
|
24
|
-
type JSONValue = string | number | boolean | {
|
|
24
|
+
type JSONValue = string | number | boolean | Date | {
|
|
25
25
|
[x: string]: JSONValue;
|
|
26
26
|
} | Array<JSONValue> | undefined | null;
|
|
27
27
|
type JSONObject = {
|
|
@@ -33,15 +33,19 @@ type Datum<T> = {
|
|
|
33
33
|
value: number;
|
|
34
34
|
percent?: number;
|
|
35
35
|
};
|
|
36
|
+
type EmptyDatum<T> = {
|
|
37
|
+
key: T;
|
|
38
|
+
value?: number | null;
|
|
39
|
+
percent?: number;
|
|
40
|
+
};
|
|
36
41
|
type CategoryDim = string;
|
|
37
|
-
type
|
|
38
|
-
|
|
39
|
-
number,
|
|
40
|
-
string | undefined | null
|
|
41
|
-
];
|
|
42
|
+
type TwoCategoryDim = [number | string | Date, string | undefined | null];
|
|
43
|
+
type CoordinatesCategoryDim = [number, number, string | undefined | null];
|
|
42
44
|
type CategoryDatum = Datum<CategoryDim>;
|
|
45
|
+
type TwoCategoryDatum = EmptyDatum<TwoCategoryDim>;
|
|
43
46
|
type CoordinatesCategoryDatum = Datum<CoordinatesCategoryDim>;
|
|
44
47
|
type CategoryData = CategoryDatum[];
|
|
48
|
+
type TwoCategoryData = TwoCategoryDatum[];
|
|
45
49
|
type CoordinatesCategoryData = CoordinatesCategoryDatum[];
|
|
46
50
|
type ArcDatum = PieArcDatum<CategoryDatum>;
|
|
47
51
|
type BarDatum = {
|
|
@@ -50,13 +54,34 @@ type BarDatum = {
|
|
|
50
54
|
width?: number;
|
|
51
55
|
};
|
|
52
56
|
type DotDatum = {
|
|
53
|
-
data:
|
|
54
|
-
x: number;
|
|
55
|
-
y
|
|
57
|
+
data: EmptyDatum<CoordinatesCategoryDim | TwoCategoryDim>;
|
|
58
|
+
x: string | number | Date;
|
|
59
|
+
y?: number | null;
|
|
56
60
|
r: number;
|
|
61
|
+
category?: string | null;
|
|
62
|
+
};
|
|
63
|
+
type LinePointDatum = {
|
|
64
|
+
x?: number | string | Date;
|
|
65
|
+
y?: number;
|
|
66
|
+
category?: string | null;
|
|
67
|
+
};
|
|
68
|
+
type Statistic = {
|
|
69
|
+
key: string;
|
|
70
|
+
value: number;
|
|
71
|
+
percent?: number;
|
|
72
|
+
min?: number;
|
|
73
|
+
max?: number;
|
|
74
|
+
values?: number[];
|
|
75
|
+
first?: number;
|
|
76
|
+
last?: number;
|
|
77
|
+
trending?: {
|
|
78
|
+
overall?: number;
|
|
79
|
+
latest?: number;
|
|
80
|
+
};
|
|
57
81
|
};
|
|
82
|
+
type Statistics = Statistic[];
|
|
58
83
|
type LegendItemDatum = {
|
|
59
|
-
data:
|
|
84
|
+
data: Statistic;
|
|
60
85
|
};
|
|
61
86
|
|
|
62
87
|
/** TOOLTIP */
|
|
@@ -65,6 +90,7 @@ declare const TooltipVariant: {
|
|
|
65
90
|
label: string;
|
|
66
91
|
value: string;
|
|
67
92
|
percent: string;
|
|
93
|
+
custom: string;
|
|
68
94
|
};
|
|
69
95
|
type TooltipVariant = ValueOf<typeof TooltipVariant>;
|
|
70
96
|
/** LEGEND */
|
|
@@ -72,6 +98,7 @@ declare const LabelVariant: {
|
|
|
72
98
|
readonly label: "label";
|
|
73
99
|
readonly value: "value";
|
|
74
100
|
readonly percent: "percent";
|
|
101
|
+
readonly custom: "custom";
|
|
75
102
|
};
|
|
76
103
|
type LabelVariant = ValueOf<typeof LabelVariant>;
|
|
77
104
|
|
|
@@ -160,7 +187,7 @@ interface UseColorProps {
|
|
|
160
187
|
/** Theme. */
|
|
161
188
|
theme: ChartTheme;
|
|
162
189
|
/** Name of the field that will be used to categorize the data. */
|
|
163
|
-
category: string;
|
|
190
|
+
category: string | ((d: JSONObject) => string);
|
|
164
191
|
}
|
|
165
192
|
declare const useColor: ({ data, theme, category }: UseColorProps) => ScaleOrdinal<string, string, never>;
|
|
166
193
|
|
|
@@ -342,6 +369,7 @@ interface AxisProps extends Omit<ComponentProps<'g'>, 'scale'> {
|
|
|
342
369
|
position?: AxisPosition;
|
|
343
370
|
/** Scale (d3.js) used to generate the axis. */
|
|
344
371
|
scale: AnyScale;
|
|
372
|
+
tickFormat?: ((d: NumericValue) => string) | ((d: StringValue) => string) | ((d: Date) => string) | ((d: ScaleValue) => string);
|
|
345
373
|
tickPadding?: number;
|
|
346
374
|
tickRotation?: number;
|
|
347
375
|
tickSize?: number;
|
|
@@ -426,7 +454,7 @@ declare const StyledChartContainer: styled_components.StyledComponent<"div", any
|
|
|
426
454
|
declare const StyledChartContainerTitle: styled_components.StyledComponent<_redsift_design_system.Comp<_redsift_design_system.FlexboxProps, HTMLDivElement>, any, ChartContainerProps, never>;
|
|
427
455
|
declare const StyledChartContainerCaption: styled_components.StyledComponent<"p", any, ChartContainerProps, never>;
|
|
428
456
|
|
|
429
|
-
interface LocaleText$
|
|
457
|
+
interface LocaleText$3 {
|
|
430
458
|
emptyChartText: string;
|
|
431
459
|
}
|
|
432
460
|
type BarChartDimensions = ChartDimensions & {
|
|
@@ -455,7 +483,7 @@ interface BarChartProps extends ChartContainerProps {
|
|
|
455
483
|
color?: string;
|
|
456
484
|
}) => string | ReactElement;
|
|
457
485
|
/** Labels and texts. */
|
|
458
|
-
localeText?: LocaleText$
|
|
486
|
+
localeText?: LocaleText$3;
|
|
459
487
|
/** Method to be called on a click on a bar. */
|
|
460
488
|
onBarClick?: (datum: BarDatum) => void;
|
|
461
489
|
/** Orientation of the bar. */
|
|
@@ -484,16 +512,28 @@ declare const StyledBarChartEmptyText: styled_components.StyledComponent<"div",
|
|
|
484
512
|
$textSize: number;
|
|
485
513
|
}, never>;
|
|
486
514
|
|
|
515
|
+
/**
|
|
516
|
+
* Component's variant.
|
|
517
|
+
*/
|
|
518
|
+
declare const DotVariant: {
|
|
519
|
+
readonly plain: "plain";
|
|
520
|
+
readonly hollow: "hollow";
|
|
521
|
+
};
|
|
522
|
+
type DotVariant = ValueOf<typeof DotVariant>;
|
|
487
523
|
/**
|
|
488
524
|
* Component props.
|
|
489
525
|
*/
|
|
490
526
|
interface DotProps extends DataPointProps<DotDatum> {
|
|
491
527
|
/** A linear continuous scale defined over a numeric domain used to determine the x position based on the coordinates. */
|
|
492
|
-
scaleX: ScaleLinear$1<number, number, never>;
|
|
528
|
+
scaleX: ScaleLinear$1<number, number, never> | ScaleTime$2<number, number, never> | ScalePoint$2<string>;
|
|
493
529
|
/** A linear continuous scale defined over a numeric domain used to determine the y position based on the coordinates. */
|
|
494
530
|
scaleY: ScaleLinear$1<number, number, never>;
|
|
531
|
+
/** Variant. */
|
|
532
|
+
variant?: DotVariant;
|
|
495
533
|
}
|
|
496
|
-
type StyledDotProps = StyledDataPointProps & Omit<DotProps, 'scaleX' | 'scaleY'
|
|
534
|
+
type StyledDotProps = StyledDataPointProps & Omit<DotProps, 'scaleX' | 'scaleY'> & {
|
|
535
|
+
$variant: DotProps['variant'];
|
|
536
|
+
};
|
|
497
537
|
|
|
498
538
|
declare const Dot: Comp<DotProps, SVGGElement>;
|
|
499
539
|
|
|
@@ -502,14 +542,14 @@ declare const Dot: Comp<DotProps, SVGGElement>;
|
|
|
502
542
|
*/
|
|
503
543
|
declare const StyledDot: styled_components.StyledComponent<_redsift_design_system.Comp<DataPointProps<any>, SVGGElement>, any, Omit<DataPointProps<any>, "data"> & {
|
|
504
544
|
$clickable: boolean;
|
|
505
|
-
} & Omit<DotProps, "scaleX" | "scaleY"
|
|
545
|
+
} & Omit<DotProps, "scaleX" | "scaleY"> & {
|
|
546
|
+
$variant: DotVariant | undefined;
|
|
547
|
+
}, never>;
|
|
506
548
|
|
|
507
549
|
/**
|
|
508
550
|
* Component props.
|
|
509
551
|
*/
|
|
510
552
|
interface LegendItemProps extends Pick<DataPointProps<LegendItemDatum>, 'color' | 'data' | 'id' | 'index' | 'isSelected' | 'labelDecorator' | 'onClick' | 'previousData' | 'role' | 'tooltipVariant'>, Omit<ComponentProps<'li'>, 'onClick' | 'role'> {
|
|
511
|
-
/** Total used to compute percentage. */
|
|
512
|
-
total?: number;
|
|
513
553
|
/** Variant. */
|
|
514
554
|
variant?: LabelVariant;
|
|
515
555
|
}
|
|
@@ -519,7 +559,7 @@ interface LegendItemProps extends Pick<DataPointProps<LegendItemDatum>, 'color'
|
|
|
519
559
|
*/
|
|
520
560
|
interface LegendProps extends Omit<ComponentProps<'ul'>, 'onClick'>, ContainerProps {
|
|
521
561
|
/** Data. */
|
|
522
|
-
data: (
|
|
562
|
+
data: (Statistic & {
|
|
523
563
|
color: string;
|
|
524
564
|
})[];
|
|
525
565
|
/** Method to determine whether a slice is selected or not. */
|
|
@@ -550,6 +590,104 @@ declare const StyledLegend: styled_components.StyledComponent<"ul", any, Omit<Le
|
|
|
550
590
|
$width?: string | number | undefined;
|
|
551
591
|
}, never>;
|
|
552
592
|
|
|
593
|
+
/**
|
|
594
|
+
* Component props.
|
|
595
|
+
*/
|
|
596
|
+
interface LineProps extends Omit<ComponentProps<'g'>, 'onClick' | 'role'>, Pick<DotProps, 'id' | 'isSelected' | 'role'> {
|
|
597
|
+
/** Line generator used to determine the path of the line. */
|
|
598
|
+
createLine: Line$1<LinePointDatum>;
|
|
599
|
+
/** Points used to compute the line path. */
|
|
600
|
+
data: LinePointDatum[];
|
|
601
|
+
/** Previous data used for animation. */
|
|
602
|
+
previousData?: LinePointDatum[];
|
|
603
|
+
}
|
|
604
|
+
type StyledLineProps = Omit<LineProps, 'createLine' | 'data'>;
|
|
605
|
+
|
|
606
|
+
declare const Line: Comp<LineProps, SVGGElement>;
|
|
607
|
+
|
|
608
|
+
/**
|
|
609
|
+
* Component style.
|
|
610
|
+
*/
|
|
611
|
+
declare const StyledLine: styled_components.StyledComponent<"g", any, StyledLineProps, never>;
|
|
612
|
+
|
|
613
|
+
/**
|
|
614
|
+
* Component's labels variant.
|
|
615
|
+
*/
|
|
616
|
+
declare const LineChartLabelVariant: {
|
|
617
|
+
readonly none: "none";
|
|
618
|
+
readonly externalLabel: "externalLabel";
|
|
619
|
+
readonly externalLabelValue: "externalLabelValue";
|
|
620
|
+
readonly externalLabelPercent: "externalLabelPercent";
|
|
621
|
+
};
|
|
622
|
+
type LineChartLabelVariant = ValueOf<typeof LineChartLabelVariant>;
|
|
623
|
+
interface LocaleText$2 {
|
|
624
|
+
emptyChartText: string;
|
|
625
|
+
}
|
|
626
|
+
type LineChartDimensions = ChartDimensions & {
|
|
627
|
+
fontSize: number;
|
|
628
|
+
};
|
|
629
|
+
/**
|
|
630
|
+
* Component props.
|
|
631
|
+
*/
|
|
632
|
+
interface LineChartProps extends ChartContainerProps {
|
|
633
|
+
/** Dataset to use to generate the chart. */
|
|
634
|
+
data?: TwoCategoryData;
|
|
635
|
+
/** Slice role. Used to indicate that dots are to be considered buttons or links. If an onClick is provided, the dots will have the role `button` unless specifically set to `link` with this prop. */
|
|
636
|
+
dotRole?: DotProps['role'];
|
|
637
|
+
/** Component to use if the chart is empty (replacing the default one). */
|
|
638
|
+
emptyComponent?: ReactNode;
|
|
639
|
+
/** Method to determine whether a dot is selected or not. */
|
|
640
|
+
isDotSelected?: (datum: DotDatum) => boolean | undefined;
|
|
641
|
+
/** Method to override the data labels. */
|
|
642
|
+
labelDecorator?: (datum: DotDatum, props?: {
|
|
643
|
+
index?: number;
|
|
644
|
+
isSelected?: boolean;
|
|
645
|
+
color?: string;
|
|
646
|
+
}) => string | ReactElement;
|
|
647
|
+
/** Define whether the labels should be displayed inside or outside the charts and if they should contain raw or percentage values. */
|
|
648
|
+
labelVariant?: LineChartLabelVariant;
|
|
649
|
+
/** Props to forward to the Legend block. Can be used to make the legend selectable. */
|
|
650
|
+
legendProps?: Omit<LegendProps, 'data' | 'ref' | 'variant' | 'width'>;
|
|
651
|
+
/** Labels and texts. */
|
|
652
|
+
localeText?: LocaleText$2;
|
|
653
|
+
/** Method to be called on a click on a dot. */
|
|
654
|
+
onDotClick?: (datum: DotDatum) => void;
|
|
655
|
+
/** LineChart size. */
|
|
656
|
+
size?: ChartSize | LineChartDimensions;
|
|
657
|
+
/** Reference to the SVG tag. */
|
|
658
|
+
svgRef?: MutableRefObject<SVGSVGElement>;
|
|
659
|
+
/** Color palette to use. You can choose among the list of available color palette or also choose to use the success/warning/danger theme for which you have to specify which key corresponds to which status. */
|
|
660
|
+
theme?: ChartTheme;
|
|
661
|
+
/** Tooltip variant. */
|
|
662
|
+
tooltipVariant?: TooltipVariant;
|
|
663
|
+
/** X axis variant. */
|
|
664
|
+
xAxisVariant?: AxisVariant;
|
|
665
|
+
/** X axis placement. */
|
|
666
|
+
xAxisPlacement?: 'bottom' | 'top' | 'both';
|
|
667
|
+
/** X axis tick format. */
|
|
668
|
+
xAxisTickFormat?: ((d: NumericValue) => string) | ((d: StringValue) => string) | ((d: Date) => string) | ((d: ScaleValue) => string);
|
|
669
|
+
/** X axis tick values. */
|
|
670
|
+
xAxisTickValues?: TicksSpec;
|
|
671
|
+
/** String to Date. */
|
|
672
|
+
dateParser?: (value: string) => Date;
|
|
673
|
+
/** Y axis variant. */
|
|
674
|
+
yAxisVariant?: AxisVariant;
|
|
675
|
+
/** Y axis placement. */
|
|
676
|
+
yAxisPlacement?: 'right' | 'left' | 'both';
|
|
677
|
+
}
|
|
678
|
+
type StyledLineChartProps = LineChartProps & {};
|
|
679
|
+
|
|
680
|
+
declare const LineChart: Comp<LineChartProps, HTMLDivElement>;
|
|
681
|
+
|
|
682
|
+
/**
|
|
683
|
+
* Component style.
|
|
684
|
+
*/
|
|
685
|
+
declare const StyledLineChart: styled_components.StyledComponent<_redsift_design_system.Comp<ChartContainerProps, HTMLDivElement>, any, LineChartProps, never>;
|
|
686
|
+
declare const StyledLineChartEmptyText: styled_components.StyledComponent<"div", any, {
|
|
687
|
+
$maxWidth: number;
|
|
688
|
+
$textSize: number;
|
|
689
|
+
}, never>;
|
|
690
|
+
|
|
553
691
|
/**
|
|
554
692
|
* Component variant.
|
|
555
693
|
*/
|
|
@@ -737,4 +875,4 @@ declare const StyledScatterPlotEmptyText: styled_components.StyledComponent<"div
|
|
|
737
875
|
$textSize: number;
|
|
738
876
|
}, never>;
|
|
739
877
|
|
|
740
|
-
export { AnyScale, Arc, ArcDatum, ArcProps, Arcs, ArcsProps, Axis, AxisPosition, AxisProps, AxisVariant, Bar, BarChart, BarChartDimensions, BarChartProps, BarDatum, BarOrientation, BarProps, CategoryData, CategoryDatum, CategoryDim, ChartContainer, ChartContainerProps, ChartDimensions, ChartSize, ChartTheme, ColorTheme, Coordinates, CoordinatesCategoryData, CoordinatesCategoryDatum, CoordinatesCategoryDim, CustomColorTheme, DataPoint, DataPointProps, Datum, Dot, DotDatum, DotProps, JSONArray, JSONObject, JSONValue, LabelVariant, Legend, LegendItemDatum, LegendProps, NumericValue, PieChart, PieChartDimensions, PieChartLabelVariant, PieChartProps, PieChartVariant, Scale, ScaleBand, ScaleLinear, ScaleLog, ScalePoint, ScaleSymlog, ScaleTime, ScaleTypeToScale, ScaleValue, ScaleWithBandwidth, ScatterPlot, ScatterPlotDimensions, ScatterPlotLabelVariant, ScatterPlotProps, ScatterPlotVariant, StringValue, StyledArc, StyledArcProps, StyledArcs, StyledArcsProps, StyledAxis, StyledAxisProps, StyledBar, StyledBarChart, StyledBarChartEmptyText, StyledBarChartProps, StyledBarProps, StyledChartContainer, StyledChartContainerCaption, StyledChartContainerProps, StyledChartContainerTitle, StyledDataPoint, StyledDataPointProps, StyledDot, StyledDotProps, StyledLegend, StyledLegendProps, StyledPieChart, StyledPieChartCenterText, StyledPieChartEmptyText, StyledPieChartProps, StyledScatterPlot, StyledScatterPlotEmptyText, StyledScatterPlotProps, SuccessDangerColorTheme, TicksSpec, TooltipVariant, UseBrushProps, UseColorProps, UseFormatCategoricalDataProps, UseZoomProps, empty, getColorScale, monochrome, scheme, successDangerScheme, useBrush, useColor, useFormatCategoricalData, useZoom };
|
|
878
|
+
export { AnyScale, Arc, ArcDatum, ArcProps, Arcs, ArcsProps, Axis, AxisPosition, AxisProps, AxisVariant, Bar, BarChart, BarChartDimensions, BarChartProps, BarDatum, BarOrientation, BarProps, CategoryData, CategoryDatum, CategoryDim, ChartContainer, ChartContainerProps, ChartDimensions, ChartSize, ChartTheme, ColorTheme, Coordinates, CoordinatesCategoryData, CoordinatesCategoryDatum, CoordinatesCategoryDim, CustomColorTheme, DataPoint, DataPointProps, Datum, Dot, DotDatum, DotProps, DotVariant, EmptyDatum, JSONArray, JSONObject, JSONValue, LabelVariant, Legend, LegendItemDatum, LegendProps, Line, LineChart, LineChartDimensions, LineChartLabelVariant, LineChartProps, LinePointDatum, LineProps, NumericValue, PieChart, PieChartDimensions, PieChartLabelVariant, PieChartProps, PieChartVariant, Scale, ScaleBand, ScaleLinear, ScaleLog, ScalePoint, ScaleSymlog, ScaleTime, ScaleTypeToScale, ScaleValue, ScaleWithBandwidth, ScatterPlot, ScatterPlotDimensions, ScatterPlotLabelVariant, ScatterPlotProps, ScatterPlotVariant, Statistic, Statistics, StringValue, StyledArc, StyledArcProps, StyledArcs, StyledArcsProps, StyledAxis, StyledAxisProps, StyledBar, StyledBarChart, StyledBarChartEmptyText, StyledBarChartProps, StyledBarProps, StyledChartContainer, StyledChartContainerCaption, StyledChartContainerProps, StyledChartContainerTitle, StyledDataPoint, StyledDataPointProps, StyledDot, StyledDotProps, StyledLegend, StyledLegendProps, StyledLine, StyledLineChart, StyledLineChartEmptyText, StyledLineChartProps, StyledLineProps, StyledPieChart, StyledPieChartCenterText, StyledPieChartEmptyText, StyledPieChartProps, StyledScatterPlot, StyledScatterPlotEmptyText, StyledScatterPlotProps, SuccessDangerColorTheme, TicksSpec, TooltipVariant, TwoCategoryData, TwoCategoryDatum, TwoCategoryDim, UseBrushProps, UseColorProps, UseFormatCategoricalDataProps, UseZoomProps, empty, getColorScale, monochrome, scheme, successDangerScheme, useBrush, useColor, useFormatCategoricalData, useZoom };
|