@mui/x-charts 7.5.0 → 7.6.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/BarChart/BarChart.js +30 -3
- package/BarChart/BarElement.d.ts +0 -3
- package/BarChart/BarElement.js +8 -19
- package/BarChart/BarLabel/BarLabel.d.ts +1342 -0
- package/BarChart/BarLabel/BarLabel.js +60 -0
- package/BarChart/BarLabel/BarLabel.types.d.ts +39 -0
- package/BarChart/BarLabel/BarLabel.types.js +5 -0
- package/BarChart/BarLabel/BarLabelItem.d.ts +53 -0
- package/BarChart/BarLabel/BarLabelItem.js +127 -0
- package/BarChart/BarLabel/BarLabelPlot.d.ts +16 -0
- package/BarChart/BarLabel/BarLabelPlot.js +106 -0
- package/BarChart/BarLabel/barLabelClasses.d.ts +13 -0
- package/BarChart/BarLabel/barLabelClasses.js +29 -0
- package/BarChart/BarLabel/getBarLabel.d.ts +10 -0
- package/BarChart/BarLabel/getBarLabel.js +31 -0
- package/BarChart/BarLabel/index.d.ts +6 -0
- package/BarChart/BarLabel/index.js +25 -0
- package/BarChart/BarPlot.d.ts +15 -4
- package/BarChart/BarPlot.js +22 -34
- package/BarChart/checkScaleErrors.d.ts +11 -0
- package/BarChart/checkScaleErrors.js +33 -0
- package/BarChart/index.d.ts +1 -0
- package/BarChart/index.js +11 -0
- package/BarChart/types.d.ts +0 -2
- package/CHANGELOG.md +148 -5418
- package/ChartContainer/ChartContainer.d.ts +3 -2
- package/ChartContainer/ChartContainer.js +20 -3
- package/ChartsAxis/ChartsAxis.js +1 -1
- package/ChartsAxisHighlight/ChartsAxisHighlight.js +1 -1
- package/ChartsClipPath/ChartsClipPath.js +1 -1
- package/ChartsGrid/ChartsGrid.js +1 -1
- package/ChartsLegend/ChartsLegend.js +1 -1
- package/ChartsLegend/DefaultChartsLegend.js +1 -1
- package/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +1 -1
- package/ChartsReferenceLine/ChartsReferenceLine.js +1 -1
- package/ChartsSurface.js +1 -1
- package/ChartsText/ChartsText.js +1 -1
- package/ChartsTooltip/ChartsAxisTooltipContent.js +1 -1
- package/ChartsTooltip/ChartsItemTooltipContent.js +1 -1
- package/ChartsTooltip/ChartsTooltip.js +1 -1
- package/ChartsTooltip/DefaultChartsAxisTooltipContent.js +1 -1
- package/ChartsTooltip/DefaultChartsItemTooltipContent.js +1 -1
- package/ChartsVoronoiHandler/ChartsVoronoiHandler.js +14 -2
- package/ChartsXAxis/ChartsXAxis.js +1 -1
- package/ChartsYAxis/ChartsYAxis.js +1 -1
- package/Gauge/Gauge.js +1 -1
- package/Gauge/GaugeContainer.js +1 -1
- package/Gauge/GaugeValueText.js +1 -1
- package/LineChart/AnimatedArea.js +1 -1
- package/LineChart/AnimatedLine.js +1 -1
- package/LineChart/AreaElement.d.ts +0 -2
- package/LineChart/AreaElement.js +8 -18
- package/LineChart/AreaPlot.js +1 -3
- package/LineChart/LineChart.js +19 -2
- package/LineChart/LineElement.d.ts +0 -2
- package/LineChart/LineElement.js +8 -18
- package/LineChart/LineHighlightElement.js +1 -1
- package/LineChart/LineHighlightPlot.js +1 -1
- package/LineChart/LinePlot.js +1 -3
- package/LineChart/MarkElement.d.ts +0 -2
- package/LineChart/MarkElement.js +11 -33
- package/LineChart/MarkPlot.js +1 -2
- package/PieChart/PieArc.d.ts +4 -1
- package/PieChart/PieArc.js +8 -4
- package/PieChart/PieArcLabel.js +1 -1
- package/PieChart/PieArcLabelPlot.d.ts +1 -1
- package/PieChart/PieArcLabelPlot.js +2 -8
- package/PieChart/PieArcPlot.d.ts +1 -1
- package/PieChart/PieArcPlot.js +6 -8
- package/PieChart/PieChart.js +19 -2
- package/PieChart/PiePlot.js +3 -7
- package/PieChart/dataTransform/useTransformData.d.ts +1 -1
- package/PieChart/dataTransform/useTransformData.js +10 -25
- package/ResponsiveChartContainer/ResponsiveChartContainer.js +14 -1
- package/ScatterChart/Scatter.js +15 -11
- package/ScatterChart/ScatterChart.js +19 -2
- package/ScatterChart/ScatterPlot.js +1 -1
- package/SparkLineChart/SparkLineChart.d.ts +1 -1
- package/SparkLineChart/SparkLineChart.js +14 -1
- package/context/HighlightedProvider/HighlightedContext.d.ts +65 -0
- package/context/HighlightedProvider/HighlightedContext.js +36 -0
- package/context/HighlightedProvider/HighlightedProvider.d.ts +20 -0
- package/context/HighlightedProvider/HighlightedProvider.js +97 -0
- package/context/HighlightedProvider/createIsFaded.d.ts +2 -0
- package/context/HighlightedProvider/createIsFaded.js +19 -0
- package/context/HighlightedProvider/createIsHighlighted.d.ts +2 -0
- package/context/HighlightedProvider/createIsHighlighted.js +19 -0
- package/context/HighlightedProvider/index.d.ts +4 -0
- package/context/HighlightedProvider/index.js +49 -0
- package/context/HighlightedProvider/useHighlighted.d.ts +9 -0
- package/context/HighlightedProvider/useHighlighted.js +24 -0
- package/context/HighlightedProvider/useItemHighlighted.d.ts +21 -0
- package/context/HighlightedProvider/useItemHighlighted.js +37 -0
- package/context/ZAxisContextProvider.js +1 -1
- package/context/index.d.ts +1 -1
- package/context/index.js +15 -0
- package/esm/BarChart/BarChart.js +30 -3
- package/esm/BarChart/BarElement.js +9 -20
- package/esm/BarChart/BarLabel/BarLabel.js +51 -0
- package/esm/BarChart/BarLabel/BarLabel.types.js +1 -0
- package/esm/BarChart/BarLabel/BarLabelItem.js +119 -0
- package/esm/BarChart/BarLabel/BarLabelPlot.js +98 -0
- package/esm/BarChart/BarLabel/barLabelClasses.js +19 -0
- package/esm/BarChart/BarLabel/getBarLabel.js +24 -0
- package/esm/BarChart/BarLabel/index.js +2 -0
- package/esm/BarChart/BarPlot.js +22 -34
- package/esm/BarChart/checkScaleErrors.js +27 -0
- package/esm/BarChart/index.js +2 -1
- package/esm/ChartContainer/ChartContainer.js +20 -3
- package/esm/ChartsAxis/ChartsAxis.js +1 -1
- package/esm/ChartsAxisHighlight/ChartsAxisHighlight.js +1 -1
- package/esm/ChartsClipPath/ChartsClipPath.js +1 -1
- package/esm/ChartsGrid/ChartsGrid.js +1 -1
- package/esm/ChartsLegend/ChartsLegend.js +1 -1
- package/esm/ChartsLegend/DefaultChartsLegend.js +1 -1
- package/esm/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +1 -1
- package/esm/ChartsReferenceLine/ChartsReferenceLine.js +1 -1
- package/esm/ChartsSurface.js +1 -1
- package/esm/ChartsText/ChartsText.js +1 -1
- package/esm/ChartsTooltip/ChartsAxisTooltipContent.js +1 -1
- package/esm/ChartsTooltip/ChartsItemTooltipContent.js +1 -1
- package/esm/ChartsTooltip/ChartsTooltip.js +1 -1
- package/esm/ChartsTooltip/DefaultChartsAxisTooltipContent.js +1 -1
- package/esm/ChartsTooltip/DefaultChartsItemTooltipContent.js +1 -1
- package/esm/ChartsVoronoiHandler/ChartsVoronoiHandler.js +14 -2
- package/esm/ChartsXAxis/ChartsXAxis.js +1 -1
- package/esm/ChartsYAxis/ChartsYAxis.js +1 -1
- package/esm/Gauge/Gauge.js +1 -1
- package/esm/Gauge/GaugeContainer.js +1 -1
- package/esm/Gauge/GaugeValueText.js +1 -1
- package/esm/LineChart/AnimatedArea.js +1 -1
- package/esm/LineChart/AnimatedLine.js +1 -1
- package/esm/LineChart/AreaElement.js +9 -19
- package/esm/LineChart/AreaPlot.js +1 -3
- package/esm/LineChart/LineChart.js +19 -2
- package/esm/LineChart/LineElement.js +9 -19
- package/esm/LineChart/LineHighlightElement.js +1 -1
- package/esm/LineChart/LineHighlightPlot.js +1 -1
- package/esm/LineChart/LinePlot.js +1 -3
- package/esm/LineChart/MarkElement.js +12 -34
- package/esm/LineChart/MarkPlot.js +1 -2
- package/esm/PieChart/PieArc.js +8 -4
- package/esm/PieChart/PieArcLabel.js +1 -1
- package/esm/PieChart/PieArcLabelPlot.js +2 -8
- package/esm/PieChart/PieArcPlot.js +6 -8
- package/esm/PieChart/PieChart.js +19 -2
- package/esm/PieChart/PiePlot.js +3 -7
- package/esm/PieChart/dataTransform/useTransformData.js +10 -25
- package/esm/ResponsiveChartContainer/ResponsiveChartContainer.js +14 -1
- package/esm/ScatterChart/Scatter.js +16 -12
- package/esm/ScatterChart/ScatterChart.js +19 -2
- package/esm/ScatterChart/ScatterPlot.js +1 -1
- package/esm/SparkLineChart/SparkLineChart.js +14 -1
- package/esm/context/HighlightedProvider/HighlightedContext.js +29 -0
- package/esm/context/HighlightedProvider/HighlightedProvider.js +89 -0
- package/esm/context/HighlightedProvider/createIsFaded.js +12 -0
- package/esm/context/HighlightedProvider/createIsHighlighted.js +12 -0
- package/esm/context/HighlightedProvider/index.js +4 -0
- package/esm/context/HighlightedProvider/useHighlighted.js +17 -0
- package/esm/context/HighlightedProvider/useItemHighlighted.js +29 -0
- package/esm/context/ZAxisContextProvider.js +1 -1
- package/esm/context/index.js +1 -0
- package/esm/hooks/useInteractionItemProps.js +9 -41
- package/hooks/useInteractionItemProps.d.ts +1 -4
- package/hooks/useInteractionItemProps.js +11 -45
- package/index.js +1 -1
- package/internals/colorScale.d.ts +1 -1
- package/internals/defaultizeColor.d.ts +13 -13
- package/models/seriesType/common.d.ts +4 -1
- package/modern/BarChart/BarChart.js +30 -3
- package/modern/BarChart/BarElement.js +9 -20
- package/modern/BarChart/BarLabel/BarLabel.js +51 -0
- package/modern/BarChart/BarLabel/BarLabel.types.js +1 -0
- package/modern/BarChart/BarLabel/BarLabelItem.js +119 -0
- package/modern/BarChart/BarLabel/BarLabelPlot.js +98 -0
- package/modern/BarChart/BarLabel/barLabelClasses.js +19 -0
- package/modern/BarChart/BarLabel/getBarLabel.js +24 -0
- package/modern/BarChart/BarLabel/index.js +2 -0
- package/modern/BarChart/BarPlot.js +22 -34
- package/modern/BarChart/checkScaleErrors.js +27 -0
- package/modern/BarChart/index.js +2 -1
- package/modern/ChartContainer/ChartContainer.js +20 -3
- package/modern/ChartsAxis/ChartsAxis.js +1 -1
- package/modern/ChartsAxisHighlight/ChartsAxisHighlight.js +1 -1
- package/modern/ChartsClipPath/ChartsClipPath.js +1 -1
- package/modern/ChartsGrid/ChartsGrid.js +1 -1
- package/modern/ChartsLegend/ChartsLegend.js +1 -1
- package/modern/ChartsLegend/DefaultChartsLegend.js +1 -1
- package/modern/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +1 -1
- package/modern/ChartsReferenceLine/ChartsReferenceLine.js +1 -1
- package/modern/ChartsSurface.js +1 -1
- package/modern/ChartsText/ChartsText.js +1 -1
- package/modern/ChartsTooltip/ChartsAxisTooltipContent.js +1 -1
- package/modern/ChartsTooltip/ChartsItemTooltipContent.js +1 -1
- package/modern/ChartsTooltip/ChartsTooltip.js +1 -1
- package/modern/ChartsTooltip/DefaultChartsAxisTooltipContent.js +1 -1
- package/modern/ChartsTooltip/DefaultChartsItemTooltipContent.js +1 -1
- package/modern/ChartsVoronoiHandler/ChartsVoronoiHandler.js +14 -2
- package/modern/ChartsXAxis/ChartsXAxis.js +1 -1
- package/modern/ChartsYAxis/ChartsYAxis.js +1 -1
- package/modern/Gauge/Gauge.js +1 -1
- package/modern/Gauge/GaugeContainer.js +1 -1
- package/modern/Gauge/GaugeValueText.js +1 -1
- package/modern/LineChart/AnimatedArea.js +1 -1
- package/modern/LineChart/AnimatedLine.js +1 -1
- package/modern/LineChart/AreaElement.js +9 -19
- package/modern/LineChart/AreaPlot.js +1 -3
- package/modern/LineChart/LineChart.js +19 -2
- package/modern/LineChart/LineElement.js +9 -19
- package/modern/LineChart/LineHighlightElement.js +1 -1
- package/modern/LineChart/LineHighlightPlot.js +1 -1
- package/modern/LineChart/LinePlot.js +1 -3
- package/modern/LineChart/MarkElement.js +12 -34
- package/modern/LineChart/MarkPlot.js +1 -2
- package/modern/PieChart/PieArc.js +8 -4
- package/modern/PieChart/PieArcLabel.js +1 -1
- package/modern/PieChart/PieArcLabelPlot.js +2 -8
- package/modern/PieChart/PieArcPlot.js +6 -8
- package/modern/PieChart/PieChart.js +19 -2
- package/modern/PieChart/PiePlot.js +3 -7
- package/modern/PieChart/dataTransform/useTransformData.js +10 -25
- package/modern/ResponsiveChartContainer/ResponsiveChartContainer.js +14 -1
- package/modern/ScatterChart/Scatter.js +16 -12
- package/modern/ScatterChart/ScatterChart.js +19 -2
- package/modern/ScatterChart/ScatterPlot.js +1 -1
- package/modern/SparkLineChart/SparkLineChart.js +14 -1
- package/modern/context/HighlightedProvider/HighlightedContext.js +29 -0
- package/modern/context/HighlightedProvider/HighlightedProvider.js +89 -0
- package/modern/context/HighlightedProvider/createIsFaded.js +12 -0
- package/modern/context/HighlightedProvider/createIsHighlighted.js +12 -0
- package/modern/context/HighlightedProvider/index.js +4 -0
- package/modern/context/HighlightedProvider/useHighlighted.js +17 -0
- package/modern/context/HighlightedProvider/useItemHighlighted.js +29 -0
- package/modern/context/ZAxisContextProvider.js +1 -1
- package/modern/context/index.js +1 -0
- package/modern/hooks/useInteractionItemProps.js +9 -41
- package/modern/index.js +1 -1
- package/package.json +3 -3
- package/themeAugmentation/components.d.ts +4 -0
- package/themeAugmentation/overrides.d.ts +3 -0
- package/themeAugmentation/props.d.ts +2 -0
- package/context/HighlightProvider.d.ts +0 -45
- package/context/HighlightProvider.js +0 -60
- package/esm/context/HighlightProvider.js +0 -51
- package/modern/context/HighlightProvider.js +0 -51
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
2
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
3
|
+
const _excluded = ["bars", "skipAnimation"];
|
|
4
|
+
import * as React from 'react';
|
|
5
|
+
import PropTypes from 'prop-types';
|
|
6
|
+
import { useTransition } from '@react-spring/web';
|
|
7
|
+
import { BarLabelItem } from './BarLabelItem';
|
|
8
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
9
|
+
const leaveStyle = ({
|
|
10
|
+
layout,
|
|
11
|
+
yOrigin,
|
|
12
|
+
x,
|
|
13
|
+
width,
|
|
14
|
+
y,
|
|
15
|
+
xOrigin,
|
|
16
|
+
height
|
|
17
|
+
}) => _extends({}, layout === 'vertical' ? {
|
|
18
|
+
y: yOrigin,
|
|
19
|
+
x: x + width / 2,
|
|
20
|
+
height: 0,
|
|
21
|
+
width
|
|
22
|
+
} : {
|
|
23
|
+
y: y + height / 2,
|
|
24
|
+
x: xOrigin,
|
|
25
|
+
height,
|
|
26
|
+
width: 0
|
|
27
|
+
});
|
|
28
|
+
const enterStyle = ({
|
|
29
|
+
x,
|
|
30
|
+
width,
|
|
31
|
+
y,
|
|
32
|
+
height
|
|
33
|
+
}) => ({
|
|
34
|
+
x: x + width / 2,
|
|
35
|
+
y: y + height / 2,
|
|
36
|
+
height,
|
|
37
|
+
width
|
|
38
|
+
});
|
|
39
|
+
/**
|
|
40
|
+
* @ignore - internal component.
|
|
41
|
+
*/
|
|
42
|
+
function BarLabelPlot(props) {
|
|
43
|
+
const {
|
|
44
|
+
bars,
|
|
45
|
+
skipAnimation
|
|
46
|
+
} = props,
|
|
47
|
+
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
48
|
+
const barLabelTransition = useTransition(bars, {
|
|
49
|
+
keys: bar => `${bar.seriesId}-${bar.dataIndex}`,
|
|
50
|
+
from: leaveStyle,
|
|
51
|
+
leave: null,
|
|
52
|
+
enter: enterStyle,
|
|
53
|
+
update: enterStyle,
|
|
54
|
+
immediate: skipAnimation
|
|
55
|
+
});
|
|
56
|
+
return /*#__PURE__*/_jsx(React.Fragment, {
|
|
57
|
+
children: barLabelTransition((style, {
|
|
58
|
+
seriesId,
|
|
59
|
+
dataIndex,
|
|
60
|
+
color,
|
|
61
|
+
value,
|
|
62
|
+
width,
|
|
63
|
+
height
|
|
64
|
+
}) => /*#__PURE__*/_jsx(BarLabelItem, _extends({
|
|
65
|
+
seriesId: seriesId,
|
|
66
|
+
dataIndex: dataIndex,
|
|
67
|
+
value: value,
|
|
68
|
+
color: color,
|
|
69
|
+
width: width,
|
|
70
|
+
height: height
|
|
71
|
+
}, other, {
|
|
72
|
+
style: style
|
|
73
|
+
})))
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
process.env.NODE_ENV !== "production" ? BarLabelPlot.propTypes = {
|
|
77
|
+
// ----------------------------- Warning --------------------------------
|
|
78
|
+
// | These PropTypes are generated from the TypeScript type definitions |
|
|
79
|
+
// | To update them edit the TypeScript types and run "pnpm proptypes" |
|
|
80
|
+
// ----------------------------------------------------------------------
|
|
81
|
+
barLabel: PropTypes.oneOfType([PropTypes.oneOf(['value']), PropTypes.func]),
|
|
82
|
+
bars: PropTypes.arrayOf(PropTypes.shape({
|
|
83
|
+
color: PropTypes.string.isRequired,
|
|
84
|
+
dataIndex: PropTypes.number.isRequired,
|
|
85
|
+
height: PropTypes.number.isRequired,
|
|
86
|
+
layout: PropTypes.oneOf(['horizontal', 'vertical']),
|
|
87
|
+
maskId: PropTypes.string.isRequired,
|
|
88
|
+
seriesId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired,
|
|
89
|
+
value: PropTypes.number,
|
|
90
|
+
width: PropTypes.number.isRequired,
|
|
91
|
+
x: PropTypes.number.isRequired,
|
|
92
|
+
xOrigin: PropTypes.number.isRequired,
|
|
93
|
+
y: PropTypes.number.isRequired,
|
|
94
|
+
yOrigin: PropTypes.number.isRequired
|
|
95
|
+
})).isRequired,
|
|
96
|
+
skipAnimation: PropTypes.bool
|
|
97
|
+
} : void 0;
|
|
98
|
+
export { BarLabelPlot };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import generateUtilityClass from '@mui/utils/generateUtilityClass';
|
|
2
|
+
import generateUtilityClasses from '@mui/utils/generateUtilityClasses';
|
|
3
|
+
import composeClasses from '@mui/utils/composeClasses';
|
|
4
|
+
export function getBarLabelUtilityClass(slot) {
|
|
5
|
+
return generateUtilityClass('MuiBarLabel', slot);
|
|
6
|
+
}
|
|
7
|
+
export const barLabelClasses = generateUtilityClasses('MuiBarLabel', ['root', 'highlighted', 'faded']);
|
|
8
|
+
export const useUtilityClasses = ownerState => {
|
|
9
|
+
const {
|
|
10
|
+
classes,
|
|
11
|
+
seriesId,
|
|
12
|
+
isFaded,
|
|
13
|
+
isHighlighted
|
|
14
|
+
} = ownerState;
|
|
15
|
+
const slots = {
|
|
16
|
+
root: ['root', `series-${seriesId}`, isHighlighted && 'highlighted', isFaded && 'faded']
|
|
17
|
+
};
|
|
18
|
+
return composeClasses(slots, getBarLabelUtilityClass, classes);
|
|
19
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export const getBarLabel = options => {
|
|
2
|
+
const {
|
|
3
|
+
barLabel,
|
|
4
|
+
value,
|
|
5
|
+
dataIndex,
|
|
6
|
+
seriesId,
|
|
7
|
+
height,
|
|
8
|
+
width
|
|
9
|
+
} = options;
|
|
10
|
+
if (barLabel === 'value') {
|
|
11
|
+
// We don't want to show the label if the value is 0
|
|
12
|
+
return value ? value?.toString() : null;
|
|
13
|
+
}
|
|
14
|
+
return barLabel({
|
|
15
|
+
seriesId,
|
|
16
|
+
dataIndex,
|
|
17
|
+
value
|
|
18
|
+
}, {
|
|
19
|
+
bar: {
|
|
20
|
+
height,
|
|
21
|
+
width
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
};
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
2
2
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
3
|
-
const _excluded = ["skipAnimation", "onItemClick", "borderRadius"];
|
|
3
|
+
const _excluded = ["skipAnimation", "onItemClick", "borderRadius", "barLabel"];
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
6
|
import { useTransition } from '@react-spring/web';
|
|
7
7
|
import { SeriesContext } from '../context/SeriesContextProvider';
|
|
8
8
|
import { CartesianContext } from '../context/CartesianContextProvider';
|
|
9
9
|
import { BarElement } from './BarElement';
|
|
10
|
-
import { isBandScaleConfig, isPointScaleConfig } from '../models/axis';
|
|
11
|
-
import { DEFAULT_X_AXIS_KEY, DEFAULT_Y_AXIS_KEY } from '../constants';
|
|
12
10
|
import getColor from './getColor';
|
|
13
11
|
import { useChartId } from '../hooks';
|
|
14
12
|
import { BarClipPath } from './BarClipPath';
|
|
13
|
+
import { BarLabelPlot } from './BarLabel/BarLabelPlot';
|
|
14
|
+
import { checkScaleErrors } from './checkScaleErrors';
|
|
15
15
|
|
|
16
16
|
/**
|
|
17
17
|
* Solution of the equations
|
|
@@ -71,30 +71,8 @@ const useAggregatedData = () => {
|
|
|
71
71
|
const xAxisConfig = xAxis[xAxisKey];
|
|
72
72
|
const yAxisConfig = yAxis[yAxisKey];
|
|
73
73
|
const verticalLayout = series[seriesId].layout === 'vertical';
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
if (!isBandScaleConfig(xAxisConfig)) {
|
|
77
|
-
throw new Error(`MUI X Charts: ${xAxisKey === DEFAULT_X_AXIS_KEY ? 'The first `xAxis`' : `The x-axis with id "${xAxisKey}"`} should be of type "band" to display the bar series of id "${seriesId}".`);
|
|
78
|
-
}
|
|
79
|
-
if (xAxis[xAxisKey].data === undefined) {
|
|
80
|
-
throw new Error(`MUI X Charts: ${xAxisKey === DEFAULT_X_AXIS_KEY ? 'The first `xAxis`' : `The x-axis with id "${xAxisKey}"`} should have data property.`);
|
|
81
|
-
}
|
|
82
|
-
baseScaleConfig = xAxisConfig;
|
|
83
|
-
if (isBandScaleConfig(yAxisConfig) || isPointScaleConfig(yAxisConfig)) {
|
|
84
|
-
throw new Error(`MUI X Charts: ${yAxisKey === DEFAULT_Y_AXIS_KEY ? 'The first `yAxis`' : `The y-axis with id "${yAxisKey}"`} should be a continuous type to display the bar series of id "${seriesId}".`);
|
|
85
|
-
}
|
|
86
|
-
} else {
|
|
87
|
-
if (!isBandScaleConfig(yAxisConfig)) {
|
|
88
|
-
throw new Error(`MUI X Charts: ${yAxisKey === DEFAULT_Y_AXIS_KEY ? 'The first `yAxis`' : `The y-axis with id "${yAxisKey}"`} should be of type "band" to display the bar series of id "${seriesId}".`);
|
|
89
|
-
}
|
|
90
|
-
if (yAxis[yAxisKey].data === undefined) {
|
|
91
|
-
throw new Error(`MUI X Charts: ${yAxisKey === DEFAULT_Y_AXIS_KEY ? 'The first `yAxis`' : `The y-axis with id "${yAxisKey}"`} should have data property.`);
|
|
92
|
-
}
|
|
93
|
-
baseScaleConfig = yAxisConfig;
|
|
94
|
-
if (isBandScaleConfig(xAxisConfig) || isPointScaleConfig(xAxisConfig)) {
|
|
95
|
-
throw new Error(`MUI X Charts: ${xAxisKey === DEFAULT_X_AXIS_KEY ? 'The first `xAxis`' : `The x-axis with id "${xAxisKey}"`} should be a continuous type to display the bar series of id "${seriesId}".`);
|
|
96
|
-
}
|
|
97
|
-
}
|
|
74
|
+
checkScaleErrors(verticalLayout, seriesId, xAxisKey, xAxis, yAxisKey, yAxis);
|
|
75
|
+
const baseScaleConfig = verticalLayout ? xAxisConfig : yAxisConfig;
|
|
98
76
|
const xScale = xAxisConfig.scale;
|
|
99
77
|
const yScale = yAxisConfig.scale;
|
|
100
78
|
const colorGetter = getColor(series[seriesId], xAxis[xAxisKey], yAxis[yAxisKey]);
|
|
@@ -127,7 +105,6 @@ const useAggregatedData = () => {
|
|
|
127
105
|
height: verticalLayout ? maxValueCoord - minValueCoord : barWidth,
|
|
128
106
|
width: verticalLayout ? barWidth : maxValueCoord - minValueCoord,
|
|
129
107
|
color: colorGetter(dataIndex),
|
|
130
|
-
highlightScope: series[seriesId].highlightScope,
|
|
131
108
|
value: series[seriesId].data[dataIndex],
|
|
132
109
|
maskId: `${chartId}_${stackId || seriesId}_${groupIndex}_${dataIndex}`
|
|
133
110
|
};
|
|
@@ -211,7 +188,8 @@ function BarPlot(props) {
|
|
|
211
188
|
const {
|
|
212
189
|
skipAnimation,
|
|
213
190
|
onItemClick,
|
|
214
|
-
borderRadius
|
|
191
|
+
borderRadius,
|
|
192
|
+
barLabel
|
|
215
193
|
} = props,
|
|
216
194
|
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
217
195
|
const transition = useTransition(completedData, {
|
|
@@ -249,14 +227,12 @@ function BarPlot(props) {
|
|
|
249
227
|
seriesId,
|
|
250
228
|
dataIndex,
|
|
251
229
|
color,
|
|
252
|
-
highlightScope,
|
|
253
230
|
maskId
|
|
254
231
|
}) => {
|
|
255
232
|
const barElement = /*#__PURE__*/_jsx(BarElement, _extends({
|
|
256
233
|
id: seriesId,
|
|
257
234
|
dataIndex: dataIndex,
|
|
258
|
-
color: color
|
|
259
|
-
highlightScope: highlightScope
|
|
235
|
+
color: color
|
|
260
236
|
}, other, {
|
|
261
237
|
onClick: onItemClick && (event => {
|
|
262
238
|
onItemClick(event, {
|
|
@@ -274,14 +250,26 @@ function BarPlot(props) {
|
|
|
274
250
|
clipPath: `url(#${maskId})`,
|
|
275
251
|
children: barElement
|
|
276
252
|
});
|
|
277
|
-
})
|
|
253
|
+
}), barLabel && /*#__PURE__*/_jsx(BarLabelPlot, _extends({
|
|
254
|
+
bars: completedData,
|
|
255
|
+
skipAnimation: skipAnimation,
|
|
256
|
+
barLabel: barLabel
|
|
257
|
+
}, other))]
|
|
278
258
|
});
|
|
279
259
|
}
|
|
280
260
|
process.env.NODE_ENV !== "production" ? BarPlot.propTypes = {
|
|
281
261
|
// ----------------------------- Warning --------------------------------
|
|
282
262
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
283
|
-
// | To update them edit the TypeScript types and run "
|
|
263
|
+
// | To update them edit the TypeScript types and run "pnpm proptypes" |
|
|
284
264
|
// ----------------------------------------------------------------------
|
|
265
|
+
/**
|
|
266
|
+
* If provided, the function will be used to format the label of the bar.
|
|
267
|
+
* It can be set to 'value' to display the current value.
|
|
268
|
+
* @param {BarItem} item The item to format.
|
|
269
|
+
* @param {BarLabelContext} context data about the bar.
|
|
270
|
+
* @returns {string} The formatted label.
|
|
271
|
+
*/
|
|
272
|
+
barLabel: PropTypes.oneOfType([PropTypes.oneOf(['value']), PropTypes.func]),
|
|
285
273
|
/**
|
|
286
274
|
* Defines the border radius of the bar element.
|
|
287
275
|
*/
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { DEFAULT_X_AXIS_KEY, DEFAULT_Y_AXIS_KEY } from '../constants';
|
|
2
|
+
import { isBandScaleConfig, isPointScaleConfig } from '../models/axis';
|
|
3
|
+
const getAxisMessage = (axisDirection, axisKey) => {
|
|
4
|
+
const axisName = `${axisDirection}-axis`;
|
|
5
|
+
const axisKeyName = `${axisDirection}Axis`;
|
|
6
|
+
const axisDefaultKey = axisDirection === 'x' ? DEFAULT_X_AXIS_KEY : DEFAULT_Y_AXIS_KEY;
|
|
7
|
+
return axisKey === axisDefaultKey ? `The first \`${axisKeyName}\`` : `The ${axisName} with id "${axisKey}"`;
|
|
8
|
+
};
|
|
9
|
+
export function checkScaleErrors(verticalLayout, seriesId, xAxisKey, xAxis, yAxisKey, yAxis) {
|
|
10
|
+
const xAxisConfig = xAxis[xAxisKey];
|
|
11
|
+
const yAxisConfig = yAxis[yAxisKey];
|
|
12
|
+
const discreteAxisConfig = verticalLayout ? xAxisConfig : yAxisConfig;
|
|
13
|
+
const continuousAxisConfig = verticalLayout ? yAxisConfig : xAxisConfig;
|
|
14
|
+
const discreteAxisKey = verticalLayout ? xAxisKey : yAxisKey;
|
|
15
|
+
const continuousAxisKey = verticalLayout ? yAxisKey : xAxisKey;
|
|
16
|
+
const discreteAxisDirection = verticalLayout ? 'x' : 'y';
|
|
17
|
+
const continuousAxisDirection = verticalLayout ? 'y' : 'x';
|
|
18
|
+
if (!isBandScaleConfig(discreteAxisConfig)) {
|
|
19
|
+
throw new Error(`MUI X Charts: ${getAxisMessage(discreteAxisDirection, discreteAxisKey)} should be of type "band" to display the bar series of id "${seriesId}".`);
|
|
20
|
+
}
|
|
21
|
+
if (discreteAxisConfig.data === undefined) {
|
|
22
|
+
throw new Error(`MUI X Charts: ${getAxisMessage(discreteAxisDirection, discreteAxisKey)} should have data property.`);
|
|
23
|
+
}
|
|
24
|
+
if (isBandScaleConfig(continuousAxisConfig) || isPointScaleConfig(continuousAxisConfig)) {
|
|
25
|
+
throw new Error(`MUI X Charts: ${getAxisMessage(continuousAxisDirection, continuousAxisKey)} should be a continuous type to display the bar series of id "${seriesId}".`);
|
|
26
|
+
}
|
|
27
|
+
}
|
package/modern/BarChart/index.js
CHANGED
|
@@ -7,8 +7,8 @@ import { InteractionProvider } from '../context/InteractionProvider';
|
|
|
7
7
|
import { useReducedMotion } from '../hooks/useReducedMotion';
|
|
8
8
|
import { ChartsSurface } from '../ChartsSurface';
|
|
9
9
|
import { CartesianContextProvider } from '../context/CartesianContextProvider';
|
|
10
|
-
import { HighlightProvider } from '../context/HighlightProvider';
|
|
11
10
|
import { ChartsAxesGradients } from '../internals/components/ChartsAxesGradients';
|
|
11
|
+
import { HighlightedProvider } from '../context';
|
|
12
12
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
13
|
const ChartContainer = /*#__PURE__*/React.forwardRef(function ChartContainer(props, ref) {
|
|
14
14
|
const {
|
|
@@ -24,6 +24,8 @@ const ChartContainer = /*#__PURE__*/React.forwardRef(function ChartContainer(pro
|
|
|
24
24
|
title,
|
|
25
25
|
desc,
|
|
26
26
|
disableAxisListener,
|
|
27
|
+
highlightedItem,
|
|
28
|
+
onHighlightChange,
|
|
27
29
|
children
|
|
28
30
|
} = props;
|
|
29
31
|
const svgRef = React.useRef(null);
|
|
@@ -44,7 +46,9 @@ const ChartContainer = /*#__PURE__*/React.forwardRef(function ChartContainer(pro
|
|
|
44
46
|
yAxis: yAxis,
|
|
45
47
|
dataset: dataset,
|
|
46
48
|
children: /*#__PURE__*/_jsx(InteractionProvider, {
|
|
47
|
-
children: /*#__PURE__*/_jsx(
|
|
49
|
+
children: /*#__PURE__*/_jsx(HighlightedProvider, {
|
|
50
|
+
highlightedItem: highlightedItem,
|
|
51
|
+
onHighlightChange: onHighlightChange,
|
|
48
52
|
children: /*#__PURE__*/_jsxs(ChartsSurface, {
|
|
49
53
|
width: width,
|
|
50
54
|
height: height,
|
|
@@ -64,7 +68,7 @@ const ChartContainer = /*#__PURE__*/React.forwardRef(function ChartContainer(pro
|
|
|
64
68
|
process.env.NODE_ENV !== "production" ? ChartContainer.propTypes = {
|
|
65
69
|
// ----------------------------- Warning --------------------------------
|
|
66
70
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
67
|
-
// | To update them edit the TypeScript types and run "
|
|
71
|
+
// | To update them edit the TypeScript types and run "pnpm proptypes" |
|
|
68
72
|
// ----------------------------------------------------------------------
|
|
69
73
|
children: PropTypes.node,
|
|
70
74
|
className: PropTypes.string,
|
|
@@ -88,6 +92,13 @@ process.env.NODE_ENV !== "production" ? ChartContainer.propTypes = {
|
|
|
88
92
|
* The height of the chart in px.
|
|
89
93
|
*/
|
|
90
94
|
height: PropTypes.number.isRequired,
|
|
95
|
+
/**
|
|
96
|
+
* The item currently highlighted. Turns highlighting into a controlled prop.
|
|
97
|
+
*/
|
|
98
|
+
highlightedItem: PropTypes.shape({
|
|
99
|
+
dataIndex: PropTypes.number,
|
|
100
|
+
seriesId: PropTypes.oneOfType([PropTypes.number, PropTypes.string])
|
|
101
|
+
}),
|
|
91
102
|
/**
|
|
92
103
|
* The margin between the SVG and the drawing area.
|
|
93
104
|
* It's used for leaving some space for extra information such as the x- and y-axis or legend.
|
|
@@ -100,6 +111,12 @@ process.env.NODE_ENV !== "production" ? ChartContainer.propTypes = {
|
|
|
100
111
|
right: PropTypes.number,
|
|
101
112
|
top: PropTypes.number
|
|
102
113
|
}),
|
|
114
|
+
/**
|
|
115
|
+
* The callback fired when the highlighted item changes.
|
|
116
|
+
*
|
|
117
|
+
* @param {HighlightItemData | null} highlightedItem The newly highlighted item.
|
|
118
|
+
*/
|
|
119
|
+
onHighlightChange: PropTypes.func,
|
|
103
120
|
/**
|
|
104
121
|
* The array of series to display.
|
|
105
122
|
* Each type of series has its own specificity.
|
|
@@ -91,7 +91,7 @@ function ChartsAxis(props) {
|
|
|
91
91
|
process.env.NODE_ENV !== "production" ? ChartsAxis.propTypes = {
|
|
92
92
|
// ----------------------------- Warning --------------------------------
|
|
93
93
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
94
|
-
// | To update them edit the TypeScript types and run "
|
|
94
|
+
// | To update them edit the TypeScript types and run "pnpm proptypes" |
|
|
95
95
|
// ----------------------------------------------------------------------
|
|
96
96
|
/**
|
|
97
97
|
* Indicate which axis to display the bottom of the charts.
|
|
@@ -97,7 +97,7 @@ function ChartsAxisHighlight(props) {
|
|
|
97
97
|
process.env.NODE_ENV !== "production" ? ChartsAxisHighlight.propTypes = {
|
|
98
98
|
// ----------------------------- Warning --------------------------------
|
|
99
99
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
100
|
-
// | To update them edit the TypeScript types and run "
|
|
100
|
+
// | To update them edit the TypeScript types and run "pnpm proptypes" |
|
|
101
101
|
// ----------------------------------------------------------------------
|
|
102
102
|
x: PropTypes.oneOf(['band', 'line', 'none']),
|
|
103
103
|
y: PropTypes.oneOf(['band', 'line', 'none'])
|
|
@@ -38,7 +38,7 @@ function ChartsClipPath(props) {
|
|
|
38
38
|
process.env.NODE_ENV !== "production" ? ChartsClipPath.propTypes = {
|
|
39
39
|
// ----------------------------- Warning --------------------------------
|
|
40
40
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
41
|
-
// | To update them edit the TypeScript types and run "
|
|
41
|
+
// | To update them edit the TypeScript types and run "pnpm proptypes" |
|
|
42
42
|
// ----------------------------------------------------------------------
|
|
43
43
|
id: PropTypes.string.isRequired,
|
|
44
44
|
offset: PropTypes.shape({
|
|
@@ -113,7 +113,7 @@ function ChartsGrid(props) {
|
|
|
113
113
|
process.env.NODE_ENV !== "production" ? ChartsGrid.propTypes = {
|
|
114
114
|
// ----------------------------- Warning --------------------------------
|
|
115
115
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
116
|
-
// | To update them edit the TypeScript types and run "
|
|
116
|
+
// | To update them edit the TypeScript types and run "pnpm proptypes" |
|
|
117
117
|
// ----------------------------------------------------------------------
|
|
118
118
|
/**
|
|
119
119
|
* Override or extend the styles applied to the component.
|
|
@@ -69,7 +69,7 @@ function ChartsLegend(inProps) {
|
|
|
69
69
|
process.env.NODE_ENV !== "production" ? ChartsLegend.propTypes = {
|
|
70
70
|
// ----------------------------- Warning --------------------------------
|
|
71
71
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
72
|
-
// | To update them edit the TypeScript types and run "
|
|
72
|
+
// | To update them edit the TypeScript types and run "pnpm proptypes" |
|
|
73
73
|
// ----------------------------------------------------------------------
|
|
74
74
|
/**
|
|
75
75
|
* Override or extend the styles applied to the component.
|
|
@@ -204,7 +204,7 @@ function DefaultChartsLegend(props) {
|
|
|
204
204
|
process.env.NODE_ENV !== "production" ? DefaultChartsLegend.propTypes = {
|
|
205
205
|
// ----------------------------- Warning --------------------------------
|
|
206
206
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
207
|
-
// | To update them edit the TypeScript types and run "
|
|
207
|
+
// | To update them edit the TypeScript types and run "pnpm proptypes" |
|
|
208
208
|
// ----------------------------------------------------------------------
|
|
209
209
|
/**
|
|
210
210
|
* Override or extend the styles applied to the component.
|
|
@@ -62,7 +62,7 @@ function ChartsOnAxisClickHandler(props) {
|
|
|
62
62
|
process.env.NODE_ENV !== "production" ? ChartsOnAxisClickHandler.propTypes = {
|
|
63
63
|
// ----------------------------- Warning --------------------------------
|
|
64
64
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
65
|
-
// | To update them edit the TypeScript types and run "
|
|
65
|
+
// | To update them edit the TypeScript types and run "pnpm proptypes" |
|
|
66
66
|
// ----------------------------------------------------------------------
|
|
67
67
|
/**
|
|
68
68
|
* The function called for onClick events.
|
|
@@ -23,7 +23,7 @@ function ChartsReferenceLine(props) {
|
|
|
23
23
|
process.env.NODE_ENV !== "production" ? ChartsReferenceLine.propTypes = {
|
|
24
24
|
// ----------------------------- Warning --------------------------------
|
|
25
25
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
26
|
-
// | To update them edit the TypeScript types and run "
|
|
26
|
+
// | To update them edit the TypeScript types and run "pnpm proptypes" |
|
|
27
27
|
// ----------------------------------------------------------------------
|
|
28
28
|
/**
|
|
29
29
|
* The id of the axis used for the reference value.
|
package/modern/ChartsSurface.js
CHANGED
|
@@ -44,7 +44,7 @@ const ChartsSurface = /*#__PURE__*/React.forwardRef(function ChartsSurface(props
|
|
|
44
44
|
process.env.NODE_ENV !== "production" ? ChartsSurface.propTypes = {
|
|
45
45
|
// ----------------------------- Warning --------------------------------
|
|
46
46
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
47
|
-
// | To update them edit the TypeScript types and run "
|
|
47
|
+
// | To update them edit the TypeScript types and run "pnpm proptypes" |
|
|
48
48
|
// ----------------------------------------------------------------------
|
|
49
49
|
children: PropTypes.node,
|
|
50
50
|
className: PropTypes.string,
|
|
@@ -70,7 +70,7 @@ function ChartsText(props) {
|
|
|
70
70
|
process.env.NODE_ENV !== "production" ? ChartsText.propTypes = {
|
|
71
71
|
// ----------------------------- Warning --------------------------------
|
|
72
72
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
73
|
-
// | To update them edit the TypeScript types and run "
|
|
73
|
+
// | To update them edit the TypeScript types and run "pnpm proptypes" |
|
|
74
74
|
// ----------------------------------------------------------------------
|
|
75
75
|
/**
|
|
76
76
|
* Height of a text line (in `em`).
|
|
@@ -80,7 +80,7 @@ function ChartsAxisTooltipContent(props) {
|
|
|
80
80
|
process.env.NODE_ENV !== "production" ? ChartsAxisTooltipContent.propTypes = {
|
|
81
81
|
// ----------------------------- Warning --------------------------------
|
|
82
82
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
83
|
-
// | To update them edit the TypeScript types and run "
|
|
83
|
+
// | To update them edit the TypeScript types and run "pnpm proptypes" |
|
|
84
84
|
// ----------------------------------------------------------------------
|
|
85
85
|
axisData: PropTypes.shape({
|
|
86
86
|
x: PropTypes.shape({
|
|
@@ -60,7 +60,7 @@ function ChartsItemTooltipContent(props) {
|
|
|
60
60
|
process.env.NODE_ENV !== "production" ? ChartsItemTooltipContent.propTypes = {
|
|
61
61
|
// ----------------------------- Warning --------------------------------
|
|
62
62
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
63
|
-
// | To update them edit the TypeScript types and run "
|
|
63
|
+
// | To update them edit the TypeScript types and run "pnpm proptypes" |
|
|
64
64
|
// ----------------------------------------------------------------------
|
|
65
65
|
classes: PropTypes.object.isRequired,
|
|
66
66
|
content: PropTypes.elementType,
|
|
@@ -110,7 +110,7 @@ function ChartsTooltip(props) {
|
|
|
110
110
|
process.env.NODE_ENV !== "production" ? ChartsTooltip.propTypes = {
|
|
111
111
|
// ----------------------------- Warning --------------------------------
|
|
112
112
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
113
|
-
// | To update them edit the TypeScript types and run "
|
|
113
|
+
// | To update them edit the TypeScript types and run "pnpm proptypes" |
|
|
114
114
|
// ----------------------------------------------------------------------
|
|
115
115
|
/**
|
|
116
116
|
* Component to override the tooltip content when trigger is set to 'axis'.
|
|
@@ -80,7 +80,7 @@ function DefaultChartsAxisTooltipContent(props) {
|
|
|
80
80
|
process.env.NODE_ENV !== "production" ? DefaultChartsAxisTooltipContent.propTypes = {
|
|
81
81
|
// ----------------------------- Warning --------------------------------
|
|
82
82
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
83
|
-
// | To update them edit the TypeScript types and run "
|
|
83
|
+
// | To update them edit the TypeScript types and run "pnpm proptypes" |
|
|
84
84
|
// ----------------------------------------------------------------------
|
|
85
85
|
/**
|
|
86
86
|
* The properties of the triggered axis.
|
|
@@ -61,7 +61,7 @@ function DefaultChartsItemTooltipContent(props) {
|
|
|
61
61
|
process.env.NODE_ENV !== "production" ? DefaultChartsItemTooltipContent.propTypes = {
|
|
62
62
|
// ----------------------------- Warning --------------------------------
|
|
63
63
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
64
|
-
// | To update them edit the TypeScript types and run "
|
|
64
|
+
// | To update them edit the TypeScript types and run "pnpm proptypes" |
|
|
65
65
|
// ----------------------------------------------------------------------
|
|
66
66
|
/**
|
|
67
67
|
* Override or extend the styles applied to the component.
|
|
@@ -8,6 +8,7 @@ import { SeriesContext } from '../context/SeriesContextProvider';
|
|
|
8
8
|
import { getValueToPositionMapper } from '../hooks/useScale';
|
|
9
9
|
import { getSVGPoint } from '../internals/utils';
|
|
10
10
|
import { useDrawingArea, useSvgRef } from '../hooks';
|
|
11
|
+
import { useHighlighted } from '../context';
|
|
11
12
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
12
13
|
function ChartsVoronoiHandler(props) {
|
|
13
14
|
const {
|
|
@@ -36,6 +37,10 @@ function ChartsVoronoiHandler(props) {
|
|
|
36
37
|
} = React.useContext(SeriesContext).scatter ?? {};
|
|
37
38
|
const voronoiRef = React.useRef({});
|
|
38
39
|
const delauneyRef = React.useRef(undefined);
|
|
40
|
+
const {
|
|
41
|
+
setHighlighted,
|
|
42
|
+
clearHighlighted
|
|
43
|
+
} = useHighlighted();
|
|
39
44
|
const defaultXAxisId = xAxisIds[0];
|
|
40
45
|
const defaultYAxisId = yAxisIds[0];
|
|
41
46
|
useEnhancedEffect(() => {
|
|
@@ -129,6 +134,7 @@ function ChartsVoronoiHandler(props) {
|
|
|
129
134
|
dispatch({
|
|
130
135
|
type: 'exitChart'
|
|
131
136
|
});
|
|
137
|
+
clearHighlighted();
|
|
132
138
|
};
|
|
133
139
|
const handleMouseMove = event => {
|
|
134
140
|
const closestPoint = getClosestPoint(event);
|
|
@@ -136,6 +142,7 @@ function ChartsVoronoiHandler(props) {
|
|
|
136
142
|
dispatch({
|
|
137
143
|
type: 'exitChart'
|
|
138
144
|
});
|
|
145
|
+
clearHighlighted();
|
|
139
146
|
return;
|
|
140
147
|
}
|
|
141
148
|
if (closestPoint === 'outside-voronoi-max-radius' || closestPoint === 'no-point-found') {
|
|
@@ -145,6 +152,7 @@ function ChartsVoronoiHandler(props) {
|
|
|
145
152
|
type: 'scatter'
|
|
146
153
|
}
|
|
147
154
|
});
|
|
155
|
+
clearHighlighted();
|
|
148
156
|
return;
|
|
149
157
|
}
|
|
150
158
|
const {
|
|
@@ -159,6 +167,10 @@ function ChartsVoronoiHandler(props) {
|
|
|
159
167
|
dataIndex
|
|
160
168
|
}
|
|
161
169
|
});
|
|
170
|
+
setHighlighted({
|
|
171
|
+
seriesId,
|
|
172
|
+
dataIndex
|
|
173
|
+
});
|
|
162
174
|
};
|
|
163
175
|
const handleMouseClick = event => {
|
|
164
176
|
if (!onItemClick) {
|
|
@@ -187,7 +199,7 @@ function ChartsVoronoiHandler(props) {
|
|
|
187
199
|
element.removeEventListener('mousemove', handleMouseMove);
|
|
188
200
|
element.removeEventListener('click', handleMouseClick);
|
|
189
201
|
};
|
|
190
|
-
}, [svgRef, dispatch, left, width, top, height, yAxis, xAxis, voronoiMaxRadius, onItemClick]);
|
|
202
|
+
}, [svgRef, dispatch, left, width, top, height, yAxis, xAxis, voronoiMaxRadius, onItemClick, setHighlighted, clearHighlighted]);
|
|
191
203
|
|
|
192
204
|
// eslint-disable-next-line react/jsx-no-useless-fragment
|
|
193
205
|
return /*#__PURE__*/_jsx(React.Fragment, {});
|
|
@@ -195,7 +207,7 @@ function ChartsVoronoiHandler(props) {
|
|
|
195
207
|
process.env.NODE_ENV !== "production" ? ChartsVoronoiHandler.propTypes = {
|
|
196
208
|
// ----------------------------- Warning --------------------------------
|
|
197
209
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
198
|
-
// | To update them edit the TypeScript types and run "
|
|
210
|
+
// | To update them edit the TypeScript types and run "pnpm proptypes" |
|
|
199
211
|
// ----------------------------------------------------------------------
|
|
200
212
|
/**
|
|
201
213
|
* Callback fired when clicking on a scatter item.
|
|
@@ -248,7 +248,7 @@ function ChartsXAxis(inProps) {
|
|
|
248
248
|
process.env.NODE_ENV !== "production" ? ChartsXAxis.propTypes = {
|
|
249
249
|
// ----------------------------- Warning --------------------------------
|
|
250
250
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
251
|
-
// | To update them edit the TypeScript types and run "
|
|
251
|
+
// | To update them edit the TypeScript types and run "pnpm proptypes" |
|
|
252
252
|
// ----------------------------------------------------------------------
|
|
253
253
|
/**
|
|
254
254
|
* The id of the axis to render.
|
|
@@ -184,7 +184,7 @@ function ChartsYAxis(inProps) {
|
|
|
184
184
|
process.env.NODE_ENV !== "production" ? ChartsYAxis.propTypes = {
|
|
185
185
|
// ----------------------------- Warning --------------------------------
|
|
186
186
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
187
|
-
// | To update them edit the TypeScript types and run "
|
|
187
|
+
// | To update them edit the TypeScript types and run "pnpm proptypes" |
|
|
188
188
|
// ----------------------------------------------------------------------
|
|
189
189
|
/**
|
|
190
190
|
* The id of the axis to render.
|
package/modern/Gauge/Gauge.js
CHANGED
|
@@ -44,7 +44,7 @@ function Gauge(props) {
|
|
|
44
44
|
process.env.NODE_ENV !== "production" ? Gauge.propTypes = {
|
|
45
45
|
// ----------------------------- Warning --------------------------------
|
|
46
46
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
47
|
-
// | To update them edit the TypeScript types and run "
|
|
47
|
+
// | To update them edit the TypeScript types and run "pnpm proptypes" |
|
|
48
48
|
// ----------------------------------------------------------------------
|
|
49
49
|
children: PropTypes.node,
|
|
50
50
|
classes: PropTypes.object,
|
|
@@ -106,7 +106,7 @@ const GaugeContainer = /*#__PURE__*/React.forwardRef(function GaugeContainer(pro
|
|
|
106
106
|
process.env.NODE_ENV !== "production" ? GaugeContainer.propTypes = {
|
|
107
107
|
// ----------------------------- Warning --------------------------------
|
|
108
108
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
109
|
-
// | To update them edit the TypeScript types and run "
|
|
109
|
+
// | To update them edit the TypeScript types and run "pnpm proptypes" |
|
|
110
110
|
// ----------------------------------------------------------------------
|
|
111
111
|
children: PropTypes.node,
|
|
112
112
|
className: PropTypes.string,
|
|
@@ -48,7 +48,7 @@ function GaugeValueText(props) {
|
|
|
48
48
|
process.env.NODE_ENV !== "production" ? GaugeValueText.propTypes = {
|
|
49
49
|
// ----------------------------- Warning --------------------------------
|
|
50
50
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
51
|
-
// | To update them edit the TypeScript types and run "
|
|
51
|
+
// | To update them edit the TypeScript types and run "pnpm proptypes" |
|
|
52
52
|
// ----------------------------------------------------------------------
|
|
53
53
|
/**
|
|
54
54
|
* Height of a text line (in `em`).
|