@redsift/charts 9.2.4 → 9.3.0-muiv5

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,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
- import { ValueOf, Comp, StylingProps } from '@redsift/design-system';
4
- import { MutableRefObject, ComponentProps, RefObject, ReactElement, ReactNode } from 'react';
3
+ import { ValueOf, Comp, ContainerProps } from '@redsift/design-system';
4
+ import { MutableRefObject, ComponentProps, ReactElement, RefObject, 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';
@@ -237,7 +237,11 @@ interface DataPointProps<T> extends Omit<ComponentProps<'g'>, 'onClick' | 'scale
237
237
  /** Whether the component is selected or not. Used only if the component is selectable. Set to `undefined` to make nor selected nor unselected. */
238
238
  isSelected?: boolean;
239
239
  /** Method modifying the label before displaying it. */
240
- labelDecorator?: (data: T) => string;
240
+ labelDecorator?: (data: T, props?: {
241
+ index?: number;
242
+ isSelected?: boolean;
243
+ color?: string;
244
+ }) => string | ReactElement;
241
245
  /** Method called when a click or keydown occurs on the component. */
242
246
  onClick?: (data: T) => void;
243
247
  /** State from which the component should start the animation, if any. */
@@ -374,6 +378,8 @@ interface BarProps extends DataPointProps<BarDatum> {
374
378
  gap?: number;
375
379
  /** Height of the bar in horizontal orientation. */
376
380
  height?: number;
381
+ /** Maximum height of the bar. */
382
+ maxHeight?: number;
377
383
  /** Orientation of the bar. */
378
384
  orientation?: BarOrientation;
379
385
  /** A linear continuous scale defined over a numeric domain used to determine the width or height of the bar (depending on the orientation). */
@@ -395,9 +401,7 @@ declare const StyledBar: styled_components.StyledComponent<_redsift_design_syste
395
401
  /**
396
402
  * Component props.
397
403
  */
398
- interface ChartContainerProps extends Omit<ComponentProps<'div'>, 'title'>, StylingProps {
399
- /** Caption. */
400
- caption?: string;
404
+ interface ChartContainerProps extends Omit<ComponentProps<'div'>, 'title'>, ContainerProps {
401
405
  /** Native HTML props to pass to the chart. */
402
406
  chartProps?: ComponentProps<'div'>;
403
407
  /** Ref to the chart. */
@@ -445,11 +449,17 @@ interface BarChartProps extends ChartContainerProps {
445
449
  /** Method to determine whether a slice is selected or not. */
446
450
  isBarSelected?: (datum: BarDatum) => void;
447
451
  /** Method to override the data labels. */
448
- labelDecorator?: (datum: BarDatum) => string;
452
+ labelDecorator?: (datum: BarDatum, props?: {
453
+ index?: number;
454
+ isSelected?: boolean;
455
+ color?: string;
456
+ }) => string | ReactElement;
449
457
  /** Labels and texts. */
450
458
  localeText?: LocaleText$2;
451
459
  /** Method to be called on a click on a bar. */
452
460
  onBarClick?: (datum: BarDatum) => void;
461
+ /** Orientation of the bar. */
462
+ orientation?: BarOrientation;
453
463
  /** 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. */
454
464
  others?: boolean | string;
455
465
  /** BarChart size. */
@@ -507,7 +517,7 @@ interface LegendItemProps extends Pick<DataPointProps<LegendItemDatum>, 'color'
507
517
  /**
508
518
  * Component props.
509
519
  */
510
- interface LegendProps extends Omit<ComponentProps<'ul'>, 'onClick'> {
520
+ interface LegendProps extends Omit<ComponentProps<'ul'>, 'onClick'>, ContainerProps {
511
521
  /** Data. */
512
522
  data: (CategoryDatum & {
513
523
  color: string;
@@ -515,15 +525,17 @@ interface LegendProps extends Omit<ComponentProps<'ul'>, 'onClick'> {
515
525
  /** Method to determine whether a slice is selected or not. */
516
526
  isLegendItemSelected?: (datum: LegendItemDatum) => void;
517
527
  /** Method to override the data labels. */
518
- labelDecorator?: (datum: LegendItemDatum) => string;
528
+ labelDecorator?: (datum: LegendItemDatum, props?: {
529
+ index?: number;
530
+ isSelected?: boolean;
531
+ color?: string;
532
+ }) => string | ReactElement;
519
533
  /** Method to be called on a click on a legend item. */
520
534
  onLegendItemClick?: (datum: LegendItemDatum) => void;
521
535
  /** LegendItem role. Used to indicate that legend items are to be considered buttons or links. If an onClick is provided, the legend items will have the role `button` unless specifically set to `link` with this prop. */
522
536
  legendItemRole?: LegendItemProps['role'];
523
537
  /** Variant. */
524
538
  variant?: LabelVariant;
525
- /** Width. */
526
- width?: string;
527
539
  }
528
540
  type StyledLegendProps = Omit<LegendProps, 'data'> & {
529
541
  $width?: LegendProps['width'];
@@ -535,7 +547,7 @@ declare const Legend: Comp<LegendProps, HTMLUListElement>;
535
547
  * Component style.
536
548
  */
537
549
  declare const StyledLegend: styled_components.StyledComponent<"ul", any, Omit<LegendProps, "data"> & {
538
- $width?: string | undefined;
550
+ $width?: string | number | undefined;
539
551
  }, never>;
540
552
 
541
553
  /**
@@ -577,14 +589,20 @@ interface PieChartProps extends ChartContainerProps {
577
589
  data?: CategoryData;
578
590
  /** Component to use if the chart is empty (replacing the default one). */
579
591
  emptyComponent?: ReactNode;
592
+ /** Whether the pie or donut is cut in half or not. */
593
+ isHalf?: boolean;
580
594
  /** Method to determine whether a slice is selected or not. */
581
595
  isSliceSelected?: (datum: ArcDatum) => boolean | undefined;
582
596
  /** Method to override the data labels. */
583
- labelDecorator?: (datum: ArcDatum) => string;
597
+ labelDecorator?: (datum: ArcDatum, props?: {
598
+ index?: number;
599
+ isSelected?: boolean;
600
+ color?: string;
601
+ }) => string | ReactElement;
584
602
  /** Define whether the labels should be displayed inside or outside the charts and if they should contain raw or percentage values. */
585
603
  labelVariant?: PieChartLabelVariant;
586
604
  /** Props to forward to the Legend block. Can be used to make the legend selectable. */
587
- legendProps?: Omit<LegendProps, 'data' | 'ref' | 'variant' | 'width'>;
605
+ legendProps?: Omit<LegendProps, 'data' | 'ref' | 'variant'>;
588
606
  /** Labels and texts. */
589
607
  localeText?: LocaleText$1;
590
608
  /** Method to be called on a click on a slice. */
@@ -670,7 +688,11 @@ interface ScatterPlotProps extends ChartContainerProps {
670
688
  /** Method to determine whether a dot is selected or not. */
671
689
  isDotSelected?: (datum: DotDatum) => boolean | undefined;
672
690
  /** Method to override the data labels. */
673
- labelDecorator?: (datum: DotDatum) => string;
691
+ labelDecorator?: (datum: DotDatum, props?: {
692
+ index?: number;
693
+ isSelected?: boolean;
694
+ color?: string;
695
+ }) => string | ReactElement;
674
696
  /** Define whether the labels should be displayed inside or outside the charts and if they should contain raw or percentage values. */
675
697
  labelVariant?: ScatterPlotLabelVariant;
676
698
  /** Props to forward to the Legend block. Can be used to make the legend selectable. */
package/index.js CHANGED
@@ -1,5 +1,5 @@
1
- import { brush, select, scaleOrdinal, zoom, interpolateRound, interpolate, scaleLinear, sum, arc, pie, min, extent, descending, scaleSqrt, max } from 'd3';
2
- import { RedsiftColorPresentationBlueDefault, RedsiftColorPresentationGreyDark, RedsiftColorPresentationGreenDefault, RedsiftColorPresentationPinkDefault, RedsiftColorPresentationAquaDefault, RedsiftColorPresentationBrownDefault, RedsiftColorPresentationRedDefault, RedsiftColorPresentationYellowDefault, RedsiftColorPresentationPurpleDefault, RedsiftColorPresentationOrangeDefault, RedsiftColorPresentationGreyDefault, RedsiftColorPresentationGreenDark, RedsiftColorPresentationPinkDark, RedsiftColorPresentationAquaDark, RedsiftColorPresentationBrownDark, RedsiftColorPresentationRedDark, RedsiftColorPresentationYellowDark, RedsiftColorPresentationPurpleDark, RedsiftColorPresentationOrangeDark, RedsiftColorPresentationBlueDark, RedsiftColorPresentationGreenDarker, RedsiftColorPresentationPinkDarker, RedsiftColorPresentationAquaDarker, RedsiftColorPresentationBrownDarker, RedsiftColorPresentationRedDarker, RedsiftColorPresentationYellowDarker, RedsiftColorPresentationPurpleDarker, RedsiftColorPresentationOrangeDarker, RedsiftColorPresentationBlueDarker, RedsiftColorPresentationGreyDarker, RedsiftColorPresentationGreenDarkerer, RedsiftColorPresentationPinkDarkerer, RedsiftColorPresentationAquaDarkerer, RedsiftColorPresentationBrownDarkerer, RedsiftColorPresentationRedDarkerer, RedsiftColorPresentationYellowDarkerer, RedsiftColorPresentationPurpleDarkerer, RedsiftColorPresentationOrangeDarkerer, RedsiftColorPresentationBlueDarkerer, RedsiftColorPresentationGreyDarkerer, RedsiftColorPresentationGreenLight, RedsiftColorPresentationPinkLight, RedsiftColorPresentationAquaLight, RedsiftColorPresentationBrownLight, RedsiftColorPresentationRedLight, RedsiftColorPresentationYellowLight, RedsiftColorPresentationPurpleLight, RedsiftColorPresentationOrangeLight, RedsiftColorPresentationBlueLight, RedsiftColorPresentationGreyLight, RedsiftColorPresentationGreenLighter, RedsiftColorPresentationPinkLighter, RedsiftColorPresentationAquaLighter, RedsiftColorPresentationBrownLighter, RedsiftColorPresentationRedLighter, RedsiftColorPresentationYellowLighter, RedsiftColorPresentationPurpleLighter, RedsiftColorPresentationOrangeLighter, RedsiftColorPresentationBlueLighter, RedsiftColorPresentationGreyLighter, RedsiftColorPresentationGreenLighterer, RedsiftColorPresentationPinkLighterer, RedsiftColorPresentationAquaLighterer, RedsiftColorPresentationBrownLighterer, RedsiftColorPresentationRedLighterer, RedsiftColorPresentationYellowLighterer, RedsiftColorPresentationPurpleLighterer, RedsiftColorPresentationOrangeLighterer, RedsiftColorPresentationBlueLighterer, RedsiftColorPresentationGreyLighterer, useId, Text, Number as Number$1, baseStyling, focusRing, Flexbox, warnIfNoAccessibleLabelFound, Heading, Button } from '@redsift/design-system';
1
+ import { brush, select, scaleOrdinal, zoom, interpolateRound, interpolate, scaleLinear, sum, scalePoint, arc, pie, min, extent, descending, scaleSqrt, max } from 'd3';
2
+ import { RedsiftColorPresentationBlueDefault, RedsiftColorPresentationGreyDark, RedsiftColorPresentationGreenDefault, RedsiftColorPresentationPinkDefault, RedsiftColorPresentationAquaDefault, RedsiftColorPresentationBrownDefault, RedsiftColorPresentationRedDefault, RedsiftColorPresentationYellowDefault, RedsiftColorPresentationPurpleDefault, RedsiftColorPresentationOrangeDefault, RedsiftColorPresentationGreyDefault, RedsiftColorPresentationGreenDark, RedsiftColorPresentationPinkDark, RedsiftColorPresentationAquaDark, RedsiftColorPresentationBrownDark, RedsiftColorPresentationRedDark, RedsiftColorPresentationYellowDark, RedsiftColorPresentationPurpleDark, RedsiftColorPresentationOrangeDark, RedsiftColorPresentationBlueDark, RedsiftColorPresentationGreenDarker, RedsiftColorPresentationPinkDarker, RedsiftColorPresentationAquaDarker, RedsiftColorPresentationBrownDarker, RedsiftColorPresentationRedDarker, RedsiftColorPresentationYellowDarker, RedsiftColorPresentationPurpleDarker, RedsiftColorPresentationOrangeDarker, RedsiftColorPresentationBlueDarker, RedsiftColorPresentationGreyDarker, RedsiftColorPresentationGreenDarkerer, RedsiftColorPresentationPinkDarkerer, RedsiftColorPresentationAquaDarkerer, RedsiftColorPresentationBrownDarkerer, RedsiftColorPresentationRedDarkerer, RedsiftColorPresentationYellowDarkerer, RedsiftColorPresentationPurpleDarkerer, RedsiftColorPresentationOrangeDarkerer, RedsiftColorPresentationBlueDarkerer, RedsiftColorPresentationGreyDarkerer, RedsiftColorPresentationGreenLight, RedsiftColorPresentationPinkLight, RedsiftColorPresentationAquaLight, RedsiftColorPresentationBrownLight, RedsiftColorPresentationRedLight, RedsiftColorPresentationYellowLight, RedsiftColorPresentationPurpleLight, RedsiftColorPresentationOrangeLight, RedsiftColorPresentationBlueLight, RedsiftColorPresentationGreyLight, RedsiftColorPresentationGreenLighter, RedsiftColorPresentationPinkLighter, RedsiftColorPresentationAquaLighter, RedsiftColorPresentationBrownLighter, RedsiftColorPresentationRedLighter, RedsiftColorPresentationYellowLighter, RedsiftColorPresentationPurpleLighter, RedsiftColorPresentationOrangeLighter, RedsiftColorPresentationBlueLighter, RedsiftColorPresentationGreyLighter, RedsiftColorPresentationGreenLighterer, RedsiftColorPresentationPinkLighterer, RedsiftColorPresentationAquaLighterer, RedsiftColorPresentationBrownLighterer, RedsiftColorPresentationRedLighterer, RedsiftColorPresentationYellowLighterer, RedsiftColorPresentationPurpleLighterer, RedsiftColorPresentationOrangeLighterer, RedsiftColorPresentationBlueLighterer, RedsiftColorPresentationGreyLighterer, useId, Text, Number as Number$1, baseStyling, baseContainer, 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 } from 'react';
5
5
  import classNames from 'classnames';
@@ -332,7 +332,11 @@ const DataPoint = /*#__PURE__*/forwardRef((props, ref) => {
332
332
  forwardedProps = _objectWithoutProperties(props, _excluded$k);
333
333
  const [_id] = useId();
334
334
  const id = propsId !== null && propsId !== void 0 ? propsId : _id;
335
- const text = labelDecorator ? labelDecorator(data) : data.data.key;
335
+ const text = labelDecorator ? labelDecorator(data, {
336
+ index,
337
+ isSelected: propsIsSelected,
338
+ color: props.color
339
+ }) : data.data.key;
336
340
  const hasText = text && tooltipVariant !== TooltipVariant.none;
337
341
  const tooltipValue = tooltipVariant === TooltipVariant.value ? data.data.value : tooltipVariant === TooltipVariant.percent && data.data.percent ? data.data.percent : undefined;
338
342
  const hasValue = tooltipValue && [TooltipVariant.value, TooltipVariant.percent].includes(tooltipVariant);
@@ -829,23 +833,23 @@ const Axis = /*#__PURE__*/forwardRef((props, ref) => {
829
833
  keys: tick => tick.key,
830
834
  initial: tick => ({
831
835
  opacity: 1,
832
- transform: `translate(${tick.x},${tick.y})`,
833
- textTransform: `translate(${tick.textX},${tick.textY}) rotate(${tickRotation})`
836
+ transform: `translate(${tick.x},${axis === 'x' ? tick.y : (y || 0) - tick.y}),rotate(${axis === 'x' ? 0 : 180})`,
837
+ textTransform: `translate(${tick.textX},${tick.textY}),rotate(${tickRotation})`
834
838
  }),
835
839
  from: tick => ({
836
840
  opacity: 0,
837
- transform: `translate(${tick.x},${tick.y})`,
838
- textTransform: `translate(${tick.textX},${tick.textY}) rotate(${tickRotation})`
841
+ transform: `translate(${tick.x},${axis === 'x' ? tick.y : (y || 0) - tick.y}),rotate(${axis === 'x' ? 0 : 180})`,
842
+ textTransform: `translate(${tick.textX},${tick.textY}),rotate(${tickRotation})`
839
843
  }),
840
844
  enter: tick => ({
841
845
  opacity: 1,
842
- transform: `translate(${tick.x},${tick.y})`,
843
- textTransform: `translate(${tick.textX},${tick.textY}) rotate(${tickRotation})`
846
+ transform: `translate(${tick.x},${axis === 'x' ? tick.y : (y || 0) - tick.y}),rotate(${axis === 'x' ? 0 : 180})`,
847
+ textTransform: `translate(${tick.textX},${tick.textY}),rotate(${tickRotation})`
844
848
  }),
845
849
  update: tick => ({
846
850
  opacity: 1,
847
- transform: `translate(${tick.x},${tick.y})`,
848
- textTransform: `translate(${tick.textX},${tick.textY}) rotate(${tickRotation})`
851
+ transform: `translate(${tick.x},${axis === 'x' ? tick.y : (y || 0) - tick.y}),rotate(${axis === 'x' ? 0 : 180})`,
852
+ textTransform: `translate(${tick.textX},${tick.textY}),rotate(${tickRotation})`
849
853
  }),
850
854
  leave: {
851
855
  opacity: 0
@@ -854,7 +858,7 @@ const Axis = /*#__PURE__*/forwardRef((props, ref) => {
854
858
  return /*#__PURE__*/React__default.createElement(StyledAxis, _extends({
855
859
  className: classNames(Axis.className, className)
856
860
  }, forwardedProps, {
857
- transform: `translate(${x},${y})`,
861
+ transform: `translate(${x},${y})${axis === 'x' ? '' : ',rotate(180)'}`,
858
862
  ref: axisRef
859
863
  }), variant === AxisVariant.default || variant === AxisVariant.tick || variant === AxisVariant.lineTick || variant === AxisVariant.tickValue ? transition((transitionProps, tick, _state, tickIndex) => {
860
864
  return /*#__PURE__*/React__default.createElement(it.g, {
@@ -952,7 +956,7 @@ const StyledBar = styled(DataPoint)`
952
956
  }}}
953
957
  `;
954
958
 
955
- const _excluded$g = ["className", "gap", "height", "orientation", "previousData", "scale", "width"];
959
+ const _excluded$g = ["className", "gap", "height", "maxHeight", "orientation", "previousData", "scale", "width"];
956
960
  const COMPONENT_NAME$7 = 'Bar';
957
961
  const CLASSNAME$7 = 'redsift-bar';
958
962
  const DEFAULT_PROPS$7 = {
@@ -960,6 +964,7 @@ const DEFAULT_PROPS$7 = {
960
964
  index: 0,
961
965
  gap: 5,
962
966
  height: 40,
967
+ maxHeight: 100,
963
968
  orientation: BarOrientation.horizontal,
964
969
  previousData: {
965
970
  data: {
@@ -984,6 +989,7 @@ const Bar = /*#__PURE__*/forwardRef((props, ref) => {
984
989
  className,
985
990
  gap,
986
991
  height,
992
+ maxHeight,
987
993
  orientation,
988
994
  previousData,
989
995
  scale,
@@ -991,9 +997,14 @@ const Bar = /*#__PURE__*/forwardRef((props, ref) => {
991
997
  } = props,
992
998
  forwardedProps = _objectWithoutProperties(props, _excluded$g);
993
999
  const interpolator = interpolate(((_data = previousData.data) === null || _data === void 0 ? void 0 : _data.value) || 0, data.data.value);
994
- const text = labelDecorator ? labelDecorator(data) : data.data.key;
1000
+ const text = labelDecorator ? labelDecorator(data, {
1001
+ index,
1002
+ isSelected: propsIsSelected,
1003
+ color
1004
+ }) : data.data.key;
995
1005
  const isSelectable = role === 'option';
996
1006
  const isDeselected = isSelectable && propsIsSelected === false;
1007
+ const isHorizontal = orientation === BarOrientation.horizontal;
997
1008
  const animatedProps = J(_objectSpread2(_objectSpread2({}, config), {}, {
998
1009
  to: async next => {
999
1010
  await next({
@@ -1007,17 +1018,17 @@ const Bar = /*#__PURE__*/forwardRef((props, ref) => {
1007
1018
  return /*#__PURE__*/React__default.createElement(StyledBar, _extends({}, forwardedProps, {
1008
1019
  ref: ref,
1009
1020
  className: classNames(Bar.className, className),
1010
- transform: orientation === BarOrientation.horizontal ? `translate(0, ${gap * (index + 1) + height * index})` : `translate(${gap * (index + 1) + width * index}, 0)`,
1021
+ transform: isHorizontal ? `translate(0, ${gap * (index + 1) + height * index})` : `translate(${gap * (index + 1) + width * index + width}, ${maxHeight}), rotate(180)`,
1011
1022
  $clickable: Boolean(onClick)
1012
- }), orientation === BarOrientation.horizontal ? /*#__PURE__*/React__default.createElement(it.rect, {
1023
+ }), isHorizontal ? /*#__PURE__*/React__default.createElement(it.rect, {
1013
1024
  height: height,
1014
1025
  fill: isDeselected ? 'var(--redsift-color-neutral-lightgrey)' : color,
1015
1026
  width: config.immediate ? scale(data.data.value) : animatedProps.t.to(t => scale(interpolator(t)))
1016
1027
  }) : /*#__PURE__*/React__default.createElement(it.rect, {
1017
- height: config.immediate ? scale(data.data.value) : animatedProps.t.to(t => scale(interpolator(t))),
1028
+ height: config.immediate ? maxHeight - scale(data.data.value) : animatedProps.t.to(t => maxHeight - scale(interpolator(t))),
1018
1029
  fill: isDeselected ? 'var(--redsift-color-neutral-lightgrey)' : color,
1019
1030
  width: width
1020
- }), orientation === BarOrientation.horizontal ? /*#__PURE__*/React__default.createElement("text", {
1031
+ }), isHorizontal ? /*#__PURE__*/React__default.createElement("text", {
1021
1032
  x: "10",
1022
1033
  y: height / 2,
1023
1034
  dy: "0.35em",
@@ -1049,8 +1060,6 @@ var intlMessages = {
1049
1060
  const StyledChartContainer = styled.div`
1050
1061
  ${baseStyling}
1051
1062
 
1052
- margin: 8px;
1053
- padding: 8px;
1054
1063
  color: var(--redsift-color-neutral-black);
1055
1064
 
1056
1065
  .redsift-chart-container__content {
@@ -1060,9 +1069,10 @@ const StyledChartContainer = styled.div`
1060
1069
  font-family: var(--redsift-typography-font-family-poppins);
1061
1070
  font-size: 11px;
1062
1071
  justify-content: center;
1063
- margin: 8px 0;
1064
1072
  position: relative;
1065
1073
 
1074
+ ${baseContainer}
1075
+
1066
1076
  ${focusRing}
1067
1077
  }
1068
1078
 
@@ -1261,7 +1271,7 @@ const LoadingBarChart = /*#__PURE__*/forwardRef((props, ref) => {
1261
1271
  }), "Loading...");
1262
1272
  });
1263
1273
 
1264
- const _excluded$c = ["areXLabelsRotated", "barProps", "caping", "className", "data", "id", "isBarSelected", "labelDecorator", "onBarClick", "others", "size", "barRole", "theme", "tooltipVariant"];
1274
+ const _excluded$c = ["areXLabelsRotated", "barProps", "caping", "className", "data", "id", "isBarSelected", "labelDecorator", "onBarClick", "orientation", "others", "size", "barRole", "theme", "tooltipVariant"];
1265
1275
  const RenderedBarChart = /*#__PURE__*/forwardRef((props, ref) => {
1266
1276
  const {
1267
1277
  areXLabelsRotated,
@@ -1273,6 +1283,7 @@ const RenderedBarChart = /*#__PURE__*/forwardRef((props, ref) => {
1273
1283
  isBarSelected,
1274
1284
  labelDecorator,
1275
1285
  onBarClick,
1286
+ orientation,
1276
1287
  others,
1277
1288
  size,
1278
1289
  barRole,
@@ -1293,12 +1304,13 @@ const RenderedBarChart = /*#__PURE__*/forwardRef((props, ref) => {
1293
1304
  useEffect(() => {
1294
1305
  cache.current = data;
1295
1306
  });
1307
+ const isHorizontal = orientation === BarOrientation.horizontal;
1296
1308
  const chartDimensions = sizeToDimension$2(size);
1297
1309
  const width = chartDimensions.width;
1298
1310
  const height = chartDimensions.height;
1299
1311
  const margins = {
1300
1312
  top: 16,
1301
- left: 16,
1313
+ left: isHorizontal ? 16 : 64,
1302
1314
  right: 16,
1303
1315
  bottom: 32
1304
1316
  };
@@ -1306,14 +1318,16 @@ const RenderedBarChart = /*#__PURE__*/forwardRef((props, ref) => {
1306
1318
  const chartWidth = width - margins.left - margins.right;
1307
1319
  const numberOfRows = data.filter(datum => datum.value).length;
1308
1320
  const gap = 5;
1321
+ const barHeight = (chartHeight - (numberOfRows + 1) * gap) / numberOfRows;
1322
+ const barWidth = (chartWidth - (numberOfRows + 1) * gap) / numberOfRows;
1323
+ const total = sum(data, d => d.value);
1309
1324
  const scale = useMemo(() => scaleLinear().domain([0, Math.max(...data.map(_ref => {
1310
1325
  let {
1311
1326
  value
1312
1327
  } = _ref;
1313
1328
  return value;
1314
- }))]).range([0, chartWidth]), [size]);
1315
- const barHeight = (chartHeight - (numberOfRows + 1) * gap) / numberOfRows;
1316
- const total = sum(data, d => d.value);
1329
+ }))]).range(isHorizontal ? [0, chartWidth] : [chartHeight, 0]), [size]);
1330
+ const scaleCategory = useMemo(() => scalePoint().domain(data.filter(datum => datum.value).map(datum => datum.key)).range([0, (numberOfRows - 1) * barWidth + (numberOfRows - 1) * gap]), [size]);
1317
1331
  return /*#__PURE__*/React__default.createElement(StyledBarChart, _extends({}, forwardedProps, {
1318
1332
  id: id,
1319
1333
  className: className,
@@ -1323,7 +1337,7 @@ const RenderedBarChart = /*#__PURE__*/forwardRef((props, ref) => {
1323
1337
  height: height
1324
1338
  }, /*#__PURE__*/React__default.createElement("g", {
1325
1339
  transform: `translate(${margins.left},${margins.top})`
1326
- }, /*#__PURE__*/React__default.createElement(Axis, {
1340
+ }, isHorizontal ? /*#__PURE__*/React__default.createElement(Axis, {
1327
1341
  position: "bottom",
1328
1342
  length: chartWidth,
1329
1343
  scale: scale,
@@ -1331,7 +1345,24 @@ const RenderedBarChart = /*#__PURE__*/forwardRef((props, ref) => {
1331
1345
  y: chartHeight,
1332
1346
  tickValues: 4,
1333
1347
  tickRotation: areXLabelsRotated ? -45 : 0
1334
- }), data.filter(datum => datum.value).map((datum, index) => {
1348
+ }) : /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(Axis, {
1349
+ position: "left",
1350
+ length: chartHeight,
1351
+ scale: scale,
1352
+ x: 0,
1353
+ y: chartHeight,
1354
+ tickValues: 4,
1355
+ tickRotation: areXLabelsRotated ? -45 : 0
1356
+ }), /*#__PURE__*/React__default.createElement(Axis, {
1357
+ position: "bottom",
1358
+ length: chartWidth,
1359
+ scale: scaleCategory,
1360
+ x: gap + barWidth / 2,
1361
+ y: chartHeight,
1362
+ tickValues: 4,
1363
+ tickRotation: areXLabelsRotated ? -45 : 0,
1364
+ variant: "tickValue"
1365
+ })), data.filter(datum => datum.value).map((datum, index) => {
1335
1366
  const percent = datum.value / total;
1336
1367
  const to = {
1337
1368
  data: _objectSpread2(_objectSpread2({}, datum), {}, {
@@ -1345,26 +1376,30 @@ const RenderedBarChart = /*#__PURE__*/forwardRef((props, ref) => {
1345
1376
  color: colorScale === null || colorScale === void 0 ? void 0 : colorScale(to.data.key),
1346
1377
  data: to,
1347
1378
  gap: gap,
1348
- height: barHeight,
1379
+ height: isHorizontal ? barHeight : undefined,
1349
1380
  id: `id${id}__bar-${index}`,
1350
1381
  index: index,
1351
1382
  isSelected: Boolean(isBarSelected(to)),
1352
1383
  key: `bar _${index}`,
1353
1384
  labelDecorator: labelDecorator,
1385
+ maxHeight: isHorizontal ? undefined : chartHeight,
1354
1386
  onClick: onBarClick,
1387
+ orientation: orientation,
1355
1388
  previousData: from,
1356
1389
  role: barRole,
1357
1390
  scale: scale,
1358
- tooltipVariant: tooltipVariant
1391
+ tooltipVariant: tooltipVariant,
1392
+ width: isHorizontal ? undefined : barWidth
1359
1393
  }));
1360
1394
  }))));
1361
1395
  });
1362
1396
 
1363
- const _excluded$b = ["areXLabelsRotated", "caping", "chartRef", "className", "data", "emptyComponent", "id", "isBarSelected", "labelDecorator", "localeText", "onBarClick", "others", "size", "barRole", "theme", "tooltipVariant"];
1397
+ const _excluded$b = ["areXLabelsRotated", "caping", "chartRef", "className", "data", "emptyComponent", "id", "isBarSelected", "labelDecorator", "localeText", "onBarClick", "orientation", "others", "size", "barRole", "theme", "tooltipVariant"];
1364
1398
  const COMPONENT_NAME$5 = 'BarChart';
1365
1399
  const CLASSNAME$5 = 'redsift-barchart';
1366
1400
  const DEFAULT_PROPS$5 = {
1367
1401
  isBarSelected: () => true,
1402
+ orientation: BarOrientation.horizontal,
1368
1403
  others: true,
1369
1404
  size: ChartSize.medium,
1370
1405
  theme: ColorTheme.default,
@@ -1386,6 +1421,7 @@ const BarChart = /*#__PURE__*/forwardRef((props, ref) => {
1386
1421
  labelDecorator,
1387
1422
  localeText,
1388
1423
  onBarClick,
1424
+ orientation,
1389
1425
  others,
1390
1426
  size,
1391
1427
  barRole,
@@ -1424,6 +1460,7 @@ const BarChart = /*#__PURE__*/forwardRef((props, ref) => {
1424
1460
  isBarSelected: isBarSelected,
1425
1461
  labelDecorator: labelDecorator,
1426
1462
  onBarClick: onBarClick,
1463
+ orientation: orientation,
1427
1464
  others: others,
1428
1465
  size: size,
1429
1466
  theme: theme,
@@ -1513,15 +1550,10 @@ Dot.displayName = COMPONENT_NAME$4;
1513
1550
  * Component style.
1514
1551
  */
1515
1552
  const StyledLegend = styled.ul`
1516
- max-width: 262px;
1517
- ${_ref => {
1518
- let {
1519
- $width
1520
- } = _ref;
1521
- return $width !== undefined ? css`
1522
- width: ${$width};
1523
- ` : null;
1524
- }}
1553
+ display: flex;
1554
+ flex-direction: column;
1555
+
1556
+ ${baseContainer}
1525
1557
  `;
1526
1558
 
1527
1559
  /**
@@ -1595,7 +1627,11 @@ const LegendItem = /*#__PURE__*/forwardRef((props, ref) => {
1595
1627
  forwardedProps = _objectWithoutProperties(props, _excluded$9);
1596
1628
  const [_id] = useId();
1597
1629
  const id = propsId !== null && propsId !== void 0 ? propsId : _id;
1598
- const text = labelDecorator ? labelDecorator(data) : data.data.key;
1630
+ const text = labelDecorator ? labelDecorator(data, {
1631
+ index,
1632
+ isSelected: propsIsSelected,
1633
+ color
1634
+ }) : data.data.key;
1599
1635
  const isEmpty = data.data.value === 0;
1600
1636
  const isSelectable = role === 'option';
1601
1637
  const isSelected = isSelectable && propsIsSelected === true;
@@ -1624,7 +1660,7 @@ const LegendItem = /*#__PURE__*/forwardRef((props, ref) => {
1624
1660
  role: role ? role : onClick ? 'button' : undefined,
1625
1661
  tabIndex: onClick ? 0 : undefined,
1626
1662
  $clickable: Boolean(onClick)
1627
- }), /*#__PURE__*/React__default.createElement("div", null), variant === LabelVariant.value ? /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(Number$1, {
1663
+ }), /*#__PURE__*/React__default.createElement("div", null), typeof text === 'string' ? variant === LabelVariant.value ? /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(Number$1, {
1628
1664
  as: "b",
1629
1665
  maximumFractionDigits: 2,
1630
1666
  value: data.data.value,
@@ -1641,7 +1677,7 @@ const LegendItem = /*#__PURE__*/forwardRef((props, ref) => {
1641
1677
  variant: "caption"
1642
1678
  }, text)) : /*#__PURE__*/React__default.createElement(Text, {
1643
1679
  variant: "caption"
1644
- }, text));
1680
+ }, text) : /*#__PURE__*/React__default.createElement(React__default.Fragment, null, text));
1645
1681
  });
1646
1682
  LegendItem.className = CLASSNAME$3;
1647
1683
  LegendItem.defaultProps = DEFAULT_PROPS$3;
@@ -1881,7 +1917,7 @@ const LoadingPieChart = /*#__PURE__*/forwardRef((props, ref) => {
1881
1917
  }), "Loading...");
1882
1918
  });
1883
1919
 
1884
- const sizeToDimension$1 = size => {
1920
+ const sizeToDimension$1 = (size, isHalf) => {
1885
1921
  if (typeof size !== 'string') {
1886
1922
  return size;
1887
1923
  }
@@ -1889,7 +1925,7 @@ const sizeToDimension$1 = size => {
1889
1925
  case ChartSize.small:
1890
1926
  return {
1891
1927
  width: 200,
1892
- height: 200,
1928
+ height: 200 * (isHalf ? 0.5 : 1),
1893
1929
  smallFontSize: 13,
1894
1930
  fontSize: 30,
1895
1931
  innerRadius: 55
@@ -1897,7 +1933,7 @@ const sizeToDimension$1 = size => {
1897
1933
  case ChartSize.large:
1898
1934
  return {
1899
1935
  width: 300,
1900
- height: 300,
1936
+ height: 300 * (isHalf ? 0.5 : 1),
1901
1937
  smallFontSize: 18,
1902
1938
  fontSize: 38,
1903
1939
  innerRadius: 80
@@ -1906,7 +1942,7 @@ const sizeToDimension$1 = size => {
1906
1942
  default:
1907
1943
  return {
1908
1944
  width: 240,
1909
- height: 240,
1945
+ height: 240 * (isHalf ? 0.5 : 1),
1910
1946
  smallFontSize: 14,
1911
1947
  fontSize: 34,
1912
1948
  innerRadius: 65
@@ -1974,13 +2010,14 @@ const EmptyPieChart = /*#__PURE__*/forwardRef((props, ref) => {
1974
2010
  }))));
1975
2011
  });
1976
2012
 
1977
- const _excluded$5 = ["caping", "className", "data", "id", "isSliceSelected", "labelDecorator", "labelVariant", "legendProps", "middleText", "onSliceClick", "others", "size", "sliceProps", "sliceRole", "subtext", "text", "theme", "tooltipVariant", "variant"];
2013
+ const _excluded$5 = ["caping", "className", "data", "id", "isHalf", "isSliceSelected", "labelDecorator", "labelVariant", "legendProps", "middleText", "onSliceClick", "others", "size", "sliceProps", "sliceRole", "subtext", "text", "theme", "tooltipVariant", "variant"];
1978
2014
  const RenderedPieChart = /*#__PURE__*/forwardRef((props, ref) => {
1979
2015
  const {
1980
2016
  caping,
1981
2017
  className,
1982
2018
  data: propsData,
1983
2019
  id,
2020
+ isHalf,
1984
2021
  isSliceSelected,
1985
2022
  labelDecorator,
1986
2023
  labelVariant,
@@ -2000,6 +2037,7 @@ const RenderedPieChart = /*#__PURE__*/forwardRef((props, ref) => {
2000
2037
  forwardedProps = _objectWithoutProperties(props, _excluded$5);
2001
2038
  const cache = useRef();
2002
2039
  const isDonut = variant === PieChartVariant.donut || variant === PieChartVariant.spacedDonut;
2040
+ const isSpaced = variant === PieChartVariant.spaced || variant === PieChartVariant.spacedDonut;
2003
2041
  const {
2004
2042
  data,
2005
2043
  colorScale
@@ -2018,9 +2056,9 @@ const RenderedPieChart = /*#__PURE__*/forwardRef((props, ref) => {
2018
2056
  smallFontSize,
2019
2057
  fontSize,
2020
2058
  innerRadius
2021
- } = sizeToDimension$1(size);
2059
+ } = sizeToDimension$1(size, isHalf);
2022
2060
  const externalRadiusPadding = 8;
2023
- const createPie = pie().value(d => d.value).sort(null);
2061
+ const createPie = pie().value(d => d.value).sort(null).startAngle(isHalf ? Math.PI * -0.5 : 0).endAngle(isHalf ? Math.PI * 0.5 : Math.PI * 2);
2024
2062
  const createArc = arc().innerRadius(isDonut ? innerRadius : 0).outerRadius(width / 2 - externalRadiusPadding);
2025
2063
  const pieData = createPie(data);
2026
2064
  const previousPieData = cache.current ? createPie(cache.current) : undefined;
@@ -2065,7 +2103,7 @@ const RenderedPieChart = /*#__PURE__*/forwardRef((props, ref) => {
2065
2103
  $smallTextSize: smallFontSize
2066
2104
  }, subtext ? /*#__PURE__*/React__default.createElement("b", null, text) : /*#__PURE__*/React__default.createElement("span", null, text), middleText ? /*#__PURE__*/React__default.createElement("b", null, middleText) : null, /*#__PURE__*/React__default.createElement("span", null, subtext)) : null, /*#__PURE__*/React__default.createElement("svg", {
2067
2105
  width: width,
2068
- height: height
2106
+ height: isHalf ? height + externalRadiusPadding : height
2069
2107
  }, /*#__PURE__*/React__default.createElement(Arcs, {
2070
2108
  arcs: pieData.filter(datum => datum.data.value).map((datum, index) => {
2071
2109
  const percent = datum.data.value / total;
@@ -2074,8 +2112,8 @@ const RenderedPieChart = /*#__PURE__*/forwardRef((props, ref) => {
2074
2112
  key: '',
2075
2113
  value: 0
2076
2114
  },
2077
- startAngle: 0,
2078
- endAngle: 0,
2115
+ startAngle: isHalf ? Math.PI * -0.5 : 0,
2116
+ endAngle: isHalf ? Math.PI * -0.5 : 0,
2079
2117
  padAngle: 0,
2080
2118
  value: 0,
2081
2119
  index: index
@@ -2097,20 +2135,20 @@ const RenderedPieChart = /*#__PURE__*/forwardRef((props, ref) => {
2097
2135
  };
2098
2136
  }),
2099
2137
  hasLabels: labelVariant === PieChartLabelVariant.internal,
2100
- hasStroke: variant === PieChartVariant.spaced || variant === PieChartVariant.spacedDonut,
2138
+ hasStroke: isSpaced,
2101
2139
  labelDecorator: labelDecorator,
2102
2140
  onClick: onSliceClick,
2103
2141
  role: sliceRole,
2104
2142
  sliceProps: sliceProps,
2105
2143
  tooltipVariant: tooltipVariant,
2106
- transform: `translate(${width / 2} ${height / 2})`
2144
+ transform: `translate(${width / 2} ${isHalf ? height : height / 2})`
2107
2145
  }))), labelVariant !== PieChartLabelVariant.none && labelVariant !== PieChartLabelVariant.internal ? /*#__PURE__*/React__default.createElement(Legend, _extends({
2108
2146
  data: data.map(d => _objectSpread2(_objectSpread2({}, d), {}, {
2109
2147
  color: colorScale === null || colorScale === void 0 ? void 0 : colorScale(d.key)
2110
2148
  })),
2111
2149
  variant: labelVariant === PieChartLabelVariant.externalLabelValue ? LabelVariant.value : labelVariant === PieChartLabelVariant.externalLabelPercent ? LabelVariant.percent : LabelVariant.label,
2112
2150
  width: legendWidth.current,
2113
- labelDecorator: labelDecorator ? datum => labelDecorator(datum) : undefined
2151
+ labelDecorator: labelDecorator ? (datum, props) => labelDecorator(datum, props) : undefined
2114
2152
  }, legendProps)) : null);
2115
2153
  });
2116
2154
 
@@ -2393,11 +2431,10 @@ var mdiChevronDown = "M7.41,8.58L12,13.17L16.59,8.58L18,10L12,16L6,10L7.41,8.58Z
2393
2431
  var mdiChevronRight = "M8.59,16.58L13.17,12L8.59,7.41L10,6L16,12L10,18L8.59,16.58Z";
2394
2432
  var mdiMouse = "M11,1.07C7.05,1.56 4,4.92 4,9H11M4,15A8,8 0 0,0 12,23A8,8 0 0,0 20,15V11H4M13,1.07V9H20C20,4.92 16.94,1.56 13,1.07Z";
2395
2433
 
2396
- const _excluded$1 = ["isBrushable", "caption", "className", "data", "dotRole", "hideControlKeyPanel", "id", "isDotSelected", "labelDecorator", "labelVariant", "legendProps", "onBrush", "onBrushEnd", "onDotClick", "size", "theme", "tooltipVariant", "variant", "xAxisVariant", "xAxisPlacement", "yAxisVariant", "yAxisPlacement"];
2434
+ const _excluded$1 = ["isBrushable", "className", "data", "dotRole", "hideControlKeyPanel", "id", "isDotSelected", "labelDecorator", "labelVariant", "legendProps", "onBrush", "onBrushEnd", "onDotClick", "size", "theme", "tooltipVariant", "variant", "xAxisVariant", "xAxisPlacement", "yAxisVariant", "yAxisPlacement"];
2397
2435
  const RenderedScatterPlot = /*#__PURE__*/forwardRef((props, ref) => {
2398
2436
  const {
2399
2437
  isBrushable,
2400
- caption,
2401
2438
  className,
2402
2439
  data: propsData,
2403
2440
  dotRole,
@@ -2608,7 +2645,7 @@ const RenderedScatterPlot = /*#__PURE__*/forwardRef((props, ref) => {
2608
2645
  length: chartHeight,
2609
2646
  scale: scaleY,
2610
2647
  x: 0,
2611
- y: 0,
2648
+ y: chartHeight,
2612
2649
  tickValues: 8,
2613
2650
  variant: yAxisVariant
2614
2651
  }) : null, ['right', 'both'].includes(yAxisPlacement) ? /*#__PURE__*/React__default.createElement(Axis, {
@@ -2616,12 +2653,10 @@ const RenderedScatterPlot = /*#__PURE__*/forwardRef((props, ref) => {
2616
2653
  length: chartHeight,
2617
2654
  scale: scaleY,
2618
2655
  x: chartWidth,
2619
- y: 0,
2656
+ y: chartHeight,
2620
2657
  tickValues: 8,
2621
2658
  variant: yAxisVariant
2622
- }) : null)), /*#__PURE__*/React__default.createElement(StyledChartContainerCaption, {
2623
- width: chartWidth - 48
2624
- }, caption)), hasCategory && labelVariant !== ScatterPlotLabelVariant.none ? /*#__PURE__*/React__default.createElement(Legend, _extends({
2659
+ }) : null))), hasCategory && labelVariant !== ScatterPlotLabelVariant.none ? /*#__PURE__*/React__default.createElement(Legend, _extends({
2625
2660
  data: countsByCategory.map(d => _objectSpread2(_objectSpread2({}, d), {}, {
2626
2661
  color: colorScale === null || colorScale === void 0 ? void 0 : colorScale(d.key)
2627
2662
  })),