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