@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
|
@@ -56,7 +56,9 @@ const ScatterChart = exports.ScatterChart = /*#__PURE__*/React.forwardRef(functi
|
|
|
56
56
|
children,
|
|
57
57
|
slots,
|
|
58
58
|
slotProps,
|
|
59
|
-
loading
|
|
59
|
+
loading,
|
|
60
|
+
highlightedItem,
|
|
61
|
+
onHighlightChange
|
|
60
62
|
} = props;
|
|
61
63
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_ResponsiveChartContainer.ResponsiveChartContainer, {
|
|
62
64
|
ref: ref,
|
|
@@ -70,6 +72,8 @@ const ScatterChart = exports.ScatterChart = /*#__PURE__*/React.forwardRef(functi
|
|
|
70
72
|
xAxis: xAxis,
|
|
71
73
|
yAxis: yAxis,
|
|
72
74
|
sx: sx,
|
|
75
|
+
highlightedItem: highlightedItem,
|
|
76
|
+
onHighlightChange: onHighlightChange,
|
|
73
77
|
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_ZAxisContextProvider.ZAxisContextProvider, {
|
|
74
78
|
zAxis: zAxis,
|
|
75
79
|
children: [!disableVoronoi && /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsVoronoiHandler.ChartsVoronoiHandler, {
|
|
@@ -108,7 +112,7 @@ const ScatterChart = exports.ScatterChart = /*#__PURE__*/React.forwardRef(functi
|
|
|
108
112
|
process.env.NODE_ENV !== "production" ? ScatterChart.propTypes = {
|
|
109
113
|
// ----------------------------- Warning --------------------------------
|
|
110
114
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
111
|
-
// | To update them edit the TypeScript types and run "
|
|
115
|
+
// | To update them edit the TypeScript types and run "pnpm proptypes" |
|
|
112
116
|
// ----------------------------------------------------------------------
|
|
113
117
|
/**
|
|
114
118
|
* The configuration of axes highlight.
|
|
@@ -159,6 +163,13 @@ process.env.NODE_ENV !== "production" ? ScatterChart.propTypes = {
|
|
|
159
163
|
* The height of the chart in px. If not defined, it takes the height of the parent element.
|
|
160
164
|
*/
|
|
161
165
|
height: _propTypes.default.number,
|
|
166
|
+
/**
|
|
167
|
+
* The item currently highlighted. Turns highlighting into a controlled prop.
|
|
168
|
+
*/
|
|
169
|
+
highlightedItem: _propTypes.default.shape({
|
|
170
|
+
dataIndex: _propTypes.default.number,
|
|
171
|
+
seriesId: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string])
|
|
172
|
+
}),
|
|
162
173
|
/**
|
|
163
174
|
* Indicate which axis to display the left of the charts.
|
|
164
175
|
* Can be a string (the id of the axis) or an object `ChartsYAxisProps`.
|
|
@@ -196,6 +207,12 @@ process.env.NODE_ENV !== "production" ? ScatterChart.propTypes = {
|
|
|
196
207
|
right: _propTypes.default.number,
|
|
197
208
|
top: _propTypes.default.number
|
|
198
209
|
}),
|
|
210
|
+
/**
|
|
211
|
+
* The callback fired when the highlighted item changes.
|
|
212
|
+
*
|
|
213
|
+
* @param {HighlightItemData | null} highlightedItem The newly highlighted item.
|
|
214
|
+
*/
|
|
215
|
+
onHighlightChange: _propTypes.default.func,
|
|
199
216
|
/**
|
|
200
217
|
* Callback fired when clicking on a scatter item.
|
|
201
218
|
* @param {MouseEvent} event The mouse event recorded on the `<svg/>` element if using Voronoi cells. Or the Mouse event from the scatter element, when `disableVoronoi=true`.
|
|
@@ -83,7 +83,7 @@ function ScatterPlot(props) {
|
|
|
83
83
|
process.env.NODE_ENV !== "production" ? ScatterPlot.propTypes = {
|
|
84
84
|
// ----------------------------- Warning --------------------------------
|
|
85
85
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
86
|
-
// | To update them edit the TypeScript types and run "
|
|
86
|
+
// | To update them edit the TypeScript types and run "pnpm proptypes" |
|
|
87
87
|
// ----------------------------------------------------------------------
|
|
88
88
|
/**
|
|
89
89
|
* Callback fired when clicking on a scatter item.
|
|
@@ -11,7 +11,7 @@ import { LinePlotSlots, LinePlotSlotProps } from '../LineChart/LinePlot';
|
|
|
11
11
|
import { MarkPlotSlots, MarkPlotSlotProps } from '../LineChart/MarkPlot';
|
|
12
12
|
import { LineHighlightPlotSlots, LineHighlightPlotSlotProps } from '../LineChart/LineHighlightPlot';
|
|
13
13
|
import { BarPlotSlots, BarPlotSlotProps } from '../BarChart/BarPlot';
|
|
14
|
-
export interface SparkLineChartSlots extends AreaPlotSlots, LinePlotSlots, MarkPlotSlots, LineHighlightPlotSlots, BarPlotSlots, ChartsTooltipSlots {
|
|
14
|
+
export interface SparkLineChartSlots extends AreaPlotSlots, LinePlotSlots, MarkPlotSlots, LineHighlightPlotSlots, Omit<BarPlotSlots, 'barLabel'>, ChartsTooltipSlots {
|
|
15
15
|
}
|
|
16
16
|
export interface SparkLineChartSlotProps extends AreaPlotSlotProps, LinePlotSlotProps, MarkPlotSlotProps, LineHighlightPlotSlotProps, BarPlotSlotProps, ChartsTooltipSlotProps {
|
|
17
17
|
}
|
|
@@ -114,7 +114,7 @@ const SparkLineChart = exports.SparkLineChart = /*#__PURE__*/React.forwardRef(fu
|
|
|
114
114
|
process.env.NODE_ENV !== "production" ? SparkLineChart.propTypes = {
|
|
115
115
|
// ----------------------------- Warning --------------------------------
|
|
116
116
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
117
|
-
// | To update them edit the TypeScript types and run "
|
|
117
|
+
// | To update them edit the TypeScript types and run "pnpm proptypes" |
|
|
118
118
|
// ----------------------------------------------------------------------
|
|
119
119
|
/**
|
|
120
120
|
* Set to `true` to fill spark line area.
|
|
@@ -156,6 +156,13 @@ process.env.NODE_ENV !== "production" ? SparkLineChart.propTypes = {
|
|
|
156
156
|
* The height of the chart in px. If not defined, it takes the height of the parent element.
|
|
157
157
|
*/
|
|
158
158
|
height: _propTypes.default.number,
|
|
159
|
+
/**
|
|
160
|
+
* The item currently highlighted. Turns highlighting into a controlled prop.
|
|
161
|
+
*/
|
|
162
|
+
highlightedItem: _propTypes.default.shape({
|
|
163
|
+
dataIndex: _propTypes.default.number,
|
|
164
|
+
seriesId: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string])
|
|
165
|
+
}),
|
|
159
166
|
/**
|
|
160
167
|
* The margin between the SVG and the drawing area.
|
|
161
168
|
* It's used for leaving some space for extra information such as the x- and y-axis or legend.
|
|
@@ -173,6 +180,12 @@ process.env.NODE_ENV !== "production" ? SparkLineChart.propTypes = {
|
|
|
173
180
|
right: _propTypes.default.number,
|
|
174
181
|
top: _propTypes.default.number
|
|
175
182
|
}),
|
|
183
|
+
/**
|
|
184
|
+
* The callback fired when the highlighted item changes.
|
|
185
|
+
*
|
|
186
|
+
* @param {HighlightItemData | null} highlightedItem The newly highlighted item.
|
|
187
|
+
*/
|
|
188
|
+
onHighlightChange: _propTypes.default.func,
|
|
176
189
|
/**
|
|
177
190
|
* Type of plot used.
|
|
178
191
|
* @default 'line'
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { SeriesId } from '../../models/seriesType/common';
|
|
3
|
+
/**
|
|
4
|
+
* The data of the highlighted item.
|
|
5
|
+
* To highlight an item, you need to provide the series id and the item id.
|
|
6
|
+
* If targeting the whole series, you can omit the item id.
|
|
7
|
+
* To clear the highlight, set the value to an empty object.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* // Highlight the item with the series id 'london' and the item id 0.
|
|
11
|
+
* { seriesId: 'london', dataIndex: 0 }
|
|
12
|
+
*
|
|
13
|
+
* // Highlight the whole series with the series id 'london'.
|
|
14
|
+
* { seriesId: 'london' }
|
|
15
|
+
*
|
|
16
|
+
* // Clear the highlight.
|
|
17
|
+
* {}
|
|
18
|
+
*/
|
|
19
|
+
export type HighlightItemData = {
|
|
20
|
+
/**
|
|
21
|
+
* The series id of the highlighted item.
|
|
22
|
+
*/
|
|
23
|
+
seriesId?: SeriesId;
|
|
24
|
+
/**
|
|
25
|
+
* The index of the item in series data.
|
|
26
|
+
*/
|
|
27
|
+
dataIndex?: number;
|
|
28
|
+
};
|
|
29
|
+
export type HighlightOptions = 'none' | 'item' | 'series';
|
|
30
|
+
export type FadeOptions = 'none' | 'series' | 'global';
|
|
31
|
+
export type HighlightScope = {
|
|
32
|
+
/**
|
|
33
|
+
* @deprecated Use `highlight` instead.
|
|
34
|
+
*/
|
|
35
|
+
highlighted?: HighlightOptions;
|
|
36
|
+
/**
|
|
37
|
+
* The scope of highlighted elements.
|
|
38
|
+
* - 'none': no highlight.
|
|
39
|
+
* - 'item': only highlight the item.
|
|
40
|
+
* - 'series': highlight all elements of the same series.
|
|
41
|
+
* @default 'none'
|
|
42
|
+
*/
|
|
43
|
+
highlight?: HighlightOptions;
|
|
44
|
+
/**
|
|
45
|
+
* @deprecated Use `fade` instead.
|
|
46
|
+
*/
|
|
47
|
+
faded?: FadeOptions;
|
|
48
|
+
/**
|
|
49
|
+
* The scope of faded elements.
|
|
50
|
+
* - 'none': no fading.
|
|
51
|
+
* - 'series': only fade element of the same series.
|
|
52
|
+
* - 'global': fade all elements that are not highlighted.
|
|
53
|
+
* @default 'none'
|
|
54
|
+
*/
|
|
55
|
+
fade?: FadeOptions;
|
|
56
|
+
};
|
|
57
|
+
export type HighlightedState = {
|
|
58
|
+
highlightScope?: Partial<HighlightScope>;
|
|
59
|
+
highlightedItem: HighlightItemData | null;
|
|
60
|
+
setHighlighted: (item: HighlightItemData) => void;
|
|
61
|
+
clearHighlighted: () => void;
|
|
62
|
+
isHighlighted: (input: HighlightItemData) => boolean;
|
|
63
|
+
isFaded: (input: HighlightItemData) => boolean;
|
|
64
|
+
};
|
|
65
|
+
export declare const HighlightedContext: React.Context<HighlightedState>;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.HighlightedContext = void 0;
|
|
7
|
+
var React = _interopRequireWildcard(require("react"));
|
|
8
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
9
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
10
|
+
/**
|
|
11
|
+
* The data of the highlighted item.
|
|
12
|
+
* To highlight an item, you need to provide the series id and the item id.
|
|
13
|
+
* If targeting the whole series, you can omit the item id.
|
|
14
|
+
* To clear the highlight, set the value to an empty object.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* // Highlight the item with the series id 'london' and the item id 0.
|
|
18
|
+
* { seriesId: 'london', dataIndex: 0 }
|
|
19
|
+
*
|
|
20
|
+
* // Highlight the whole series with the series id 'london'.
|
|
21
|
+
* { seriesId: 'london' }
|
|
22
|
+
*
|
|
23
|
+
* // Clear the highlight.
|
|
24
|
+
* {}
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
const HighlightedContext = exports.HighlightedContext = /*#__PURE__*/React.createContext({
|
|
28
|
+
highlightedItem: null,
|
|
29
|
+
setHighlighted: () => {},
|
|
30
|
+
clearHighlighted: () => {},
|
|
31
|
+
isHighlighted: () => false,
|
|
32
|
+
isFaded: () => false
|
|
33
|
+
});
|
|
34
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
35
|
+
HighlightedContext.displayName = 'HighlightedContext';
|
|
36
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { HighlightItemData } from './HighlightedContext';
|
|
3
|
+
export type HighlightedProviderProps = {
|
|
4
|
+
children: React.ReactNode;
|
|
5
|
+
/**
|
|
6
|
+
* The item currently highlighted. Turns highlighting into a controlled prop.
|
|
7
|
+
*/
|
|
8
|
+
highlightedItem?: HighlightItemData | null;
|
|
9
|
+
/**
|
|
10
|
+
* The callback fired when the highlighted item changes.
|
|
11
|
+
*
|
|
12
|
+
* @param {HighlightItemData | null} highlightedItem The newly highlighted item.
|
|
13
|
+
*/
|
|
14
|
+
onHighlightChange?: (highlightedItem: HighlightItemData | null) => void;
|
|
15
|
+
};
|
|
16
|
+
declare function HighlightedProvider({ children, highlightedItem: highlightedItemProps, onHighlightChange, }: HighlightedProviderProps): React.JSX.Element;
|
|
17
|
+
declare namespace HighlightedProvider {
|
|
18
|
+
var propTypes: any;
|
|
19
|
+
}
|
|
20
|
+
export { HighlightedProvider };
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.HighlightedProvider = HighlightedProvider;
|
|
8
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
|
+
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
|
|
10
|
+
var React = _interopRequireWildcard(require("react"));
|
|
11
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
12
|
+
var _useControlled = _interopRequireDefault(require("@mui/utils/useControlled"));
|
|
13
|
+
var _HighlightedContext = require("./HighlightedContext");
|
|
14
|
+
var _createIsFaded = require("./createIsFaded");
|
|
15
|
+
var _createIsHighlighted = require("./createIsHighlighted");
|
|
16
|
+
var _useSeries = require("../../hooks/useSeries");
|
|
17
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
18
|
+
const _excluded = ["highlighted", "faded"];
|
|
19
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
20
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
21
|
+
const mergeDeprecatedOptions = options => {
|
|
22
|
+
const _ref = options ?? {},
|
|
23
|
+
{
|
|
24
|
+
highlighted,
|
|
25
|
+
faded
|
|
26
|
+
} = _ref,
|
|
27
|
+
rest = (0, _objectWithoutPropertiesLoose2.default)(_ref, _excluded);
|
|
28
|
+
return (0, _extends2.default)({
|
|
29
|
+
highlight: highlighted,
|
|
30
|
+
fade: faded
|
|
31
|
+
}, rest);
|
|
32
|
+
};
|
|
33
|
+
function HighlightedProvider({
|
|
34
|
+
children,
|
|
35
|
+
highlightedItem: highlightedItemProps,
|
|
36
|
+
onHighlightChange
|
|
37
|
+
}) {
|
|
38
|
+
const [highlightedItem, setHighlightedItem] = (0, _useControlled.default)({
|
|
39
|
+
controlled: highlightedItemProps,
|
|
40
|
+
default: null,
|
|
41
|
+
name: 'HighlightedProvider',
|
|
42
|
+
state: 'highlightedItem'
|
|
43
|
+
});
|
|
44
|
+
const series = (0, _useSeries.useSeries)();
|
|
45
|
+
const seriesById = React.useMemo(() => {
|
|
46
|
+
const map = new Map();
|
|
47
|
+
Object.keys(series).forEach(seriesType => {
|
|
48
|
+
const seriesData = series[seriesType];
|
|
49
|
+
Object.keys(seriesData?.series ?? {}).forEach(seriesId => {
|
|
50
|
+
const seriesItem = seriesData?.series[seriesId];
|
|
51
|
+
map.set(seriesId, mergeDeprecatedOptions(seriesItem?.highlightScope));
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
return map;
|
|
55
|
+
}, [series]);
|
|
56
|
+
const highlightScope = highlightedItem && highlightedItem.seriesId ? seriesById.get(highlightedItem.seriesId) ?? undefined : undefined;
|
|
57
|
+
const providerValue = React.useMemo(() => {
|
|
58
|
+
return {
|
|
59
|
+
highlightScope,
|
|
60
|
+
highlightedItem,
|
|
61
|
+
setHighlighted: itemData => {
|
|
62
|
+
setHighlightedItem(itemData);
|
|
63
|
+
onHighlightChange?.(itemData);
|
|
64
|
+
},
|
|
65
|
+
clearHighlighted: () => {
|
|
66
|
+
setHighlightedItem(null);
|
|
67
|
+
onHighlightChange?.(null);
|
|
68
|
+
},
|
|
69
|
+
isHighlighted: (0, _createIsHighlighted.createIsHighlighted)(highlightScope, highlightedItem),
|
|
70
|
+
isFaded: (0, _createIsFaded.createIsFaded)(highlightScope, highlightedItem)
|
|
71
|
+
};
|
|
72
|
+
}, [highlightedItem, highlightScope, setHighlightedItem, onHighlightChange]);
|
|
73
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_HighlightedContext.HighlightedContext.Provider, {
|
|
74
|
+
value: providerValue,
|
|
75
|
+
children: children
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
process.env.NODE_ENV !== "production" ? HighlightedProvider.propTypes = {
|
|
79
|
+
// ----------------------------- Warning --------------------------------
|
|
80
|
+
// | These PropTypes are generated from the TypeScript type definitions |
|
|
81
|
+
// | To update them edit the TypeScript types and run "pnpm proptypes" |
|
|
82
|
+
// ----------------------------------------------------------------------
|
|
83
|
+
children: _propTypes.default.node,
|
|
84
|
+
/**
|
|
85
|
+
* The item currently highlighted. Turns highlighting into a controlled prop.
|
|
86
|
+
*/
|
|
87
|
+
highlightedItem: _propTypes.default.shape({
|
|
88
|
+
dataIndex: _propTypes.default.number,
|
|
89
|
+
seriesId: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string])
|
|
90
|
+
}),
|
|
91
|
+
/**
|
|
92
|
+
* The callback fired when the highlighted item changes.
|
|
93
|
+
*
|
|
94
|
+
* @param {HighlightItemData | null} highlightedItem The newly highlighted item.
|
|
95
|
+
*/
|
|
96
|
+
onHighlightChange: _propTypes.default.func
|
|
97
|
+
} : void 0;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.createIsFaded = void 0;
|
|
7
|
+
const createIsFaded = (highlightScope, highlightedItem) => input => {
|
|
8
|
+
if (!highlightScope) {
|
|
9
|
+
return false;
|
|
10
|
+
}
|
|
11
|
+
if (highlightScope.fade === 'series') {
|
|
12
|
+
return input.seriesId === highlightedItem?.seriesId && input.dataIndex !== highlightedItem?.dataIndex;
|
|
13
|
+
}
|
|
14
|
+
if (highlightScope.fade === 'global') {
|
|
15
|
+
return input.seriesId !== highlightedItem?.seriesId || input.dataIndex !== highlightedItem?.dataIndex;
|
|
16
|
+
}
|
|
17
|
+
return false;
|
|
18
|
+
};
|
|
19
|
+
exports.createIsFaded = createIsFaded;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.createIsHighlighted = void 0;
|
|
7
|
+
const createIsHighlighted = (highlightScope, highlightedItem) => input => {
|
|
8
|
+
if (!highlightScope) {
|
|
9
|
+
return false;
|
|
10
|
+
}
|
|
11
|
+
if (highlightScope.highlight === 'series') {
|
|
12
|
+
return input.seriesId === highlightedItem?.seriesId;
|
|
13
|
+
}
|
|
14
|
+
if (highlightScope.highlight === 'item') {
|
|
15
|
+
return input.dataIndex === highlightedItem?.dataIndex && input.seriesId === highlightedItem?.seriesId;
|
|
16
|
+
}
|
|
17
|
+
return false;
|
|
18
|
+
};
|
|
19
|
+
exports.createIsHighlighted = createIsHighlighted;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var _HighlightedProvider = require("./HighlightedProvider");
|
|
7
|
+
Object.keys(_HighlightedProvider).forEach(function (key) {
|
|
8
|
+
if (key === "default" || key === "__esModule") return;
|
|
9
|
+
if (key in exports && exports[key] === _HighlightedProvider[key]) return;
|
|
10
|
+
Object.defineProperty(exports, key, {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function () {
|
|
13
|
+
return _HighlightedProvider[key];
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
var _HighlightedContext = require("./HighlightedContext");
|
|
18
|
+
Object.keys(_HighlightedContext).forEach(function (key) {
|
|
19
|
+
if (key === "default" || key === "__esModule") return;
|
|
20
|
+
if (key in exports && exports[key] === _HighlightedContext[key]) return;
|
|
21
|
+
Object.defineProperty(exports, key, {
|
|
22
|
+
enumerable: true,
|
|
23
|
+
get: function () {
|
|
24
|
+
return _HighlightedContext[key];
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
var _useHighlighted = require("./useHighlighted");
|
|
29
|
+
Object.keys(_useHighlighted).forEach(function (key) {
|
|
30
|
+
if (key === "default" || key === "__esModule") return;
|
|
31
|
+
if (key in exports && exports[key] === _useHighlighted[key]) return;
|
|
32
|
+
Object.defineProperty(exports, key, {
|
|
33
|
+
enumerable: true,
|
|
34
|
+
get: function () {
|
|
35
|
+
return _useHighlighted[key];
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
var _useItemHighlighted = require("./useItemHighlighted");
|
|
40
|
+
Object.keys(_useItemHighlighted).forEach(function (key) {
|
|
41
|
+
if (key === "default" || key === "__esModule") return;
|
|
42
|
+
if (key in exports && exports[key] === _useItemHighlighted[key]) return;
|
|
43
|
+
Object.defineProperty(exports, key, {
|
|
44
|
+
enumerable: true,
|
|
45
|
+
get: function () {
|
|
46
|
+
return _useItemHighlighted[key];
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { HighlightedState } from './HighlightedContext';
|
|
2
|
+
/**
|
|
3
|
+
* A hook to get the highlighted state of the chart.
|
|
4
|
+
*
|
|
5
|
+
* Please consider using the `useItemHighlighted` hook if you need to check the state of a specific item.
|
|
6
|
+
*
|
|
7
|
+
* @returns {HighlightedState} the state of the chart
|
|
8
|
+
*/
|
|
9
|
+
export declare function useHighlighted(): HighlightedState;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useHighlighted = useHighlighted;
|
|
7
|
+
var React = _interopRequireWildcard(require("react"));
|
|
8
|
+
var _HighlightedContext = require("./HighlightedContext");
|
|
9
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
10
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
11
|
+
/**
|
|
12
|
+
* A hook to get the highlighted state of the chart.
|
|
13
|
+
*
|
|
14
|
+
* Please consider using the `useItemHighlighted` hook if you need to check the state of a specific item.
|
|
15
|
+
*
|
|
16
|
+
* @returns {HighlightedState} the state of the chart
|
|
17
|
+
*/
|
|
18
|
+
function useHighlighted() {
|
|
19
|
+
const highlighted = React.useContext(_HighlightedContext.HighlightedContext);
|
|
20
|
+
if (highlighted === undefined) {
|
|
21
|
+
throw new Error(['MUI X: Could not find the highlighted ref context.', 'It looks like you rendered your component outside of a ChartsContainer parent component.'].join('\n'));
|
|
22
|
+
}
|
|
23
|
+
return highlighted;
|
|
24
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { HighlightItemData } from './HighlightedContext';
|
|
2
|
+
export type ItemHighlightedState = {
|
|
3
|
+
/**
|
|
4
|
+
* Whether the item is highlighted.
|
|
5
|
+
*/
|
|
6
|
+
isHighlighted: boolean;
|
|
7
|
+
/**
|
|
8
|
+
* Whether the item is faded.
|
|
9
|
+
*/
|
|
10
|
+
isFaded: boolean;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* A hook to check the highlighted state of the item.
|
|
14
|
+
* This function already calculates that an item is not faded if it is highlighted.
|
|
15
|
+
*
|
|
16
|
+
* If you need fine control over the state, use the `useHighlighted` hook instead.
|
|
17
|
+
*
|
|
18
|
+
* @param {HighlightItemData} item is the item to check
|
|
19
|
+
* @returns {ItemHighlightedState} the state of the item
|
|
20
|
+
*/
|
|
21
|
+
export declare function useItemHighlighted(item: HighlightItemData | null): ItemHighlightedState;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useItemHighlighted = useItemHighlighted;
|
|
7
|
+
var React = _interopRequireWildcard(require("react"));
|
|
8
|
+
var _HighlightedContext = require("./HighlightedContext");
|
|
9
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
10
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
11
|
+
/**
|
|
12
|
+
* A hook to check the highlighted state of the item.
|
|
13
|
+
* This function already calculates that an item is not faded if it is highlighted.
|
|
14
|
+
*
|
|
15
|
+
* If you need fine control over the state, use the `useHighlighted` hook instead.
|
|
16
|
+
*
|
|
17
|
+
* @param {HighlightItemData} item is the item to check
|
|
18
|
+
* @returns {ItemHighlightedState} the state of the item
|
|
19
|
+
*/
|
|
20
|
+
function useItemHighlighted(item) {
|
|
21
|
+
const highlighted = React.useContext(_HighlightedContext.HighlightedContext);
|
|
22
|
+
if (highlighted === undefined) {
|
|
23
|
+
throw new Error(['MUI X: Could not find the highlighted ref context.', 'It looks like you rendered your component outside of a ChartsContainer parent component.'].join('\n'));
|
|
24
|
+
}
|
|
25
|
+
if (!item) {
|
|
26
|
+
return {
|
|
27
|
+
isHighlighted: false,
|
|
28
|
+
isFaded: false
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
const isHighlighted = highlighted.isHighlighted(item);
|
|
32
|
+
const isFaded = !isHighlighted && highlighted.isFaded(item);
|
|
33
|
+
return {
|
|
34
|
+
isHighlighted,
|
|
35
|
+
isFaded
|
|
36
|
+
};
|
|
37
|
+
}
|
|
@@ -65,7 +65,7 @@ function ZAxisContextProvider(props) {
|
|
|
65
65
|
process.env.NODE_ENV !== "production" ? ZAxisContextProvider.propTypes = {
|
|
66
66
|
// ----------------------------- Warning --------------------------------
|
|
67
67
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
68
|
-
// | To update them edit the TypeScript types and run "
|
|
68
|
+
// | To update them edit the TypeScript types and run "pnpm proptypes" |
|
|
69
69
|
// ----------------------------------------------------------------------
|
|
70
70
|
children: _propTypes.default.node,
|
|
71
71
|
/**
|
package/context/index.d.ts
CHANGED
package/context/index.js
CHANGED
|
@@ -3,10 +3,25 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
+
var _exportNames = {
|
|
7
|
+
ZAxisContextProvider: true
|
|
8
|
+
};
|
|
6
9
|
Object.defineProperty(exports, "ZAxisContextProvider", {
|
|
7
10
|
enumerable: true,
|
|
8
11
|
get: function () {
|
|
9
12
|
return _ZAxisContextProvider.ZAxisContextProvider;
|
|
10
13
|
}
|
|
11
14
|
});
|
|
15
|
+
var _HighlightedProvider = require("./HighlightedProvider");
|
|
16
|
+
Object.keys(_HighlightedProvider).forEach(function (key) {
|
|
17
|
+
if (key === "default" || key === "__esModule") return;
|
|
18
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
19
|
+
if (key in exports && exports[key] === _HighlightedProvider[key]) return;
|
|
20
|
+
Object.defineProperty(exports, key, {
|
|
21
|
+
enumerable: true,
|
|
22
|
+
get: function () {
|
|
23
|
+
return _HighlightedProvider[key];
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
});
|
|
12
27
|
var _ZAxisContextProvider = require("./ZAxisContextProvider");
|
package/esm/BarChart/BarChart.js
CHANGED
|
@@ -52,7 +52,10 @@ const BarChart = /*#__PURE__*/React.forwardRef(function BarChart(props, ref) {
|
|
|
52
52
|
children,
|
|
53
53
|
slots,
|
|
54
54
|
slotProps,
|
|
55
|
-
loading
|
|
55
|
+
loading,
|
|
56
|
+
barLabel,
|
|
57
|
+
highlightedItem,
|
|
58
|
+
onHighlightChange
|
|
56
59
|
} = props;
|
|
57
60
|
const id = useId();
|
|
58
61
|
const clipPathId = `${id}-clip-path`;
|
|
@@ -88,6 +91,8 @@ const BarChart = /*#__PURE__*/React.forwardRef(function BarChart(props, ref) {
|
|
|
88
91
|
dataset: dataset,
|
|
89
92
|
sx: sx,
|
|
90
93
|
disableAxisListener: tooltip?.trigger !== 'axis' && axisHighlight?.x === 'none' && axisHighlight?.y === 'none' && !onAxisClick,
|
|
94
|
+
highlightedItem: highlightedItem,
|
|
95
|
+
onHighlightChange: onHighlightChange,
|
|
91
96
|
children: [onAxisClick && /*#__PURE__*/_jsx(ChartsOnAxisClickHandler, {
|
|
92
97
|
onAxisClick: onAxisClick
|
|
93
98
|
}), grid && /*#__PURE__*/_jsx(ChartsGrid, {
|
|
@@ -100,7 +105,8 @@ const BarChart = /*#__PURE__*/React.forwardRef(function BarChart(props, ref) {
|
|
|
100
105
|
slotProps: slotProps,
|
|
101
106
|
skipAnimation: skipAnimation,
|
|
102
107
|
onItemClick: onItemClick,
|
|
103
|
-
borderRadius: borderRadius
|
|
108
|
+
borderRadius: borderRadius,
|
|
109
|
+
barLabel: barLabel
|
|
104
110
|
}), /*#__PURE__*/_jsx(ChartsOverlay, {
|
|
105
111
|
loading: loading,
|
|
106
112
|
slots: slots,
|
|
@@ -127,7 +133,7 @@ const BarChart = /*#__PURE__*/React.forwardRef(function BarChart(props, ref) {
|
|
|
127
133
|
process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
|
|
128
134
|
// ----------------------------- Warning --------------------------------
|
|
129
135
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
130
|
-
// | To update them edit the TypeScript types and run "
|
|
136
|
+
// | To update them edit the TypeScript types and run "pnpm proptypes" |
|
|
131
137
|
// ----------------------------------------------------------------------
|
|
132
138
|
/**
|
|
133
139
|
* The configuration of axes highlight.
|
|
@@ -139,6 +145,14 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
|
|
|
139
145
|
x: PropTypes.oneOf(['band', 'line', 'none']),
|
|
140
146
|
y: PropTypes.oneOf(['band', 'line', 'none'])
|
|
141
147
|
}),
|
|
148
|
+
/**
|
|
149
|
+
* If provided, the function will be used to format the label of the bar.
|
|
150
|
+
* It can be set to 'value' to display the current value.
|
|
151
|
+
* @param {BarItem} item The item to format.
|
|
152
|
+
* @param {BarLabelContext} context data about the bar.
|
|
153
|
+
* @returns {string} The formatted label.
|
|
154
|
+
*/
|
|
155
|
+
barLabel: PropTypes.oneOfType([PropTypes.oneOf(['value']), PropTypes.func]),
|
|
142
156
|
/**
|
|
143
157
|
* Defines the border radius of the bar element.
|
|
144
158
|
*/
|
|
@@ -178,6 +192,13 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
|
|
|
178
192
|
* The height of the chart in px. If not defined, it takes the height of the parent element.
|
|
179
193
|
*/
|
|
180
194
|
height: PropTypes.number,
|
|
195
|
+
/**
|
|
196
|
+
* The item currently highlighted. Turns highlighting into a controlled prop.
|
|
197
|
+
*/
|
|
198
|
+
highlightedItem: PropTypes.shape({
|
|
199
|
+
dataIndex: PropTypes.number,
|
|
200
|
+
seriesId: PropTypes.oneOfType([PropTypes.number, PropTypes.string])
|
|
201
|
+
}),
|
|
181
202
|
/**
|
|
182
203
|
* The direction of the bar elements.
|
|
183
204
|
* @default 'vertical'
|
|
@@ -227,6 +248,12 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
|
|
|
227
248
|
* @param {null | AxisData} data The data about the clicked axis and items associated with it.
|
|
228
249
|
*/
|
|
229
250
|
onAxisClick: PropTypes.func,
|
|
251
|
+
/**
|
|
252
|
+
* The callback fired when the highlighted item changes.
|
|
253
|
+
*
|
|
254
|
+
* @param {HighlightItemData | null} highlightedItem The newly highlighted item.
|
|
255
|
+
*/
|
|
256
|
+
onHighlightChange: PropTypes.func,
|
|
230
257
|
/**
|
|
231
258
|
* Callback fired when a bar item is clicked.
|
|
232
259
|
* @param {React.MouseEvent<SVGElement, MouseEvent>} event The event source of the callback.
|