@redsift/charts 10.1.0-alpha.3 → 10.1.0-alpha.4

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.
Files changed (4) hide show
  1. package/index.d.ts +79 -57
  2. package/index.js +309 -271
  3. package/index.js.map +1 -1
  4. package/package.json +2 -2
package/index.d.ts CHANGED
@@ -136,6 +136,7 @@ type Datum<T> = {
136
136
  key: T;
137
137
  value: number;
138
138
  percent?: number;
139
+ cumulativeValue?: number;
139
140
  };
140
141
  type EmptyDatum<T> = {
141
142
  key: T;
@@ -561,6 +562,73 @@ declare const StyledChartContainerCaption: styled_components.StyledComponent<"p"
561
562
  $theme: Theme;
562
563
  }, never>;
563
564
 
565
+ /**
566
+ * Component props.
567
+ */
568
+ interface LegendItemProps extends Pick<DataPointProps<LegendItemDatum>, 'color' | 'data' | 'id' | 'index' | 'isSelected' | 'labelDecorator' | 'onClick' | 'previousData' | 'role' | 'tooltipVariant'>, Omit<ComponentProps<'li'>, 'onClick' | 'role'> {
569
+ /** Method modifying what's displayed within the legend when the variant is "custom". */
570
+ legendDecorator?: (datum: LegendItemDatum, props?: {
571
+ index?: number;
572
+ isSelected?: boolean;
573
+ color?: string;
574
+ }) => string | ReactElement;
575
+ /** Variant. */
576
+ variant?: LegendVariant;
577
+ }
578
+
579
+ /**
580
+ * Component props.
581
+ */
582
+ interface LegendProps extends Omit<ComponentProps<'ul'>, 'onClick'>, ContainerProps {
583
+ /** Data. */
584
+ data: (Statistic & {
585
+ color: string;
586
+ })[];
587
+ /** Method to determine whether a slice is selected or not. */
588
+ isLegendItemSelected?: (datum: LegendItemDatum) => void;
589
+ /** Method to override the data labels. */
590
+ labelDecorator?: (datum: LegendItemDatum, props?: {
591
+ index?: number;
592
+ isSelected?: boolean;
593
+ color?: string;
594
+ }) => string | ReactElement;
595
+ /** Method modifying what's displayed within the legend when the variant is "custom". */
596
+ legendDecorator?: (datum: LegendItemDatum, props?: {
597
+ index?: number;
598
+ isSelected?: boolean;
599
+ color?: string;
600
+ }) => string | ReactElement;
601
+ /** Method to be called on a click on a legend item. */
602
+ onLegendItemClick?: (datum: LegendItemDatum) => void;
603
+ /** 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. */
604
+ legendItemRole?: LegendItemProps['role'];
605
+ /** Variant. */
606
+ variant?: LegendVariant;
607
+ }
608
+ type StyledLegendProps = Omit<LegendProps, 'data'> & {
609
+ $width?: LegendProps['width'];
610
+ };
611
+
612
+ declare const Legend: Comp<LegendProps, HTMLUListElement>;
613
+
614
+ /**
615
+ * Component style.
616
+ */
617
+ declare const StyledLegend: styled_components.StyledComponent<"ul", any, Omit<LegendProps, "data"> & {
618
+ $width?: string | number | undefined;
619
+ }, never>;
620
+
621
+ /**
622
+ * Component's labels variant.
623
+ */
624
+ declare const BarChartLegendVariant: {
625
+ readonly none: "none";
626
+ readonly externalLabel: "externalLabel";
627
+ readonly externalLabelValue: "externalLabelValue";
628
+ readonly externalLabelPercent: "externalLabelPercent";
629
+ readonly custom: "custom";
630
+ };
631
+ type BarChartLegendVariant = ValueOf<typeof BarChartLegendVariant>;
564
632
  interface LocaleText$3 {
565
633
  emptyChartText: string;
566
634
  }
@@ -589,6 +657,16 @@ interface BarChartProps extends ChartContainerProps, ChartAxesProps {
589
657
  isSelected?: boolean;
590
658
  color?: string;
591
659
  }) => string | ReactElement;
