@redsift/charts 7.8.1 → 8.0.0-alpha.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/index.d.ts CHANGED
@@ -1,9 +1,120 @@
1
- import { PieArcDatum as PieArcDatum$1 } from 'd3-shape';
1
+ import { BrushBehavior, ScaleLinear as ScaleLinear$1, ScaleOrdinal, Arc as Arc$1 } from 'd3';
2
2
  import * as _redsift_design_system from '@redsift/design-system';
3
- import { ValueOf, Comp } from '@redsift/design-system';
4
- import { ScaleOrdinal, ScaleLinear } from 'd3';
5
- import { ComponentProps } from 'react';
3
+ import { ValueOf, Comp, StylingProps } from '@redsift/design-system';
4
+ import { MutableRefObject, ComponentProps, ReactElement, ReactNode } from 'react';
5
+ import { PieArcDatum } from 'd3-shape';
6
+ import * as d3_scale from 'd3-scale';
7
+ import { ScaleLinear as ScaleLinear$2, ScaleLogarithmic, ScaleSymLog, ScalePoint as ScalePoint$1, ScaleBand as ScaleBand$1, ScaleTime as ScaleTime$1 } from 'd3-scale';
6
8
  import * as styled_components from 'styled-components';
9
+ import * as _react_spring_web from '@react-spring/web';
10
+
11
+ interface UseBrushProps {
12
+ brushRef: MutableRefObject<BrushBehavior<unknown> | undefined>;
13
+ svgRef: MutableRefObject<SVGSVGElement | SVGGElement | undefined>;
14
+ extent?: [[number, number], [number, number]];
15
+ scaleX: ScaleLinear$1<number, number>;
16
+ scaleY: ScaleLinear$1<number, number>;
17
+ isBrushable?: boolean;
18
+ isGridded?: boolean;
19
+ onBrush?: (selection: [[number, number], [number, number]] | null, scaleX: ScaleLinear$1<number, number>, scaleY: ScaleLinear$1<number, number>) => void;
20
+ onBrushEnd?: (selection: [[number, number], [number, number]] | null, scaleX: ScaleLinear$1<number, number>, scaleY: ScaleLinear$1<number, number>) => void;
21
+ }
22
+ declare const useBrush: ({ brushRef: propsBrushRef, svgRef, extent, scaleX, scaleY, isBrushable, isGridded, onBrush, onBrushEnd, }: UseBrushProps) => void;
23
+
24
+ type JSONValue = string | number | boolean | {
25
+ [x: string]: JSONValue;
26
+ } | Array<JSONValue> | undefined | null;
27
+ type JSONObject = {
28
+ [x: string]: JSONValue;
29
+ };
30
+ type JSONArray = Array<JSONObject>;
31
+ type Datum<T> = {
32
+ key: T;
33
+ value: number;
34
+ percent?: number;
35
+ };
36
+ type CategoryDim = string;
37
+ type CoordinatesCategoryDim = [
38
+ number,
39
+ number,
40
+ string | undefined | null
41
+ ];
42
+ type CategoryDatum = Datum<CategoryDim>;
43
+ type CoordinatesCategoryDatum = Datum<CoordinatesCategoryDim>;
44
+ type CategoryData = CategoryDatum[];
45
+ type CoordinatesCategoryData = CoordinatesCategoryDatum[];
46
+ type ArcDatum = PieArcDatum<CategoryDatum>;
47
+ type BarDatum = {
48
+ data: CategoryDatum;
49
+ height?: number;
50
+ width?: number;
51
+ };
52
+ type DotDatum = {
53
+ data: CoordinatesCategoryDatum;
54
+ x: number;
55
+ y: number;
56
+ r: number;
57
+ };
58
+
59
+ /** TOOLTIP */
60
+ declare const TooltipVariant: {
61
+ none: string;
62
+ label: string;
63
+ value: string;
64
+ percent: string;
65
+ };
66
+ type TooltipVariant = ValueOf<typeof TooltipVariant>;
67
+ /** LEGEND */
68
+ declare const LabelVariant: {
69
+ readonly label: "label";
70
+ readonly value: "value";
71
+ readonly percent: "percent";
72
+ };
73
+ type LabelVariant = ValueOf<typeof LabelVariant>;
74
+
75
+ type Coordinates = {
76
+ x: number;
77
+ y: number;
78
+ };
79
+ type NumericValue = {
80
+ valueOf(): number;
81
+ };
82
+ type StringValue = {
83
+ toString(): string;
84
+ };
85
+ type ScaleValue = NumericValue | StringValue | Date;
86
+ interface ScaleLinear<Output> extends ScaleLinear$2<number, Output, never> {
87
+ type: 'linear';
88
+ stacked: boolean;
89
+ }
90
+ interface ScaleLog extends ScaleLogarithmic<number, number> {
91
+ type: 'log';
92
+ }
93
+ interface ScaleSymlog extends ScaleSymLog<number, number> {
94
+ type: 'symlog';
95
+ }
96
+ interface ScalePoint<Input extends StringValue> extends ScalePoint$1<Input> {
97
+ type: 'point';
98
+ }
99
+ interface ScaleBand<Input extends StringValue> extends ScaleBand$1<Input> {
100
+ type: 'band';
101
+ }
102
+ interface ScaleTime<Input> extends ScaleTime$1<Input, number> {
103
+ type: 'time';
104
+ useUTC: boolean;
105
+ }
106
+ interface ScaleTypeToScale<Input, Output> {
107
+ linear: Input extends NumericValue ? ScaleLinear<Output> : never;
108
+ log: Input extends NumericValue ? ScaleLog : never;
109
+ symlog: Input extends NumericValue ? ScaleSymlog : never;
110
+ point: Input extends StringValue ? ScalePoint<Input> : never;
111
+ band: Input extends StringValue ? ScaleBand<Input> : never;
112
+ time: Input extends StringValue | Date ? ScaleTime<Input> : never;
113
+ }
114
+ type Scale<Input, Output> = ScaleTypeToScale<Input, Output>[keyof ScaleTypeToScale<Input, Output>];
115
+ type AnyScale = Scale<any, any>;
116
+ type ScaleWithBandwidth = ScaleBand<any> | ScalePoint<any>;
117
+ type TicksSpec = number | string | ScaleValue[];
7
118
 
