@redsift/charts 11.4.0-muiv5-alpha.1 → 11.4.0-muiv5-alpha.3
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 +8 -5
- package/index.js +29 -8
- package/index.js.map +1 -1
- package/package.json +2 -2
package/index.d.ts
CHANGED
|
@@ -844,13 +844,16 @@ interface BarChartState extends ChartAxesProps, Required<Pick<RenderedLinearBarC
|
|
|
844
844
|
sectionHeight?: number;
|
|
845
845
|
xScaleType?: XScaleType;
|
|
846
846
|
}
|
|
847
|
-
interface BarChartSectionProps extends Omit<ComponentProps<'g'>, 'onClick' | 'role'> {
|
|
847
|
+
interface BarChartSectionProps extends Omit<ComponentProps<'g'>, 'onClick' | 'role' | 'color'> {
|
|
848
848
|
/** Starting point in percentage of the chart height. */
|
|
849
849
|
from?: number;
|
|
850
850
|
/** Ending point in percentage of the chart height. */
|
|
851
851
|
to?: number;
|
|
852
|
-
/**
|
|
853
|
-
color?:
|
|
852
|
+
/** Color. */
|
|
853
|
+
color?: 'red' | 'green' | {
|
|
854
|
+
textColor: string;
|
|
855
|
+
backgroundColor?: string;
|
|
856
|
+
};
|
|
854
857
|
/** Section title */
|
|
855
858
|
title?: string;
|
|
856
859
|
/** Title position relative to section */
|
|
@@ -861,7 +864,7 @@ interface BarChartSectionProps extends Omit<ComponentProps<'g'>, 'onClick' | 'ro
|
|
|
861
864
|
}
|
|
862
865
|
interface StyledBarChartSectionProps {
|
|
863
866
|
$theme: Theme;
|
|
864
|
-
$
|
|
867
|
+
$textColor: string;
|
|
865
868
|
}
|
|
866
869
|
interface BarChartBarsProps extends Omit<ComponentProps<'g'>, 'onClick' | 'role'> {
|
|
867
870
|
category?: string;
|
|
@@ -876,7 +879,7 @@ declare const BarChart: Comp<BarChartProps, HTMLDivElement> & {
|
|
|
876
879
|
GroupedTooltip: React$1.FC<{
|
|
877
880
|
dateFormatter: (date: Date) => string;
|
|
878
881
|
categories: string[];
|
|
879
|
-
categoryDecorator
|
|
882
|
+
categoryDecorator?: ((category: string) => string) | undefined;
|
|
880
883
|
categoryColor: (category: string) => string;
|
|
881
884
|
datum: BarDatum;
|
|
882
885
|
groupedData: ComputedBarProps[] | undefined;
|
package/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { brush, select, scaleOrdinal, zoom, interpolateRound, interpolate, scaleLinear, sum, scaleBand, extent, scaleUtc, scalePoint, utcParse, scaleLog, scaleTime, line, arc, pie, min, descending, scaleSqrt, max } from 'd3';
|
|
2
|
-
import { RedsiftColorPresentationBlueDefault, RedsiftColorPresentationGreyDark, RedsiftColorPresentationAquaDefault, RedsiftColorPresentationPinkDefault, RedsiftColorPresentationGreyDefault, RedsiftColorPresentationYellowDefault, RedsiftColorPresentationPurpleDefault, RedsiftColorPresentationGreenDefault, RedsiftColorPresentationBrownDefault, RedsiftColorPresentationRedDefault, RedsiftColorPresentationOrangeDefault, 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, Theme, useId, useTheme, Text, Number as Number$1, baseStyling, baseContainer, focusRing, Flexbox, warnIfNoAccessibleLabelFound, useMessageFormatter, ThemeProvider, Heading, Button, isComponent } from '@redsift/design-system';
|
|
2
|
+
import { RedsiftColorPresentationBlueDefault, RedsiftColorPresentationGreyDark, RedsiftColorPresentationAquaDefault, RedsiftColorPresentationPinkDefault, RedsiftColorPresentationGreyDefault, RedsiftColorPresentationYellowDefault, RedsiftColorPresentationPurpleDefault, RedsiftColorPresentationGreenDefault, RedsiftColorPresentationBrownDefault, RedsiftColorPresentationRedDefault, RedsiftColorPresentationOrangeDefault, 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, Theme, useId, useTheme, Text, Number as Number$1, baseStyling, baseContainer, focusRing, Flexbox, warnIfNoAccessibleLabelFound, useMessageFormatter, ThemeProvider, Heading, Button, isComponent, RedsiftColorGreenD1, RedsiftColorRedD1, RedsiftColorNeutralBlack } from '@redsift/design-system';
|
|
3
3
|
import * as React from 'react';
|
|
4
4
|
import React__default, { useRef, useEffect, useMemo, useState, useLayoutEffect, forwardRef, useCallback, useContext, createContext } from 'react';
|
|
5
5
|
import classNames from 'classnames';
|
|
@@ -1480,11 +1480,10 @@ const StyledBarChartSection = styled.g`
|
|
|
1480
1480
|
text.colored {
|
|
1481
1481
|
${_ref => {
|
|
1482
1482
|
let {
|
|
1483
|
-
$
|
|
1484
|
-
$color
|
|
1483
|
+
$textColor
|
|
1485
1484
|
} = _ref;
|
|
1486
1485
|
return css`
|
|
1487
|
-
fill: ${$
|
|
1486
|
+
fill: ${$textColor};
|
|
1488
1487
|
`;
|
|
1489
1488
|
}}
|
|
1490
1489
|
}
|
|
@@ -2077,7 +2076,7 @@ const BarChartGroupedTooltip = _ref => {
|
|
|
2077
2076
|
fontWeight: "400",
|
|
2078
2077
|
fontSize: "14px",
|
|
2079
2078
|
lineHeight: "18px"
|
|
2080
|
-
}, categoryDecorator(category)), /*#__PURE__*/React__default.createElement(Text, {
|
|
2079
|
+
}, categoryDecorator ? categoryDecorator(category) : category), /*#__PURE__*/React__default.createElement(Text, {
|
|
2081
2080
|
fontWeight: "600",
|
|
2082
2081
|
fontSize: "14px",
|
|
2083
2082
|
lineHeight: "18px"
|
|
@@ -2845,6 +2844,28 @@ const BarChartSection = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
2845
2844
|
direction
|
|
2846
2845
|
} = props,
|
|
2847
2846
|
forwardedProps = _objectWithoutProperties(props, _excluded$f);
|
|
2847
|
+
const {
|
|
2848
|
+
textColor,
|
|
2849
|
+
backgroundColor
|
|
2850
|
+
} = useMemo(() => {
|
|
2851
|
+
if (color === 'green') {
|
|
2852
|
+
return {
|
|
2853
|
+
textColor: RedsiftColorGreenD1,
|
|
2854
|
+
backgroundColor: '#F7FBF9'
|
|
2855
|
+
};
|
|
2856
|
+
} else if (color === 'red') {
|
|
2857
|
+
return {
|
|
2858
|
+
textColor: RedsiftColorRedD1,
|
|
2859
|
+
backgroundColor: '#FFF7F7'
|
|
2860
|
+
};
|
|
2861
|
+
} else if (color === undefined) {
|
|
2862
|
+
return {
|
|
2863
|
+
textColor: RedsiftColorNeutralBlack,
|
|
2864
|
+
backgroundColor: undefined
|
|
2865
|
+
};
|
|
2866
|
+
}
|
|
2867
|
+
return color;
|
|
2868
|
+
}, [color]);
|
|
2848
2869
|
const theme = useTheme();
|
|
2849
2870
|
const context = useBarChartContext();
|
|
2850
2871
|
const {
|
|
@@ -2916,13 +2937,13 @@ const BarChartSection = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
2916
2937
|
transform: `translate(${margins.left},${(margins.top || 0) + sectionY})`,
|
|
2917
2938
|
ref: ref,
|
|
2918
2939
|
$theme: theme,
|
|
2919
|
-
$
|
|
2920
|
-
}),
|
|
2940
|
+
$textColor: textColor
|
|
2941
|
+
}), backgroundColor ? /*#__PURE__*/React__default.createElement("rect", {
|
|
2921
2942
|
x: 0,
|
|
2922
2943
|
y: 0,
|
|
2923
2944
|
width: chartWidth,
|
|
2924
2945
|
height: sectionHeight,
|
|
2925
|
-
fill:
|
|
2946
|
+
fill: backgroundColor
|
|
2926
2947
|
}) : null, title && /*#__PURE__*/React__default.createElement("text", {
|
|
2927
2948
|
className: "title colored",
|
|
2928
2949
|
x: titleX,
|