@mui/x-charts 6.0.0-alpha.13 → 6.0.0-alpha.15
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 +6 -3
- package/BarChart/BarChart.js +7 -10
- package/BarChart/BarElement.js +2 -4
- package/BarChart/formatter.js +1 -2
- package/BarChart/legend.js +1 -2
- package/CHANGELOG.md +165 -1
- package/ChartContainer/index.js +2 -3
- package/ChartsAxis/axisClasses.js +1 -2
- package/ChartsLegend/ChartsLegend.d.ts +43 -24
- package/ChartsLegend/ChartsLegend.js +186 -148
- package/ChartsLegend/chartsLegendClasses.js +1 -2
- package/ChartsLegend/utils.d.ts +1 -6
- package/ChartsSurface.js +5 -14
- package/ChartsTooltip/ChartsAxisTooltipContent.d.ts +1 -0
- package/ChartsTooltip/ChartsAxisTooltipContent.js +17 -8
- package/ChartsTooltip/ChartsItemTooltipContent.d.ts +3 -2
- package/ChartsTooltip/ChartsItemTooltipContent.js +16 -6
- package/ChartsTooltip/ChartsTooltip.d.ts +23 -0
- package/ChartsTooltip/ChartsTooltip.js +47 -13
- package/ChartsTooltip/ChartsTooltipTable.js +6 -11
- package/ChartsTooltip/tooltipClasses.js +1 -2
- package/ChartsXAxis/ChartsXAxis.js +48 -25
- package/ChartsYAxis/ChartsYAxis.js +47 -26
- package/LineChart/AreaElement.js +2 -4
- package/LineChart/LineChart.d.ts +6 -3
- package/LineChart/LineChart.js +11 -11
- package/LineChart/LineElement.js +2 -4
- package/LineChart/LineHighlightElement.js +1 -2
- package/LineChart/MarkElement.js +1 -2
- package/LineChart/formatter.js +1 -2
- package/LineChart/legend.js +1 -2
- package/PieChart/PieArc.d.ts +1 -0
- package/PieChart/PieArc.js +6 -4
- package/PieChart/PieArcLabel.js +1 -2
- package/PieChart/PieChart.d.ts +8 -4
- package/PieChart/PieChart.js +11 -10
- package/PieChart/PiePlot.d.ts +8 -0
- package/PieChart/PiePlot.js +21 -5
- package/PieChart/formatter.js +1 -2
- package/PieChart/legend.js +1 -2
- package/ResponsiveChartContainer/index.js +2 -3
- package/ScatterChart/ScatterChart.d.ts +6 -3
- package/ScatterChart/ScatterChart.js +7 -10
- package/ScatterChart/formatter.js +1 -2
- package/ScatterChart/legend.js +1 -2
- package/SparkLineChart/SparkLineChart.d.ts +3 -3
- package/SparkLineChart/SparkLineChart.js +7 -3
- package/colorPalettes/colorPalettes.js +6 -12
- package/constants.js +5 -8
- package/context/CartesianContextProvider.js +11 -12
- package/context/DrawingProvider.d.ts +2 -0
- package/context/DrawingProvider.js +4 -4
- package/context/HighlightProvider.js +1 -2
- package/context/InteractionProvider.js +1 -2
- package/context/SeriesContextProvider.js +1 -2
- package/esm/BarChart/BarChart.js +6 -8
- package/esm/ChartsLegend/ChartsLegend.js +184 -142
- package/esm/ChartsSurface.js +3 -11
- package/esm/ChartsTooltip/ChartsAxisTooltipContent.js +17 -8
- package/esm/ChartsTooltip/ChartsItemTooltipContent.js +15 -6
- package/esm/ChartsTooltip/ChartsTooltip.js +47 -12
- package/esm/ChartsXAxis/ChartsXAxis.js +47 -24
- package/esm/ChartsYAxis/ChartsYAxis.js +46 -25
- package/esm/LineChart/LineChart.js +10 -9
- package/esm/PieChart/PieArc.js +5 -2
- package/esm/PieChart/PieChart.js +11 -10
- package/esm/PieChart/PiePlot.js +17 -2
- package/esm/ScatterChart/ScatterChart.js +6 -8
- package/esm/SparkLineChart/SparkLineChart.js +6 -1
- package/esm/constants.js +1 -1
- package/esm/context/CartesianContextProvider.js +11 -11
- package/esm/context/DrawingProvider.js +2 -0
- package/esm/hooks/useChartDimensions.js +2 -0
- package/esm/hooks/useTicks.js +5 -5
- package/esm/internals/components/AxisSharedComponents.js +15 -70
- package/esm/internals/components/ChartsText.js +71 -0
- package/esm/internals/domUtils.js +113 -0
- package/hooks/useChartDimensions.d.ts +2 -0
- package/hooks/useChartDimensions.js +3 -2
- package/hooks/useTicks.d.ts +2 -3
- package/hooks/useTicks.js +7 -8
- package/index.js +1 -1
- package/internals/components/AxisSharedComponents.d.ts +0 -4
- package/internals/components/AxisSharedComponents.js +18 -78
- package/internals/components/ChartsText.d.ts +32 -0
- package/internals/components/ChartsText.js +81 -0
- package/internals/defaultizeValueFormatter.js +1 -2
- package/internals/domUtils.d.ts +14 -0
- package/internals/domUtils.js +122 -0
- package/internals/stackSeries.js +2 -4
- package/legacy/BarChart/BarChart.js +6 -8
- package/legacy/ChartsLegend/ChartsLegend.js +196 -140
- package/legacy/ChartsSurface.js +2 -11
- package/legacy/ChartsTooltip/ChartsAxisTooltipContent.js +17 -8
- package/legacy/ChartsTooltip/ChartsItemTooltipContent.js +15 -6
- package/legacy/ChartsTooltip/ChartsTooltip.js +50 -12
- package/legacy/ChartsXAxis/ChartsXAxis.js +47 -24
- package/legacy/ChartsYAxis/ChartsYAxis.js +46 -25
- package/legacy/LineChart/LineChart.js +10 -9
- package/legacy/PieChart/PieArc.js +4 -1
- package/legacy/PieChart/PieChart.js +11 -10
- package/legacy/PieChart/PiePlot.js +17 -2
- package/legacy/ScatterChart/ScatterChart.js +6 -8
- package/legacy/SparkLineChart/SparkLineChart.js +6 -1
- package/legacy/constants.js +1 -1
- package/legacy/context/CartesianContextProvider.js +11 -11
- package/legacy/context/DrawingProvider.js +2 -0
- package/legacy/hooks/useChartDimensions.js +2 -0
- package/legacy/hooks/useTicks.js +5 -5
- package/legacy/index.js +1 -1
- package/legacy/internals/components/AxisSharedComponents.js +9 -63
- package/legacy/internals/components/ChartsText.js +77 -0
- package/legacy/internals/domUtils.js +121 -0
- package/models/axis.d.ts +6 -5
- package/models/layout.d.ts +7 -6
- package/modern/BarChart/BarChart.js +6 -8
- package/modern/ChartsLegend/ChartsLegend.js +184 -142
- package/modern/ChartsSurface.js +3 -11
- package/modern/ChartsTooltip/ChartsAxisTooltipContent.js +17 -8
- package/modern/ChartsTooltip/ChartsItemTooltipContent.js +15 -6
- package/modern/ChartsTooltip/ChartsTooltip.js +46 -12
- package/modern/ChartsXAxis/ChartsXAxis.js +47 -24
- package/modern/ChartsYAxis/ChartsYAxis.js +46 -25
- package/modern/LineChart/LineChart.js +10 -9
- package/modern/PieChart/PieArc.js +5 -2
- package/modern/PieChart/PieChart.js +11 -10
- package/modern/PieChart/PiePlot.js +17 -2
- package/modern/ScatterChart/ScatterChart.js +6 -8
- package/modern/SparkLineChart/SparkLineChart.js +6 -1
- package/modern/constants.js +1 -1
- package/modern/context/CartesianContextProvider.js +11 -11
- package/modern/context/DrawingProvider.js +2 -0
- package/modern/hooks/useChartDimensions.js +2 -0
- package/modern/hooks/useTicks.js +5 -5
- package/modern/index.js +1 -1
- package/modern/internals/components/AxisSharedComponents.js +15 -70
- package/modern/internals/components/ChartsText.js +71 -0
- package/modern/internals/domUtils.js +113 -0
- package/package.json +3 -3
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
2
2
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
3
|
-
const _excluded = ["scale", "
|
|
3
|
+
const _excluded = ["scale", "tickNumber"];
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
|
+
import { useSlotProps } from '@mui/base/utils';
|
|
6
7
|
import { unstable_composeClasses as composeClasses } from '@mui/utils';
|
|
7
8
|
import { useThemeProps, useTheme } from '@mui/material/styles';
|
|
8
9
|
import { CartesianContext } from '../context/CartesianContextProvider';
|
|
9
10
|
import { DrawingContext } from '../context/DrawingProvider';
|
|
10
11
|
import useTicks from '../hooks/useTicks';
|
|
11
12
|
import { getAxisUtilityClass } from '../ChartsAxis/axisClasses';
|
|
12
|
-
import {
|
|
13
|
+
import { AxisRoot } from '../internals/components/AxisSharedComponents';
|
|
14
|
+
import { ChartsText } from '../internals/components/ChartsText';
|
|
13
15
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
16
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
15
17
|
const useUtilityClasses = ownerState => {
|
|
@@ -47,7 +49,7 @@ function ChartsXAxis(inProps) {
|
|
|
47
49
|
xAxis: {
|
|
48
50
|
[_props$axisId]: {
|
|
49
51
|
scale: xScale,
|
|
50
|
-
|
|
52
|
+
tickNumber
|
|
51
53
|
}
|
|
52
54
|
}
|
|
53
55
|
} = _React$useContext,
|
|
@@ -78,7 +80,7 @@ function ChartsXAxis(inProps) {
|
|
|
78
80
|
const tickSize = disableTicks ? 4 : tickSizeProp;
|
|
79
81
|
const xTicks = useTicks({
|
|
80
82
|
scale: xScale,
|
|
81
|
-
|
|
83
|
+
tickNumber,
|
|
82
84
|
valueFormatter
|
|
83
85
|
});
|
|
84
86
|
const positionSigne = position === 'bottom' ? 1 : -1;
|
|
@@ -86,10 +88,38 @@ function ChartsXAxis(inProps) {
|
|
|
86
88
|
x: left + width / 2,
|
|
87
89
|
y: positionSigne * (tickFontSize + tickSize + 10)
|
|
88
90
|
};
|
|
89
|
-
const Line = (_slots$axisLine = slots == null ? void 0 : slots.axisLine) != null ? _slots$axisLine :
|
|
90
|
-
const Tick = (_slots$axisTick = slots == null ? void 0 : slots.axisTick) != null ? _slots$axisTick :
|
|
91
|
-
const TickLabel = (_slots$axisTickLabel = slots == null ? void 0 : slots.axisTickLabel) != null ? _slots$axisTickLabel :
|
|
92
|
-
const Label = (_slots$axisLabel = slots == null ? void 0 : slots.axisLabel) != null ? _slots$axisLabel :
|
|
91
|
+
const Line = (_slots$axisLine = slots == null ? void 0 : slots.axisLine) != null ? _slots$axisLine : 'line';
|
|
92
|
+
const Tick = (_slots$axisTick = slots == null ? void 0 : slots.axisTick) != null ? _slots$axisTick : 'line';
|
|
93
|
+
const TickLabel = (_slots$axisTickLabel = slots == null ? void 0 : slots.axisTickLabel) != null ? _slots$axisTickLabel : ChartsText;
|
|
94
|
+
const Label = (_slots$axisLabel = slots == null ? void 0 : slots.axisLabel) != null ? _slots$axisLabel : ChartsText;
|
|
95
|
+
const axisTickLabelProps = useSlotProps({
|
|
96
|
+
elementType: TickLabel,
|
|
97
|
+
externalSlotProps: slotProps == null ? void 0 : slotProps.axisTickLabel,
|
|
98
|
+
additionalProps: {
|
|
99
|
+
textAnchor: 'middle',
|
|
100
|
+
dominantBaseline: position === 'bottom' ? 'hanging' : 'auto',
|
|
101
|
+
style: {
|
|
102
|
+
fontSize: tickFontSize
|
|
103
|
+
},
|
|
104
|
+
className: classes.tickLabel
|
|
105
|
+
},
|
|
106
|
+
className: classes.tickLabel,
|
|
107
|
+
ownerState: {}
|
|
108
|
+
});
|
|
109
|
+
const axisLabelProps = useSlotProps({
|
|
110
|
+
elementType: Label,
|
|
111
|
+
externalSlotProps: slotProps == null ? void 0 : slotProps.axisLabel,
|
|
112
|
+
additionalProps: {
|
|
113
|
+
textAnchor: 'middle',
|
|
114
|
+
dominantBaseline: position === 'bottom' ? 'hanging' : 'auto',
|
|
115
|
+
style: {
|
|
116
|
+
fontSize: labelFontSize,
|
|
117
|
+
transformOrigin: `${labelRefPoint.x}px ${labelRefPoint.y}px`
|
|
118
|
+
},
|
|
119
|
+
className: classes.label
|
|
120
|
+
},
|
|
121
|
+
ownerState: {}
|
|
122
|
+
});
|
|
93
123
|
return /*#__PURE__*/_jsxs(AxisRoot, {
|
|
94
124
|
transform: `translate(0, ${position === 'bottom' ? top + height : top})`,
|
|
95
125
|
className: classes.root,
|
|
@@ -113,24 +143,17 @@ function ChartsXAxis(inProps) {
|
|
|
113
143
|
}, slotProps == null ? void 0 : slotProps.axisTick)), formattedValue !== undefined && /*#__PURE__*/_jsx(TickLabel, _extends({
|
|
114
144
|
x: xTickLabel,
|
|
115
145
|
y: yTickLabel,
|
|
116
|
-
"transform-origin": `${xTickLabel}px ${yTickLabel}px
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
},
|
|
120
|
-
className: classes.tickLabel
|
|
121
|
-
}, slotProps == null ? void 0 : slotProps.axisTickLabel, {
|
|
122
|
-
children: formattedValue
|
|
146
|
+
"transform-origin": `${xTickLabel}px ${yTickLabel}px`
|
|
147
|
+
}, axisTickLabelProps, {
|
|
148
|
+
text: formattedValue.toString()
|
|
123
149
|
}))]
|
|
124
150
|
}, index);
|
|
125
|
-
}), label && /*#__PURE__*/_jsx(
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
}, slotProps == null ? void 0 : slotProps.axisLabel, {
|
|
132
|
-
children: label
|
|
133
|
-
}))]
|
|
151
|
+
}), label && /*#__PURE__*/_jsx("g", {
|
|
152
|
+
className: classes.label,
|
|
153
|
+
children: /*#__PURE__*/_jsx(Label, _extends({}, labelRefPoint, axisLabelProps, {
|
|
154
|
+
text: label
|
|
155
|
+
}))
|
|
156
|
+
})]
|
|
134
157
|
});
|
|
135
158
|
}
|
|
136
159
|
process.env.NODE_ENV !== "production" ? ChartsXAxis.propTypes = {
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
2
2
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
3
|
-
const _excluded = ["scale", "
|
|
3
|
+
const _excluded = ["scale", "tickNumber"];
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
|
+
import { useSlotProps } from '@mui/base/utils';
|
|
6
7
|
import { unstable_composeClasses as composeClasses } from '@mui/utils';
|
|
7
8
|
import { useThemeProps, useTheme } from '@mui/material/styles';
|
|
8
9
|
import { CartesianContext } from '../context/CartesianContextProvider';
|
|
9
10
|
import { DrawingContext } from '../context/DrawingProvider';
|
|
10
11
|
import useTicks from '../hooks/useTicks';
|
|
11
|
-
import {
|
|
12
|
+
import { AxisRoot } from '../internals/components/AxisSharedComponents';
|
|
13
|
+
import { ChartsText } from '../internals/components/ChartsText';
|
|
12
14
|
import { getAxisUtilityClass } from '../ChartsAxis/axisClasses';
|
|
13
15
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
16
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
@@ -47,7 +49,7 @@ function ChartsYAxis(inProps) {
|
|
|
47
49
|
yAxis: {
|
|
48
50
|
[_props$axisId]: {
|
|
49
51
|
scale: yScale,
|
|
50
|
-
|
|
52
|
+
tickNumber
|
|
51
53
|
}
|
|
52
54
|
}
|
|
53
55
|
} = _React$useContext,
|
|
@@ -78,7 +80,7 @@ function ChartsYAxis(inProps) {
|
|
|
78
80
|
const tickSize = disableTicks ? 4 : tickSizeProp;
|
|
79
81
|
const yTicks = useTicks({
|
|
80
82
|
scale: yScale,
|
|
81
|
-
|
|
83
|
+
tickNumber,
|
|
82
84
|
valueFormatter
|
|
83
85
|
});
|
|
84
86
|
const positionSigne = position === 'right' ? 1 : -1;
|
|
@@ -86,10 +88,38 @@ function ChartsYAxis(inProps) {
|
|
|
86
88
|
x: positionSigne * (tickFontSize + tickSize + 10),
|
|
87
89
|
y: top + height / 2
|
|
88
90
|
};
|
|
89
|
-
const Line = (_slots$axisLine = slots == null ? void 0 : slots.axisLine) != null ? _slots$axisLine :
|
|
90
|
-
const Tick = (_slots$axisTick = slots == null ? void 0 : slots.axisTick) != null ? _slots$axisTick :
|
|
91
|
-
const TickLabel = (_slots$axisTickLabel = slots == null ? void 0 : slots.axisTickLabel) != null ? _slots$axisTickLabel :
|
|
92
|
-
const Label = (_slots$axisLabel = slots == null ? void 0 : slots.axisLabel) != null ? _slots$axisLabel :
|
|
91
|
+
const Line = (_slots$axisLine = slots == null ? void 0 : slots.axisLine) != null ? _slots$axisLine : 'line';
|
|
92
|
+
const Tick = (_slots$axisTick = slots == null ? void 0 : slots.axisTick) != null ? _slots$axisTick : 'line';
|
|
93
|
+
const TickLabel = (_slots$axisTickLabel = slots == null ? void 0 : slots.axisTickLabel) != null ? _slots$axisTickLabel : ChartsText;
|
|
94
|
+
const Label = (_slots$axisLabel = slots == null ? void 0 : slots.axisLabel) != null ? _slots$axisLabel : ChartsText;
|
|
95
|
+
const axisTickLabelProps = useSlotProps({
|
|
96
|
+
elementType: TickLabel,
|
|
97
|
+
externalSlotProps: slotProps == null ? void 0 : slotProps.axisTickLabel,
|
|
98
|
+
additionalProps: {
|
|
99
|
+
textAnchor: position === 'right' ? 'start' : 'end',
|
|
100
|
+
dominantBaseline: 'central',
|
|
101
|
+
style: {
|
|
102
|
+
fontSize: tickFontSize
|
|
103
|
+
},
|
|
104
|
+
className: classes.tickLabel
|
|
105
|
+
},
|
|
106
|
+
ownerState: {}
|
|
107
|
+
});
|
|
108
|
+
const axisLabelProps = useSlotProps({
|
|
109
|
+
elementType: Label,
|
|
110
|
+
externalSlotProps: slotProps == null ? void 0 : slotProps.axisLabel,
|
|
111
|
+
additionalProps: {
|
|
112
|
+
textAnchor: 'middle',
|
|
113
|
+
dominantBaseline: 'auto',
|
|
114
|
+
style: {
|
|
115
|
+
fontSize: labelFontSize,
|
|
116
|
+
transform: `rotate(${positionSigne * 90}deg)`,
|
|
117
|
+
transformOrigin: `${labelRefPoint.x}px ${labelRefPoint.y}px`
|
|
118
|
+
},
|
|
119
|
+
className: classes.label
|
|
120
|
+
},
|
|
121
|
+
ownerState: {}
|
|
122
|
+
});
|
|
93
123
|
return /*#__PURE__*/_jsxs(AxisRoot, {
|
|
94
124
|
transform: `translate(${position === 'right' ? left + width : left}, 0)`,
|
|
95
125
|
className: classes.root,
|
|
@@ -114,24 +144,15 @@ function ChartsYAxis(inProps) {
|
|
|
114
144
|
x: xTickLabel,
|
|
115
145
|
y: yTickLabel,
|
|
116
146
|
"transform-origin": `${xTickLabel}px ${yTickLabel}px`,
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
},
|
|
120
|
-
className: classes.tickLabel
|
|
121
|
-
}, slotProps == null ? void 0 : slotProps.axisTickLabel, {
|
|
122
|
-
children: formattedValue.toLocaleString()
|
|
123
|
-
}))]
|
|
147
|
+
text: formattedValue.toString()
|
|
148
|
+
}, axisTickLabelProps))]
|
|
124
149
|
}, index);
|
|
125
|
-
}), label && /*#__PURE__*/_jsx(
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
className: classes.label
|
|
132
|
-
}, slotProps == null ? void 0 : slotProps.axisLabel, {
|
|
133
|
-
children: label
|
|
134
|
-
}))]
|
|
150
|
+
}), label && /*#__PURE__*/_jsx("g", {
|
|
151
|
+
className: classes.label,
|
|
152
|
+
children: /*#__PURE__*/_jsx(Label, _extends({}, labelRefPoint, axisLabelProps, {
|
|
153
|
+
text: label
|
|
154
|
+
}))
|
|
155
|
+
})]
|
|
135
156
|
});
|
|
136
157
|
}
|
|
137
158
|
process.env.NODE_ENV !== "production" ? ChartsYAxis.propTypes = {
|
|
@@ -91,7 +91,10 @@ const LineChart = /*#__PURE__*/React.forwardRef(function LineChart(props, ref) {
|
|
|
91
91
|
}), /*#__PURE__*/_jsx(ChartsLegend, _extends({}, legend, {
|
|
92
92
|
slots: slots,
|
|
93
93
|
slotProps: slotProps
|
|
94
|
-
})), /*#__PURE__*/_jsx(ChartsTooltip, _extends({}, tooltip
|
|
94
|
+
})), /*#__PURE__*/_jsx(ChartsTooltip, _extends({}, tooltip, {
|
|
95
|
+
slots: slots,
|
|
96
|
+
slotProps: slotProps
|
|
97
|
+
})), /*#__PURE__*/_jsx(ChartsClipPath, {
|
|
95
98
|
id: clipPathId
|
|
96
99
|
}), children]
|
|
97
100
|
});
|
|
@@ -165,23 +168,19 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
|
|
|
165
168
|
tickNumber: PropTypes.number,
|
|
166
169
|
tickSize: PropTypes.number
|
|
167
170
|
}), PropTypes.string]),
|
|
171
|
+
/**
|
|
172
|
+
* @deprecated Consider using `slotProps.legend` instead.
|
|
173
|
+
*/
|
|
168
174
|
legend: PropTypes.shape({
|
|
169
175
|
classes: PropTypes.object,
|
|
170
176
|
direction: PropTypes.oneOf(['column', 'row']),
|
|
171
177
|
hidden: PropTypes.bool,
|
|
172
|
-
itemWidth: PropTypes.number,
|
|
173
|
-
markSize: PropTypes.number,
|
|
174
|
-
offset: PropTypes.shape({
|
|
175
|
-
x: PropTypes.number,
|
|
176
|
-
y: PropTypes.number
|
|
177
|
-
}),
|
|
178
178
|
position: PropTypes.shape({
|
|
179
179
|
horizontal: PropTypes.oneOf(['left', 'middle', 'right']).isRequired,
|
|
180
180
|
vertical: PropTypes.oneOf(['bottom', 'middle', 'top']).isRequired
|
|
181
181
|
}),
|
|
182
182
|
slotProps: PropTypes.object,
|
|
183
|
-
slots: PropTypes.object
|
|
184
|
-
spacing: PropTypes.number
|
|
183
|
+
slots: PropTypes.object
|
|
185
184
|
}),
|
|
186
185
|
margin: PropTypes.shape({
|
|
187
186
|
bottom: PropTypes.number,
|
|
@@ -250,6 +249,8 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
|
|
|
250
249
|
axisContent: PropTypes.elementType,
|
|
251
250
|
classes: PropTypes.object,
|
|
252
251
|
itemContent: PropTypes.elementType,
|
|
252
|
+
slotProps: PropTypes.object,
|
|
253
|
+
slots: PropTypes.object,
|
|
253
254
|
trigger: PropTypes.oneOf(['axis', 'item', 'none'])
|
|
254
255
|
}),
|
|
255
256
|
/**
|
package/esm/PieChart/PieArc.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
|
-
const _excluded = ["id", "dataIndex", "classes", "color", "highlightScope", "innerRadius", "outerRadius", "cornerRadius", "highlighted", "faded"];
|
|
3
|
+
const _excluded = ["id", "dataIndex", "classes", "color", "highlightScope", "innerRadius", "outerRadius", "cornerRadius", "highlighted", "faded", "onClick"];
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import { arc as d3Arc } from 'd3-shape';
|
|
6
6
|
import PropTypes from 'prop-types';
|
|
@@ -55,7 +55,8 @@ export default function PieArc(props) {
|
|
|
55
55
|
highlighted,
|
|
56
56
|
faded = {
|
|
57
57
|
additionalRadius: -5
|
|
58
|
-
}
|
|
58
|
+
},
|
|
59
|
+
onClick
|
|
59
60
|
} = props,
|
|
60
61
|
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
61
62
|
const getInteractionItemProps = useInteractionItemProps(highlightScope);
|
|
@@ -92,6 +93,8 @@ export default function PieArc(props) {
|
|
|
92
93
|
innerRadius,
|
|
93
94
|
outerRadius
|
|
94
95
|
})),
|
|
96
|
+
onClick: onClick,
|
|
97
|
+
cursor: onClick ? 'pointer' : 'unset',
|
|
95
98
|
ownerState: ownerState,
|
|
96
99
|
className: classes.root
|
|
97
100
|
}, getInteractionItemProps({
|
package/esm/PieChart/PieChart.js
CHANGED
|
@@ -46,7 +46,8 @@ function PieChart(props) {
|
|
|
46
46
|
bottomAxis = null,
|
|
47
47
|
children,
|
|
48
48
|
slots,
|
|
49
|
-
slotProps
|
|
49
|
+
slotProps,
|
|
50
|
+
onClick
|
|
50
51
|
} = props;
|
|
51
52
|
const margin = _extends({}, defaultMargin, marginProps);
|
|
52
53
|
return /*#__PURE__*/_jsxs(ResponsiveChartContainer, {
|
|
@@ -74,7 +75,8 @@ function PieChart(props) {
|
|
|
74
75
|
slotProps: slotProps
|
|
75
76
|
}), /*#__PURE__*/_jsx(PiePlot, {
|
|
76
77
|
slots: slots,
|
|
77
|
-
slotProps: slotProps
|
|
78
|
+
slotProps: slotProps,
|
|
79
|
+
onClick: onClick
|
|
78
80
|
}), /*#__PURE__*/_jsx(ChartsLegend, _extends({}, legend, {
|
|
79
81
|
slots: slots,
|
|
80
82
|
slotProps: slotProps
|
|
@@ -146,23 +148,19 @@ process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
|
|
|
146
148
|
tickNumber: PropTypes.number,
|
|
147
149
|
tickSize: PropTypes.number
|
|
148
150
|
}), PropTypes.string]),
|
|
151
|
+
/**
|
|
152
|
+
* @deprecated Consider using `slotProps.legend` instead.
|
|
153
|
+
*/
|
|
149
154
|
legend: PropTypes.shape({
|
|
150
155
|
classes: PropTypes.object,
|
|
151
156
|
direction: PropTypes.oneOf(['column', 'row']),
|
|
152
157
|
hidden: PropTypes.bool,
|
|
153
|
-
itemWidth: PropTypes.number,
|
|
154
|
-
markSize: PropTypes.number,
|
|
155
|
-
offset: PropTypes.shape({
|
|
156
|
-
x: PropTypes.number,
|
|
157
|
-
y: PropTypes.number
|
|
158
|
-
}),
|
|
159
158
|
position: PropTypes.shape({
|
|
160
159
|
horizontal: PropTypes.oneOf(['left', 'middle', 'right']).isRequired,
|
|
161
160
|
vertical: PropTypes.oneOf(['bottom', 'middle', 'top']).isRequired
|
|
162
161
|
}),
|
|
163
162
|
slotProps: PropTypes.object,
|
|
164
|
-
slots: PropTypes.object
|
|
165
|
-
spacing: PropTypes.number
|
|
163
|
+
slots: PropTypes.object
|
|
166
164
|
}),
|
|
167
165
|
margin: PropTypes.shape({
|
|
168
166
|
bottom: PropTypes.number,
|
|
@@ -170,6 +168,7 @@ process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
|
|
|
170
168
|
right: PropTypes.number,
|
|
171
169
|
top: PropTypes.number
|
|
172
170
|
}),
|
|
171
|
+
onClick: PropTypes.func,
|
|
173
172
|
/**
|
|
174
173
|
* Indicate which axis to display the right of the charts.
|
|
175
174
|
* Can be a string (the id of the axis) or an object `ChartsYAxisProps`.
|
|
@@ -244,6 +243,8 @@ process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
|
|
|
244
243
|
axisContent: PropTypes.elementType,
|
|
245
244
|
classes: PropTypes.object,
|
|
246
245
|
itemContent: PropTypes.elementType,
|
|
246
|
+
slotProps: PropTypes.object,
|
|
247
|
+
slots: PropTypes.object,
|
|
247
248
|
trigger: PropTypes.oneOf(['axis', 'item', 'none'])
|
|
248
249
|
}),
|
|
249
250
|
/**
|
package/esm/PieChart/PiePlot.js
CHANGED
|
@@ -27,7 +27,8 @@ function PiePlot(props) {
|
|
|
27
27
|
var _slots$pieArc, _slots$pieArcLabel;
|
|
28
28
|
const {
|
|
29
29
|
slots,
|
|
30
|
-
slotProps
|
|
30
|
+
slotProps,
|
|
31
|
+
onClick
|
|
31
32
|
} = props;
|
|
32
33
|
const seriesData = React.useContext(SeriesContext).pie;
|
|
33
34
|
const {
|
|
@@ -78,7 +79,14 @@ function PiePlot(props) {
|
|
|
78
79
|
dataIndex: index,
|
|
79
80
|
highlightScope: series[seriesId].highlightScope,
|
|
80
81
|
highlighted: highlighted,
|
|
81
|
-
faded: faded
|
|
82
|
+
faded: faded,
|
|
83
|
+
onClick: onClick && (event => {
|
|
84
|
+
onClick(event, {
|
|
85
|
+
type: 'pie',
|
|
86
|
+
seriesId,
|
|
87
|
+
dataIndex: index
|
|
88
|
+
}, item);
|
|
89
|
+
})
|
|
82
90
|
}, slotProps == null ? void 0 : slotProps.pieArc));
|
|
83
91
|
}), data.map((item, index) => {
|
|
84
92
|
return /*#__PURE__*/_createElement(ArcLabel, _extends({}, item, {
|
|
@@ -103,6 +111,13 @@ process.env.NODE_ENV !== "production" ? PiePlot.propTypes = {
|
|
|
103
111
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
104
112
|
// | To update them edit the TypeScript types and run "yarn proptypes" |
|
|
105
113
|
// ----------------------------------------------------------------------
|
|
114
|
+
/**
|
|
115
|
+
* Callback fired when a pie item is clicked.
|
|
116
|
+
* @param {React.MouseEvent<SVGPathElement, MouseEvent>} event The event source of the callback.
|
|
117
|
+
* @param {PieItemIdentifier} pieItemIdentifier The pie item identifier.
|
|
118
|
+
* @param {DefaultizedPieValueType} item The pie item.
|
|
119
|
+
*/
|
|
120
|
+
onClick: PropTypes.func,
|
|
106
121
|
/**
|
|
107
122
|
* The props used for each component slot.
|
|
108
123
|
* @default {}
|
|
@@ -128,23 +128,19 @@ process.env.NODE_ENV !== "production" ? ScatterChart.propTypes = {
|
|
|
128
128
|
tickNumber: PropTypes.number,
|
|
129
129
|
tickSize: PropTypes.number
|
|
130
130
|
}), PropTypes.string]),
|
|
131
|
+
/**
|
|
132
|
+
* @deprecated Consider using `slotProps.legend` instead.
|
|
133
|
+
*/
|
|
131
134
|
legend: PropTypes.shape({
|
|
132
135
|
classes: PropTypes.object,
|
|
133
136
|
direction: PropTypes.oneOf(['column', 'row']),
|
|
134
137
|
hidden: PropTypes.bool,
|
|
135
|
-
itemWidth: PropTypes.number,
|
|
136
|
-
markSize: PropTypes.number,
|
|
137
|
-
offset: PropTypes.shape({
|
|
138
|
-
x: PropTypes.number,
|
|
139
|
-
y: PropTypes.number
|
|
140
|
-
}),
|
|
141
138
|
position: PropTypes.shape({
|
|
142
139
|
horizontal: PropTypes.oneOf(['left', 'middle', 'right']).isRequired,
|
|
143
140
|
vertical: PropTypes.oneOf(['bottom', 'middle', 'top']).isRequired
|
|
144
141
|
}),
|
|
145
142
|
slotProps: PropTypes.object,
|
|
146
|
-
slots: PropTypes.object
|
|
147
|
-
spacing: PropTypes.number
|
|
143
|
+
slots: PropTypes.object
|
|
148
144
|
}),
|
|
149
145
|
margin: PropTypes.shape({
|
|
150
146
|
bottom: PropTypes.number,
|
|
@@ -210,6 +206,8 @@ process.env.NODE_ENV !== "production" ? ScatterChart.propTypes = {
|
|
|
210
206
|
axisContent: PropTypes.elementType,
|
|
211
207
|
classes: PropTypes.object,
|
|
212
208
|
itemContent: PropTypes.elementType,
|
|
209
|
+
slotProps: PropTypes.object,
|
|
210
|
+
slots: PropTypes.object,
|
|
213
211
|
trigger: PropTypes.oneOf(['axis', 'item', 'none'])
|
|
214
212
|
}),
|
|
215
213
|
/**
|
|
@@ -84,7 +84,10 @@ const SparkLineChart = /*#__PURE__*/React.forwardRef(function SparkLineChart(pro
|
|
|
84
84
|
slots: slots,
|
|
85
85
|
slotProps: slotProps
|
|
86
86
|
})]
|
|
87
|
-
}), /*#__PURE__*/_jsx(ChartsAxisHighlight, _extends({}, axisHighlight)), showTooltip && /*#__PURE__*/_jsx(ChartsTooltip, _extends({}, tooltip
|
|
87
|
+
}), /*#__PURE__*/_jsx(ChartsAxisHighlight, _extends({}, axisHighlight)), showTooltip && /*#__PURE__*/_jsx(ChartsTooltip, _extends({}, tooltip, {
|
|
88
|
+
slotProps: slotProps,
|
|
89
|
+
slots: slots
|
|
90
|
+
})), children]
|
|
88
91
|
});
|
|
89
92
|
});
|
|
90
93
|
process.env.NODE_ENV !== "production" ? SparkLineChart.propTypes = {
|
|
@@ -159,6 +162,8 @@ process.env.NODE_ENV !== "production" ? SparkLineChart.propTypes = {
|
|
|
159
162
|
axisContent: PropTypes.elementType,
|
|
160
163
|
classes: PropTypes.object,
|
|
161
164
|
itemContent: PropTypes.elementType,
|
|
165
|
+
slotProps: PropTypes.object,
|
|
166
|
+
slots: PropTypes.object,
|
|
162
167
|
trigger: PropTypes.oneOf(['axis', 'item', 'none'])
|
|
163
168
|
}),
|
|
164
169
|
/**
|
package/esm/constants.js
CHANGED
|
@@ -10,7 +10,7 @@ import { getScale } from '../internals/getScale';
|
|
|
10
10
|
import { DrawingContext } from './DrawingProvider';
|
|
11
11
|
import { SeriesContext } from './SeriesContextProvider';
|
|
12
12
|
import { DEFAULT_X_AXIS_KEY, DEFAULT_Y_AXIS_KEY } from '../constants';
|
|
13
|
-
import {
|
|
13
|
+
import { getTickNumber } from '../hooks/useTicks';
|
|
14
14
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
15
15
|
const DEFAULT_CATEGORY_GAP_RATIO = 0.2;
|
|
16
16
|
const DEFAULT_BAR_GAP_RATIO = 0.1;
|
|
@@ -113,13 +113,13 @@ function CartesianContextProvider({
|
|
|
113
113
|
barGapRatio
|
|
114
114
|
}, axis, {
|
|
115
115
|
scale: scaleBand(axis.data, range).paddingInner(categoryGapRatio).paddingOuter(categoryGapRatio / 2),
|
|
116
|
-
|
|
116
|
+
tickNumber: axis.data.length
|
|
117
117
|
});
|
|
118
118
|
}
|
|
119
119
|
if (isPointScaleConfig(axis)) {
|
|
120
120
|
completedXAxis[axis.id] = _extends({}, axis, {
|
|
121
121
|
scale: scalePoint(axis.data, range),
|
|
122
|
-
|
|
122
|
+
tickNumber: axis.data.length
|
|
123
123
|
});
|
|
124
124
|
}
|
|
125
125
|
if (axis.scaleType === 'band' || axis.scaleType === 'point') {
|
|
@@ -128,17 +128,17 @@ function CartesianContextProvider({
|
|
|
128
128
|
}
|
|
129
129
|
const scaleType = (_axis$scaleType = axis.scaleType) != null ? _axis$scaleType : 'linear';
|
|
130
130
|
const extremums = [(_axis$min = axis.min) != null ? _axis$min : minData, (_axis$max = axis.max) != null ? _axis$max : maxData];
|
|
131
|
-
const
|
|
131
|
+
const tickNumber = getTickNumber(_extends({}, axis, {
|
|
132
132
|
range,
|
|
133
133
|
domain: extremums
|
|
134
134
|
}));
|
|
135
|
-
const niceScale = getScale(scaleType, extremums, range).nice(
|
|
135
|
+
const niceScale = getScale(scaleType, extremums, range).nice(tickNumber);
|
|
136
136
|
const niceDomain = niceScale.domain();
|
|
137
137
|
const domain = [(_axis$min2 = axis.min) != null ? _axis$min2 : niceDomain[0], (_axis$max2 = axis.max) != null ? _axis$max2 : niceDomain[1]];
|
|
138
138
|
completedXAxis[axis.id] = _extends({}, axis, {
|
|
139
139
|
scaleType,
|
|
140
140
|
scale: niceScale.domain(domain),
|
|
141
|
-
|
|
141
|
+
tickNumber
|
|
142
142
|
});
|
|
143
143
|
});
|
|
144
144
|
const allYAxis = [...((_yAxis$map = yAxis == null ? void 0 : yAxis.map((axis, index) => _extends({
|
|
@@ -163,13 +163,13 @@ function CartesianContextProvider({
|
|
|
163
163
|
barGapRatio: 0
|
|
164
164
|
}, axis, {
|
|
165
165
|
scale: scaleBand(axis.data, [range[1], range[0]]).paddingInner(categoryGapRatio).paddingOuter(categoryGapRatio / 2),
|
|
166
|
-
|
|
166
|
+
tickNumber: axis.data.length
|
|
167
167
|
});
|
|
168
168
|
}
|
|
169
169
|
if (isPointScaleConfig(axis)) {
|
|
170
170
|
completedYAxis[axis.id] = _extends({}, axis, {
|
|
171
171
|
scale: scalePoint(axis.data, [range[1], range[0]]),
|
|
172
|
-
|
|
172
|
+
tickNumber: axis.data.length
|
|
173
173
|
});
|
|
174
174
|
}
|
|
175
175
|
if (axis.scaleType === 'band' || axis.scaleType === 'point') {
|
|
@@ -178,17 +178,17 @@ function CartesianContextProvider({
|
|
|
178
178
|
}
|
|
179
179
|
const scaleType = (_axis$scaleType2 = axis.scaleType) != null ? _axis$scaleType2 : 'linear';
|
|
180
180
|
const extremums = [(_axis$min3 = axis.min) != null ? _axis$min3 : minData, (_axis$max3 = axis.max) != null ? _axis$max3 : maxData];
|
|
181
|
-
const
|
|
181
|
+
const tickNumber = getTickNumber(_extends({}, axis, {
|
|
182
182
|
range,
|
|
183
183
|
domain: extremums
|
|
184
184
|
}));
|
|
185
|
-
const niceScale = getScale(scaleType, extremums, range).nice(
|
|
185
|
+
const niceScale = getScale(scaleType, extremums, range).nice(tickNumber);
|
|
186
186
|
const niceDomain = niceScale.domain();
|
|
187
187
|
const domain = [(_axis$min4 = axis.min) != null ? _axis$min4 : niceDomain[0], (_axis$max4 = axis.max) != null ? _axis$max4 : niceDomain[1]];
|
|
188
188
|
completedYAxis[axis.id] = _extends({}, axis, {
|
|
189
189
|
scaleType,
|
|
190
190
|
scale: niceScale.domain(domain),
|
|
191
|
-
|
|
191
|
+
tickNumber
|
|
192
192
|
});
|
|
193
193
|
});
|
|
194
194
|
return {
|
|
@@ -6,6 +6,8 @@ const useChartDimensions = (width, height, margin) => {
|
|
|
6
6
|
const drawingArea = React.useMemo(() => ({
|
|
7
7
|
left: defaultizedMargin.left,
|
|
8
8
|
top: defaultizedMargin.top,
|
|
9
|
+
right: defaultizedMargin.right,
|
|
10
|
+
bottom: defaultizedMargin.bottom,
|
|
9
11
|
width: Math.max(0, width - defaultizedMargin.left - defaultizedMargin.right),
|
|
10
12
|
height: Math.max(0, height - defaultizedMargin.top - defaultizedMargin.bottom)
|
|
11
13
|
}), [width, height, defaultizedMargin.top, defaultizedMargin.bottom, defaultizedMargin.left, defaultizedMargin.right]);
|
package/esm/hooks/useTicks.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { isBandScale } from '../internals/isBandScale';
|
|
3
|
-
export function
|
|
3
|
+
export function getTickNumber(params) {
|
|
4
4
|
const {
|
|
5
5
|
tickMaxStep,
|
|
6
6
|
tickMinStep,
|
|
@@ -16,7 +16,7 @@ export function getTicksNumber(params) {
|
|
|
16
16
|
function useTicks(options) {
|
|
17
17
|
const {
|
|
18
18
|
scale,
|
|
19
|
-
|
|
19
|
+
tickNumber,
|
|
20
20
|
valueFormatter
|
|
21
21
|
} = options;
|
|
22
22
|
return React.useMemo(() => {
|
|
@@ -49,14 +49,14 @@ function useTicks(options) {
|
|
|
49
49
|
};
|
|
50
50
|
});
|
|
51
51
|
}
|
|
52
|
-
return scale.ticks(
|
|
52
|
+
return scale.ticks(tickNumber).map(value => {
|
|
53
53
|
var _valueFormatter3;
|
|
54
54
|
return {
|
|
55
|
-
formattedValue: (_valueFormatter3 = valueFormatter == null ? void 0 : valueFormatter(value)) != null ? _valueFormatter3 : scale.tickFormat(
|
|
55
|
+
formattedValue: (_valueFormatter3 = valueFormatter == null ? void 0 : valueFormatter(value)) != null ? _valueFormatter3 : scale.tickFormat(tickNumber)(value),
|
|
56
56
|
offset: scale(value),
|
|
57
57
|
labelOffset: 0
|
|
58
58
|
};
|
|
59
59
|
});
|
|
60
|
-
}, [
|
|
60
|
+
}, [tickNumber, scale, valueFormatter]);
|
|
61
61
|
}
|
|
62
62
|
export default useTicks;
|