8
119
  type ChartDimensions = {
9
120
  width: number;
@@ -13,15 +124,21 @@ type ChartDimensions = {
13
124
  marginBottom?: number;
14
125
  marginLeft?: number;
15
126
  };
16
- type Datum = {
17
- name: string;
18
- value: number;
127
+ declare const ChartSize: {
128
+ readonly small: "small";
129
+ readonly medium: "medium";
130
+ readonly large: "large";
19
131
  };
20
- type PieArcDatum = PieArcDatum$1<Datum>;
132
+ type ChartSize = ValueOf<typeof ChartSize>;
133
+
21
134
  declare const ColorTheme: {
22
135
  readonly default: "default";
23
136
  readonly dark: "dark";
24
137
  readonly darker: "darker";
138
+ readonly darkerer: "darkerer";
139
+ readonly light: "light";
140
+ readonly lighter: "lighter";
141
+ readonly lighterer: "lighterer";
25
142
  readonly monochrome: "monochrome";
26
143
  };
27
144
  type ColorTheme = ValueOf<typeof ColorTheme>;
@@ -31,14 +148,65 @@ type SuccessDangerColorTheme = {
31
148
  danger: string;
32
149
  neutral?: string;
33
150
  };
151
+ type CustomColorTheme = Record<string, string>;
152
+ type ChartTheme = ColorTheme | SuccessDangerColorTheme | CustomColorTheme;
153
+
154
+ interface UseColorProps {
155
+ /** Dataset to use to generate the chart. */
156
+ data: JSONArray;
157
+ /** Theme. */
158
+ theme: ChartTheme;
159
+ /** Name of the field that will be used to categorize the data. */
160
+ category: string;
161
+ }
162
+ declare const useColor: ({ data, theme, category }: UseColorProps) => ScaleOrdinal<string, string, never> | undefined;
163
+
164
+ interface UseFormatCategoricalDataProps {
165
+ /** Dataset to use to generate the chart, should be a list of objects containing a key and a value. */
166
+ data: CategoryData;
167
+ /** Theme. */
168
+ theme: ChartTheme;
169
+ /** Number of categories to use, the rest being put into a new category called "Others". */
170
+ caping?: number;
171
+ /** Whether a category should be displayed for categories that has been removed by the caping option. Optionaly, this prop can be used to change the label of this category. */
172
+ others?: boolean | string;
173
+ }
174
+ declare const useFormatCategoricalData: ({ data, caping, others, theme, }: UseFormatCategoricalDataProps) => {
175
+ data: CategoryData;
176
+ colorScale: d3_scale.ScaleOrdinal<string, string, never> | undefined;
177
+ };
34
178
 
35
- declare const monochrome = "#B6DAEE";
179
+ interface UseZoomProps {
180
+ svgRef: MutableRefObject<SVGSVGElement | undefined>;
181
+ scaleX: ScaleLinear$1<number, number>;
182
+ scaleY: ScaleLinear$1<number, number>;
183
+ defaultTransform?: {
184
+ k: number;
185
+ x: number;
186
+ y: number;
187
+ };
188
+ onZoom?: () => void;
189
+ }
190
+ declare const useZoom: ({ svgRef, scaleX, scaleY, defaultTransform, onZoom, }: UseZoomProps) => {
191
+ transform: {
192
+ k: number;
193
+ x: number;
194
+ y: number;
195
+ };
196
+ scaleX: ScaleLinear$1<number, number, never>;
197
+ scaleY: ScaleLinear$1<number, number, never>;
198
+ };
199
+
200
+ declare const monochrome = "#73C5EB";
201
+ declare const empty = "#BFBFBF";
36
202
  declare const scheme: {
37
203
  default: string[];
38
204
  dark: string[];
39
205
  darker: string[];
206
+ darkerer: string[];
40
207
  light: string[];
41
208
  lighter: string[];
209
+ lighterer: string[];
42
210
  monochrome: string[];
43
211
  empty: string[];
44
212
  };
@@ -48,123 +216,259 @@ declare const successDangerScheme: {
48
216
  danger: string;
49
217
  neutral: string;
50
218
  };
51
- declare const getColorScale: (theme: ColorTheme | SuccessDangerColorTheme, isEmpty?: boolean) => ScaleOrdinal<string, string>;
219
+ declare const getColorScale: (theme: ChartTheme, domain?: string[], isEmpty?: boolean) => ScaleOrdinal<string, string>;
52
220
 
53
221
  /**
54
- * Component size.
222
+ * Component props.
55
223
  */
56
- declare const HorizontalBarChartSize: {
57
- readonly small: "small";
58
- readonly medium: "medium";
59
- readonly large: "large";
224
+ interface DataPointProps<T> extends Omit<ComponentProps<'g'>, 'onClick' | 'scale'> {
225
+ /** Color of the DataPoint. */
226
+ color?: string;
227
+ /** Data. Also state to which the component should end the animation, if any. */
228
+ data: T;
229
+ /** Id. Used for accessibility. */
230
+ id?: string;
231
+ /** Position in the list of siblings. Used for placement and selection. */
232
+ index?: number;
233
+ /** Whether the component is selected or not. Used only if the component is selectable. Set to `undefined` to make nor selected nor unselected. */
234
+ isSelected?: boolean;
235
+ /** Method modifying the label before displaying it. */
236
+ labelDecorator?: (data: T) => string;
237
+ /** Method called when a click or keydown occurs on the component. */
238
+ onClick?: (data: T) => void;
239
+ /** State from which the component should start the animation, if any. */
240
+ previousData?: T;
241
+ /** Role. Will be set to 'button' if onClick is provided. If 'option', then the component becomes selectable. */
242
+ role?: 'button' | 'link' | 'option';
243
+ /** Tooltip variant. */
244
+ tooltipVariant?: TooltipVariant;
245
+ }
246
+ type StyledDataPointProps = Omit<DataPointProps<any>, 'data'> & {
247
+ $clickable: boolean;
60
248
  };
61
- type HorizontalBarChartSize = ValueOf<typeof HorizontalBarChartSize>;
249
+
62
250
  /**
63
- * Component theme.
251
+ * Component props.
64
252
  */
65
- declare const HorizontalBarChartTheme: {
66
- readonly default: "default"; /**
67
- * Component theme.
68
- */
69
- readonly dark: "dark";
70
- readonly darker: "darker";
71
- readonly monochrome: "monochrome";
253
+ interface ArcProps extends DataPointProps<ArcDatum> {
254
+ /** Arc generator used to determine the width of the arc. */
255
+ createArc: Arc$1<any, ArcDatum>;
256
+ /** Whether the arc has a stroke or not. Used to create a gap between two siblings. */
257
+ hasStroke?: boolean;
258
+ }
259
+ type StyledArcProps = StyledDataPointProps & Omit<ArcProps, 'createArc'> & {
260
+ $hasStroke: ArcProps['hasStroke'];
72
261
  };
73
- type HorizontalBarChartTheme = ValueOf<typeof HorizontalBarChartTheme>;
262
+
263
+ declare const Arc: Comp<ArcProps, SVGGElement>;
264
+
74
265
  /**
75
- * Tooltip label variant.
266
+ * Component style.
76
267
  */
77
- declare const HorizontalBarChartTooltipVariant: {
78
- none: string;
79
- label: string;
80
- value: string;
81
- percent: string;
268
+ declare const StyledArc: styled_components.StyledComponent<_redsift_design_system.Comp<DataPointProps<any>, SVGGElement>, any, Omit<DataPointProps<any>, "data"> & {
269
+ $clickable: boolean;
270
+ } & Omit<ArcProps, "createArc"> & {
271
+ $hasStroke: boolean | undefined;
272
+ }, never>;
273
+
274
+ /**
275
+ * Component props.
276
+ */
277
+ interface ArcsProps extends Omit<ComponentProps<'g'>, 'onClick' | 'role'>, Pick<ArcProps, 'id' | 'labelDecorator' | 'onClick' | 'role' | 'hasStroke' | 'tooltipVariant'> {
278
+ /** Arc props. */
279
+ arcs: Omit<ArcProps, 'ref'>[];
280
+ /** Whether arcs have internal labels or not. */
281
+ hasLabels?: boolean;
282
+ }
283
+ type StyledArcsProps = Omit<ArcsProps, 'arcs'> & {};
284
+
285
+ declare const Arcs: Comp<ArcsProps, SVGGElement>;
286
+
287
+ /**
288
+ * Component style.
289
+ */
290
+ declare const StyledArcs: styled_components.StyledComponent<"g", any, Omit<ArcsProps, "arcs">, never>;
291
+
292
+ /**
293
+ * Component variant.
294
+ */
295
+ declare const AxisPosition: {
296
+ top: string;
297
+ right: string;
298
+ bottom: string;
299
+ left: string;
82
300
  };
83
- type HorizontalBarChartTooltipVariant = ValueOf<typeof HorizontalBarChartTooltipVariant>;
84
- interface LocaleText$1 {
301
+ type AxisPosition = ValueOf<typeof AxisPosition>;
302
+ /**
303
+ * Component props.
304
+ */
305
+ interface AxisProps extends Omit<ComponentProps<'g'>, 'scale'> {
306
+ areLabelsRotated?: boolean;
307
+ format?: string;
308
+ legend?: string;
309
+ legendOffset?: number;
310
+ legendPosition?: 'start' | 'middle' | 'end';
311
+ /** Length of the axis. */
312
+ length?: number;
313
+ /** Position of axis. top|bottom means this is an x axis, right|left means this is an y axis. */
314
+ position?: AxisPosition;
315
+ /** Scale (d3.js) used to generate the axis. */
316
+ scale: AnyScale;
317
+ tickPadding?: number;
318
+ tickRotation?: number;
319
+ tickSize?: number;
320
+ tickValues?: TicksSpec;
321
+ /** X position. */
322
+ x?: number;
323
+ /** Y position. */
324
+ y?: number;
325
+ }
326
+ type StyledAxisProps = Omit<AxisProps, 'areXLabelsRotated' | 'size' | 'scale'> & {};
327
+
328
+ declare const Axis: Comp<AxisProps, SVGGElement>;
329
+
330
+ /**
331
+ * Component style.
332
+ */
333
+ declare const StyledAxis: styled_components.StyledComponent<_react_spring_web.AnimatedComponent<"g">, any, Omit<AxisProps, "size" | "scale" | "areXLabelsRotated">, never>;
334
+
335
+ /**
336
+ * Component variant.
337
+ */
338
+ declare const BarOrientation: {
339
+ horizontal: string;
340
+ vertical: string;
341
+ };
342
+ type BarOrientation = ValueOf<typeof BarOrientation>;
343
+ /**
344
+ * Component props.
345
+ */
346
+ interface BarProps extends DataPointProps<BarDatum> {
347
+ /** Gap between two siblings. */
348
+ gap?: number;
349
+ /** Height of the bar in horizontal orientation. */
350
+ height?: number;
351
+ /** Orientation of the bar. */
352
+ orientation?: BarOrientation;
353
+ /** A linear continuous scale defined over a numeric domain used to determine the width or height of the bar (depending on the orientation). */
354
+ scale: ScaleLinear$1<number, number, never>;
355
+ /** Width of the bar in vertical orientation. */
356
+ width?: number;
357
+ }
358
+ type StyledBarProps = StyledDataPointProps & Omit<BarProps, 'scale'>;
359
+
360
+ declare const Bar: Comp<BarProps, SVGGElement>;
361
+
362
+ /**
363
+ * Component style.
364
+ */
365
+ declare const StyledBar: styled_components.StyledComponent<_redsift_design_system.Comp<DataPointProps<any>, SVGGElement>, any, Omit<DataPointProps<any>, "data"> & {
366
+ $clickable: boolean;
367
+ } & Omit<BarProps, "scale">, never>;
368
+
369
+ /**
370
+ * Component props.
371
+ */
372
+ interface ChartContainerProps extends Omit<ComponentProps<'div'>, 'title'>, StylingProps {
373
+ /** Caption. */
374
+ caption?: string;
375
+ /** Id. */
376
+ id?: string;
377
+ /** Method called when the Reset button is displayed (defines whether or not the button should be displayed). */
378
+ onReset?: () => void;
379
+ /** Title. */
380
+ title?: string | ReactElement;
381
+ }
382
+ type StyledChartContainerProps = ChartContainerProps & {};
383
+
384
+ declare const ChartContainer: Comp<ChartContainerProps, HTMLDivElement>;
385
+
386
+ /**
387
+ * Component style.
388
+ */
389
+ declare const StyledChartContainer: styled_components.StyledComponent<"div", any, ChartContainerProps, never>;
390
+ declare const StyledChartContainerTitle: styled_components.StyledComponent<_redsift_design_system.Comp<_redsift_design_system.FlexboxProps, HTMLDivElement>, any, ChartContainerProps, never>;
391
+ declare const StyledChartContainerCaption: styled_components.StyledComponent<"p", any, ChartContainerProps, never>;
392
+
393
+ /**
394
+ * Component props.
395
+ */
396
+ interface LegendProps extends ComponentProps<'ul'> {
397
+ /** Data. */
398
+ data: (CategoryDatum & {
399
+ color: string;
400
+ })[];
401
+ /** Variant. */
402
+ variant?: LabelVariant;
403
+ /** Width. */
404
+ width?: string;
405
+ }
406
+ type StyledLegendProps = Omit<LegendProps, 'data'> & {
407
+ $width?: LegendProps['width'];
408
+ };
409
+
410
+ declare const Legend: Comp<LegendProps, HTMLUListElement>;
411
+
412
+ /**
413
+ * Component style.
414
+ */
415
+ declare const StyledLegend: styled_components.StyledComponent<"ul", any, Omit<LegendProps, "data"> & {
416
+ $width?: string | undefined;
417
+ }, never>;
418
+ declare const StyledLabel: styled_components.StyledComponent<"li", any, {
419
+ $color: string;
420
+ }, never>;
421
+
422
+ interface LocaleText$2 {
85
423
  emptyChartText: string;
86
424
  }
425
+ type BarChartDimensions = ChartDimensions & {
426
+ fontSize: number;
427
+ };
87
428
  /**
88
429
  * Component props.
89
430
  */
90
- interface HorizontalBarChartProps extends ComponentProps<'div'> {
431
+ interface BarChartProps extends ChartContainerProps {
91
432
  /** Whether the x axis labels are rotated or not. */
92
433
  areXLabelsRotated?: boolean;
93
434
  /** Number of categories to use, the rest being put into a new category called "Others". */
94
435
  caping?: number;
95
- /** Caption. */
96
- caption?: string;
97
- /** Dataset to use to generate the chart, should be a list of objects containing a name and a value. */
98
- data: Datum[];
436
+ /** Dataset to use to generate the chart, should be a list of objects containing a key and a value. */
437
+ data?: CategoryData;
438
+ /** Component to use if the chart is empty (replacing the default one). */
439
+ emptyComponent?: ReactNode;
440
+ /** Method to determine whether a slice is selected or not. */
441
+ isBarSelected?: (datum: BarDatum) => void;
442
+ /** Method to override the data labels. */
443
+ labelDecorator?: (datum: BarDatum) => string;
99
444
  /** Labels and texts. */
100
- localeText?: LocaleText$1;
445
+ localeText?: LocaleText$2;
101
446
  /** Method to be called on a click on a bar. */
102
- onBarClick?: (data: Datum) => void;
447
+ onBarClick?: (datum: BarDatum) => void;
103
448
  /** Whether a category should be displayed for categories that has been removed by the caping option. Optionaly, this prop can be used to change the label of this category. */
104
449
  others?: boolean | string;
105
- /** HorizontalBarChart size. */
106
- size?: HorizontalBarChartSize;
450
+ /** BarChart size. */
451
+ size?: ChartSize | BarChartDimensions;
107
452
  /** Bar role. Used to indicate that bars are to be considered buttons or links. If an onClick is provided, the bars will have the role `button` unless specifically set to `link` with this prop. */
108
- barRole?: 'button' | 'link';
453
+ barRole?: BarProps['role'];
109
454
  /** 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. */
110
- theme?: HorizontalBarChartTheme | SuccessDangerColorTheme;
111
- /** Title. */
112
- title?: string;
455
+ theme?: ChartTheme;
113
456
  /** Tooltip variant. */
114
- tooltipVariant?: HorizontalBarChartTooltipVariant;
115
- }
116
- type StyledHorizontalBarChartProps = Omit<HorizontalBarChartProps, 'data'> & {};
117
- interface HorizontalBarChartBarProps extends ComponentProps<'g'> {
118
- chartId: string;
119
- color: string;
120
- data: Datum;
121
- gap: number;
122
- height: number;
123
- index: number;
124
- isEmpty: boolean;
125
- onClick?: () => void;
126
- role?: HorizontalBarChartProps['barRole'];
127
- showTooltip: boolean;
128
- tooltipLabelOnly: boolean;
129
- tooltipPercent: number | null;
130
- width: number;
131
- }
132
- type StyledHorizontalBarChartBarProps = Omit<HorizontalBarChartBarProps, 'chartId' | 'color' | 'data' | 'gap' | 'height' | 'index' | 'isEmpty' | 'showTooltip' | 'tooltipPercent' | 'tooltipLabelOnly' | 'width'> & {
133
- $clickable: boolean;
134
- };
135
- interface HorizontalBarChartAxisBottomProps extends ComponentProps<'g'> {
136
- areXLabelsRotated: boolean;
137
- chartHeight: number;
138
- d3scale: ScaleLinear<number, number>;
457
+ tooltipVariant?: TooltipVariant;
139
458
  }
140
- type StyledHorizontalBarChartAxisBottomProps = Omit<HorizontalBarChartAxisBottomProps, 'areXLabelsRotated' | 'chartHeight' | 'd3scale'> & {};
459
+ type StyledBarChartProps = BarChartProps & {};
141
460
 
142
- declare const HorizontalBarChart: Comp<HorizontalBarChartProps, HTMLDivElement>;
461
+ declare const BarChart: Comp<BarChartProps, HTMLDivElement>;
143
462
 
144
463
  /**
145
464
  * Component style.
146
465
  */
147
- declare const StyledHorizontalBarChart: styled_components.StyledComponent<"div", any, Omit<HorizontalBarChartProps, "data">, never>;
148
- declare const StyledHorizontalBarChartTitle: styled_components.StyledComponent<_redsift_design_system.Comp<_redsift_design_system.FlexboxProps, HTMLDivElement>, any, Omit<HorizontalBarChartProps, "data">, never>;
149
- declare const StyledHorizontalBarChartCaption: styled_components.StyledComponent<"p", any, Omit<HorizontalBarChartProps, "data">, never>;
150
- declare const StyledHorizontalBarChartEmptyText: styled_components.StyledComponent<"div", any, {
466
+ declare const StyledBarChart: styled_components.StyledComponent<_redsift_design_system.Comp<ChartContainerProps, HTMLDivElement>, any, BarChartProps, never>;
467
+ declare const StyledBarChartEmptyText: styled_components.StyledComponent<"div", any, {
151
468
  $maxWidth: number;
152
469
  $textSize: number;
153
470
  }, never>;
154
- declare const StyledHorizontalBarChartBar: styled_components.StyledComponent<"g", any, Omit<HorizontalBarChartBarProps, "height" | "width" | "gap" | "data" | "color" | "chartId" | "index" | "isEmpty" | "showTooltip" | "tooltipPercent" | "tooltipLabelOnly"> & {
155
- $clickable: boolean;
156
- }, never>;
157
- declare const StyledHorizontalBarChartAxisBottom: styled_components.StyledComponent<"g", any, {}, never>;
158
471
 
159
- /**
160
- * Component size.
161
- */
162
- declare const PieChartSize: {
163
- readonly small: "small";
164
- readonly medium: "medium";
165
- readonly large: "large";
166
- };
167
- type PieChartSize = ValueOf<typeof PieChartSize>;
168
472
  /**
169
473
  * Component variant.
170
474
  */
@@ -186,51 +490,40 @@ declare const PieChartLabelVariant: {
186
490
  readonly externalLabelPercent: "externalLabelPercent";
187
491
  };
188
492
  type PieChartLabelVariant = ValueOf<typeof PieChartLabelVariant>;
189
- /**
190
- * Component theme.
191
- */
192
- declare const PieChartTheme: {
193
- readonly default: "default";
194
- readonly dark: "dark";
195
- readonly darker: "darker";
196
- readonly monochrome: "monochrome";
197
- };
198
- type PieChartTheme = ValueOf<typeof PieChartTheme>;
199
- /**
200
- * Tooltip label variant.
201
- */
202
- declare const PieChartTooltipVariant: {
203
- none: string;
204
- label: string;
205
- value: string;
206
- percent: string;
207
- };
208
- type PieChartTooltipVariant = ValueOf<typeof PieChartTooltipVariant>;
209
- interface LocaleText {
493
+ interface LocaleText$1 {
210
494
  emptyChartText: string;
211
495
  }
496
+ type PieChartDimensions = ChartDimensions & {
497
+ smallFontSize: number;
498
+ fontSize: number;
499
+ innerRadius: number;
500
+ };
212
501
  /**
213
502
  * Component props.
214
503
  */
215
- interface PieChartProps extends ComponentProps<'div'> {
504
+ interface PieChartProps extends ChartContainerProps {
216
505
  /** Number of categories to use, the rest being put into a new category called "Others". */
217
506
  caping?: number;
218
- /** Caption. */
219
- caption?: string;
220
- /** Dataset to use to generate the chart, should be a list of objects containing a name and a value. */
221
- data: Datum[];
507
+ /** Dataset to use to generate the chart, should be a list of objects containing a key and a value. */
508
+ data?: CategoryData;
509
+ /** Component to use if the chart is empty (replacing the default one). */
510
+ emptyComponent?: ReactNode;
511
+ /** Method to determine whether a slice is selected or not. */
512
+ isSliceSelected?: (datum: ArcDatum) => boolean | undefined;
513
+ /** Method to override the data labels. */
514
+ labelDecorator?: (datum: ArcDatum) => string;
222
515
  /** Define whether the labels should be displayed inside or outside the charts and if they should contain raw or percentage values. */
223
516
  labelVariant?: PieChartLabelVariant;
224
517
  /** Labels and texts. */
225
- localeText?: LocaleText;
518
+ localeText?: LocaleText$1;
226
519
  /** Method to be called on a click on a slice. */
227
- onSliceClick?: (data: Datum) => void;
520
+ onSliceClick?: (datum: ArcDatum) => void;
228
521
  /** Whether a category should be displayed for categories that has been removed by the caping option. Optionaly, this prop can be used to change the label of this category. */
229
522
  others?: boolean | string;
230
523
  /** PieChart size. */
231
- size?: PieChartSize;
524
+ size?: ChartSize | PieChartDimensions;
232
525
  /** Slice role. Used to indicate that slices are to be considered buttons or links. If an onClick is provided, the slices will have the role `button` unless specifically set to `link` with this prop. */
233
- sliceRole?: 'button' | 'link';
526
+ sliceRole?: ArcProps['role'];
234
527
  /** Secondary text to be displayed in the middle of the chart, between the main text and subtext. Recommended to be used with donut variants only. */
235
528
  middleText?: string;
236
529
  /** Secondary text to be displayed in the middle of the chart, above the main text. Recommended to be used with `donut` variants only. */
@@ -238,42 +531,20 @@ interface PieChartProps extends ComponentProps<'div'> {
238
531
  /** Main text to be displayed in the middle of the chart. Recommended to be used with `donut` variants only. */
239
532
  text?: string;
240
533
  /** 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. */
241
- theme?: PieChartTheme | SuccessDangerColorTheme;
242
- /** Title. */
243
- title?: string;
534
+ theme?: ChartTheme;
244
535
  /** PieChart variant. */
245
536
  variant?: PieChartVariant;
246
537
  /** Tooltip variant. */
247
- tooltipVariant?: PieChartTooltipVariant;
248
- }
249
- type StyledPieChartProps = Omit<PieChartProps, 'data'> & {};
250
- interface PieChartArcProps extends ComponentProps<'g'> {
251
- chartId: string;
252
- color: string;
253
- data: Datum;
254
- index: number;
255
- onClick?: () => void;
256
- path: string;
257
- role?: PieChartProps['sliceRole'];
258
- spaced?: boolean;
259
- showTooltip: boolean;
260
- tooltipPercent: number | null;
261
- tooltipLabelOnly: boolean;
262
- isEmpty: boolean;
538
+ tooltipVariant?: TooltipVariant;
263
539
  }
264
- type StyledPieChartArcProps = Omit<PieChartArcProps, 'chartId' | 'color' | 'data' | 'index' | 'path' | 'spaced' | 'showTooltip' | 'tooltipPercent' | 'tooltipLabelOnly' | 'isEmpty'> & {
265
- $spaced: boolean;
266
- $clickable: boolean;
267
- };
540
+ type StyledPieChartProps = PieChartProps & {};
268
541
 
269
542
  declare const PieChart: Comp<PieChartProps, HTMLDivElement>;
270
543
 
271
544
  /**
272
545
  * Component style.
273
546
  */
274
- declare const StyledPieChart: styled_components.StyledComponent<"div", any, Omit<PieChartProps, "data">, never>;
275
- declare const StyledPieChartTitle: styled_components.StyledComponent<_redsift_design_system.Comp<_redsift_design_system.FlexboxProps, HTMLDivElement>, any, Omit<PieChartProps, "data">, never>;
276
- declare const StyledPieChartCaption: styled_components.StyledComponent<"p", any, Omit<PieChartProps, "data">, never>;
547
+ declare const StyledPieChart: styled_components.StyledComponent<_redsift_design_system.Comp<ChartContainerProps, HTMLDivElement>, any, PieChartProps, never>;
277
548
  declare const StyledPieChartCenterText: styled_components.StyledComponent<"div", any, {
278
549
  $maxWidth: number;
279
550
  $textSize: number;
@@ -284,12 +555,89 @@ declare const StyledPieChartEmptyText: styled_components.StyledComponent<"div",
284
555
  $textSize: number;
285
556
  $isDonut: boolean;
286
557
  }, never>;
287
- declare const StyledPieChartLabel: styled_components.StyledComponent<"li", any, {
288
- $color: string;
289
- }, never>;
290
- declare const StyledPieChartArc: styled_components.StyledComponent<"g", any, Omit<PieChartArcProps, "data" | "path" | "color" | "chartId" | "index" | "isEmpty" | "showTooltip" | "tooltipPercent" | "tooltipLabelOnly" | "spaced"> & {
291
- $spaced: boolean;
292
- $clickable: boolean;
558
+
559
+ /**
560
+ * Component props.
561
+ */
562
+ interface DotProps extends DataPointProps<DotDatum> {
563
+ /** A linear continuous scale defined over a numeric domain used to determine the x position based on the coordinates. */
564
+ scaleX: ScaleLinear$1<number, number, never>;
565
+ /** A linear continuous scale defined over a numeric domain used to determine the y position based on the coordinates. */
566
+ scaleY: ScaleLinear$1<number, number, never>;
567
+ }
568
+
569
+ /**
570
+ * Component variant.
571
+ */
572
+ declare const ScatterPlotVariant: {
573
+ readonly default: "default";
574
+ readonly gridded: "gridded";
575
+ };
576
+ type ScatterPlotVariant = ValueOf<typeof ScatterPlotVariant>;
577
+ /**
578
+ * Component's labels variant.
579
+ */
580
+ declare const ScatterPlotLabelVariant: {
581
+ readonly none: "none";
582
+ readonly externalLabel: "externalLabel";
583
+ readonly externalLabelValue: "externalLabelValue";
584
+ readonly externalLabelPercent: "externalLabelPercent";
585
+ };
586
+ type ScatterPlotLabelVariant = ValueOf<typeof ScatterPlotLabelVariant>;
587
+ interface LocaleText {
588
+ emptyChartText: string;
589
+ }
590
+ type ScatterPlotDimensions = ChartDimensions & {
591
+ fontSize: number;
592
+ };
593
+ /**
594
+ * Component props.
595
+ */
596
+ interface ScatterPlotProps extends ChartContainerProps {
597
+ /** Dataset to use to generate the chart. */
598
+ data?: CoordinatesCategoryData;
599
+ /** 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. */
600
+ dotRole?: DotProps['role'];
601
+ /** Component to use if the chart is empty (replacing the default one). */
602
+ emptyComponent?: ReactNode;
603
+ /** Whether the scatter plot dots are selectable using brush or not. */
604
+ isBrushable?: boolean;
605
+ /** Method to determine whether a dot is selected or not. */
606
+ isDotSelected?: (datum: DotDatum) => boolean | undefined;
607
+ /** Method to override the data labels. */
608
+ labelDecorator?: (datum: DotDatum) => string;
609
+ /** Define whether the labels should be displayed inside or outside the charts and if they should contain raw or percentage values. */
610
+ labelVariant?: ScatterPlotLabelVariant;
611
+ /** Labels and texts. */
612
+ localeText?: LocaleText;
613
+ /** Method called on brush. */
614
+ onBrush?: (selection: [[number, number], [number, number]] | null, scaleX: ScaleLinear$1<number, number>, scaleY: ScaleLinear$1<number, number>) => void;
615
+ /** Method called on brush end. */
616
+ onBrushEnd?: (selection: [[number, number], [number, number]] | null, scaleX?: ScaleLinear$1<number, number>, scaleY?: ScaleLinear$1<number, number>) => void;
617
+ /** Method to be called on a click on a dot. */
618
+ onDotClick?: (datum: DotDatum) => void;
619
+ /** ScatterPlot size. */
620
+ size?: ChartSize | ScatterPlotDimensions;
621
+ /** Reference to the SVG tag. */
622
+ svgRef?: MutableRefObject<SVGSVGElement>;
623
+ /** 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. */
624
+ theme?: ChartTheme;
625
+ /** Tooltip variant. */
626
+ tooltipVariant?: TooltipVariant;
627
+ /** Variant. */
628
+ variant?: ScatterPlotVariant;
629
+ }
630
+ type StyledScatterPlotProps = ScatterPlotProps & {};
631
+
632
+ declare const ScatterPlot: Comp<ScatterPlotProps, HTMLDivElement>;
633
+
634
+ /**
635
+ * Component style.
636
+ */
637
+ declare const StyledScatterPlot: styled_components.StyledComponent<_redsift_design_system.Comp<ChartContainerProps, HTMLDivElement>, any, ScatterPlotProps, never>;
638
+ declare const StyledScatterPlotEmptyText: styled_components.StyledComponent<"div", any, {
639
+ $maxWidth: number;
640
+ $textSize: number;
293
641
  }, never>;
294
642
 
295
- export { ChartDimensions, ColorTheme, Datum, HorizontalBarChart, HorizontalBarChartAxisBottomProps, HorizontalBarChartBarProps, HorizontalBarChartProps, HorizontalBarChartSize, HorizontalBarChartTheme, HorizontalBarChartTooltipVariant, PieArcDatum, PieChart, PieChartArcProps, PieChartLabelVariant, PieChartProps, PieChartSize, PieChartTheme, PieChartTooltipVariant, PieChartVariant, StyledHorizontalBarChart, StyledHorizontalBarChartAxisBottom, StyledHorizontalBarChartAxisBottomProps, StyledHorizontalBarChartBar, StyledHorizontalBarChartBarProps, StyledHorizontalBarChartCaption, StyledHorizontalBarChartEmptyText, StyledHorizontalBarChartProps, StyledHorizontalBarChartTitle, StyledPieChart, StyledPieChartArc, StyledPieChartArcProps, StyledPieChartCaption, StyledPieChartCenterText, StyledPieChartEmptyText, StyledPieChartLabel, StyledPieChartProps, StyledPieChartTitle, SuccessDangerColorTheme, getColorScale, monochrome, scheme, successDangerScheme };
643
+ export { AnyScale, Arc, ArcDatum, ArcProps, Arcs, ArcsProps, Axis, AxisPosition, AxisProps, Bar, BarChart, BarChartDimensions, BarChartProps, BarDatum, BarOrientation, BarProps, CategoryData, CategoryDatum, CategoryDim, ChartContainer, ChartContainerProps, ChartDimensions, ChartSize, ChartTheme, ColorTheme, Coordinates, CoordinatesCategoryData, CoordinatesCategoryDatum, CoordinatesCategoryDim, CustomColorTheme, Datum, DotDatum, JSONArray, JSONObject, JSONValue, LabelVariant, Legend, 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, StyledLabel, 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 };