@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
|
@@ -484,6 +484,53 @@ process.env.NODE_ENV !== "production" ? SparkLineChart.propTypes = {
|
|
|
484
484
|
tickPlacement: _propTypes.default.oneOf(['end', 'extremities', 'middle', 'start']),
|
|
485
485
|
tickSize: _propTypes.default.number,
|
|
486
486
|
valueFormatter: _propTypes.default.func
|
|
487
|
+
}), _propTypes.default.shape({
|
|
488
|
+
axis: _propTypes.default.oneOf(['x']),
|
|
489
|
+
classes: _propTypes.default.object,
|
|
490
|
+
colorMap: _propTypes.default.oneOfType([_propTypes.default.shape({
|
|
491
|
+
color: _propTypes.default.oneOfType([_propTypes.default.arrayOf(_propTypes.default.string.isRequired), _propTypes.default.func]).isRequired,
|
|
492
|
+
max: _propTypes.default.oneOfType([_propTypes.default.instanceOf(Date), _propTypes.default.number]),
|
|
493
|
+
min: _propTypes.default.oneOfType([_propTypes.default.instanceOf(Date), _propTypes.default.number]),
|
|
494
|
+
type: _propTypes.default.oneOf(['continuous']).isRequired
|
|
495
|
+
}), _propTypes.default.shape({
|
|
496
|
+
colors: _propTypes.default.arrayOf(_propTypes.default.string).isRequired,
|
|
497
|
+
thresholds: _propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.instanceOf(Date), _propTypes.default.number]).isRequired).isRequired,
|
|
498
|
+
type: _propTypes.default.oneOf(['piecewise']).isRequired
|
|
499
|
+
})]),
|
|
500
|
+
constant: _propTypes.default.number,
|
|
501
|
+
data: _propTypes.default.array,
|
|
502
|
+
dataKey: _propTypes.default.string,
|
|
503
|
+
disableLine: _propTypes.default.bool,
|
|
504
|
+
disableTicks: _propTypes.default.bool,
|
|
505
|
+
domainLimit: _propTypes.default.oneOfType([_propTypes.default.oneOf(['nice', 'strict']), _propTypes.default.func]),
|
|
506
|
+
fill: _propTypes.default.string,
|
|
507
|
+
height: _propTypes.default.number,
|
|
508
|
+
hideTooltip: _propTypes.default.bool,
|
|
509
|
+
id: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]),
|
|
510
|
+
ignoreTooltip: _propTypes.default.bool,
|
|
511
|
+
label: _propTypes.default.string,
|
|
512
|
+
labelStyle: _propTypes.default.object,
|
|
513
|
+
max: _propTypes.default.oneOfType([_propTypes.default.instanceOf(Date), _propTypes.default.number]),
|
|
514
|
+
min: _propTypes.default.oneOfType([_propTypes.default.instanceOf(Date), _propTypes.default.number]),
|
|
515
|
+
offset: _propTypes.default.number,
|
|
516
|
+
position: _propTypes.default.oneOf(['bottom', 'none', 'top']),
|
|
517
|
+
reverse: _propTypes.default.bool,
|
|
518
|
+
scaleType: _propTypes.default.oneOf(['symlog']),
|
|
519
|
+
slotProps: _propTypes.default.object,
|
|
520
|
+
slots: _propTypes.default.object,
|
|
521
|
+
stroke: _propTypes.default.string,
|
|
522
|
+
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]),
|
|
523
|
+
tickInterval: _propTypes.default.oneOfType([_propTypes.default.oneOf(['auto']), _propTypes.default.array, _propTypes.default.func]),
|
|
524
|
+
tickLabelInterval: _propTypes.default.oneOfType([_propTypes.default.oneOf(['auto']), _propTypes.default.func]),
|
|
525
|
+
tickLabelMinGap: _propTypes.default.number,
|
|
526
|
+
tickLabelPlacement: _propTypes.default.oneOf(['middle', 'tick']),
|
|
527
|
+
tickLabelStyle: _propTypes.default.object,
|
|
528
|
+
tickMaxStep: _propTypes.default.number,
|
|
529
|
+
tickMinStep: _propTypes.default.number,
|
|
530
|
+
tickNumber: _propTypes.default.number,
|
|
531
|
+
tickPlacement: _propTypes.default.oneOf(['end', 'extremities', 'middle', 'start']),
|
|
532
|
+
tickSize: _propTypes.default.number,
|
|
533
|
+
valueFormatter: _propTypes.default.func
|
|
487
534
|
}), _propTypes.default.shape({
|
|
488
535
|
axis: _propTypes.default.oneOf(['x']),
|
|
489
536
|
classes: _propTypes.default.object,
|
|
@@ -866,6 +913,52 @@ process.env.NODE_ENV !== "production" ? SparkLineChart.propTypes = {
|
|
|
866
913
|
tickSize: _propTypes.default.number,
|
|
867
914
|
valueFormatter: _propTypes.default.func,
|
|
868
915
|
width: _propTypes.default.number
|
|
916
|
+
}), _propTypes.default.shape({
|
|
917
|
+
axis: _propTypes.default.oneOf(['y']),
|
|
918
|
+
classes: _propTypes.default.object,
|
|
919
|
+
colorMap: _propTypes.default.oneOfType([_propTypes.default.shape({
|
|
920
|
+
color: _propTypes.default.oneOfType([_propTypes.default.arrayOf(_propTypes.default.string.isRequired), _propTypes.default.func]).isRequired,
|
|
921
|
+
max: _propTypes.default.oneOfType([_propTypes.default.instanceOf(Date), _propTypes.default.number]),
|
|
922
|
+
min: _propTypes.default.oneOfType([_propTypes.default.instanceOf(Date), _propTypes.default.number]),
|
|
923
|
+
type: _propTypes.default.oneOf(['continuous']).isRequired
|
|
924
|
+
}), _propTypes.default.shape({
|
|
925
|
+
colors: _propTypes.default.arrayOf(_propTypes.default.string).isRequired,
|
|
926
|
+
thresholds: _propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.instanceOf(Date), _propTypes.default.number]).isRequired).isRequired,
|
|
927
|
+
type: _propTypes.default.oneOf(['piecewise']).isRequired
|
|
928
|
+
})]),
|
|
929
|
+
constant: _propTypes.default.number,
|
|
930
|
+
data: _propTypes.default.array,
|
|
931
|
+
dataKey: _propTypes.default.string,
|
|
932
|
+
disableLine: _propTypes.default.bool,
|
|
933
|
+
disableTicks: _propTypes.default.bool,
|
|
934
|
+
domainLimit: _propTypes.default.oneOfType([_propTypes.default.oneOf(['nice', 'strict']), _propTypes.default.func]),
|
|
935
|
+
fill: _propTypes.default.string,
|
|
936
|
+
hideTooltip: _propTypes.default.bool,
|
|
937
|
+
id: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]),
|
|
938
|
+
ignoreTooltip: _propTypes.default.bool,
|
|
939
|
+
label: _propTypes.default.string,
|
|
940
|
+
labelStyle: _propTypes.default.object,
|
|
941
|
+
max: _propTypes.default.oneOfType([_propTypes.default.instanceOf(Date), _propTypes.default.number]),
|
|
942
|
+
min: _propTypes.default.oneOfType([_propTypes.default.instanceOf(Date), _propTypes.default.number]),
|
|
943
|
+
offset: _propTypes.default.number,
|
|
944
|
+
position: _propTypes.default.oneOf(['left', 'none', 'right']),
|
|
945
|
+
reverse: _propTypes.default.bool,
|
|
946
|
+
scaleType: _propTypes.default.oneOf(['symlog']),
|
|
947
|
+
slotProps: _propTypes.default.object,
|
|
948
|
+
slots: _propTypes.default.object,
|
|
949
|
+
stroke: _propTypes.default.string,
|
|
950
|
+
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]),
|
|
951
|
+
tickInterval: _propTypes.default.oneOfType([_propTypes.default.oneOf(['auto']), _propTypes.default.array, _propTypes.default.func]),
|
|
952
|
+
tickLabelInterval: _propTypes.default.oneOfType([_propTypes.default.oneOf(['auto']), _propTypes.default.func]),
|
|
953
|
+
tickLabelPlacement: _propTypes.default.oneOf(['middle', 'tick']),
|
|
954
|
+
tickLabelStyle: _propTypes.default.object,
|
|
955
|
+
tickMaxStep: _propTypes.default.number,
|
|
956
|
+
tickMinStep: _propTypes.default.number,
|
|
957
|
+
tickNumber: _propTypes.default.number,
|
|
958
|
+
tickPlacement: _propTypes.default.oneOf(['end', 'extremities', 'middle', 'start']),
|
|
959
|
+
tickSize: _propTypes.default.number,
|
|
960
|
+
valueFormatter: _propTypes.default.func,
|
|
961
|
+
width: _propTypes.default.number
|
|
869
962
|
}), _propTypes.default.shape({
|
|
870
963
|
axis: _propTypes.default.oneOf(['y']),
|
|
871
964
|
classes: _propTypes.default.object,
|
|
@@ -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/esm/BarChart/BarChart.js
CHANGED
|
@@ -16,7 +16,7 @@ import { useBarChartProps } from "./useBarChartProps.js";
|
|
|
16
16
|
import { ChartDataProvider } from "../ChartDataProvider/index.js";
|
|
17
17
|
import { ChartsSurface } from "../ChartsSurface/index.js";
|
|
18
18
|
import { useChartContainerProps } from "../ChartContainer/useChartContainerProps.js";
|
|
19
|
-
import { ChartsWrapper } from "../
|
|
19
|
+
import { ChartsWrapper } from "../ChartsWrapper/index.js";
|
|
20
20
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
21
21
|
/**
|
|
22
22
|
* Demos:
|
|
@@ -203,7 +203,7 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
|
|
|
203
203
|
onItemClick: PropTypes.func,
|
|
204
204
|
/**
|
|
205
205
|
* The series to display in the bar chart.
|
|
206
|
-
* An array of [[
|
|
206
|
+
* An array of [[BarSeries]] objects.
|
|
207
207
|
*/
|
|
208
208
|
series: PropTypes.arrayOf(PropTypes.object).isRequired,
|
|
209
209
|
/**
|
|
@@ -388,6 +388,53 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
|
|
|
388
388
|
tickPlacement: PropTypes.oneOf(['end', 'extremities', 'middle', 'start']),
|
|
389
389
|
tickSize: PropTypes.number,
|
|
390
390
|
valueFormatter: PropTypes.func
|
|
391
|
+
}), PropTypes.shape({
|
|
392
|
+
axis: PropTypes.oneOf(['x']),
|
|
393
|
+
classes: PropTypes.object,
|
|
394
|
+
colorMap: PropTypes.oneOfType([PropTypes.shape({
|
|
395
|
+
color: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.string.isRequired), PropTypes.func]).isRequired,
|
|
396
|
+
max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
397
|
+
min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
398
|
+
type: PropTypes.oneOf(['continuous']).isRequired
|
|
399
|
+
}), PropTypes.shape({
|
|
400
|
+
colors: PropTypes.arrayOf(PropTypes.string).isRequired,
|
|
401
|
+
thresholds: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]).isRequired).isRequired,
|
|
402
|
+
type: PropTypes.oneOf(['piecewise']).isRequired
|
|
403
|
+
})]),
|
|
404
|
+
constant: PropTypes.number,
|
|
405
|
+
data: PropTypes.array,
|
|
406
|
+
dataKey: PropTypes.string,
|
|
407
|
+
disableLine: PropTypes.bool,
|
|
408
|
+
disableTicks: PropTypes.bool,
|
|
409
|
+
domainLimit: PropTypes.oneOfType([PropTypes.oneOf(['nice', 'strict']), PropTypes.func]),
|
|
410
|
+
fill: PropTypes.string,
|
|
411
|
+
height: PropTypes.number,
|
|
412
|
+
hideTooltip: PropTypes.bool,
|
|
413
|
+
id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
414
|
+
ignoreTooltip: PropTypes.bool,
|
|
415
|
+
label: PropTypes.string,
|
|
416
|
+
labelStyle: PropTypes.object,
|
|
417
|
+
max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
418
|
+
min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
419
|
+
offset: PropTypes.number,
|
|
420
|
+
position: PropTypes.oneOf(['bottom', 'none', 'top']),
|
|
421
|
+
reverse: PropTypes.bool,
|
|
422
|
+
scaleType: PropTypes.oneOf(['symlog']),
|
|
423
|
+
slotProps: PropTypes.object,
|
|
424
|
+
slots: PropTypes.object,
|
|
425
|
+
stroke: PropTypes.string,
|
|
426
|
+
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
|
|
427
|
+
tickInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.array, PropTypes.func]),
|
|
428
|
+
tickLabelInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.func]),
|
|
429
|
+
tickLabelMinGap: PropTypes.number,
|
|
430
|
+
tickLabelPlacement: PropTypes.oneOf(['middle', 'tick']),
|
|
431
|
+
tickLabelStyle: PropTypes.object,
|
|
432
|
+
tickMaxStep: PropTypes.number,
|
|
433
|
+
tickMinStep: PropTypes.number,
|
|
434
|
+
tickNumber: PropTypes.number,
|
|
435
|
+
tickPlacement: PropTypes.oneOf(['end', 'extremities', 'middle', 'start']),
|
|
436
|
+
tickSize: PropTypes.number,
|
|
437
|
+
valueFormatter: PropTypes.func
|
|
391
438
|
}), PropTypes.shape({
|
|
392
439
|
axis: PropTypes.oneOf(['x']),
|
|
393
440
|
classes: PropTypes.object,
|
|
@@ -771,6 +818,52 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
|
|
|
771
818
|
tickSize: PropTypes.number,
|
|
772
819
|
valueFormatter: PropTypes.func,
|
|
773
820
|
width: PropTypes.number
|
|
821
|
+
}), PropTypes.shape({
|
|
822
|
+
axis: PropTypes.oneOf(['y']),
|
|
823
|
+
classes: PropTypes.object,
|
|
824
|
+
colorMap: PropTypes.oneOfType([PropTypes.shape({
|
|
825
|
+
color: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.string.isRequired), PropTypes.func]).isRequired,
|
|
826
|
+
max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
827
|
+
min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
828
|
+
type: PropTypes.oneOf(['continuous']).isRequired
|
|
829
|
+
}), PropTypes.shape({
|
|
830
|
+
colors: PropTypes.arrayOf(PropTypes.string).isRequired,
|
|
831
|
+
thresholds: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]).isRequired).isRequired,
|
|
832
|
+
type: PropTypes.oneOf(['piecewise']).isRequired
|
|
833
|
+
})]),
|
|
834
|
+
constant: PropTypes.number,
|
|
835
|
+
data: PropTypes.array,
|
|
836
|
+
dataKey: PropTypes.string,
|
|
837
|
+
disableLine: PropTypes.bool,
|
|
838
|
+
disableTicks: PropTypes.bool,
|
|
839
|
+
domainLimit: PropTypes.oneOfType([PropTypes.oneOf(['nice', 'strict']), PropTypes.func]),
|
|
840
|
+
fill: PropTypes.string,
|
|
841
|
+
hideTooltip: PropTypes.bool,
|
|
842
|
+
id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
843
|
+
ignoreTooltip: PropTypes.bool,
|
|
844
|
+
label: PropTypes.string,
|
|
845
|
+
labelStyle: PropTypes.object,
|
|
846
|
+
max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
847
|
+
min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
848
|
+
offset: PropTypes.number,
|
|
849
|
+
position: PropTypes.oneOf(['left', 'none', 'right']),
|
|
850
|
+
reverse: PropTypes.bool,
|
|
851
|
+
scaleType: PropTypes.oneOf(['symlog']),
|
|
852
|
+
slotProps: PropTypes.object,
|
|
853
|
+
slots: PropTypes.object,
|
|
854
|
+
stroke: PropTypes.string,
|
|
855
|
+
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
|
|
856
|
+
tickInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.array, PropTypes.func]),
|
|
857
|
+
tickLabelInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.func]),
|
|
858
|
+
tickLabelPlacement: PropTypes.oneOf(['middle', 'tick']),
|
|
859
|
+
tickLabelStyle: PropTypes.object,
|
|
860
|
+
tickMaxStep: PropTypes.number,
|
|
861
|
+
tickMinStep: PropTypes.number,
|
|
862
|
+
tickNumber: PropTypes.number,
|
|
863
|
+
tickPlacement: PropTypes.oneOf(['end', 'extremities', 'middle', 'start']),
|
|
864
|
+
tickSize: PropTypes.number,
|
|
865
|
+
valueFormatter: PropTypes.func,
|
|
866
|
+
width: PropTypes.number
|
|
774
867
|
}), PropTypes.shape({
|
|
775
868
|
axis: PropTypes.oneOf(['y']),
|
|
776
869
|
classes: PropTypes.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;
|
|
@@ -1,24 +1,10 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
-
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
4
|
-
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
5
|
-
const _excluded = ["maskId", "x", "y", "width", "height", "skipAnimation"];
|
|
6
3
|
import * as React from 'react';
|
|
7
4
|
import { interpolateNumber } from '@mui/x-charts-vendor/d3-interpolate';
|
|
8
5
|
import { useAnimate } from "../hooks/animation/index.js";
|
|
9
|
-
import { getRadius } from "./getRadius.js";
|
|
10
6
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
|
-
function
|
|
12
|
-
const radiusData = _extends({}, ownerState, {
|
|
13
|
-
borderRadius
|
|
14
|
-
});
|
|
15
|
-
const topLeft = Math.min(size, getRadius('top-left', radiusData));
|
|
16
|
-
const topRight = Math.min(size, getRadius('top-right', radiusData));
|
|
17
|
-
const bottomRight = Math.min(size, getRadius('bottom-right', radiusData));
|
|
18
|
-
const bottomLeft = Math.min(size, getRadius('bottom-left', radiusData));
|
|
19
|
-
return `inset(0px round ${topLeft}px ${topRight}px ${bottomRight}px ${bottomLeft}px)`;
|
|
20
|
-
}
|
|
21
|
-
function barClipRectPropsInterpolator(from, to) {
|
|
7
|
+
function barClipPathPropsInterpolator(from, to) {
|
|
22
8
|
const interpolateX = interpolateNumber(from.x, to.x);
|
|
23
9
|
const interpolateY = interpolateNumber(from.y, to.y);
|
|
24
10
|
const interpolateWidth = interpolateNumber(from.width, to.width);
|
|
@@ -34,12 +20,12 @@ function barClipRectPropsInterpolator(from, to) {
|
|
|
34
20
|
};
|
|
35
21
|
};
|
|
36
22
|
}
|
|
37
|
-
export function
|
|
23
|
+
export function useAnimateBarClipPath(props) {
|
|
38
24
|
const initialProps = {
|
|
39
|
-
x: props.x,
|
|
40
|
-
y: props.
|
|
41
|
-
width: props.
|
|
42
|
-
height: props.
|
|
25
|
+
x: props.layout === 'vertical' ? props.x : props.xOrigin,
|
|
26
|
+
y: props.layout === 'vertical' ? props.yOrigin : props.y,
|
|
27
|
+
width: props.layout === 'vertical' ? props.width : 0,
|
|
28
|
+
height: props.layout === 'vertical' ? 0 : props.height,
|
|
43
29
|
borderRadius: props.borderRadius
|
|
44
30
|
};
|
|
45
31
|
return useAnimate({
|
|
@@ -49,60 +35,88 @@ export function useAnimateBarClipRect(props) {
|
|
|
49
35
|
height: props.height,
|
|
50
36
|
borderRadius: props.borderRadius
|
|
51
37
|
}, {
|
|
52
|
-
createInterpolator:
|
|
38
|
+
createInterpolator: barClipPathPropsInterpolator,
|
|
53
39
|
transformProps: p => ({
|
|
54
|
-
|
|
55
|
-
y: p.y,
|
|
56
|
-
width: p.width,
|
|
57
|
-
height: p.height,
|
|
58
|
-
style: {
|
|
59
|
-
clipPath: buildClipPath(props.ownerState.layout === 'vertical' ? p.height : p.width, p.borderRadius, props.ownerState)
|
|
60
|
-
}
|
|
40
|
+
d: generateClipPath(props.hasNegative, props.hasPositive, props.layout, p.x, p.y, p.width, p.height, props.xOrigin, props.yOrigin, p.borderRadius)
|
|
61
41
|
}),
|
|
62
|
-
applyProps(element,
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
42
|
+
applyProps(element, {
|
|
43
|
+
d
|
|
44
|
+
}) {
|
|
45
|
+
if (d) {
|
|
46
|
+
element.setAttribute('d', d);
|
|
47
|
+
}
|
|
68
48
|
},
|
|
69
49
|
initialProps,
|
|
70
50
|
skip: props.skipAnimation,
|
|
71
51
|
ref: props.ref
|
|
72
52
|
});
|
|
73
53
|
}
|
|
74
|
-
function BarClipRect(props) {
|
|
75
|
-
const animatedProps = useAnimateBarClipRect(_extends({}, props, {
|
|
76
|
-
borderRadius: props.ownerState.borderRadius ?? 0
|
|
77
|
-
}));
|
|
78
|
-
return /*#__PURE__*/_jsx("rect", _extends({}, animatedProps));
|
|
79
|
-
}
|
|
80
54
|
/**
|
|
81
55
|
* @ignore - internal component.
|
|
82
56
|
*/
|
|
83
57
|
function BarClipPath(props) {
|
|
84
58
|
const {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
59
|
+
maskId,
|
|
60
|
+
x,
|
|
61
|
+
y,
|
|
62
|
+
width,
|
|
63
|
+
height,
|
|
64
|
+
skipAnimation
|
|
65
|
+
} = props;
|
|
66
|
+
const {
|
|
67
|
+
ref,
|
|
68
|
+
d
|
|
69
|
+
} = useAnimateBarClipPath({
|
|
70
|
+
layout: props.layout ?? 'vertical',
|
|
71
|
+
hasNegative: props.hasNegative,
|
|
72
|
+
hasPositive: props.hasPositive,
|
|
73
|
+
xOrigin: props.xOrigin,
|
|
74
|
+
yOrigin: props.yOrigin,
|
|
75
|
+
x,
|
|
76
|
+
y,
|
|
77
|
+
width,
|
|
78
|
+
height,
|
|
79
|
+
borderRadius: props.borderRadius ?? 0,
|
|
80
|
+
skipAnimation
|
|
81
|
+
});
|
|
93
82
|
if (!props.borderRadius || props.borderRadius <= 0) {
|
|
94
83
|
return null;
|
|
95
84
|
}
|
|
96
85
|
return /*#__PURE__*/_jsx("clipPath", {
|
|
97
86
|
id: maskId,
|
|
98
|
-
children: /*#__PURE__*/_jsx(
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
y: y,
|
|
102
|
-
width: width,
|
|
103
|
-
height: height,
|
|
104
|
-
skipAnimation: skipAnimation
|
|
87
|
+
children: /*#__PURE__*/_jsx("path", {
|
|
88
|
+
ref: ref,
|
|
89
|
+
d: d
|
|
105
90
|
})
|
|
106
91
|
});
|
|
107
92
|
}
|
|
93
|
+
function generateClipPath(hasNegative, hasPositive, layout, x, y, width, height, xOrigin, yOrigin, borderRadius) {
|
|
94
|
+
if (layout === 'vertical') {
|
|
95
|
+
if (hasPositive && hasNegative) {
|
|
96
|
+
const bR = Math.min(borderRadius, width / 2, height / 2);
|
|
97
|
+
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)}`;
|
|
98
|
+
}
|
|
99
|
+
const bR = Math.min(borderRadius, width / 2);
|
|
100
|
+
if (hasPositive) {
|
|
101
|
+
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`;
|
|
102
|
+
}
|
|
103
|
+
if (hasNegative) {
|
|
104
|
+
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`;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
if (layout === 'horizontal') {
|
|
108
|
+
if (hasPositive && hasNegative) {
|
|
109
|
+
const bR = Math.min(borderRadius, width / 2, height / 2);
|
|
110
|
+
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}`;
|
|
111
|
+
}
|
|
112
|
+
const bR = Math.min(borderRadius, height / 2);
|
|
113
|
+
if (hasPositive) {
|
|
114
|
+
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`;
|
|
115
|
+
}
|
|
116
|
+
if (hasNegative) {
|
|
117
|
+
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`;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
return undefined;
|
|
121
|
+
}
|
|
108
122
|
export { BarClipPath };
|
package/esm/BarChart/BarPlot.js
CHANGED
|
@@ -64,6 +64,8 @@ function BarPlot(props) {
|
|
|
64
64
|
id,
|
|
65
65
|
x,
|
|
66
66
|
y,
|
|
67
|
+
xOrigin,
|
|
68
|
+
yOrigin,
|
|
67
69
|
width,
|
|
68
70
|
height,
|
|
69
71
|
hasPositive,
|
|
@@ -78,6 +80,8 @@ function BarPlot(props) {
|
|
|
78
80
|
layout: layout,
|
|
79
81
|
x: x,
|
|
80
82
|
y: y,
|
|
83
|
+
xOrigin: xOrigin,
|
|
84
|
+
yOrigin: yOrigin,
|
|
81
85
|
width: width,
|
|
82
86
|
height: height,
|
|
83
87
|
skipAnimation: skipAnimation ?? false
|
|
@@ -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>;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { findMinMax } from "../../internals/findMinMax.js";
|
|
1
2
|
const createResult = (data, direction) => {
|
|
2
3
|
if (direction === 'x') {
|
|
3
4
|
return {
|
|
@@ -24,9 +25,7 @@ const getBaseExtremum = params => {
|
|
|
24
25
|
x: null,
|
|
25
26
|
y: null
|
|
26
27
|
}, i)) : axis.data;
|
|
27
|
-
|
|
28
|
-
const maxX = Math.max(...(data ?? []));
|
|
29
|
-
return [minX, maxX];
|
|
28
|
+
return findMinMax(data ?? []);
|
|
30
29
|
};
|
|
31
30
|
const getValueExtremum = direction => params => {
|
|
32
31
|
const {
|
|
@@ -2,7 +2,7 @@ import _extends from "@babel/runtime/helpers/esm/extends";
|
|
|
2
2
|
import { stack as d3Stack } from '@mui/x-charts-vendor/d3-shape';
|
|
3
3
|
import { warnOnce } from '@mui/x-internals/warning';
|
|
4
4
|
import { getStackingGroups } from "../../internals/stackSeries.js";
|
|
5
|
-
|
|
5
|
+
const barValueFormatter = v => v == null ? '' : v.toLocaleString();
|
|
6
6
|
const seriesProcessor = (params, dataset) => {
|
|
7
7
|
const {
|
|
8
8
|
seriesOrder,
|
|
@@ -46,7 +46,9 @@ const seriesProcessor = (params, dataset) => {
|
|
|
46
46
|
const dataKey = series[id].dataKey;
|
|
47
47
|
completedSeries[id] = _extends({
|
|
48
48
|
layout: 'vertical',
|
|
49
|
-
labelMarkType: 'square'
|
|
49
|
+
labelMarkType: 'square',
|
|
50
|
+
minBarSize: 0,
|
|
51
|
+
valueFormatter: series[id].valueFormatter ?? barValueFormatter
|
|
50
52
|
}, series[id], {
|
|
51
53
|
data: dataKey ? dataset.map(data => {
|
|
52
54
|
const value = data[dataKey];
|
|
@@ -67,7 +69,7 @@ const seriesProcessor = (params, dataset) => {
|
|
|
67
69
|
return {
|
|
68
70
|
seriesOrder,
|
|
69
71
|
stackingGroups,
|
|
70
|
-
series:
|
|
72
|
+
series: completedSeries
|
|
71
73
|
};
|
|
72
74
|
};
|
|
73
75
|
export 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
|
|
@@ -47,7 +47,8 @@ export function useBarPlotData(drawingArea, xAxes, yAxes) {
|
|
|
47
47
|
const {
|
|
48
48
|
stackedData,
|
|
49
49
|
data: currentSeriesData,
|
|
50
|
-
layout
|
|
50
|
+
layout,
|
|
51
|
+
minBarSize
|
|
51
52
|
} = series[seriesId];
|
|
52
53
|
const seriesDataPoints = baseScaleConfig.data.map((baseValue, dataIndex) => {
|
|
53
54
|
if (currentSeriesData[dataIndex] == null) {
|
|
@@ -58,16 +59,20 @@ export function useBarPlotData(drawingArea, xAxes, yAxes) {
|
|
|
58
59
|
const minValueCoord = Math.round(Math.min(...valueCoordinates));
|
|
59
60
|
const maxValueCoord = Math.round(Math.max(...valueCoordinates));
|
|
60
61
|
const stackId = series[seriesId].stack;
|
|
62
|
+
const {
|
|
63
|
+
barSize,
|
|
64
|
+
startCoordinate
|
|
65
|
+
} = getValueCoordinate(verticalLayout, minValueCoord, maxValueCoord, currentSeriesData[dataIndex], minBarSize);
|
|
61
66
|
const result = {
|
|
62
67
|
seriesId,
|
|
63
68
|
dataIndex,
|
|
64
69
|
layout,
|
|
65
|
-
x: verticalLayout ? xScale(baseValue) + barOffset :
|
|
66
|
-
y: verticalLayout ?
|
|
70
|
+
x: verticalLayout ? xScale(baseValue) + barOffset : startCoordinate,
|
|
71
|
+
y: verticalLayout ? startCoordinate : yScale(baseValue) + barOffset,
|
|
67
72
|
xOrigin: xScale(0) ?? 0,
|
|
68
73
|
yOrigin: yScale(0) ?? 0,
|
|
69
|
-
height: verticalLayout ?
|
|
70
|
-
width: verticalLayout ? barWidth :
|
|
74
|
+
height: verticalLayout ? barSize : barWidth,
|
|
75
|
+
width: verticalLayout ? barWidth : barSize,
|
|
71
76
|
color: colorGetter(dataIndex),
|
|
72
77
|
value: currentSeriesData[dataIndex],
|
|
73
78
|
maskId: `${chartId}_${stackId || seriesId}_${groupIndex}_${dataIndex}`
|
|
@@ -136,4 +141,26 @@ function getBandSize({
|
|
|
136
141
|
barWidth,
|
|
137
142
|
offset
|
|
138
143
|
};
|
|
144
|
+
}
|
|
145
|
+
function getValueCoordinate(isVertical, minValueCoord, maxValueCoord, baseValue, minBarSize) {
|
|
146
|
+
if (baseValue === 0 || baseValue == null) {
|
|
147
|
+
return {
|
|
148
|
+
barSize: 0,
|
|
149
|
+
startCoordinate: minValueCoord
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
const isSizeLessThanMin = maxValueCoord - minValueCoord < minBarSize;
|
|
153
|
+
const barSize = isSizeLessThanMin ? minBarSize : maxValueCoord - minValueCoord;
|
|
154
|
+
const isVerticalAndPositive = isVertical && baseValue >= 0;
|
|
155
|
+
const isHorizontalAndNegative = !isVertical && baseValue < 0;
|
|
156
|
+
if (isSizeLessThanMin && (isVerticalAndPositive || isHorizontalAndNegative)) {
|
|
157
|
+
return {
|
|
158
|
+
barSize,
|
|
159
|
+
startCoordinate: maxValueCoord - barSize
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
return {
|
|
163
|
+
barSize,
|
|
164
|
+
startCoordinate: minValueCoord
|
|
165
|
+
};
|
|
139
166
|
}
|