@mui/x-charts 8.8.0 → 8.9.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/BarChart/BarChart.d.ts +3 -2
- package/BarChart/BarChart.js +95 -2
- package/BarChart/BarClipPath.d.ts +17 -12
- package/BarChart/BarClipPath.js +70 -57
- package/BarChart/BarPlot.js +4 -0
- package/BarChart/barClasses.d.ts +1 -1
- package/BarChart/seriesConfig/extremums.js +2 -3
- package/BarChart/seriesConfig/seriesProcessor.js +5 -3
- package/BarChart/useBarChartProps.d.ts +1 -1
- package/BarChart/useBarPlotData.js +32 -5
- package/CHANGELOG.md +225 -24
- package/ChartContainer/ChartContainer.js +141 -0
- package/ChartsLabel/ChartsLabelMark.d.ts +2 -1
- package/ChartsLabel/index.d.ts +1 -0
- package/ChartsLabel/index.js +18 -0
- package/ChartsLegend/chartsLegendClasses.d.ts +1 -1
- package/ChartsLegend/piecewiseColorLegendClasses.d.ts +1 -1
- package/{internals/components/ChartsWrapper → ChartsWrapper}/ChartsWrapper.d.ts +13 -4
- package/{internals/components/ChartsWrapper → ChartsWrapper}/ChartsWrapper.js +33 -7
- package/LineChart/LineChart.d.ts +3 -2
- package/LineChart/LineChart.js +95 -2
- package/LineChart/seriesConfig/extremums.js +2 -3
- package/LineChart/useLineChartProps.d.ts +1 -1
- package/PieChart/PieArcLabelPlot.js +3 -0
- package/PieChart/PieArcPlot.js +3 -0
- package/PieChart/PieChart.d.ts +3 -2
- package/PieChart/PieChart.js +2 -2
- package/PieChart/pieClasses.d.ts +1 -1
- package/RadarChart/RadarAxisHighlight/RadarAxisHighlight.js +3 -5
- package/RadarChart/RadarAxisHighlight/useRadarAxisHighlight.d.ts +2 -13
- package/RadarChart/RadarAxisHighlight/useRadarAxisHighlight.js +8 -45
- package/RadarChart/RadarChart.d.ts +3 -2
- package/RadarChart/RadarChart.js +24 -3
- package/RadarChart/RadarDataProvider/RadarDataProvider.d.ts +3 -2
- package/RadarChart/RadarMetricLabels/useRadarMetricData.js +4 -2
- package/RadarChart/RadarSeriesPlot/RadarSeriesArea.js +19 -3
- package/RadarChart/RadarSeriesPlot/RadarSeriesMarks.js +20 -4
- package/RadarChart/RadarSeriesPlot/RadarSeriesPlot.js +38 -4
- package/RadarChart/RadarSeriesPlot/RadarSeriesPlot.types.d.ts +32 -3
- package/RadarChart/RadarSeriesPlot/useRadarRotationIndex.d.ts +8 -0
- package/RadarChart/RadarSeriesPlot/useRadarRotationIndex.js +38 -0
- package/RadarChart/RadarSeriesPlot/useRadarSeriesData.d.ts +2 -2
- package/RadarChart/index.d.ts +1 -1
- package/RadarChart/useRadarChartProps.d.ts +4 -1
- package/RadarChart/useRadarChartProps.js +15 -3
- package/ScatterChart/ScatterChart.d.ts +3 -2
- package/ScatterChart/ScatterChart.js +95 -2
- package/ScatterChart/seriesConfig/extremums.js +50 -23
- package/ScatterChart/useScatterChartProps.d.ts +1 -1
- package/SparkLineChart/SparkLineChart.js +93 -0
- package/esm/BarChart/BarChart.d.ts +3 -2
- package/esm/BarChart/BarChart.js +95 -2
- package/esm/BarChart/BarClipPath.d.ts +17 -12
- package/esm/BarChart/BarClipPath.js +69 -55
- package/esm/BarChart/BarPlot.js +4 -0
- package/esm/BarChart/barClasses.d.ts +1 -1
- package/esm/BarChart/seriesConfig/extremums.js +2 -3
- package/esm/BarChart/seriesConfig/seriesProcessor.js +5 -3
- package/esm/BarChart/useBarChartProps.d.ts +1 -1
- package/esm/BarChart/useBarPlotData.js +32 -5
- package/esm/ChartContainer/ChartContainer.js +141 -0
- package/esm/ChartsLabel/ChartsLabelMark.d.ts +2 -1
- package/esm/ChartsLabel/index.d.ts +1 -0
- package/esm/ChartsLabel/index.js +1 -0
- package/esm/ChartsLegend/chartsLegendClasses.d.ts +1 -1
- package/esm/ChartsLegend/piecewiseColorLegendClasses.d.ts +1 -1
- package/esm/{internals/components/ChartsWrapper → ChartsWrapper}/ChartsWrapper.d.ts +13 -4
- package/esm/{internals/components/ChartsWrapper → ChartsWrapper}/ChartsWrapper.js +31 -6
- package/esm/LineChart/LineChart.d.ts +3 -2
- package/esm/LineChart/LineChart.js +95 -2
- package/esm/LineChart/seriesConfig/extremums.js +2 -3
- package/esm/LineChart/useLineChartProps.d.ts +1 -1
- package/esm/PieChart/PieArcLabelPlot.js +3 -0
- package/esm/PieChart/PieArcPlot.js +3 -0
- package/esm/PieChart/PieChart.d.ts +3 -2
- package/esm/PieChart/PieChart.js +2 -2
- package/esm/PieChart/pieClasses.d.ts +1 -1
- package/esm/RadarChart/RadarAxisHighlight/RadarAxisHighlight.js +3 -5
- package/esm/RadarChart/RadarAxisHighlight/useRadarAxisHighlight.d.ts +2 -13
- package/esm/RadarChart/RadarAxisHighlight/useRadarAxisHighlight.js +8 -45
- package/esm/RadarChart/RadarChart.d.ts +3 -2
- package/esm/RadarChart/RadarChart.js +24 -3
- package/esm/RadarChart/RadarDataProvider/RadarDataProvider.d.ts +3 -2
- package/esm/RadarChart/RadarMetricLabels/useRadarMetricData.js +4 -2
- package/esm/RadarChart/RadarSeriesPlot/RadarSeriesArea.js +19 -3
- package/esm/RadarChart/RadarSeriesPlot/RadarSeriesMarks.js +20 -4
- package/esm/RadarChart/RadarSeriesPlot/RadarSeriesPlot.js +38 -4
- package/esm/RadarChart/RadarSeriesPlot/RadarSeriesPlot.types.d.ts +32 -3
- package/esm/RadarChart/RadarSeriesPlot/useRadarRotationIndex.d.ts +8 -0
- package/esm/RadarChart/RadarSeriesPlot/useRadarRotationIndex.js +32 -0
- package/esm/RadarChart/RadarSeriesPlot/useRadarSeriesData.d.ts +2 -2
- package/esm/RadarChart/index.d.ts +1 -1
- package/esm/RadarChart/useRadarChartProps.d.ts +4 -1
- package/esm/RadarChart/useRadarChartProps.js +15 -3
- package/esm/ScatterChart/ScatterChart.d.ts +3 -2
- package/esm/ScatterChart/ScatterChart.js +95 -2
- package/esm/ScatterChart/seriesConfig/extremums.js +50 -23
- package/esm/ScatterChart/useScatterChartProps.d.ts +1 -1
- package/esm/SparkLineChart/SparkLineChart.js +93 -0
- package/esm/hooks/useTicks.d.ts +6 -1
- package/esm/hooks/useTicks.js +94 -58
- package/esm/index.d.ts +2 -1
- package/esm/index.js +6 -2
- package/esm/internals/findMinMax.d.ts +1 -0
- package/esm/internals/findMinMax.js +13 -0
- package/esm/internals/getScale.js +3 -0
- package/esm/internals/index.d.ts +1 -1
- package/esm/internals/index.js +1 -1
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/computeAxisValue.js +4 -1
- package/esm/internals/plugins/featurePlugins/useChartHighlight/createIsFaded.d.ts +1 -1
- package/esm/internals/plugins/featurePlugins/useChartHighlight/createIsFaded.js +19 -11
- package/esm/internals/plugins/featurePlugins/useChartHighlight/createIsHighlighted.d.ts +1 -1
- package/esm/internals/plugins/featurePlugins/useChartHighlight/createIsHighlighted.js +19 -11
- package/esm/internals/plugins/featurePlugins/useChartHighlight/useChartHighlight.selectors.js +10 -4
- package/esm/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.js +4 -4
- package/esm/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarAxis.js +44 -1
- package/esm/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarAxis.types.d.ts +8 -1
- package/esm/internals/plugins/featurePlugins/useChartVoronoi/useChartVoronoi.js +17 -12
- package/esm/internals/symlogScale.d.ts +2 -0
- package/esm/internals/symlogScale.js +94 -0
- package/esm/models/axis.d.ts +47 -5
- package/esm/models/axis.js +3 -0
- package/esm/models/seriesType/bar.d.ts +11 -1
- package/esm/models/seriesType/common.d.ts +9 -3
- package/esm/models/seriesType/line.d.ts +3 -1
- package/esm/models/seriesType/scatter.d.ts +4 -1
- package/esm/tests/web-components.js +49 -0
- package/hooks/useTicks.d.ts +6 -1
- package/hooks/useTicks.js +95 -58
- package/index.d.ts +2 -1
- package/index.js +13 -1
- package/internals/findMinMax.d.ts +1 -0
- package/internals/findMinMax.js +19 -0
- package/internals/getScale.js +3 -0
- package/internals/index.d.ts +1 -1
- package/internals/index.js +12 -12
- package/internals/plugins/featurePlugins/useChartCartesianAxis/computeAxisValue.js +3 -0
- package/internals/plugins/featurePlugins/useChartHighlight/createIsFaded.d.ts +1 -1
- package/internals/plugins/featurePlugins/useChartHighlight/createIsFaded.js +20 -13
- package/internals/plugins/featurePlugins/useChartHighlight/createIsHighlighted.d.ts +1 -1
- package/internals/plugins/featurePlugins/useChartHighlight/createIsHighlighted.js +20 -13
- package/internals/plugins/featurePlugins/useChartHighlight/useChartHighlight.selectors.js +10 -4
- package/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.js +4 -4
- package/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarAxis.js +44 -1
- package/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarAxis.types.d.ts +8 -1
- package/internals/plugins/featurePlugins/useChartVoronoi/useChartVoronoi.js +17 -12
- package/internals/symlogScale.d.ts +2 -0
- package/internals/symlogScale.js +100 -0
- package/models/axis.d.ts +47 -5
- package/models/axis.js +4 -0
- package/models/seriesType/bar.d.ts +11 -1
- package/models/seriesType/common.d.ts +9 -3
- package/models/seriesType/line.d.ts +3 -1
- package/models/seriesType/scatter.d.ts +4 -1
- package/package.json +6 -7
- package/tests/web-components.js +55 -0
- package/BarChart/getRadius.d.ts +0 -20
- package/BarChart/getRadius.js +0 -37
- package/esm/BarChart/getRadius.d.ts +0 -20
- package/esm/BarChart/getRadius.js +0 -30
- /package/{esm/internals/components/ChartsWrapper → ChartsWrapper}/index.d.ts +0 -0
- /package/{internals/components/ChartsWrapper → ChartsWrapper}/index.js +0 -0
- /package/{internals/components → esm}/ChartsWrapper/index.d.ts +0 -0
- /package/esm/{internals/components/ChartsWrapper → ChartsWrapper}/index.js +0 -0
package/BarChart/BarChart.d.ts
CHANGED
|
@@ -15,12 +15,13 @@ import { ChartsOverlayProps, ChartsOverlaySlotProps, ChartsOverlaySlots } from "
|
|
|
15
15
|
import { BarChartPluginsSignatures } from "./BarChart.plugins.js";
|
|
16
16
|
export interface BarChartSlots extends ChartsAxisSlots, BarPlotSlots, ChartsLegendSlots, ChartsOverlaySlots, ChartsTooltipSlots, ChartsToolbarSlots, Partial<ChartsSlots> {}
|
|
17
17
|
export interface BarChartSlotProps extends ChartsAxisSlotProps, BarPlotSlotProps, ChartsLegendSlotProps, ChartsOverlaySlotProps, ChartsTooltipSlotProps, ChartsToolbarSlotProps, Partial<ChartsSlotProps> {}
|
|
18
|
+
export type BarSeries = MakeOptional<BarSeriesType, 'type'>;
|
|
18
19
|
export interface BarChartProps extends Omit<ChartContainerProps<'bar', BarChartPluginsSignatures>, 'series' | 'plugins' | 'zAxis' | 'experimentalFeatures'>, Omit<ChartsAxisProps, 'slots' | 'slotProps'>, Omit<BarPlotProps, 'slots' | 'slotProps'>, Omit<ChartsOverlayProps, 'slots' | 'slotProps'> {
|
|
19
20
|
/**
|
|
20
21
|
* The series to display in the bar chart.
|
|
21
|
-
* An array of [[
|
|
22
|
+
* An array of [[BarSeries]] objects.
|
|
22
23
|
*/
|
|
23
|
-
series: Readonly<
|
|
24
|
+
series: Readonly<BarSeries[]>;
|
|
24
25
|
/**
|
|
25
26
|
* Option to display a cartesian grid in the background.
|
|
26
27
|
*/
|
package/BarChart/BarChart.js
CHANGED
|
@@ -23,7 +23,7 @@ var _useBarChartProps = require("./useBarChartProps");
|
|
|
23
23
|
var _ChartDataProvider = require("../ChartDataProvider");
|
|
24
24
|
var _ChartsSurface = require("../ChartsSurface");
|
|
25
25
|
var _useChartContainerProps = require("../ChartContainer/useChartContainerProps");
|
|
26
|
-
var _ChartsWrapper = require("../
|
|
26
|
+
var _ChartsWrapper = require("../ChartsWrapper");
|
|
27
27
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
28
28
|
/**
|
|
29
29
|
* Demos:
|
|
@@ -210,7 +210,7 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
|
|
|
210
210
|
onItemClick: _propTypes.default.func,
|
|
211
211
|
/**
|
|
212
212
|
* The series to display in the bar chart.
|
|
213
|
-
* An array of [[
|
|
213
|
+
* An array of [[BarSeries]] objects.
|
|
214
214
|
*/
|
|
215
215
|
series: _propTypes.default.arrayOf(_propTypes.default.object).isRequired,
|
|
216
216
|
/**
|
|
@@ -395,6 +395,53 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
|
|
|
395
395
|
tickPlacement: _propTypes.default.oneOf(['end', 'extremities', 'middle', 'start']),
|
|
396
396
|
tickSize: _propTypes.default.number,
|
|
397
397
|
valueFormatter: _propTypes.default.func
|
|
398
|
+
}), _propTypes.default.shape({
|
|
399
|
+
axis: _propTypes.default.oneOf(['x']),
|
|
400
|
+
classes: _propTypes.default.object,
|
|
401
|
+
colorMap: _propTypes.default.oneOfType([_propTypes.default.shape({
|
|
402
|
+
color: _propTypes.default.oneOfType([_propTypes.default.arrayOf(_propTypes.default.string.isRequired), _propTypes.default.func]).isRequired,
|
|
403
|
+
max: _propTypes.default.oneOfType([_propTypes.default.instanceOf(Date), _propTypes.default.number]),
|
|
404
|
+
min: _propTypes.default.oneOfType([_propTypes.default.instanceOf(Date), _propTypes.default.number]),
|
|
405
|
+
type: _propTypes.default.oneOf(['continuous']).isRequired
|
|
406
|
+
}), _propTypes.default.shape({
|
|
407
|
+
colors: _propTypes.default.arrayOf(_propTypes.default.string).isRequired,
|
|
408
|
+
thresholds: _propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.instanceOf(Date), _propTypes.default.number]).isRequired).isRequired,
|
|
409
|
+
type: _propTypes.default.oneOf(['piecewise']).isRequired
|
|
410
|
+
})]),
|
|
411
|
+
constant: _propTypes.default.number,
|
|
412
|
+
data: _propTypes.default.array,
|
|
413
|
+
dataKey: _propTypes.default.string,
|
|
414
|
+
disableLine: _propTypes.default.bool,
|
|
415
|
+
disableTicks: _propTypes.default.bool,
|
|
416
|
+
domainLimit: _propTypes.default.oneOfType([_propTypes.default.oneOf(['nice', 'strict']), _propTypes.default.func]),
|
|
417
|
+
fill: _propTypes.default.string,
|
|
418
|
+
height: _propTypes.default.number,
|
|
419
|
+
hideTooltip: _propTypes.default.bool,
|
|
420
|
+
id: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]),
|
|
421
|
+
ignoreTooltip: _propTypes.default.bool,
|
|
422
|
+
label: _propTypes.default.string,
|
|
423
|
+
labelStyle: _propTypes.default.object,
|
|
424
|
+
max: _propTypes.default.oneOfType([_propTypes.default.instanceOf(Date), _propTypes.default.number]),
|
|
425
|
+
min: _propTypes.default.oneOfType([_propTypes.default.instanceOf(Date), _propTypes.default.number]),
|
|
426
|
+
offset: _propTypes.default.number,
|
|
427
|
+
position: _propTypes.default.oneOf(['bottom', 'none', 'top']),
|
|
428
|
+
reverse: _propTypes.default.bool,
|
|
429
|
+
scaleType: _propTypes.default.oneOf(['symlog']),
|
|
430
|
+
slotProps: _propTypes.default.object,
|
|
431
|
+
slots: _propTypes.default.object,
|
|
432
|
+
stroke: _propTypes.default.string,
|
|
433
|
+
sx: _propTypes.default.oneOfType([_propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.object, _propTypes.default.bool])), _propTypes.default.func, _propTypes.default.object]),
|
|
434
|
+
tickInterval: _propTypes.default.oneOfType([_propTypes.default.oneOf(['auto']), _propTypes.default.array, _propTypes.default.func]),
|
|
435
|
+
tickLabelInterval: _propTypes.default.oneOfType([_propTypes.default.oneOf(['auto']), _propTypes.default.func]),
|
|
436
|
+
tickLabelMinGap: _propTypes.default.number,
|
|
437
|
+
tickLabelPlacement: _propTypes.default.oneOf(['middle', 'tick']),
|
|
438
|
+
tickLabelStyle: _propTypes.default.object,
|
|
439
|
+
tickMaxStep: _propTypes.default.number,
|
|
440
|
+
tickMinStep: _propTypes.default.number,
|
|
441
|
+
tickNumber: _propTypes.default.number,
|
|
442
|
+
tickPlacement: _propTypes.default.oneOf(['end', 'extremities', 'middle', 'start']),
|
|
443
|
+
tickSize: _propTypes.default.number,
|
|
444
|
+
valueFormatter: _propTypes.default.func
|
|
398
445
|
}), _propTypes.default.shape({
|
|
399
446
|
axis: _propTypes.default.oneOf(['x']),
|
|
400
447
|
classes: _propTypes.default.object,
|
|
@@ -778,6 +825,52 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
|
|
|
778
825
|
tickSize: _propTypes.default.number,
|
|
779
826
|
valueFormatter: _propTypes.default.func,
|
|
780
827
|
width: _propTypes.default.number
|
|
828
|
+
}), _propTypes.default.shape({
|
|
829
|
+
axis: _propTypes.default.oneOf(['y']),
|
|
830
|
+
classes: _propTypes.default.object,
|
|
831
|
+
colorMap: _propTypes.default.oneOfType([_propTypes.default.shape({
|
|
832
|
+
color: _propTypes.default.oneOfType([_propTypes.default.arrayOf(_propTypes.default.string.isRequired), _propTypes.default.func]).isRequired,
|
|
833
|
+
max: _propTypes.default.oneOfType([_propTypes.default.instanceOf(Date), _propTypes.default.number]),
|
|
834
|
+
min: _propTypes.default.oneOfType([_propTypes.default.instanceOf(Date), _propTypes.default.number]),
|
|
835
|
+
type: _propTypes.default.oneOf(['continuous']).isRequired
|
|
836
|
+
}), _propTypes.default.shape({
|
|
837
|
+
colors: _propTypes.default.arrayOf(_propTypes.default.string).isRequired,
|
|
838
|
+
thresholds: _propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.instanceOf(Date), _propTypes.default.number]).isRequired).isRequired,
|
|
839
|
+
type: _propTypes.default.oneOf(['piecewise']).isRequired
|
|
840
|
+
})]),
|
|
841
|
+
constant: _propTypes.default.number,
|
|
842
|
+
data: _propTypes.default.array,
|
|
843
|
+
dataKey: _propTypes.default.string,
|
|
844
|
+
disableLine: _propTypes.default.bool,
|
|
845
|
+
disableTicks: _propTypes.default.bool,
|
|
846
|
+
domainLimit: _propTypes.default.oneOfType([_propTypes.default.oneOf(['nice', 'strict']), _propTypes.default.func]),
|
|
847
|
+
fill: _propTypes.default.string,
|
|
848
|
+
hideTooltip: _propTypes.default.bool,
|
|
849
|
+
id: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]),
|
|
850
|
+
ignoreTooltip: _propTypes.default.bool,
|
|
851
|
+
label: _propTypes.default.string,
|
|
852
|
+
labelStyle: _propTypes.default.object,
|
|
853
|
+
max: _propTypes.default.oneOfType([_propTypes.default.instanceOf(Date), _propTypes.default.number]),
|
|
854
|
+
min: _propTypes.default.oneOfType([_propTypes.default.instanceOf(Date), _propTypes.default.number]),
|
|
855
|
+
offset: _propTypes.default.number,
|
|
856
|
+
position: _propTypes.default.oneOf(['left', 'none', 'right']),
|
|
857
|
+
reverse: _propTypes.default.bool,
|
|
858
|
+
scaleType: _propTypes.default.oneOf(['symlog']),
|
|
859
|
+
slotProps: _propTypes.default.object,
|
|
860
|
+
slots: _propTypes.default.object,
|
|
861
|
+
stroke: _propTypes.default.string,
|
|
862
|
+
sx: _propTypes.default.oneOfType([_propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.object, _propTypes.default.bool])), _propTypes.default.func, _propTypes.default.object]),
|
|
863
|
+
tickInterval: _propTypes.default.oneOfType([_propTypes.default.oneOf(['auto']), _propTypes.default.array, _propTypes.default.func]),
|
|
864
|
+
tickLabelInterval: _propTypes.default.oneOfType([_propTypes.default.oneOf(['auto']), _propTypes.default.func]),
|
|
865
|
+
tickLabelPlacement: _propTypes.default.oneOf(['middle', 'tick']),
|
|
866
|
+
tickLabelStyle: _propTypes.default.object,
|
|
867
|
+
tickMaxStep: _propTypes.default.number,
|
|
868
|
+
tickMinStep: _propTypes.default.number,
|
|
869
|
+
tickNumber: _propTypes.default.number,
|
|
870
|
+
tickPlacement: _propTypes.default.oneOf(['end', 'extremities', 'middle', 'start']),
|
|
871
|
+
tickSize: _propTypes.default.number,
|
|
872
|
+
valueFormatter: _propTypes.default.func,
|
|
873
|
+
width: _propTypes.default.number
|
|
781
874
|
}), _propTypes.default.shape({
|
|
782
875
|
axis: _propTypes.default.oneOf(['y']),
|
|
783
876
|
classes: _propTypes.default.object,
|
|
@@ -1,18 +1,21 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
interface UseAnimateBarClipPathParams {
|
|
3
|
+
ref?: React.Ref<SVGPathElement>;
|
|
4
|
+
layout: 'vertical' | 'horizontal';
|
|
5
|
+
hasNegative: boolean;
|
|
6
|
+
hasPositive: boolean;
|
|
7
|
+
xOrigin: number;
|
|
8
|
+
yOrigin: number;
|
|
9
|
+
x: number;
|
|
10
|
+
y: number;
|
|
11
|
+
width: number;
|
|
12
|
+
height: number;
|
|
5
13
|
borderRadius: number;
|
|
6
|
-
|
|
7
|
-
};
|
|
8
|
-
type UseAnimateBarClipRectReturn = {
|
|
9
|
-
ref: React.Ref<SVGRectElement>;
|
|
10
|
-
style: React.CSSProperties;
|
|
11
|
-
} & Pick<BarClipRectProps, 'x' | 'y' | 'width' | 'height'>;
|
|
12
|
-
export declare function useAnimateBarClipRect(props: UseAnimateBarClipRectParams): UseAnimateBarClipRectReturn;
|
|
13
|
-
interface BarClipRectProps extends Pick<BarClipPathProps, 'x' | 'y' | 'width' | 'height' | 'skipAnimation'> {
|
|
14
|
-
ownerState: GetRadiusData;
|
|
14
|
+
skipAnimation: boolean;
|
|
15
15
|
}
|
|
16
|
+
export declare function useAnimateBarClipPath(props: UseAnimateBarClipPathParams): import("../index.js").UseAnimateReturn<SVGPathElement, {
|
|
17
|
+
d: string | undefined;
|
|
18
|
+
}>;
|
|
16
19
|
export interface BarClipPathProps {
|
|
17
20
|
maskId: string;
|
|
18
21
|
borderRadius?: number;
|
|
@@ -21,6 +24,8 @@ export interface BarClipPathProps {
|
|
|
21
24
|
layout?: 'vertical' | 'horizontal';
|
|
22
25
|
x: number;
|
|
23
26
|
y: number;
|
|
27
|
+
xOrigin: number;
|
|
28
|
+
yOrigin: number;
|
|
24
29
|
width: number;
|
|
25
30
|
height: number;
|
|
26
31
|
skipAnimation: boolean;
|
package/BarChart/BarClipPath.js
CHANGED
|
@@ -1,32 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
'use client';
|
|
3
3
|
|
|
4
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
5
4
|
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
6
5
|
Object.defineProperty(exports, "__esModule", {
|
|
7
6
|
value: true
|
|
8
7
|
});
|
|
9
8
|
exports.BarClipPath = BarClipPath;
|
|
10
|
-
exports.
|
|
11
|
-
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
|
|
12
|
-
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
|
+
exports.useAnimateBarClipPath = useAnimateBarClipPath;
|
|
13
10
|
var React = _interopRequireWildcard(require("react"));
|
|
14
11
|
var _d3Interpolate = require("@mui/x-charts-vendor/d3-interpolate");
|
|
15
12
|
var _animation = require("../hooks/animation");
|
|
16
|
-
var _getRadius = require("./getRadius");
|
|
17
13
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
18
|
-
|
|
19
|
-
function buildClipPath(size, borderRadius, ownerState) {
|
|
20
|
-
const radiusData = (0, _extends2.default)({}, ownerState, {
|
|
21
|
-
borderRadius
|
|
22
|
-
});
|
|
23
|
-
const topLeft = Math.min(size, (0, _getRadius.getRadius)('top-left', radiusData));
|
|
24
|
-
const topRight = Math.min(size, (0, _getRadius.getRadius)('top-right', radiusData));
|
|
25
|
-
const bottomRight = Math.min(size, (0, _getRadius.getRadius)('bottom-right', radiusData));
|
|
26
|
-
const bottomLeft = Math.min(size, (0, _getRadius.getRadius)('bottom-left', radiusData));
|
|
27
|
-
return `inset(0px round ${topLeft}px ${topRight}px ${bottomRight}px ${bottomLeft}px)`;
|
|
28
|
-
}
|
|
29
|
-
function barClipRectPropsInterpolator(from, to) {
|
|
14
|
+
function barClipPathPropsInterpolator(from, to) {
|
|
30
15
|
const interpolateX = (0, _d3Interpolate.interpolateNumber)(from.x, to.x);
|
|
31
16
|
const interpolateY = (0, _d3Interpolate.interpolateNumber)(from.y, to.y);
|
|
32
17
|
const interpolateWidth = (0, _d3Interpolate.interpolateNumber)(from.width, to.width);
|
|
@@ -42,12 +27,12 @@ function barClipRectPropsInterpolator(from, to) {
|
|
|
42
27
|
};
|
|
43
28
|
};
|
|
44
29
|
}
|
|
45
|
-
function
|
|
30
|
+
function useAnimateBarClipPath(props) {
|
|
46
31
|
const initialProps = {
|
|
47
|
-
x: props.x,
|
|
48
|
-
y: props.
|
|
49
|
-
width: props.
|
|
50
|
-
height: props.
|
|
32
|
+
x: props.layout === 'vertical' ? props.x : props.xOrigin,
|
|
33
|
+
y: props.layout === 'vertical' ? props.yOrigin : props.y,
|
|
34
|
+
width: props.layout === 'vertical' ? props.width : 0,
|
|
35
|
+
height: props.layout === 'vertical' ? 0 : props.height,
|
|
51
36
|
borderRadius: props.borderRadius
|
|
52
37
|
};
|
|
53
38
|
return (0, _animation.useAnimate)({
|
|
@@ -57,59 +42,87 @@ function useAnimateBarClipRect(props) {
|
|
|
57
42
|
height: props.height,
|
|
58
43
|
borderRadius: props.borderRadius
|
|
59
44
|
}, {
|
|
60
|
-
createInterpolator:
|
|
45
|
+
createInterpolator: barClipPathPropsInterpolator,
|
|
61
46
|
transformProps: p => ({
|
|
62
|
-
|
|
63
|
-
y: p.y,
|
|
64
|
-
width: p.width,
|
|
65
|
-
height: p.height,
|
|
66
|
-
style: {
|
|
67
|
-
clipPath: buildClipPath(props.ownerState.layout === 'vertical' ? p.height : p.width, p.borderRadius, props.ownerState)
|
|
68
|
-
}
|
|
47
|
+
d: generateClipPath(props.hasNegative, props.hasPositive, props.layout, p.x, p.y, p.width, p.height, props.xOrigin, props.yOrigin, p.borderRadius)
|
|
69
48
|
}),
|
|
70
|
-
applyProps(element,
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
49
|
+
applyProps(element, {
|
|
50
|
+
d
|
|
51
|
+
}) {
|
|
52
|
+
if (d) {
|
|
53
|
+
element.setAttribute('d', d);
|
|
54
|
+
}
|
|
76
55
|
},
|
|
77
56
|
initialProps,
|
|
78
57
|
skip: props.skipAnimation,
|
|
79
58
|
ref: props.ref
|
|
80
59
|
});
|
|
81
60
|
}
|
|
82
|
-
function BarClipRect(props) {
|
|
83
|
-
const animatedProps = useAnimateBarClipRect((0, _extends2.default)({}, props, {
|
|
84
|
-
borderRadius: props.ownerState.borderRadius ?? 0
|
|
85
|
-
}));
|
|
86
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)("rect", (0, _extends2.default)({}, animatedProps));
|
|
87
|
-
}
|
|
88
61
|
/**
|
|
89
62
|
* @ignore - internal component.
|
|
90
63
|
*/
|
|
91
64
|
function BarClipPath(props) {
|
|
92
65
|
const {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
66
|
+
maskId,
|
|
67
|
+
x,
|
|
68
|
+
y,
|
|
69
|
+
width,
|
|
70
|
+
height,
|
|
71
|
+
skipAnimation
|
|
72
|
+
} = props;
|
|
73
|
+
const {
|
|
74
|
+
ref,
|
|
75
|
+
d
|
|
76
|
+
} = useAnimateBarClipPath({
|
|
77
|
+
layout: props.layout ?? 'vertical',
|
|
78
|
+
hasNegative: props.hasNegative,
|
|
79
|
+
hasPositive: props.hasPositive,
|
|
80
|
+
xOrigin: props.xOrigin,
|
|
81
|
+
yOrigin: props.yOrigin,
|
|
82
|
+
x,
|
|
83
|
+
y,
|
|
84
|
+
width,
|
|
85
|
+
height,
|
|
86
|
+
borderRadius: props.borderRadius ?? 0,
|
|
87
|
+
skipAnimation
|
|
88
|
+
});
|
|
101
89
|
if (!props.borderRadius || props.borderRadius <= 0) {
|
|
102
90
|
return null;
|
|
103
91
|
}
|
|
104
92
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)("clipPath", {
|
|
105
93
|
id: maskId,
|
|
106
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
y: y,
|
|
110
|
-
width: width,
|
|
111
|
-
height: height,
|
|
112
|
-
skipAnimation: skipAnimation
|
|
94
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("path", {
|
|
95
|
+
ref: ref,
|
|
96
|
+
d: d
|
|
113
97
|
})
|
|
114
98
|
});
|
|
99
|
+
}
|
|
100
|
+
function generateClipPath(hasNegative, hasPositive, layout, x, y, width, height, xOrigin, yOrigin, borderRadius) {
|
|
101
|
+
if (layout === 'vertical') {
|
|
102
|
+
if (hasPositive && hasNegative) {
|
|
103
|
+
const bR = Math.min(borderRadius, width / 2, height / 2);
|
|
104
|
+
return `M${x},${y + height / 2} v${-(height / 2 - bR)} a${bR},${bR} 0 0 1 ${bR},${-bR} h${width - bR * 2} a${bR},${bR} 0 0 1 ${bR},${bR} v${height - 2 * bR} a${bR},${bR} 0 0 1 ${-bR},${bR} h${-(width - bR * 2)} a${bR},${bR} 0 0 1 ${-bR},${-bR} v${-(height / 2 - bR)}`;
|
|
105
|
+
}
|
|
106
|
+
const bR = Math.min(borderRadius, width / 2);
|
|
107
|
+
if (hasPositive) {
|
|
108
|
+
return `M${x},${Math.max(yOrigin, y + bR)} v${Math.min(0, -(yOrigin - y - bR))} a${bR},${bR} 0 0 1 ${bR},${-bR} h${width - bR * 2} a${bR},${bR} 0 0 1 ${bR},${bR} v${Math.max(0, yOrigin - y - bR)} Z`;
|
|
109
|
+
}
|
|
110
|
+
if (hasNegative) {
|
|
111
|
+
return `M${x},${Math.min(yOrigin, y + height - bR)} v${Math.max(0, height - bR)} a${bR},${bR} 0 0 0 ${bR},${bR} h${width - bR * 2} a${bR},${bR} 0 0 0 ${bR},${-bR} v${-Math.max(0, height - bR)} Z`;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
if (layout === 'horizontal') {
|
|
115
|
+
if (hasPositive && hasNegative) {
|
|
116
|
+
const bR = Math.min(borderRadius, width / 2, height / 2);
|
|
117
|
+
return `M${x + width / 2},${y} h${width / 2 - bR} a${bR},${bR} 0 0 1 ${bR},${bR} v${height - bR * 2} a${bR},${bR} 0 0 1 ${-bR},${bR} h${-(width - 2 * bR)} a${bR},${bR} 0 0 1 ${-bR},${-bR} v${-(height - bR * 2)} a${bR},${bR} 0 0 1 ${bR},${-bR} h${width / 2 - bR}`;
|
|
118
|
+
}
|
|
119
|
+
const bR = Math.min(borderRadius, height / 2);
|
|
120
|
+
if (hasPositive) {
|
|
121
|
+
return `M${Math.min(xOrigin, x - bR)},${y} h${width} a${bR},${bR} 0 0 1 ${bR},${bR} v${height - bR * 2} a${bR},${bR} 0 0 1 ${-bR},${bR} h${-width} Z`;
|
|
122
|
+
}
|
|
123
|
+
if (hasNegative) {
|
|
124
|
+
return `M${Math.max(xOrigin, x + width + bR)},${y} h${-width} a${bR},${bR} 0 0 0 ${-bR},${bR} v${height - bR * 2} a${bR},${bR} 0 0 0 ${bR},${bR} h${width} Z`;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
return undefined;
|
|
115
128
|
}
|
package/BarChart/BarPlot.js
CHANGED
|
@@ -71,6 +71,8 @@ function BarPlot(props) {
|
|
|
71
71
|
id,
|
|
72
72
|
x,
|
|
73
73
|
y,
|
|
74
|
+
xOrigin,
|
|
75
|
+
yOrigin,
|
|
74
76
|
width,
|
|
75
77
|
height,
|
|
76
78
|
hasPositive,
|
|
@@ -85,6 +87,8 @@ function BarPlot(props) {
|
|
|
85
87
|
layout: layout,
|
|
86
88
|
x: x,
|
|
87
89
|
y: y,
|
|
90
|
+
xOrigin: xOrigin,
|
|
91
|
+
yOrigin: yOrigin,
|
|
88
92
|
width: width,
|
|
89
93
|
height: height,
|
|
90
94
|
skipAnimation: skipAnimation ?? false
|
package/BarChart/barClasses.d.ts
CHANGED
|
@@ -9,4 +9,4 @@ export interface BarClasses {
|
|
|
9
9
|
export type BarClassKey = keyof BarClasses;
|
|
10
10
|
export declare function getBarUtilityClass(slot: string): string;
|
|
11
11
|
export declare const barClasses: BarClasses;
|
|
12
|
-
export declare const useUtilityClasses: (classes?: Partial<BarClasses>) => Record<"
|
|
12
|
+
export declare const useUtilityClasses: (classes?: Partial<BarClasses>) => Record<"series" | "root" | "seriesLabels", string>;
|
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.getExtremumY = exports.getExtremumX = void 0;
|
|
7
|
+
var _findMinMax = require("../../internals/findMinMax");
|
|
7
8
|
const createResult = (data, direction) => {
|
|
8
9
|
if (direction === 'x') {
|
|
9
10
|
return {
|
|
@@ -30,9 +31,7 @@ const getBaseExtremum = params => {
|
|
|
30
31
|
x: null,
|
|
31
32
|
y: null
|
|
32
33
|
}, i)) : axis.data;
|
|
33
|
-
|
|
34
|
-
const maxX = Math.max(...(data ?? []));
|
|
35
|
-
return [minX, maxX];
|
|
34
|
+
return (0, _findMinMax.findMinMax)(data ?? []);
|
|
36
35
|
};
|
|
37
36
|
const getValueExtremum = direction => params => {
|
|
38
37
|
const {
|
|
@@ -9,7 +9,7 @@ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")
|
|
|
9
9
|
var _d3Shape = require("@mui/x-charts-vendor/d3-shape");
|
|
10
10
|
var _warning = require("@mui/x-internals/warning");
|
|
11
11
|
var _stackSeries = require("../../internals/stackSeries");
|
|
12
|
-
|
|
12
|
+
const barValueFormatter = v => v == null ? '' : v.toLocaleString();
|
|
13
13
|
const seriesProcessor = (params, dataset) => {
|
|
14
14
|
const {
|
|
15
15
|
seriesOrder,
|
|
@@ -53,7 +53,9 @@ const seriesProcessor = (params, dataset) => {
|
|
|
53
53
|
const dataKey = series[id].dataKey;
|
|
54
54
|
completedSeries[id] = (0, _extends2.default)({
|
|
55
55
|
layout: 'vertical',
|
|
56
|
-
labelMarkType: 'square'
|
|
56
|
+
labelMarkType: 'square',
|
|
57
|
+
minBarSize: 0,
|
|
58
|
+
valueFormatter: series[id].valueFormatter ?? barValueFormatter
|
|
57
59
|
}, series[id], {
|
|
58
60
|
data: dataKey ? dataset.map(data => {
|
|
59
61
|
const value = data[dataKey];
|
|
@@ -74,7 +76,7 @@ const seriesProcessor = (params, dataset) => {
|
|
|
74
76
|
return {
|
|
75
77
|
seriesOrder,
|
|
76
78
|
stackingGroups,
|
|
77
|
-
series:
|
|
79
|
+
series: completedSeries
|
|
78
80
|
};
|
|
79
81
|
};
|
|
80
82
|
var _default = exports.default = seriesProcessor;
|
|
@@ -8,7 +8,7 @@ import { ChartsOverlayProps } from "../ChartsOverlay/index.js";
|
|
|
8
8
|
import { ChartsAxisProps } from "../ChartsAxis/index.js";
|
|
9
9
|
import { ChartsAxisHighlightProps } from "../ChartsAxisHighlight/index.js";
|
|
10
10
|
import { ChartsLegendSlotExtension } from "../ChartsLegend/index.js";
|
|
11
|
-
import type { ChartsWrapperProps } from "../
|
|
11
|
+
import type { ChartsWrapperProps } from "../ChartsWrapper/index.js";
|
|
12
12
|
import { BarChartPluginsSignatures } from "./BarChart.plugins.js";
|
|
13
13
|
/**
|
|
14
14
|
* A helper function that extracts BarChartProps from the input props
|
|
@@ -54,7 +54,8 @@ function useBarPlotData(drawingArea, xAxes, yAxes) {
|
|
|
54
54
|
const {
|
|
55
55
|
stackedData,
|
|
56
56
|
data: currentSeriesData,
|
|
57
|
-
layout
|
|
57
|
+
layout,
|
|
58
|
+
minBarSize
|
|
58
59
|
} = series[seriesId];
|
|
59
60
|
const seriesDataPoints = baseScaleConfig.data.map((baseValue, dataIndex) => {
|
|
60
61
|
if (currentSeriesData[dataIndex] == null) {
|
|
@@ -65,16 +66,20 @@ function useBarPlotData(drawingArea, xAxes, yAxes) {
|
|
|
65
66
|
const minValueCoord = Math.round(Math.min(...valueCoordinates));
|
|
66
67
|
const maxValueCoord = Math.round(Math.max(...valueCoordinates));
|
|
67
68
|
const stackId = series[seriesId].stack;
|
|
69
|
+
const {
|
|
70
|
+
barSize,
|
|
71
|
+
startCoordinate
|
|
72
|
+
} = getValueCoordinate(verticalLayout, minValueCoord, maxValueCoord, currentSeriesData[dataIndex], minBarSize);
|
|
68
73
|
const result = {
|
|
69
74
|
seriesId,
|
|
70
75
|
dataIndex,
|
|
71
76
|
layout,
|
|
72
|
-
x: verticalLayout ? xScale(baseValue) + barOffset :
|
|
73
|
-
y: verticalLayout ?
|
|
77
|
+
x: verticalLayout ? xScale(baseValue) + barOffset : startCoordinate,
|
|
78
|
+
y: verticalLayout ? startCoordinate : yScale(baseValue) + barOffset,
|
|
74
79
|
xOrigin: xScale(0) ?? 0,
|
|
75
80
|
yOrigin: yScale(0) ?? 0,
|
|
76
|
-
height: verticalLayout ?
|
|
77
|
-
width: verticalLayout ? barWidth :
|
|
81
|
+
height: verticalLayout ? barSize : barWidth,
|
|
82
|
+
width: verticalLayout ? barWidth : barSize,
|
|
78
83
|
color: colorGetter(dataIndex),
|
|
79
84
|
value: currentSeriesData[dataIndex],
|
|
80
85
|
maskId: `${chartId}_${stackId || seriesId}_${groupIndex}_${dataIndex}`
|
|
@@ -143,4 +148,26 @@ function getBandSize({
|
|
|
143
148
|
barWidth,
|
|
144
149
|
offset
|
|
145
150
|
};
|
|
151
|
+
}
|
|
152
|
+
function getValueCoordinate(isVertical, minValueCoord, maxValueCoord, baseValue, minBarSize) {
|
|
153
|
+
if (baseValue === 0 || baseValue == null) {
|
|
154
|
+
return {
|
|
155
|
+
barSize: 0,
|
|
156
|
+
startCoordinate: minValueCoord
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
const isSizeLessThanMin = maxValueCoord - minValueCoord < minBarSize;
|
|
160
|
+
const barSize = isSizeLessThanMin ? minBarSize : maxValueCoord - minValueCoord;
|
|
161
|
+
const isVerticalAndPositive = isVertical && baseValue >= 0;
|
|
162
|
+
const isHorizontalAndNegative = !isVertical && baseValue < 0;
|
|
163
|
+
if (isSizeLessThanMin && (isVerticalAndPositive || isHorizontalAndNegative)) {
|
|
164
|
+
return {
|
|
165
|
+
barSize,
|
|
166
|
+
startCoordinate: maxValueCoord - barSize
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
return {
|
|
170
|
+
barSize,
|
|
171
|
+
startCoordinate: minValueCoord
|
|
172
|
+
};
|
|
146
173
|
}
|