660
+ /** Method modifying what's displayed within the legend when the legendVariant is "custom". */
661
+ legendDecorator?: (datum: BarDatum, props?: {
662
+ index?: number;
663
+ isSelected?: boolean;
664
+ color?: string;
665
+ }) => string | ReactElement;
666
+ /** Define whether the labels should be displayed inside or outside the charts and if they should contain raw or percentage values. If set to "custom", use `legendDecorator` to customize it. */
667
+ legendVariant?: BarChartLegendVariant;
668
+ /** Props to forward to the Legend block. Can be used to make the legend selectable. */
669
+ legendProps?: Omit<LegendProps, 'data' | 'ref' | 'variant' | 'width'>;
592
670
  /** Labels and texts. */
593
671
  localeText?: LocaleText$3;
594
672
  /** Custom margins, used to give more space for axes labels and legend for instance. */
@@ -668,62 +746,6 @@ declare const StyledDot: styled_components.StyledComponent<_redsift_design_syste
668
746
  $theme: _redsift_design_system.Theme;
669
747
  }, never>;
670
748
 
671
- /**
672
- * Component props.
673
- */
674
- interface LegendItemProps extends Pick<DataPointProps<LegendItemDatum>, 'color' | 'data' | 'id' | 'index' | 'isSelected' | 'labelDecorator' | 'onClick' | 'previousData' | 'role' | 'tooltipVariant'>, Omit<ComponentProps<'li'>, 'onClick' | 'role'> {
675
- /** Method modifying what's displayed within the legend when the variant is "custom". */
676
- legendDecorator?: (datum: LegendItemDatum, props?: {
677
- index?: number;
678
- isSelected?: boolean;
679
- color?: string;
680
- }) => string | ReactElement;
681
- /** Variant. */
682
- variant?: LegendVariant;
683
- }
684
-
685
- /**
686
- * Component props.
687
- */
688
- interface LegendProps extends Omit<ComponentProps<'ul'>, 'onClick'>, ContainerProps {
689
- /** Data. */
690
- data: (Statistic & {
691
- color: string;
692
- })[];
693
- /** Method to determine whether a slice is selected or not. */
694
- isLegendItemSelected?: (datum: LegendItemDatum) => void;
695
- /** Method to override the data labels. */
696
- labelDecorator?: (datum: LegendItemDatum, props?: {
697
- index?: number;
698
- isSelected?: boolean;
699
- color?: string;
700
- }) => string | ReactElement;
701
- /** Method modifying what's displayed within the legend when the variant is "custom". */
702
- legendDecorator?: (datum: LegendItemDatum, props?: {
703
- index?: number;
704
- isSelected?: boolean;
705
- color?: string;
706
- }) => string | ReactElement;
707
- /** Method to be called on a click on a legend item. */
708
- onLegendItemClick?: (datum: LegendItemDatum) => void;
709
- /** 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. */
710
- legendItemRole?: LegendItemProps['role'];
711
- /** Variant. */
712
- variant?: LegendVariant;
713
- }
714
- type StyledLegendProps = Omit<LegendProps, 'data'> & {
715
- $width?: LegendProps['width'];
716
- };
717
-
718
- declare const Legend: Comp<LegendProps, HTMLUListElement>;
719
-
720
- /**
721
- * Component style.
722
- */
723
- declare const StyledLegend: styled_components.StyledComponent<"ul", any, Omit<LegendProps, "data"> & {
724
- $width?: string | number | undefined;
725
- }, never>;
726
-
727
749
  /**
728
750
  * Component props.
729
751
  */
@@ -1046,4 +1068,4 @@ declare const StyledScatterPlotEmptyText: styled_components.StyledComponent<"div
1046
1068
  $theme: Theme;
1047
1069
  }, never>;
1048
1070
 
