@redsift/charts 8.0.0-alpha.8 → 8.0.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 +15 -4
- package/index.js +90 -43
- package/index.js.map +1 -1
- package/package.json +6 -10
package/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
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
3
|
import { ValueOf, Comp, StylingProps } from '@redsift/design-system';
|
|
4
|
-
import { MutableRefObject, ComponentProps, ReactElement, ReactNode } from 'react';
|
|
4
|
+
import { MutableRefObject, ComponentProps, RefObject, ReactElement, ReactNode } from 'react';
|
|
5
5
|
import { PieArcDatum } from 'd3-shape';
|
|
6
6
|
import * as d3_scale from 'd3-scale';
|
|
7
7
|
import { ScaleLinear as ScaleLinear$2, ScaleLogarithmic, ScaleSymLog, ScalePoint as ScalePoint$1, ScaleBand as ScaleBand$1, ScaleTime as ScaleTime$1 } from 'd3-scale';
|
|
@@ -162,7 +162,7 @@ interface UseColorProps {
|
|
|
162
162
|
/** Name of the field that will be used to categorize the data. */
|
|
163
163
|
category: string;
|
|
164
164
|
}
|
|
165
|
-
declare const useColor: ({ data, theme, category }: UseColorProps) => ScaleOrdinal<string, string, never
|
|
165
|
+
declare const useColor: ({ data, theme, category }: UseColorProps) => ScaleOrdinal<string, string, never>;
|
|
166
166
|
|
|
167
167
|
interface UseFormatCategoricalDataProps {
|
|
168
168
|
/** Dataset to use to generate the chart, should be a list of objects containing a key and a value. */
|
|
@@ -176,7 +176,7 @@ interface UseFormatCategoricalDataProps {
|
|
|
176
176
|
}
|
|
177
177
|
declare const useFormatCategoricalData: ({ data, caping, others, theme, }: UseFormatCategoricalDataProps) => {
|
|
178
178
|
data: CategoryData;
|
|
179
|
-
colorScale: d3_scale.ScaleOrdinal<string, string, never
|
|
179
|
+
colorScale: d3_scale.ScaleOrdinal<string, string, never>;
|
|
180
180
|
};
|
|
181
181
|
|
|
182
182
|
interface UseZoomProps {
|
|
@@ -188,9 +188,10 @@ interface UseZoomProps {
|
|
|
188
188
|
x: number;
|
|
189
189
|
y: number;
|
|
190
190
|
};
|
|
191
|
+
size?: any;
|
|
191
192
|
onZoom?: () => void;
|
|
192
193
|
}
|
|
193
|
-
declare const useZoom: ({ svgRef, scaleX, scaleY, defaultTransform, onZoom, }: UseZoomProps) => {
|
|
194
|
+
declare const useZoom: ({ svgRef, scaleX, scaleY, defaultTransform, size, onZoom, }: UseZoomProps) => {
|
|
194
195
|
transform: {
|
|
195
196
|
k: number;
|
|
196
197
|
x: number;
|
|
@@ -291,6 +292,8 @@ interface ArcsProps extends Omit<ComponentProps<'g'>, 'onClick' | 'role'>, Pick<
|
|
|
291
292
|
arcs: Omit<ArcProps, 'ref'>[];
|
|
292
293
|
/** Whether arcs have internal labels or not. */
|
|
293
294
|
hasLabels?: boolean;
|
|
295
|
+
/** Native HTML props to forward to each slice. */
|
|
296
|
+
sliceProps?: Omit<ComponentProps<'g'>, 'onClick' | 'ref' | 'width'>;
|
|
294
297
|
}
|
|
295
298
|
type StyledArcsProps = Omit<ArcsProps, 'arcs'> & {};
|
|
296
299
|
|
|
@@ -395,6 +398,10 @@ declare const StyledBar: styled_components.StyledComponent<_redsift_design_syste
|
|
|
395
398
|
interface ChartContainerProps extends Omit<ComponentProps<'div'>, 'title'>, StylingProps {
|
|
396
399
|
/** Caption. */
|
|
397
400
|
caption?: string;
|
|
401
|
+
/** Native HTML props to pass to the chart. */
|
|
402
|
+
chartProps?: ComponentProps<'div'>;
|
|
403
|
+
/** Ref to the chart. */
|
|
404
|
+
chartRef?: RefObject<HTMLDivElement>;
|
|
398
405
|
/** Id. */
|
|
399
406
|
id?: string;
|
|
400
407
|
/** Method called when the Reset button is displayed (defines whether or not the button should be displayed). */
|
|
@@ -425,6 +432,8 @@ type BarChartDimensions = ChartDimensions & {
|
|
|
425
432
|
interface BarChartProps extends ChartContainerProps {
|
|
426
433
|
/** Whether the x axis labels are rotated or not. */
|
|
427
434
|
areXLabelsRotated?: boolean;
|
|
435
|
+
/** Native HTML props to forward to each bar. */
|
|
436
|
+
barProps?: Omit<ComponentProps<'g'>, 'onClick' | 'orientation' | 'ref' | 'scale' | 'width'>;
|
|
428
437
|
/** Number of categories to use, the rest being put into a new category called "Others". */
|
|
429
438
|
caping?: number;
|
|
430
439
|
/** Dataset to use to generate the chart, should be a list of objects containing a key and a value. */
|
|
@@ -580,6 +589,8 @@ interface PieChartProps extends ChartContainerProps {
|
|
|
580
589
|
others?: boolean | string;
|
|
581
590
|
/** PieChart size. */
|
|
582
591
|
size?: ChartSize | PieChartDimensions;
|
|
592
|
+
/** Native HTML props to forward to each slice. */
|
|
593
|
+
sliceProps?: Omit<ComponentProps<'g'>, 'onClick' | 'ref' | 'width'>;
|
|
583
594
|
/** 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. */
|
|
584
595
|
sliceRole?: ArcProps['role'];
|
|
585
596
|
/** 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. */
|
package/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { brush, select, scaleOrdinal, zoom, interpolateRound, interpolate, scaleLinear, sum, arc, pie, min, extent, descending, scaleSqrt, max } from 'd3';
|
|
2
|
-
import { RedsiftDataVizColorBlueDefault, RedsiftDataVizColorGreyDark, RedsiftDataVizColorGreenDefault, RedsiftDataVizColorPinkDefault, RedsiftDataVizColorAquaDefault, RedsiftDataVizColorBrownDefault, RedsiftDataVizColorRedDefault, RedsiftDataVizColorYellowDefault, RedsiftDataVizColorPurpleDefault, RedsiftDataVizColorOrangeDefault, RedsiftDataVizColorGreyDefault, RedsiftDataVizColorGreenDark, RedsiftDataVizColorPinkDark, RedsiftDataVizColorAquaDark, RedsiftDataVizColorBrownDark, RedsiftDataVizColorRedDark, RedsiftDataVizColorYellowDark, RedsiftDataVizColorPurpleDark, RedsiftDataVizColorOrangeDark, RedsiftDataVizColorBlueDark, RedsiftDataVizColorGreenDarker, RedsiftDataVizColorPinkDarker, RedsiftDataVizColorAquaDarker, RedsiftDataVizColorBrownDarker, RedsiftDataVizColorRedDarker, RedsiftDataVizColorYellowDarker, RedsiftDataVizColorPurpleDarker, RedsiftDataVizColorOrangeDarker, RedsiftDataVizColorBlueDarker, RedsiftDataVizColorGreyDarker, RedsiftDataVizColorGreenDarkerer, RedsiftDataVizColorPinkDarkerer, RedsiftDataVizColorAquaDarkerer, RedsiftDataVizColorBrownDarkerer, RedsiftDataVizColorRedDarkerer, RedsiftDataVizColorYellowDarkerer, RedsiftDataVizColorPurpleDarkerer, RedsiftDataVizColorOrangeDarkerer, RedsiftDataVizColorBlueDarkerer, RedsiftDataVizColorGreyDarkerer, RedsiftDataVizColorGreenLight, RedsiftDataVizColorPinkLight, RedsiftDataVizColorAquaLight, RedsiftDataVizColorBrownLight, RedsiftDataVizColorRedLight, RedsiftDataVizColorYellowLight, RedsiftDataVizColorPurpleLight, RedsiftDataVizColorOrangeLight, RedsiftDataVizColorBlueLight, RedsiftDataVizColorGreyLight, RedsiftDataVizColorGreenLighter, RedsiftDataVizColorPinkLighter, RedsiftDataVizColorAquaLighter, RedsiftDataVizColorBrownLighter, RedsiftDataVizColorRedLighter, RedsiftDataVizColorYellowLighter, RedsiftDataVizColorPurpleLighter, RedsiftDataVizColorOrangeLighter, RedsiftDataVizColorBlueLighter, RedsiftDataVizColorGreyLighter, RedsiftDataVizColorGreenLighterer, RedsiftDataVizColorPinkLighterer, RedsiftDataVizColorAquaLighterer, RedsiftDataVizColorBrownLighterer, RedsiftDataVizColorRedLighterer, RedsiftDataVizColorYellowLighterer, RedsiftDataVizColorPurpleLighterer, RedsiftDataVizColorOrangeLighterer, RedsiftDataVizColorBlueLighterer, RedsiftDataVizColorGreyLighterer, Text, Number as Number$1, baseStyling, Flexbox, warnIfNoAccessibleLabelFound, Heading, Button } from '@redsift/design-system';
|
|
2
|
+
import { RedsiftDataVizColorBlueDefault, RedsiftDataVizColorGreyDark, RedsiftDataVizColorGreenDefault, RedsiftDataVizColorPinkDefault, RedsiftDataVizColorAquaDefault, RedsiftDataVizColorBrownDefault, RedsiftDataVizColorRedDefault, RedsiftDataVizColorYellowDefault, RedsiftDataVizColorPurpleDefault, RedsiftDataVizColorOrangeDefault, RedsiftDataVizColorGreyDefault, RedsiftDataVizColorGreenDark, RedsiftDataVizColorPinkDark, RedsiftDataVizColorAquaDark, RedsiftDataVizColorBrownDark, RedsiftDataVizColorRedDark, RedsiftDataVizColorYellowDark, RedsiftDataVizColorPurpleDark, RedsiftDataVizColorOrangeDark, RedsiftDataVizColorBlueDark, RedsiftDataVizColorGreenDarker, RedsiftDataVizColorPinkDarker, RedsiftDataVizColorAquaDarker, RedsiftDataVizColorBrownDarker, RedsiftDataVizColorRedDarker, RedsiftDataVizColorYellowDarker, RedsiftDataVizColorPurpleDarker, RedsiftDataVizColorOrangeDarker, RedsiftDataVizColorBlueDarker, RedsiftDataVizColorGreyDarker, RedsiftDataVizColorGreenDarkerer, RedsiftDataVizColorPinkDarkerer, RedsiftDataVizColorAquaDarkerer, RedsiftDataVizColorBrownDarkerer, RedsiftDataVizColorRedDarkerer, RedsiftDataVizColorYellowDarkerer, RedsiftDataVizColorPurpleDarkerer, RedsiftDataVizColorOrangeDarkerer, RedsiftDataVizColorBlueDarkerer, RedsiftDataVizColorGreyDarkerer, RedsiftDataVizColorGreenLight, RedsiftDataVizColorPinkLight, RedsiftDataVizColorAquaLight, RedsiftDataVizColorBrownLight, RedsiftDataVizColorRedLight, RedsiftDataVizColorYellowLight, RedsiftDataVizColorPurpleLight, RedsiftDataVizColorOrangeLight, RedsiftDataVizColorBlueLight, RedsiftDataVizColorGreyLight, RedsiftDataVizColorGreenLighter, RedsiftDataVizColorPinkLighter, RedsiftDataVizColorAquaLighter, RedsiftDataVizColorBrownLighter, RedsiftDataVizColorRedLighter, RedsiftDataVizColorYellowLighter, RedsiftDataVizColorPurpleLighter, RedsiftDataVizColorOrangeLighter, RedsiftDataVizColorBlueLighter, RedsiftDataVizColorGreyLighter, RedsiftDataVizColorGreenLighterer, RedsiftDataVizColorPinkLighterer, RedsiftDataVizColorAquaLighterer, RedsiftDataVizColorBrownLighterer, RedsiftDataVizColorRedLighterer, RedsiftDataVizColorYellowLighterer, RedsiftDataVizColorPurpleLighterer, RedsiftDataVizColorOrangeLighterer, RedsiftDataVizColorBlueLighterer, RedsiftDataVizColorGreyLighterer, Text, Number as Number$1, baseStyling, focusRing, Flexbox, warnIfNoAccessibleLabelFound, Heading, Button } from '@redsift/design-system';
|
|
3
3
|
import * as React from 'react';
|
|
4
4
|
import React__default, { useRef, useEffect, useMemo, useState, useLayoutEffect, forwardRef, useCallback, useContext, useId } from 'react';
|
|
5
5
|
import classNames from 'classnames';
|
|
@@ -92,11 +92,8 @@ const useColor = _ref => {
|
|
|
92
92
|
theme,
|
|
93
93
|
category
|
|
94
94
|
} = _ref;
|
|
95
|
-
const
|
|
96
|
-
|
|
97
|
-
colorScaleRef.current = getColorScale(theme, data.map(d => d[category]));
|
|
98
|
-
}
|
|
99
|
-
return colorScaleRef.current;
|
|
95
|
+
const colorScale = useMemo(() => getColorScale(theme, data.map(d => d[category])), [theme]);
|
|
96
|
+
return colorScale;
|
|
100
97
|
};
|
|
101
98
|
|
|
102
99
|
function ownKeys(object, enumerableOnly) {
|
|
@@ -225,7 +222,7 @@ const useFormatCategoricalData = _ref => {
|
|
|
225
222
|
}
|
|
226
223
|
}
|
|
227
224
|
return computedData;
|
|
228
|
-
}, [data]);
|
|
225
|
+
}, [data, caping]);
|
|
229
226
|
const colorScale = useColor({
|
|
230
227
|
data: computedData,
|
|
231
228
|
theme,
|
|
@@ -247,6 +244,7 @@ const useZoom = _ref => {
|
|
|
247
244
|
x: 0,
|
|
248
245
|
y: 0
|
|
249
246
|
},
|
|
247
|
+
size,
|
|
250
248
|
onZoom
|
|
251
249
|
} = _ref;
|
|
252
250
|
const zx = useRef(scaleX);
|
|
@@ -262,7 +260,7 @@ const useZoom = _ref => {
|
|
|
262
260
|
});
|
|
263
261
|
select(svgRef.current).call(zoom$1);
|
|
264
262
|
}
|
|
265
|
-
}, [svgRef.current]);
|
|
263
|
+
}, [svgRef.current, size]);
|
|
266
264
|
return {
|
|
267
265
|
transform,
|
|
268
266
|
scaleX: zx.current,
|
|
@@ -351,7 +349,9 @@ const DataPoint = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
351
349
|
}
|
|
352
350
|
}
|
|
353
351
|
};
|
|
354
|
-
const DataPointComponent = /*#__PURE__*/React__default.createElement(StyledDataPoint, _extends({
|
|
352
|
+
const DataPointComponent = /*#__PURE__*/React__default.createElement(StyledDataPoint, _extends({
|
|
353
|
+
tabIndex: onClick ? 0 : undefined
|
|
354
|
+
}, forwardedProps, {
|
|
355
355
|
className: classNames(className, `_${index}`, {
|
|
356
356
|
selected: isSelected,
|
|
357
357
|
deselected: isDeselected
|
|
@@ -364,7 +364,6 @@ const DataPoint = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
364
364
|
onClick: onClick ? () => onClick(data) : undefined,
|
|
365
365
|
onKeyDown: onClick ? e => onKeyDown(e) : undefined,
|
|
366
366
|
role: role ? role : onClick ? 'button' : undefined,
|
|
367
|
-
tabIndex: onClick ? 0 : undefined,
|
|
368
367
|
$clickable: Boolean(onClick)
|
|
369
368
|
}), children, !showTooltip && !isEmpty ? /*#__PURE__*/React__default.createElement("title", {
|
|
370
369
|
id: `${id}-title`
|
|
@@ -408,12 +407,14 @@ const StyledArc = styled(DataPoint)`
|
|
|
408
407
|
cursor: pointer;
|
|
409
408
|
|
|
410
409
|
&:hover,
|
|
411
|
-
&:focus
|
|
410
|
+
&:focus,
|
|
411
|
+
&.focused {
|
|
412
412
|
opacity: 0.8;
|
|
413
413
|
outline: none;
|
|
414
414
|
}
|
|
415
415
|
|
|
416
|
-
&:focus-visible
|
|
416
|
+
&:focus-visible,
|
|
417
|
+
&.focused {
|
|
417
418
|
path {
|
|
418
419
|
stroke: var(--redsift-color-default-primary);
|
|
419
420
|
stroke-width: 4px;
|
|
@@ -498,7 +499,7 @@ Arc.displayName = COMPONENT_NAME$a;
|
|
|
498
499
|
*/
|
|
499
500
|
const StyledArcs = styled.g``;
|
|
500
501
|
|
|
501
|
-
const _excluded$i = ["arcs", "className", "color", "hasLabels", "hasStroke", "id", "labelDecorator", "onClick", "role", "tooltipVariant"];
|
|
502
|
+
const _excluded$i = ["arcs", "className", "color", "hasLabels", "hasStroke", "id", "labelDecorator", "onClick", "role", "sliceProps", "tooltipVariant"];
|
|
502
503
|
const COMPONENT_NAME$9 = 'Arcs';
|
|
503
504
|
const CLASSNAME$9 = 'redsift-arcs';
|
|
504
505
|
const DEFAULT_PROPS$9 = {};
|
|
@@ -513,6 +514,7 @@ const Arcs = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
513
514
|
labelDecorator,
|
|
514
515
|
onClick,
|
|
515
516
|
role,
|
|
517
|
+
sliceProps,
|
|
516
518
|
tooltipVariant
|
|
517
519
|
} = props,
|
|
518
520
|
forwardedProps = _objectWithoutProperties(props, _excluded$i);
|
|
@@ -536,7 +538,7 @@ const Arcs = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
536
538
|
var _arc$index, _arc$id;
|
|
537
539
|
const arcIndex = (_arc$index = arc.index) !== null && _arc$index !== void 0 ? _arc$index : index;
|
|
538
540
|
const arcId = (_arc$id = arc.id) !== null && _arc$id !== void 0 ? _arc$id : `id${id}__arc-${arcIndex}`;
|
|
539
|
-
return /*#__PURE__*/React__default.createElement(Arc, _extends({
|
|
541
|
+
return /*#__PURE__*/React__default.createElement(Arc, _extends({}, sliceProps, {
|
|
540
542
|
color: color,
|
|
541
543
|
hasStroke: hasStroke,
|
|
542
544
|
labelDecorator: labelDecorator,
|
|
@@ -591,6 +593,10 @@ const AxisPosition = {
|
|
|
591
593
|
left: 'left'
|
|
592
594
|
};
|
|
593
595
|
|
|
596
|
+
/**
|
|
597
|
+
* Component props.
|
|
598
|
+
*/
|
|
599
|
+
|
|
594
600
|
/**
|
|
595
601
|
* Component style.
|
|
596
602
|
*/
|
|
@@ -887,6 +893,10 @@ const BarOrientation = {
|
|
|
887
893
|
vertical: 'vertical'
|
|
888
894
|
};
|
|
889
895
|
|
|
896
|
+
/**
|
|
897
|
+
* Component props.
|
|
898
|
+
*/
|
|
899
|
+
|
|
890
900
|
/**
|
|
891
901
|
* Component style.
|
|
892
902
|
*/
|
|
@@ -903,20 +913,39 @@ const StyledBar = styled(DataPoint)`
|
|
|
903
913
|
cursor: pointer;
|
|
904
914
|
|
|
905
915
|
&:hover,
|
|
906
|
-
&:focus
|
|
916
|
+
&:focus,
|
|
917
|
+
&.focused {
|
|
907
918
|
outline: none;
|
|
908
919
|
rect {
|
|
909
920
|
fill-opacity: 0.7;
|
|
910
921
|
}
|
|
911
922
|
}
|
|
912
923
|
|
|
913
|
-
&:focus-visible {
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
924
|
+
// &:focus-visible {
|
|
925
|
+
// rect {
|
|
926
|
+
// stroke: var(--redsift-color-default-primary);
|
|
927
|
+
// stroke-width: 4px;
|
|
928
|
+
// paint-order: stroke;
|
|
929
|
+
// }
|
|
930
|
+
// }
|
|
931
|
+
|
|
932
|
+
@media (prefers-reduced-motion: no-preference) {
|
|
933
|
+
&:focus-visible,
|
|
934
|
+
&.focused {
|
|
935
|
+
outline: 2px solid var(--redsift-color-default-primary);
|
|
936
|
+
transition: outline-offset 75ms ease-out;
|
|
937
|
+
}
|
|
938
|
+
|
|
939
|
+
&:not(&:active)&:focus-visible,
|
|
940
|
+
&:not(&:active)&.focused {
|
|
941
|
+
transition-duration: 0.25s;
|
|
918
942
|
}
|
|
919
943
|
}
|
|
944
|
+
|
|
945
|
+
&:not(&:active)&:focus-visible,
|
|
946
|
+
&:not(&:active)&.focused {
|
|
947
|
+
outline-offset: 0.2rem;
|
|
948
|
+
}
|
|
920
949
|
` : '';
|
|
921
950
|
}}}
|
|
922
951
|
`;
|
|
@@ -1031,6 +1060,8 @@ const StyledChartContainer = styled.div`
|
|
|
1031
1060
|
justify-content: center;
|
|
1032
1061
|
margin: 8px 0;
|
|
1033
1062
|
position: relative;
|
|
1063
|
+
|
|
1064
|
+
${focusRing}
|
|
1034
1065
|
}
|
|
1035
1066
|
|
|
1036
1067
|
svg {
|
|
@@ -1045,7 +1076,7 @@ const StyledChartContainerCaption = styled.p`
|
|
|
1045
1076
|
line-height: var(--redsift-typography-caption-line-height);
|
|
1046
1077
|
`;
|
|
1047
1078
|
|
|
1048
|
-
const _excluded$f = ["aria-label", "aria-labelledby", "caption", "children", "className", "id", "title", "onReset"];
|
|
1079
|
+
const _excluded$f = ["aria-label", "aria-labelledby", "caption", "chartProps", "chartRef", "children", "className", "id", "title", "onReset"];
|
|
1049
1080
|
const COMPONENT_NAME$6 = 'ChartContainer';
|
|
1050
1081
|
const CLASSNAME$6 = 'redsift-chart-container';
|
|
1051
1082
|
const DEFAULT_PROPS$6 = {};
|
|
@@ -1054,6 +1085,8 @@ const ChartContainer = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
1054
1085
|
'aria-label': propsAriaLabel,
|
|
1055
1086
|
'aria-labelledby': propsAriaLabelledby,
|
|
1056
1087
|
caption,
|
|
1088
|
+
chartProps,
|
|
1089
|
+
chartRef,
|
|
1057
1090
|
children,
|
|
1058
1091
|
className,
|
|
1059
1092
|
id: propsId,
|
|
@@ -1081,12 +1114,13 @@ const ChartContainer = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
1081
1114
|
className: `${ChartContainer.className}-title__reset-button`,
|
|
1082
1115
|
color: "question",
|
|
1083
1116
|
variant: "unstyled",
|
|
1084
|
-
|
|
1085
|
-
}, stringFormatter.format('reset')) : null) : null, children ? /*#__PURE__*/React__default.createElement("div", {
|
|
1117
|
+
onClick: onReset
|
|
1118
|
+
}, stringFormatter.format('reset')) : null) : null, children ? /*#__PURE__*/React__default.createElement("div", _extends({}, chartProps, {
|
|
1119
|
+
ref: chartRef,
|
|
1086
1120
|
className: `${ChartContainer.className}__content`,
|
|
1087
1121
|
"aria-label": ariaLabel,
|
|
1088
1122
|
"aria-labelledby": ariaLabelledby
|
|
1089
|
-
}, children) : null, caption ? /*#__PURE__*/React__default.createElement(StyledChartContainerCaption, {
|
|
1123
|
+
}), children) : null, caption ? /*#__PURE__*/React__default.createElement(StyledChartContainerCaption, {
|
|
1090
1124
|
className: `${ChartContainer.className}__caption`
|
|
1091
1125
|
}, caption) : null);
|
|
1092
1126
|
});
|
|
@@ -1221,10 +1255,11 @@ const LoadingBarChart = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
1221
1255
|
}), "Loading...");
|
|
1222
1256
|
});
|
|
1223
1257
|
|
|
1224
|
-
const _excluded$c = ["areXLabelsRotated", "caping", "className", "data", "id", "isBarSelected", "labelDecorator", "onBarClick", "others", "size", "barRole", "theme", "tooltipVariant"];
|
|
1258
|
+
const _excluded$c = ["areXLabelsRotated", "barProps", "caping", "className", "data", "id", "isBarSelected", "labelDecorator", "onBarClick", "others", "size", "barRole", "theme", "tooltipVariant"];
|
|
1225
1259
|
const RenderedBarChart = /*#__PURE__*/forwardRef((props, ref) => {
|
|
1226
1260
|
const {
|
|
1227
1261
|
areXLabelsRotated,
|
|
1262
|
+
barProps,
|
|
1228
1263
|
caping,
|
|
1229
1264
|
className,
|
|
1230
1265
|
data: propsData,
|
|
@@ -1265,15 +1300,12 @@ const RenderedBarChart = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
1265
1300
|
const chartWidth = width - margins.left - margins.right;
|
|
1266
1301
|
const numberOfRows = data.length;
|
|
1267
1302
|
const gap = 5;
|
|
1268
|
-
const
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
return value;
|
|
1275
|
-
}))]).range([0, chartWidth]);
|
|
1276
|
-
}
|
|
1303
|
+
const scale = useMemo(() => scaleLinear().domain([0, Math.max(...data.map(_ref => {
|
|
1304
|
+
let {
|
|
1305
|
+
value
|
|
1306
|
+
} = _ref;
|
|
1307
|
+
return value;
|
|
1308
|
+
}))]).range([0, chartWidth]), [size]);
|
|
1277
1309
|
const barHeight = (chartHeight - (numberOfRows + 1) * gap) / numberOfRows;
|
|
1278
1310
|
const total = sum(data, d => d.value);
|
|
1279
1311
|
return /*#__PURE__*/React__default.createElement(StyledBarChart, _extends({}, forwardedProps, {
|
|
@@ -1288,7 +1320,7 @@ const RenderedBarChart = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
1288
1320
|
}, /*#__PURE__*/React__default.createElement(Axis, {
|
|
1289
1321
|
position: "bottom",
|
|
1290
1322
|
length: chartWidth,
|
|
1291
|
-
scale:
|
|
1323
|
+
scale: scale,
|
|
1292
1324
|
x: 0,
|
|
1293
1325
|
y: chartHeight,
|
|
1294
1326
|
tickValues: 4,
|
|
@@ -1303,7 +1335,7 @@ const RenderedBarChart = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
1303
1335
|
const from = cache.current ? {
|
|
1304
1336
|
data: cache.current[index]
|
|
1305
1337
|
} : undefined;
|
|
1306
|
-
return /*#__PURE__*/React__default.createElement(Bar, {
|
|
1338
|
+
return /*#__PURE__*/React__default.createElement(Bar, _extends({}, barProps, {
|
|
1307
1339
|
color: colorScale === null || colorScale === void 0 ? void 0 : colorScale(to.data.key),
|
|
1308
1340
|
data: to,
|
|
1309
1341
|
gap: gap,
|
|
@@ -1316,13 +1348,13 @@ const RenderedBarChart = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
1316
1348
|
onClick: onBarClick,
|
|
1317
1349
|
previousData: from,
|
|
1318
1350
|
role: barRole,
|
|
1319
|
-
scale:
|
|
1351
|
+
scale: scale,
|
|
1320
1352
|
tooltipVariant: tooltipVariant
|
|
1321
|
-
});
|
|
1353
|
+
}));
|
|
1322
1354
|
}))));
|
|
1323
1355
|
});
|
|
1324
1356
|
|
|
1325
|
-
const _excluded$b = ["areXLabelsRotated", "caping", "className", "data", "emptyComponent", "id", "isBarSelected", "labelDecorator", "localeText", "onBarClick", "others", "size", "barRole", "theme", "tooltipVariant"];
|
|
1357
|
+
const _excluded$b = ["areXLabelsRotated", "caping", "chartRef", "className", "data", "emptyComponent", "id", "isBarSelected", "labelDecorator", "localeText", "onBarClick", "others", "size", "barRole", "theme", "tooltipVariant"];
|
|
1326
1358
|
const COMPONENT_NAME$5 = 'BarChart';
|
|
1327
1359
|
const CLASSNAME$5 = 'redsift-barchart';
|
|
1328
1360
|
const DEFAULT_PROPS$5 = {
|
|
@@ -1339,6 +1371,7 @@ const BarChart = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
1339
1371
|
const {
|
|
1340
1372
|
areXLabelsRotated,
|
|
1341
1373
|
caping,
|
|
1374
|
+
chartRef,
|
|
1342
1375
|
className,
|
|
1343
1376
|
data: propsData,
|
|
1344
1377
|
emptyComponent,
|
|
@@ -1377,6 +1410,7 @@ const BarChart = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
1377
1410
|
areXLabelsRotated: areXLabelsRotated,
|
|
1378
1411
|
barRole: barRole,
|
|
1379
1412
|
caping: caping,
|
|
1413
|
+
chartRef: chartRef,
|
|
1380
1414
|
className: classNames(BarChart.className, className),
|
|
1381
1415
|
data: propsData,
|
|
1382
1416
|
id: id,
|
|
@@ -1677,6 +1711,10 @@ const PieChartLabelVariant = {
|
|
|
1677
1711
|
externalLabelPercent: 'externalLabelPercent'
|
|
1678
1712
|
};
|
|
1679
1713
|
|
|
1714
|
+
/**
|
|
1715
|
+
* Component props.
|
|
1716
|
+
*/
|
|
1717
|
+
|
|
1680
1718
|
/**
|
|
1681
1719
|
* Component style.
|
|
1682
1720
|
*/
|
|
@@ -1928,7 +1966,7 @@ const EmptyPieChart = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
1928
1966
|
}))));
|
|
1929
1967
|
});
|
|
1930
1968
|
|
|
1931
|
-
const _excluded$5 = ["caping", "className", "data", "id", "isSliceSelected", "labelDecorator", "labelVariant", "middleText", "onSliceClick", "others", "size", "sliceRole", "subtext", "text", "theme", "tooltipVariant", "variant"];
|
|
1969
|
+
const _excluded$5 = ["caping", "className", "data", "id", "isSliceSelected", "labelDecorator", "labelVariant", "middleText", "onSliceClick", "others", "size", "sliceProps", "sliceRole", "subtext", "text", "theme", "tooltipVariant", "variant"];
|
|
1932
1970
|
const RenderedPieChart = /*#__PURE__*/forwardRef((props, ref) => {
|
|
1933
1971
|
const {
|
|
1934
1972
|
caping,
|
|
@@ -1942,6 +1980,7 @@ const RenderedPieChart = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
1942
1980
|
onSliceClick,
|
|
1943
1981
|
others,
|
|
1944
1982
|
size,
|
|
1983
|
+
sliceProps,
|
|
1945
1984
|
sliceRole,
|
|
1946
1985
|
subtext,
|
|
1947
1986
|
text,
|
|
@@ -2024,9 +2063,10 @@ const RenderedPieChart = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
2024
2063
|
hasStroke: variant === PieChartVariant.spaced || variant === PieChartVariant.spacedDonut,
|
|
2025
2064
|
labelDecorator: labelDecorator,
|
|
2026
2065
|
onClick: onSliceClick,
|
|
2066
|
+
role: sliceRole,
|
|
2067
|
+
sliceProps: sliceProps,
|
|
2027
2068
|
tooltipVariant: tooltipVariant,
|
|
2028
|
-
transform: `translate(${width / 2} ${height / 2})
|
|
2029
|
-
role: sliceRole
|
|
2069
|
+
transform: `translate(${width / 2} ${height / 2})`
|
|
2030
2070
|
}))), labelVariant !== PieChartLabelVariant.none && labelVariant !== PieChartLabelVariant.internal ? /*#__PURE__*/React__default.createElement(Legend, {
|
|
2031
2071
|
data: data.map(d => _objectSpread2(_objectSpread2({}, d), {}, {
|
|
2032
2072
|
color: colorScale === null || colorScale === void 0 ? void 0 : colorScale(d.key)
|
|
@@ -2035,7 +2075,7 @@ const RenderedPieChart = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
2035
2075
|
}) : null);
|
|
2036
2076
|
});
|
|
2037
2077
|
|
|
2038
|
-
const _excluded$4 = ["caping", "className", "data", "emptyComponent", "id", "isSliceSelected", "labelDecorator", "labelVariant", "localeText", "middleText", "onSliceClick", "others", "size", "sliceRole", "subtext", "text", "theme", "tooltipVariant", "variant"];
|
|
2078
|
+
const _excluded$4 = ["caping", "chartRef", "className", "data", "emptyComponent", "id", "isSliceSelected", "labelDecorator", "labelVariant", "localeText", "middleText", "onSliceClick", "others", "size", "sliceRole", "subtext", "text", "theme", "tooltipVariant", "variant"];
|
|
2039
2079
|
const COMPONENT_NAME$1 = 'PieChart';
|
|
2040
2080
|
const CLASSNAME$1 = 'redsift-piechart';
|
|
2041
2081
|
const DEFAULT_PROPS$1 = {
|
|
@@ -2053,6 +2093,7 @@ const DEFAULT_PROPS$1 = {
|
|
|
2053
2093
|
const PieChart = /*#__PURE__*/forwardRef((props, ref) => {
|
|
2054
2094
|
const {
|
|
2055
2095
|
caping,
|
|
2096
|
+
chartRef,
|
|
2056
2097
|
className,
|
|
2057
2098
|
data: propsData,
|
|
2058
2099
|
emptyComponent,
|
|
@@ -2095,6 +2136,7 @@ const PieChart = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
2095
2136
|
}
|
|
2096
2137
|
return /*#__PURE__*/React__default.createElement(RenderedPieChart, _extends({
|
|
2097
2138
|
caping: caping,
|
|
2139
|
+
chartRef: chartRef,
|
|
2098
2140
|
className: classNames(PieChart.className, className),
|
|
2099
2141
|
data: propsData,
|
|
2100
2142
|
id: id,
|
|
@@ -2136,6 +2178,10 @@ const ScatterPlotLabelVariant = {
|
|
|
2136
2178
|
externalLabelPercent: 'externalLabelPercent'
|
|
2137
2179
|
};
|
|
2138
2180
|
|
|
2181
|
+
/**
|
|
2182
|
+
* Component props.
|
|
2183
|
+
*/
|
|
2184
|
+
|
|
2139
2185
|
/**
|
|
2140
2186
|
* Component style.
|
|
2141
2187
|
*/
|
|
@@ -2374,6 +2420,7 @@ const RenderedScatterPlot = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
2374
2420
|
svgRef,
|
|
2375
2421
|
scaleX: extendedScaleX,
|
|
2376
2422
|
scaleY: extendedScaleY,
|
|
2423
|
+
size,
|
|
2377
2424
|
onZoom: () => {
|
|
2378
2425
|
if (brushRef.current && svgBrushRef.current) {
|
|
2379
2426
|
brushRef.current.clear(select(svgBrushRef.current));
|