@redsift/charts 11.4.0-muiv5-alpha.0 → 11.4.0-muiv5-alpha.2
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 -4
- package/index.js +31 -9
- 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;
|
|
@@ -875,6 +878,7 @@ declare const BarChart: Comp<BarChartProps, HTMLDivElement> & {
|
|
|
875
878
|
Axis: Comp<AxisProps, SVGGElement>;
|
|
876
879
|
GroupedTooltip: React$1.FC<{
|
|
877
880
|
dateFormatter: (date: Date) => string;
|
|
881
|
+
categories: string[];
|
|
878
882
|
categoryDecorator: (category: string) => string;
|
|
879
883
|
categoryColor: (category: string) => string;
|
|
880
884
|
datum: BarDatum;
|
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
|
}
|
|
@@ -1959,7 +1958,7 @@ const BarChartBars = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
1959
1958
|
tooltipDecorator,
|
|
1960
1959
|
xScaleType
|
|
1961
1960
|
} = useBarChartContext();
|
|
1962
|
-
const filteredBarChartBars = bars.filter(bar => bar.category === category);
|
|
1961
|
+
const filteredBarChartBars = bars.filter(bar => bar.category === category && bar.value > 0);
|
|
1963
1962
|
const categoryIndex = categories.indexOf(category);
|
|
1964
1963
|
const categoryLength = categories.length;
|
|
1965
1964
|
return /*#__PURE__*/React__default.createElement(StyledBarChartBars, _extends({
|
|
@@ -2020,6 +2019,7 @@ BarChartBars.displayName = COMPONENT_NAME$9;
|
|
|
2020
2019
|
const BarChartGroupedTooltip = _ref => {
|
|
2021
2020
|
let {
|
|
2022
2021
|
dateFormatter,
|
|
2022
|
+
categories,
|
|
2023
2023
|
categoryDecorator,
|
|
2024
2024
|
categoryColor,
|
|
2025
2025
|
datum,
|
|
@@ -2058,7 +2058,7 @@ const BarChartGroupedTooltip = _ref => {
|
|
|
2058
2058
|
flexDirection: "column",
|
|
2059
2059
|
marginTop: "4px",
|
|
2060
2060
|
gap: "8px"
|
|
2061
|
-
},
|
|
2061
|
+
}, categories.map(category => {
|
|
2062
2062
|
var _groupedData$find;
|
|
2063
2063
|
const value = groupedData === null || groupedData === void 0 ? void 0 : (_groupedData$find = groupedData.find(d => d.category === category)) === null || _groupedData$find === void 0 ? void 0 : _groupedData$find.value;
|
|
2064
2064
|
const color = categoryColor(category);
|
|
@@ -2844,6 +2844,28 @@ const BarChartSection = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
2844
2844
|
direction
|
|
2845
2845
|
} = props,
|
|
2846
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]);
|
|
2847
2869
|
const theme = useTheme();
|
|
2848
2870
|
const context = useBarChartContext();
|
|
2849
2871
|
const {
|
|
@@ -2915,13 +2937,13 @@ const BarChartSection = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
2915
2937
|
transform: `translate(${margins.left},${(margins.top || 0) + sectionY})`,
|
|
2916
2938
|
ref: ref,
|
|
2917
2939
|
$theme: theme,
|
|
2918
|
-
$
|
|
2919
|
-
}),
|
|
2940
|
+
$textColor: textColor
|
|
2941
|
+
}), backgroundColor ? /*#__PURE__*/React__default.createElement("rect", {
|
|
2920
2942
|
x: 0,
|
|
2921
2943
|
y: 0,
|
|
2922
2944
|
width: chartWidth,
|
|
2923
2945
|
height: sectionHeight,
|
|
2924
|
-
fill:
|
|
2946
|
+
fill: backgroundColor
|
|
2925
2947
|
}) : null, title && /*#__PURE__*/React__default.createElement("text", {
|
|
2926
2948
|
className: "title colored",
|
|
2927
2949
|
x: titleX,
|