1049
- export { AnyScale, Arc, ArcDatum, ArcProps, Arcs, ArcsProps, Axis, AxisPosition, AxisProps, AxisVariant, Bar, BarChart, BarChartDimensions, BarChartProps, BarDatum, BarOrientation, BarProps, CategoricalOrLinearDim, CategoryData, CategoryDatum, CategoryDim, ChartAxesProps, ChartContainer, ChartContainerProps, ChartDimensions, ChartSize, ChartTheme, ColorTheme, Coordinates, CoordinatesCategoryData, CoordinatesCategoryDatum, CoordinatesCategoryDim, CustomColorTheme, DataPoint, DataPointProps, Datum, Dot, DotDatum, DotProps, DotVariant, EmptyDatum, JSONArray, JSONObject, JSONValue, LabelVariant, Legend, LegendItemDatum, LegendProps, LegendVariant, Line, LineChart, LineChartDimensions, LineChartLegendVariant, LineChartProps, LinePointDatum, LineProps, LinearData, LinearDatum, LinearDim, MarginProps, NumericValue, PieChart, PieChartDimensions, PieChartLegendVariant, PieChartProps, PieChartVariant, Scale, ScaleBand, ScaleLinear, ScaleLog, ScalePoint, ScaleSymlog, ScaleTime, ScaleTypeToScale, ScaleValue, ScaleWithBandwidth, ScatterPlot, ScatterPlotDimensions, ScatterPlotLegendVariant, ScatterPlotProps, ScatterPlotVariant, SortingMethod, Statistic, Statistics, StringValue, StyledArc, StyledArcProps, StyledArcs, StyledArcsProps, StyledAxis, StyledAxisProps, StyledBar, StyledBarChart, StyledBarChartEmptyText, StyledBarChartProps, StyledBarProps, StyledChartContainer, StyledChartContainerCaption, StyledChartContainerProps, StyledChartContainerTitle, StyledDataPoint, StyledDataPointProps, StyledDot, StyledDotProps, StyledLegend, StyledLegendProps, StyledLine, StyledLineChart, StyledLineChartEmptyText, StyledLineChartProps, StyledLineProps, StyledPieChart, StyledPieChartCenterText, StyledPieChartEmptyText, StyledPieChartProps, StyledScatterPlot, StyledScatterPlotEmptyText, StyledScatterPlotProps, SuccessDangerColorTheme, TicksSpec, TooltipVariant, TwoCategoryData, TwoCategoryDatum, TwoCategoryDim, UseBrushProps, UseColorProps, UseFormatCategoricalDataProps, UseZoomProps, empty, getColorScale, getSortingMethod, isValidDate, monochrome, scheme, successDangerScheme, useBrush, useColor, useFormatCategoricalData, useZoom };
1071
+ export { AnyScale, Arc, ArcDatum, ArcProps, Arcs, ArcsProps, Axis, AxisPosition, AxisProps, AxisVariant, Bar, BarChart, BarChartDimensions, BarChartLegendVariant, BarChartProps, BarDatum, BarOrientation, BarProps, CategoricalOrLinearDim, CategoryData, CategoryDatum, CategoryDim, ChartAxesProps, ChartContainer, ChartContainerProps, ChartDimensions, ChartSize, ChartTheme, ColorTheme, Coordinates, CoordinatesCategoryData, CoordinatesCategoryDatum, CoordinatesCategoryDim, CustomColorTheme, DataPoint, DataPointProps, Datum, Dot, DotDatum, DotProps, DotVariant, EmptyDatum, JSONArray, JSONObject, JSONValue, LabelVariant, Legend, LegendItemDatum, LegendProps, LegendVariant, Line, LineChart, LineChartDimensions, LineChartLegendVariant, LineChartProps, LinePointDatum, LineProps, LinearData, LinearDatum, LinearDim, MarginProps, NumericValue, PieChart, PieChartDimensions, PieChartLegendVariant, PieChartProps, PieChartVariant, Scale, ScaleBand, ScaleLinear, ScaleLog, ScalePoint, ScaleSymlog, ScaleTime, ScaleTypeToScale, ScaleValue, ScaleWithBandwidth, ScatterPlot, ScatterPlotDimensions, ScatterPlotLegendVariant, ScatterPlotProps, ScatterPlotVariant, SortingMethod, Statistic, Statistics, StringValue, StyledArc, StyledArcProps, StyledArcs, StyledArcsProps, StyledAxis, StyledAxisProps, StyledBar, StyledBarChart, StyledBarChartEmptyText, StyledBarChartProps, StyledBarProps, StyledChartContainer, StyledChartContainerCaption, StyledChartContainerProps, StyledChartContainerTitle, StyledDataPoint, StyledDataPointProps, StyledDot, StyledDotProps, StyledLegend, StyledLegendProps, StyledLine, StyledLineChart, StyledLineChartEmptyText, StyledLineChartProps, StyledLineProps, StyledPieChart, StyledPieChartCenterText, StyledPieChartEmptyText, StyledPieChartProps, StyledScatterPlot, StyledScatterPlotEmptyText, StyledScatterPlotProps, SuccessDangerColorTheme, TicksSpec, TooltipVariant, TwoCategoryData, TwoCategoryDatum, TwoCategoryDim, UseBrushProps, UseColorProps, UseFormatCategoricalDataProps, UseZoomProps, empty, getColorScale, getSortingMethod, isValidDate, monochrome, scheme, successDangerScheme, useBrush, useColor, useFormatCategoricalData, useZoom };