@mui/x-charts 7.4.0 → 7.5.1
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 +24 -13
- package/BarChart/BarElement.d.ts +10 -5
- package/BarChart/BarElement.js +4 -3
- 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 +138 -0
- package/BarChart/BarLabel/BarLabelPlot.d.ts +16 -0
- package/BarChart/BarLabel/BarLabelPlot.js +110 -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 +18 -4
- package/BarChart/index.d.ts +1 -0
- package/BarChart/index.js +11 -0
- package/BarChart/legend.js +13 -6
- package/CHANGELOG.md +132 -5395
- package/ChartContainer/ChartContainer.js +11 -11
- 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/ChartsOverlay/ChartsLoadingOverlay.js +3 -3
- package/ChartsOverlay/ChartsNoDataOverlay.js +2 -2
- package/ChartsOverlay/ChartsOverlay.d.ts +9 -0
- 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 +5 -3
- package/ChartsTooltip/DefaultChartsItemTooltipContent.js +8 -4
- package/ChartsTooltip/utils.js +13 -8
- package/ChartsVoronoiHandler/ChartsVoronoiHandler.js +1 -1
- package/ChartsXAxis/ChartsXAxis.js +2 -3
- package/ChartsYAxis/ChartsYAxis.js +3 -3
- 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 +1 -1
- package/LineChart/AreaElement.js +4 -4
- package/LineChart/AreaPlot.js +4 -3
- package/LineChart/LineChart.js +12 -11
- package/LineChart/LineElement.d.ts +1 -1
- package/LineChart/LineElement.js +4 -4
- package/LineChart/LineHighlightElement.d.ts +1 -1
- package/LineChart/LineHighlightElement.js +1 -1
- package/LineChart/LineHighlightPlot.js +1 -1
- package/LineChart/LinePlot.js +1 -1
- package/LineChart/MarkElement.d.ts +1 -1
- package/LineChart/MarkElement.js +1 -16
- package/LineChart/MarkPlot.js +1 -1
- package/LineChart/legend.js +13 -6
- package/PieChart/PieArc.d.ts +1 -1
- package/PieChart/PieArc.js +1 -1
- package/PieChart/PieArcLabel.d.ts +1 -1
- package/PieChart/PieArcLabel.js +4 -2
- package/PieChart/PieArcLabelPlot.js +15 -6
- package/PieChart/PieArcPlot.js +2 -2
- package/PieChart/PieChart.js +12 -11
- package/PieChart/PiePlot.js +1 -1
- package/PieChart/formatter.js +4 -1
- package/PieChart/legend.js +15 -5
- package/ResponsiveChartContainer/ResponsiveChartContainer.js +11 -11
- package/ScatterChart/Scatter.js +1 -1
- package/ScatterChart/ScatterChart.js +17 -16
- package/ScatterChart/ScatterPlot.js +1 -1
- package/ScatterChart/legend.js +13 -6
- package/SparkLineChart/SparkLineChart.d.ts +1 -1
- package/SparkLineChart/SparkLineChart.js +6 -6
- package/context/ZAxisContextProvider.js +6 -6
- package/esm/BarChart/BarChart.js +24 -13
- package/esm/BarChart/BarElement.js +4 -3
- package/esm/BarChart/BarLabel/BarLabel.js +51 -0
- package/esm/BarChart/BarLabel/BarLabel.types.js +1 -0
- package/esm/BarChart/BarLabel/BarLabelItem.js +130 -0
- package/esm/BarChart/BarLabel/BarLabelPlot.js +102 -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 +18 -4
- package/esm/BarChart/index.js +2 -1
- package/esm/BarChart/legend.js +13 -6
- package/esm/ChartContainer/ChartContainer.js +11 -11
- 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/ChartsOverlay/ChartsLoadingOverlay.js +3 -3
- package/esm/ChartsOverlay/ChartsNoDataOverlay.js +2 -2
- 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 +5 -3
- package/esm/ChartsTooltip/DefaultChartsItemTooltipContent.js +8 -4
- package/esm/ChartsTooltip/utils.js +13 -8
- package/esm/ChartsVoronoiHandler/ChartsVoronoiHandler.js +1 -1
- package/esm/ChartsXAxis/ChartsXAxis.js +2 -3
- package/esm/ChartsYAxis/ChartsYAxis.js +3 -3
- 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 +4 -4
- package/esm/LineChart/AreaPlot.js +4 -3
- package/esm/LineChart/LineChart.js +12 -11
- package/esm/LineChart/LineElement.js +4 -4
- package/esm/LineChart/LineHighlightElement.js +1 -1
- package/esm/LineChart/LineHighlightPlot.js +1 -1
- package/esm/LineChart/LinePlot.js +1 -1
- package/esm/LineChart/MarkElement.js +1 -16
- package/esm/LineChart/MarkPlot.js +1 -1
- package/esm/LineChart/legend.js +13 -6
- package/esm/PieChart/PieArc.js +1 -1
- package/esm/PieChart/PieArcLabel.js +4 -2
- package/esm/PieChart/PieArcLabelPlot.js +15 -6
- package/esm/PieChart/PieArcPlot.js +2 -2
- package/esm/PieChart/PieChart.js +12 -11
- package/esm/PieChart/PiePlot.js +1 -1
- package/esm/PieChart/formatter.js +4 -1
- package/esm/PieChart/legend.js +15 -5
- package/esm/ResponsiveChartContainer/ResponsiveChartContainer.js +11 -11
- package/esm/ScatterChart/Scatter.js +1 -1
- package/esm/ScatterChart/ScatterChart.js +17 -16
- package/esm/ScatterChart/ScatterPlot.js +1 -1
- package/esm/ScatterChart/legend.js +13 -6
- package/esm/SparkLineChart/SparkLineChart.js +6 -6
- package/esm/context/ZAxisContextProvider.js +6 -6
- package/esm/hooks/useAxisEvents.js +12 -7
- package/esm/internals/getLabel.js +3 -0
- package/hooks/useAxisEvents.js +12 -7
- package/index.js +1 -1
- package/internals/defaultizeColor.d.ts +7 -5
- package/internals/getLabel.d.ts +1 -0
- package/internals/getLabel.js +9 -0
- package/internals/utils.d.ts +1 -1
- package/models/seriesType/bar.d.ts +4 -1
- package/models/seriesType/line.d.ts +4 -1
- package/models/seriesType/pie.d.ts +9 -4
- package/models/seriesType/scatter.d.ts +4 -1
- package/modern/BarChart/BarChart.js +24 -13
- package/modern/BarChart/BarElement.js +4 -3
- package/modern/BarChart/BarLabel/BarLabel.js +51 -0
- package/modern/BarChart/BarLabel/BarLabel.types.js +1 -0
- package/modern/BarChart/BarLabel/BarLabelItem.js +130 -0
- package/modern/BarChart/BarLabel/BarLabelPlot.js +102 -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 +18 -4
- package/modern/BarChart/index.js +2 -1
- package/modern/BarChart/legend.js +13 -6
- package/modern/ChartContainer/ChartContainer.js +11 -11
- 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/ChartsOverlay/ChartsLoadingOverlay.js +3 -3
- package/modern/ChartsOverlay/ChartsNoDataOverlay.js +2 -2
- 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 +5 -3
- package/modern/ChartsTooltip/DefaultChartsItemTooltipContent.js +8 -4
- package/modern/ChartsTooltip/utils.js +13 -8
- package/modern/ChartsVoronoiHandler/ChartsVoronoiHandler.js +1 -1
- package/modern/ChartsXAxis/ChartsXAxis.js +2 -3
- package/modern/ChartsYAxis/ChartsYAxis.js +3 -3
- 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 +4 -4
- package/modern/LineChart/AreaPlot.js +4 -3
- package/modern/LineChart/LineChart.js +12 -11
- package/modern/LineChart/LineElement.js +4 -4
- package/modern/LineChart/LineHighlightElement.js +1 -1
- package/modern/LineChart/LineHighlightPlot.js +1 -1
- package/modern/LineChart/LinePlot.js +1 -1
- package/modern/LineChart/MarkElement.js +1 -16
- package/modern/LineChart/MarkPlot.js +1 -1
- package/modern/LineChart/legend.js +13 -6
- package/modern/PieChart/PieArc.js +1 -1
- package/modern/PieChart/PieArcLabel.js +4 -2
- package/modern/PieChart/PieArcLabelPlot.js +15 -6
- package/modern/PieChart/PieArcPlot.js +2 -2
- package/modern/PieChart/PieChart.js +12 -11
- package/modern/PieChart/PiePlot.js +1 -1
- package/modern/PieChart/formatter.js +4 -1
- package/modern/PieChart/legend.js +15 -5
- package/modern/ResponsiveChartContainer/ResponsiveChartContainer.js +11 -11
- package/modern/ScatterChart/Scatter.js +1 -1
- package/modern/ScatterChart/ScatterChart.js +17 -16
- package/modern/ScatterChart/ScatterPlot.js +1 -1
- package/modern/ScatterChart/legend.js +13 -6
- package/modern/SparkLineChart/SparkLineChart.js +6 -6
- package/modern/context/ZAxisContextProvider.js +6 -6
- package/modern/hooks/useAxisEvents.js +12 -7
- package/modern/index.js +1 -1
- package/modern/internals/getLabel.js +3 -0
- package/package.json +2 -2
- package/themeAugmentation/components.d.ts +4 -0
- package/themeAugmentation/overrides.d.ts +3 -0
- package/themeAugmentation/props.d.ts +2 -0
|
@@ -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.
|
|
@@ -235,6 +235,11 @@ process.env.NODE_ENV !== "production" ? SparkLineChart.propTypes = {
|
|
|
235
235
|
axisId: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]),
|
|
236
236
|
classes: _propTypes.default.object,
|
|
237
237
|
colorMap: _propTypes.default.oneOfType([_propTypes.default.shape({
|
|
238
|
+
colors: _propTypes.default.arrayOf(_propTypes.default.string).isRequired,
|
|
239
|
+
type: _propTypes.default.oneOf(['ordinal']).isRequired,
|
|
240
|
+
unknownColor: _propTypes.default.string,
|
|
241
|
+
values: _propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.instanceOf(Date), _propTypes.default.number, _propTypes.default.string]).isRequired)
|
|
242
|
+
}), _propTypes.default.shape({
|
|
238
243
|
color: _propTypes.default.oneOfType([_propTypes.default.arrayOf(_propTypes.default.string.isRequired), _propTypes.default.func]).isRequired,
|
|
239
244
|
max: _propTypes.default.oneOfType([_propTypes.default.instanceOf(Date), _propTypes.default.number]),
|
|
240
245
|
min: _propTypes.default.oneOfType([_propTypes.default.instanceOf(Date), _propTypes.default.number]),
|
|
@@ -243,11 +248,6 @@ process.env.NODE_ENV !== "production" ? SparkLineChart.propTypes = {
|
|
|
243
248
|
colors: _propTypes.default.arrayOf(_propTypes.default.string).isRequired,
|
|
244
249
|
thresholds: _propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.instanceOf(Date), _propTypes.default.number]).isRequired).isRequired,
|
|
245
250
|
type: _propTypes.default.oneOf(['piecewise']).isRequired
|
|
246
|
-
}), _propTypes.default.shape({
|
|
247
|
-
colors: _propTypes.default.arrayOf(_propTypes.default.string).isRequired,
|
|
248
|
-
type: _propTypes.default.oneOf(['ordinal']).isRequired,
|
|
249
|
-
unknownColor: _propTypes.default.string,
|
|
250
|
-
values: _propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.instanceOf(Date), _propTypes.default.number, _propTypes.default.string]).isRequired)
|
|
251
251
|
})]),
|
|
252
252
|
data: _propTypes.default.array,
|
|
253
253
|
dataKey: _propTypes.default.string,
|
|
@@ -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
|
/**
|
|
@@ -77,6 +77,11 @@ process.env.NODE_ENV !== "production" ? ZAxisContextProvider.propTypes = {
|
|
|
77
77
|
*/
|
|
78
78
|
zAxis: _propTypes.default.arrayOf(_propTypes.default.shape({
|
|
79
79
|
colorMap: _propTypes.default.oneOfType([_propTypes.default.shape({
|
|
80
|
+
colors: _propTypes.default.arrayOf(_propTypes.default.string).isRequired,
|
|
81
|
+
type: _propTypes.default.oneOf(['ordinal']).isRequired,
|
|
82
|
+
unknownColor: _propTypes.default.string,
|
|
83
|
+
values: _propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.instanceOf(Date), _propTypes.default.number, _propTypes.default.string]).isRequired)
|
|
84
|
+
}), _propTypes.default.shape({
|
|
80
85
|
color: _propTypes.default.oneOfType([_propTypes.default.arrayOf(_propTypes.default.string.isRequired), _propTypes.default.func]).isRequired,
|
|
81
86
|
max: _propTypes.default.oneOfType([_propTypes.default.instanceOf(Date), _propTypes.default.number]),
|
|
82
87
|
min: _propTypes.default.oneOfType([_propTypes.default.instanceOf(Date), _propTypes.default.number]),
|
|
@@ -85,11 +90,6 @@ process.env.NODE_ENV !== "production" ? ZAxisContextProvider.propTypes = {
|
|
|
85
90
|
colors: _propTypes.default.arrayOf(_propTypes.default.string).isRequired,
|
|
86
91
|
thresholds: _propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.instanceOf(Date), _propTypes.default.number]).isRequired).isRequired,
|
|
87
92
|
type: _propTypes.default.oneOf(['piecewise']).isRequired
|
|
88
|
-
}), _propTypes.default.shape({
|
|
89
|
-
colors: _propTypes.default.arrayOf(_propTypes.default.string).isRequired,
|
|
90
|
-
type: _propTypes.default.oneOf(['ordinal']).isRequired,
|
|
91
|
-
unknownColor: _propTypes.default.string,
|
|
92
|
-
values: _propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.instanceOf(Date), _propTypes.default.number, _propTypes.default.string]).isRequired)
|
|
93
93
|
})]),
|
|
94
94
|
data: _propTypes.default.array,
|
|
95
95
|
dataKey: _propTypes.default.string,
|
package/esm/BarChart/BarChart.js
CHANGED
|
@@ -52,7 +52,8 @@ const BarChart = /*#__PURE__*/React.forwardRef(function BarChart(props, ref) {
|
|
|
52
52
|
children,
|
|
53
53
|
slots,
|
|
54
54
|
slotProps,
|
|
55
|
-
loading
|
|
55
|
+
loading,
|
|
56
|
+
barLabel
|
|
56
57
|
} = props;
|
|
57
58
|
const id = useId();
|
|
58
59
|
const clipPathId = `${id}-clip-path`;
|
|
@@ -100,7 +101,8 @@ const BarChart = /*#__PURE__*/React.forwardRef(function BarChart(props, ref) {
|
|
|
100
101
|
slotProps: slotProps,
|
|
101
102
|
skipAnimation: skipAnimation,
|
|
102
103
|
onItemClick: onItemClick,
|
|
103
|
-
borderRadius: borderRadius
|
|
104
|
+
borderRadius: borderRadius,
|
|
105
|
+
barLabel: barLabel
|
|
104
106
|
}), /*#__PURE__*/_jsx(ChartsOverlay, {
|
|
105
107
|
loading: loading,
|
|
106
108
|
slots: slots,
|
|
@@ -127,7 +129,7 @@ const BarChart = /*#__PURE__*/React.forwardRef(function BarChart(props, ref) {
|
|
|
127
129
|
process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
|
|
128
130
|
// ----------------------------- Warning --------------------------------
|
|
129
131
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
130
|
-
// | To update them edit the TypeScript types and run "
|
|
132
|
+
// | To update them edit the TypeScript types and run "pnpm proptypes" |
|
|
131
133
|
// ----------------------------------------------------------------------
|
|
132
134
|
/**
|
|
133
135
|
* The configuration of axes highlight.
|
|
@@ -139,6 +141,14 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
|
|
|
139
141
|
x: PropTypes.oneOf(['band', 'line', 'none']),
|
|
140
142
|
y: PropTypes.oneOf(['band', 'line', 'none'])
|
|
141
143
|
}),
|
|
144
|
+
/**
|
|
145
|
+
* If provided, the function will be used to format the label of the bar.
|
|
146
|
+
* It can be set to 'value' to display the current value.
|
|
147
|
+
* @param {BarItem} item The item to format.
|
|
148
|
+
* @param {BarLabelContext} context data about the bar.
|
|
149
|
+
* @returns {string} The formatted label.
|
|
150
|
+
*/
|
|
151
|
+
barLabel: PropTypes.oneOfType([PropTypes.oneOf(['value']), PropTypes.func]),
|
|
142
152
|
/**
|
|
143
153
|
* Defines the border radius of the bar element.
|
|
144
154
|
*/
|
|
@@ -205,6 +215,7 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
|
|
|
205
215
|
}),
|
|
206
216
|
/**
|
|
207
217
|
* If `true`, a loading overlay is displayed.
|
|
218
|
+
* @default false
|
|
208
219
|
*/
|
|
209
220
|
loading: PropTypes.bool,
|
|
210
221
|
/**
|
|
@@ -297,6 +308,11 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
|
|
|
297
308
|
axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
298
309
|
classes: PropTypes.object,
|
|
299
310
|
colorMap: PropTypes.oneOfType([PropTypes.shape({
|
|
311
|
+
colors: PropTypes.arrayOf(PropTypes.string).isRequired,
|
|
312
|
+
type: PropTypes.oneOf(['ordinal']).isRequired,
|
|
313
|
+
unknownColor: PropTypes.string,
|
|
314
|
+
values: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number, PropTypes.string]).isRequired)
|
|
315
|
+
}), PropTypes.shape({
|
|
300
316
|
color: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.string.isRequired), PropTypes.func]).isRequired,
|
|
301
317
|
max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
302
318
|
min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
@@ -305,11 +321,6 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
|
|
|
305
321
|
colors: PropTypes.arrayOf(PropTypes.string).isRequired,
|
|
306
322
|
thresholds: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]).isRequired).isRequired,
|
|
307
323
|
type: PropTypes.oneOf(['piecewise']).isRequired
|
|
308
|
-
}), PropTypes.shape({
|
|
309
|
-
colors: PropTypes.arrayOf(PropTypes.string).isRequired,
|
|
310
|
-
type: PropTypes.oneOf(['ordinal']).isRequired,
|
|
311
|
-
unknownColor: PropTypes.string,
|
|
312
|
-
values: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number, PropTypes.string]).isRequired)
|
|
313
324
|
})]),
|
|
314
325
|
data: PropTypes.array,
|
|
315
326
|
dataKey: PropTypes.string,
|
|
@@ -350,6 +361,11 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
|
|
|
350
361
|
axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
351
362
|
classes: PropTypes.object,
|
|
352
363
|
colorMap: PropTypes.oneOfType([PropTypes.shape({
|
|
364
|
+
colors: PropTypes.arrayOf(PropTypes.string).isRequired,
|
|
365
|
+
type: PropTypes.oneOf(['ordinal']).isRequired,
|
|
366
|
+
unknownColor: PropTypes.string,
|
|
367
|
+
values: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number, PropTypes.string]).isRequired)
|
|
368
|
+
}), PropTypes.shape({
|
|
353
369
|
color: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.string.isRequired), PropTypes.func]).isRequired,
|
|
354
370
|
max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
355
371
|
min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
@@ -358,11 +374,6 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
|
|
|
358
374
|
colors: PropTypes.arrayOf(PropTypes.string).isRequired,
|
|
359
375
|
thresholds: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]).isRequired).isRequired,
|
|
360
376
|
type: PropTypes.oneOf(['piecewise']).isRequired
|
|
361
|
-
}), PropTypes.shape({
|
|
362
|
-
colors: PropTypes.arrayOf(PropTypes.string).isRequired,
|
|
363
|
-
type: PropTypes.oneOf(['ordinal']).isRequired,
|
|
364
|
-
unknownColor: PropTypes.string,
|
|
365
|
-
values: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number, PropTypes.string]).isRequired)
|
|
366
377
|
})]),
|
|
367
378
|
data: PropTypes.array,
|
|
368
379
|
dataKey: PropTypes.string,
|
|
@@ -79,16 +79,17 @@ function BarElement(props) {
|
|
|
79
79
|
const barProps = useSlotProps({
|
|
80
80
|
elementType: Bar,
|
|
81
81
|
externalSlotProps: slotProps?.bar,
|
|
82
|
-
|
|
82
|
+
externalForwardedProps: other,
|
|
83
|
+
additionalProps: _extends({}, getInteractionItemProps({
|
|
83
84
|
type: 'bar',
|
|
84
85
|
seriesId: id,
|
|
85
86
|
dataIndex
|
|
86
87
|
}), {
|
|
87
88
|
style,
|
|
88
|
-
className: classes.root,
|
|
89
89
|
onClick,
|
|
90
90
|
cursor: onClick ? 'pointer' : 'unset'
|
|
91
91
|
}),
|
|
92
|
+
className: classes.root,
|
|
92
93
|
ownerState
|
|
93
94
|
});
|
|
94
95
|
return /*#__PURE__*/_jsx(Bar, _extends({}, barProps));
|
|
@@ -96,7 +97,7 @@ function BarElement(props) {
|
|
|
96
97
|
process.env.NODE_ENV !== "production" ? BarElement.propTypes = {
|
|
97
98
|
// ----------------------------- Warning --------------------------------
|
|
98
99
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
99
|
-
// | To update them edit the TypeScript types and run "
|
|
100
|
+
// | To update them edit the TypeScript types and run "pnpm proptypes" |
|
|
100
101
|
// ----------------------------------------------------------------------
|
|
101
102
|
classes: PropTypes.object,
|
|
102
103
|
dataIndex: PropTypes.number.isRequired,
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
2
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
3
|
+
const _excluded = ["seriesId", "dataIndex", "color", "isFaded", "isHighlighted", "classes"];
|
|
4
|
+
import * as React from 'react';
|
|
5
|
+
import { styled, useThemeProps } from '@mui/material/styles';
|
|
6
|
+
import { animated } from '@react-spring/web';
|
|
7
|
+
import PropTypes from 'prop-types';
|
|
8
|
+
import { barLabelClasses } from './barLabelClasses';
|
|
9
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
10
|
+
export const BarLabelComponent = styled(animated.text, {
|
|
11
|
+
name: 'MuiBarLabel',
|
|
12
|
+
slot: 'Root',
|
|
13
|
+
overridesResolver: (_, styles) => [{
|
|
14
|
+
[`&.${barLabelClasses.faded}`]: styles.faded
|
|
15
|
+
}, {
|
|
16
|
+
[`&.${barLabelClasses.highlighted}`]: styles.highlighted
|
|
17
|
+
}, styles.root]
|
|
18
|
+
})(({
|
|
19
|
+
theme
|
|
20
|
+
}) => _extends({}, theme?.typography?.body2, {
|
|
21
|
+
stroke: 'none',
|
|
22
|
+
fill: (theme.vars || theme)?.palette?.text?.primary,
|
|
23
|
+
transition: 'opacity 0.2s ease-in, fill 0.2s ease-in',
|
|
24
|
+
textAnchor: 'middle',
|
|
25
|
+
dominantBaseline: 'central',
|
|
26
|
+
pointerEvents: 'none',
|
|
27
|
+
opacity: 1,
|
|
28
|
+
[`&.${barLabelClasses.faded}`]: {
|
|
29
|
+
opacity: 0.3
|
|
30
|
+
}
|
|
31
|
+
}));
|
|
32
|
+
function BarLabel(props) {
|
|
33
|
+
const themeProps = useThemeProps({
|
|
34
|
+
props,
|
|
35
|
+
name: 'MuiBarLabel'
|
|
36
|
+
});
|
|
37
|
+
const otherProps = _objectWithoutPropertiesLoose(themeProps, _excluded);
|
|
38
|
+
return /*#__PURE__*/_jsx(BarLabelComponent, _extends({}, otherProps));
|
|
39
|
+
}
|
|
40
|
+
process.env.NODE_ENV !== "production" ? BarLabel.propTypes = {
|
|
41
|
+
// ----------------------------- Warning --------------------------------
|
|
42
|
+
// | These PropTypes are generated from the TypeScript type definitions |
|
|
43
|
+
// | To update them edit the TypeScript types and run "pnpm proptypes" |
|
|
44
|
+
// ----------------------------------------------------------------------
|
|
45
|
+
classes: PropTypes.object,
|
|
46
|
+
dataIndex: PropTypes.number.isRequired,
|
|
47
|
+
isFaded: PropTypes.bool.isRequired,
|
|
48
|
+
isHighlighted: PropTypes.bool.isRequired,
|
|
49
|
+
seriesId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired
|
|
50
|
+
} : void 0;
|
|
51
|
+
export { BarLabel };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
|
+
const _excluded = ["seriesId", "classes", "color", "style", "dataIndex", "barLabel", "slots", "slotProps", "height", "width", "value"],
|
|
4
|
+
_excluded2 = ["ownerState"];
|
|
5
|
+
import * as React from 'react';
|
|
6
|
+
import { useSlotProps } from '@mui/base/utils';
|
|
7
|
+
import PropTypes from 'prop-types';
|
|
8
|
+
import { InteractionContext } from '../../context/InteractionProvider';
|
|
9
|
+
import { getIsFaded, getIsHighlighted } from '../../hooks/useInteractionItemProps';
|
|
10
|
+
import { useUtilityClasses } from './barLabelClasses';
|
|
11
|
+
import { HighlighContext } from '../../context/HighlightProvider';
|
|
12
|
+
import { getBarLabel } from './getBarLabel';
|
|
13
|
+
import { BarLabel } from './BarLabel';
|
|
14
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
15
|
+
/**
|
|
16
|
+
* @ignore - internal component.
|
|
17
|
+
*/
|
|
18
|
+
function BarLabelItem(props) {
|
|
19
|
+
const {
|
|
20
|
+
seriesId,
|
|
21
|
+
classes: innerClasses,
|
|
22
|
+
color,
|
|
23
|
+
style,
|
|
24
|
+
dataIndex,
|
|
25
|
+
barLabel,
|
|
26
|
+
slots,
|
|
27
|
+
slotProps,
|
|
28
|
+
height,
|
|
29
|
+
width,
|
|
30
|
+
value
|
|
31
|
+
} = props,
|
|
32
|
+
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
33
|
+
const {
|
|
34
|
+
item
|
|
35
|
+
} = React.useContext(InteractionContext);
|
|
36
|
+
const {
|
|
37
|
+
scope
|
|
38
|
+
} = React.useContext(HighlighContext);
|
|
39
|
+
const isHighlighted = getIsHighlighted(item, {
|
|
40
|
+
type: 'bar',
|
|
41
|
+
seriesId,
|
|
42
|
+
dataIndex
|
|
43
|
+
}, scope);
|
|
44
|
+
const isFaded = !isHighlighted && getIsFaded(item, {
|
|
45
|
+
type: 'bar',
|
|
46
|
+
seriesId,
|
|
47
|
+
dataIndex
|
|
48
|
+
}, scope);
|
|
49
|
+
const ownerState = {
|
|
50
|
+
seriesId,
|
|
51
|
+
classes: innerClasses,
|
|
52
|
+
color,
|
|
53
|
+
isFaded,
|
|
54
|
+
isHighlighted,
|
|
55
|
+
dataIndex
|
|
56
|
+
};
|
|
57
|
+
const classes = useUtilityClasses(ownerState);
|
|
58
|
+
const Component = slots?.barLabel ?? BarLabel;
|
|
59
|
+
const _useSlotProps = useSlotProps({
|
|
60
|
+
elementType: Component,
|
|
61
|
+
externalSlotProps: slotProps?.barLabel,
|
|
62
|
+
additionalProps: _extends({}, other, {
|
|
63
|
+
style,
|
|
64
|
+
className: classes.root
|
|
65
|
+
}),
|
|
66
|
+
ownerState
|
|
67
|
+
}),
|
|
68
|
+
{
|
|
69
|
+
ownerState: barLabelOwnerState
|
|
70
|
+
} = _useSlotProps,
|
|
71
|
+
barLabelProps = _objectWithoutPropertiesLoose(_useSlotProps, _excluded2);
|
|
72
|
+
if (!barLabel) {
|
|
73
|
+
return null;
|
|
74
|
+
}
|
|
75
|
+
const formattedLabelText = getBarLabel({
|
|
76
|
+
barLabel,
|
|
77
|
+
value,
|
|
78
|
+
dataIndex,
|
|
79
|
+
seriesId,
|
|
80
|
+
height,
|
|
81
|
+
width
|
|
82
|
+
});
|
|
83
|
+
if (!formattedLabelText) {
|
|
84
|
+
return null;
|
|
85
|
+
}
|
|
86
|
+
return /*#__PURE__*/_jsx(Component, _extends({}, barLabelProps, barLabelOwnerState, {
|
|
87
|
+
children: formattedLabelText
|
|
88
|
+
}));
|
|
89
|
+
}
|
|
90
|
+
process.env.NODE_ENV !== "production" ? BarLabelItem.propTypes = {
|
|
91
|
+
// ----------------------------- Warning --------------------------------
|
|
92
|
+
// | These PropTypes are generated from the TypeScript type definitions |
|
|
93
|
+
// | To update them edit the TypeScript types and run "pnpm proptypes" |
|
|
94
|
+
// ----------------------------------------------------------------------
|
|
95
|
+
/**
|
|
96
|
+
* If provided, the function will be used to format the label of the bar.
|
|
97
|
+
* It can be set to 'value' to display the current value.
|
|
98
|
+
* @param {BarItem} item The item to format.
|
|
99
|
+
* @param {BarLabelContext} context data about the bar.
|
|
100
|
+
* @returns {string} The formatted label.
|
|
101
|
+
*/
|
|
102
|
+
barLabel: PropTypes.oneOfType([PropTypes.oneOf(['value']), PropTypes.func]),
|
|
103
|
+
classes: PropTypes.object,
|
|
104
|
+
color: PropTypes.string.isRequired,
|
|
105
|
+
dataIndex: PropTypes.number.isRequired,
|
|
106
|
+
/**
|
|
107
|
+
* The height of the bar.
|
|
108
|
+
*/
|
|
109
|
+
height: PropTypes.number.isRequired,
|
|
110
|
+
seriesId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired,
|
|
111
|
+
/**
|
|
112
|
+
* The props used for each component slot.
|
|
113
|
+
* @default {}
|
|
114
|
+
*/
|
|
115
|
+
slotProps: PropTypes.object,
|
|
116
|
+
/**
|
|
117
|
+
* Overridable component slots.
|
|
118
|
+
* @default {}
|
|
119
|
+
*/
|
|
120
|
+
slots: PropTypes.object,
|
|
121
|
+
/**
|
|
122
|
+
* The value of the data point.
|
|
123
|
+
*/
|
|
124
|
+
value: PropTypes.number,
|
|
125
|
+
/**
|
|
126
|
+
* The width of the bar.
|
|
127
|
+
*/
|
|
128
|
+
width: PropTypes.number.isRequired
|
|
129
|
+
} : void 0;
|
|
130
|
+
export { BarLabelItem };
|
|
@@ -0,0 +1,102 @@
|
|
|
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
|
+
highlightScope: PropTypes.shape({
|
|
87
|
+
faded: PropTypes.oneOf(['global', 'none', 'series']),
|
|
88
|
+
highlighted: PropTypes.oneOf(['item', 'none', 'series'])
|
|
89
|
+
}),
|
|
90
|
+
layout: PropTypes.oneOf(['horizontal', 'vertical']),
|
|
91
|
+
maskId: PropTypes.string.isRequired,
|
|
92
|
+
seriesId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired,
|
|
93
|
+
value: PropTypes.number,
|
|
94
|
+
width: PropTypes.number.isRequired,
|
|
95
|
+
x: PropTypes.number.isRequired,
|
|
96
|
+
xOrigin: PropTypes.number.isRequired,
|
|
97
|
+
y: PropTypes.number.isRequired,
|
|
98
|
+
yOrigin: PropTypes.number.isRequired
|
|
99
|
+
})).isRequired,
|
|
100
|
+
skipAnimation: PropTypes.bool
|
|
101
|
+
} : void 0;
|
|
102
|
+
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
|
+
};
|
package/esm/BarChart/BarPlot.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
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';
|
|
@@ -12,6 +12,7 @@ import { DEFAULT_X_AXIS_KEY, DEFAULT_Y_AXIS_KEY } from '../constants';
|
|
|
12
12
|
import getColor from './getColor';
|
|
13
13
|
import { useChartId } from '../hooks';
|
|
14
14
|
import { BarClipPath } from './BarClipPath';
|
|
15
|
+
import { BarLabelPlot } from './BarLabel/BarLabelPlot';
|
|
15
16
|
|
|
16
17
|
/**
|
|
17
18
|
* Solution of the equations
|
|
@@ -211,7 +212,8 @@ function BarPlot(props) {
|
|
|
211
212
|
const {
|
|
212
213
|
skipAnimation,
|
|
213
214
|
onItemClick,
|
|
214
|
-
borderRadius
|
|
215
|
+
borderRadius,
|
|
216
|
+
barLabel
|
|
215
217
|
} = props,
|
|
216
218
|
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
217
219
|
const transition = useTransition(completedData, {
|
|
@@ -274,14 +276,26 @@ function BarPlot(props) {
|
|
|
274
276
|
clipPath: `url(#${maskId})`,
|
|
275
277
|
children: barElement
|
|
276
278
|
});
|
|
277
|
-
})
|
|
279
|
+
}), barLabel && /*#__PURE__*/_jsx(BarLabelPlot, _extends({
|
|
280
|
+
bars: completedData,
|
|
281
|
+
skipAnimation: skipAnimation,
|
|
282
|
+
barLabel: barLabel
|
|
283
|
+
}, other))]
|
|
278
284
|
});
|
|
279
285
|
}
|
|
280
286
|
process.env.NODE_ENV !== "production" ? BarPlot.propTypes = {
|
|
281
287
|
// ----------------------------- Warning --------------------------------
|
|
282
288
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
283
|
-
// | To update them edit the TypeScript types and run "
|
|
289
|
+
// | To update them edit the TypeScript types and run "pnpm proptypes" |
|
|
284
290
|
// ----------------------------------------------------------------------
|
|
291
|
+
/**
|
|
292
|
+
* If provided, the function will be used to format the label of the bar.
|
|
293
|
+
* It can be set to 'value' to display the current value.
|
|
294
|
+
* @param {BarItem} item The item to format.
|
|
295
|
+
* @param {BarLabelContext} context data about the bar.
|
|
296
|
+
* @returns {string} The formatted label.
|
|
297
|
+
*/
|
|
298
|
+
barLabel: PropTypes.oneOfType([PropTypes.oneOf(['value']), PropTypes.func]),
|
|
285
299
|
/**
|
|
286
300
|
* Defines the border radius of the bar element.
|
|
287
301
|
*/
|
package/esm/BarChart/index.js
CHANGED
package/esm/BarChart/legend.js
CHANGED
|
@@ -1,13 +1,20 @@
|
|
|
1
|
+
import { getLabel } from '../internals/getLabel';
|
|
1
2
|
const legendGetter = params => {
|
|
2
3
|
const {
|
|
3
4
|
seriesOrder,
|
|
4
5
|
series
|
|
5
6
|
} = params;
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
7
|
+
return seriesOrder.reduce((acc, seriesId) => {
|
|
8
|
+
const formattedLabel = getLabel(series[seriesId].label, 'legend');
|
|
9
|
+
if (formattedLabel === undefined) {
|
|
10
|
+
return acc;
|
|
11
|
+
}
|
|
12
|
+
acc.push({
|
|
13
|
+
color: series[seriesId].color,
|
|
14
|
+
label: formattedLabel,
|
|
15
|
+
id: seriesId
|
|
16
|
+
});
|
|
17
|
+
return acc;
|
|
18
|
+
}, []);
|
|
12
19
|
};
|
|
13
20
|
export default legendGetter;
|