@mui/x-charts 7.0.0-beta.2 → 7.0.0-beta.4
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 +21 -5
- package/BarChart/BarChart.js +27 -7
- package/CHANGELOG.md +298 -23
- package/ChartsGrid/ChartsGrid.d.ts +30 -0
- package/ChartsGrid/ChartsGrid.js +128 -0
- package/ChartsGrid/chartsGridClasses.d.ts +13 -0
- package/ChartsGrid/chartsGridClasses.js +14 -0
- package/ChartsGrid/index.d.ts +2 -0
- package/ChartsGrid/index.js +27 -0
- package/ChartsGrid/package.json +6 -0
- package/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +1 -1
- package/ChartsSurface.js +6 -4
- package/ChartsTooltip/utils.js +1 -1
- package/ChartsVoronoiHandler/ChartsVoronoiHandler.d.ts +0 -1
- package/ChartsVoronoiHandler/ChartsVoronoiHandler.js +1 -2
- package/ChartsXAxis/ChartsXAxis.js +3 -3
- package/ChartsYAxis/ChartsYAxis.js +3 -3
- package/Gauge/Gauge.d.ts +13 -0
- package/Gauge/Gauge.js +154 -0
- package/Gauge/GaugeContainer.d.ts +17 -0
- package/Gauge/GaugeContainer.js +214 -0
- package/Gauge/GaugeProvider.d.ts +117 -0
- package/Gauge/GaugeProvider.js +99 -0
- package/Gauge/GaugeReferenceArc.d.ts +2 -0
- package/Gauge/GaugeReferenceArc.js +44 -0
- package/Gauge/GaugeValueArc.d.ts +2 -0
- package/Gauge/GaugeValueArc.js +51 -0
- package/Gauge/GaugeValueText.d.ts +15 -0
- package/Gauge/GaugeValueText.js +77 -0
- package/Gauge/gaugeClasses.d.ts +14 -0
- package/Gauge/gaugeClasses.js +15 -0
- package/Gauge/index.d.ts +7 -0
- package/Gauge/index.js +87 -0
- package/Gauge/package.json +6 -0
- package/Gauge/utils.d.ts +19 -0
- package/Gauge/utils.js +75 -0
- package/LineChart/LineChart.d.ts +24 -5
- package/LineChart/LineChart.js +31 -7
- package/PieChart/PieArc.d.ts +4 -4
- package/PieChart/PieArc.js +9 -9
- package/PieChart/PieArcLabelPlot.js +13 -13
- package/PieChart/PieChart.d.ts +22 -0
- package/PieChart/PieChart.js +22 -2
- package/ResponsiveChartContainer/ResponsiveChartContainer.d.ts +0 -2
- package/ResponsiveChartContainer/ResponsiveChartContainer.js +2 -68
- package/ResponsiveChartContainer/useChartContainerDimensions.d.ts +2 -0
- package/ResponsiveChartContainer/useChartContainerDimensions.js +76 -0
- package/ScatterChart/ScatterChart.d.ts +18 -0
- package/ScatterChart/ScatterChart.js +25 -3
- package/SparkLineChart/SparkLineChart.js +0 -2
- package/context/CartesianContextProvider.d.ts +0 -8
- package/context/CartesianContextProvider.js +4 -89
- package/context/DrawingProvider.d.ts +2 -11
- package/context/DrawingProvider.js +10 -35
- package/context/HighlightProvider.js +3 -0
- package/context/InteractionProvider.js +3 -0
- package/context/SeriesContextProvider.js +3 -0
- package/context/index.d.ts +0 -2
- package/context/index.js +1 -15
- package/esm/BarChart/BarChart.js +27 -7
- package/esm/ChartsGrid/ChartsGrid.js +121 -0
- package/esm/ChartsGrid/chartsGridClasses.js +6 -0
- package/esm/ChartsGrid/index.js +2 -0
- package/esm/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +2 -2
- package/esm/ChartsSurface.js +6 -4
- package/esm/ChartsTooltip/utils.js +2 -2
- package/esm/ChartsVoronoiHandler/ChartsVoronoiHandler.js +2 -3
- package/esm/ChartsXAxis/ChartsXAxis.js +2 -2
- package/esm/ChartsYAxis/ChartsYAxis.js +2 -2
- package/esm/Gauge/Gauge.js +147 -0
- package/esm/Gauge/GaugeContainer.js +209 -0
- package/esm/Gauge/GaugeProvider.js +88 -0
- package/esm/Gauge/GaugeReferenceArc.js +35 -0
- package/esm/Gauge/GaugeValueArc.js +42 -0
- package/esm/Gauge/GaugeValueText.js +69 -0
- package/esm/Gauge/gaugeClasses.js +7 -0
- package/esm/Gauge/index.js +7 -0
- package/esm/Gauge/utils.js +68 -0
- package/esm/LineChart/LineChart.js +31 -7
- package/esm/PieChart/PieArc.js +9 -9
- package/esm/PieChart/PieArcLabelPlot.js +13 -13
- package/esm/PieChart/PieChart.js +22 -2
- package/esm/ResponsiveChartContainer/ResponsiveChartContainer.js +2 -68
- package/esm/ResponsiveChartContainer/useChartContainerDimensions.js +66 -0
- package/esm/ScatterChart/ScatterChart.js +25 -3
- package/esm/SparkLineChart/SparkLineChart.js +0 -2
- package/esm/context/CartesianContextProvider.js +3 -88
- package/esm/context/DrawingProvider.js +10 -36
- package/esm/context/HighlightProvider.js +3 -0
- package/esm/context/InteractionProvider.js +3 -0
- package/esm/context/SeriesContextProvider.js +3 -0
- package/esm/context/index.js +1 -2
- package/esm/hooks/useAxisEvents.js +2 -2
- package/esm/hooks/useTicks.js +2 -3
- package/esm/index.js +2 -0
- package/hooks/useAxisEvents.js +1 -1
- package/hooks/useTicks.d.ts +2 -3
- package/hooks/useTicks.js +2 -3
- package/index.d.ts +2 -0
- package/index.js +23 -1
- package/modern/BarChart/BarChart.js +27 -7
- package/modern/ChartsGrid/ChartsGrid.js +121 -0
- package/modern/ChartsGrid/chartsGridClasses.js +6 -0
- package/modern/ChartsGrid/index.js +2 -0
- package/modern/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +2 -2
- package/modern/ChartsSurface.js +6 -4
- package/modern/ChartsTooltip/utils.js +2 -2
- package/modern/ChartsVoronoiHandler/ChartsVoronoiHandler.js +2 -3
- package/modern/ChartsXAxis/ChartsXAxis.js +2 -2
- package/modern/ChartsYAxis/ChartsYAxis.js +2 -2
- package/modern/Gauge/Gauge.js +147 -0
- package/modern/Gauge/GaugeContainer.js +206 -0
- package/modern/Gauge/GaugeProvider.js +88 -0
- package/modern/Gauge/GaugeReferenceArc.js +35 -0
- package/modern/Gauge/GaugeValueArc.js +42 -0
- package/modern/Gauge/GaugeValueText.js +69 -0
- package/modern/Gauge/gaugeClasses.js +7 -0
- package/modern/Gauge/index.js +7 -0
- package/modern/Gauge/utils.js +68 -0
- package/modern/LineChart/LineChart.js +31 -7
- package/modern/PieChart/PieArc.js +9 -9
- package/modern/PieChart/PieArcLabelPlot.js +13 -13
- package/modern/PieChart/PieChart.js +22 -2
- package/modern/ResponsiveChartContainer/ResponsiveChartContainer.js +2 -68
- package/modern/ResponsiveChartContainer/useChartContainerDimensions.js +66 -0
- package/modern/ScatterChart/ScatterChart.js +25 -3
- package/modern/SparkLineChart/SparkLineChart.js +0 -2
- package/modern/context/CartesianContextProvider.js +3 -88
- package/modern/context/DrawingProvider.js +10 -36
- package/modern/context/HighlightProvider.js +3 -0
- package/modern/context/InteractionProvider.js +3 -0
- package/modern/context/SeriesContextProvider.js +3 -0
- package/modern/context/index.js +1 -2
- package/modern/hooks/useAxisEvents.js +2 -2
- package/modern/hooks/useTicks.js +2 -3
- package/modern/index.js +3 -1
- package/package.json +4 -4
- package/legacy/BarChart/BarChart.js +0 -418
- package/legacy/BarChart/BarElement.js +0 -119
- package/legacy/BarChart/BarPlot.js +0 -232
- package/legacy/BarChart/extremums.js +0 -45
- package/legacy/BarChart/formatter.js +0 -78
- package/legacy/BarChart/index.js +0 -3
- package/legacy/BarChart/legend.js +0 -15
- package/legacy/ChartContainer/ChartContainer.js +0 -189
- package/legacy/ChartContainer/index.js +0 -1
- package/legacy/ChartsAxis/ChartsAxis.js +0 -215
- package/legacy/ChartsAxis/axisClasses.js +0 -5
- package/legacy/ChartsAxis/index.js +0 -2
- package/legacy/ChartsAxisHighlight/ChartsAxisHighlight.js +0 -105
- package/legacy/ChartsAxisHighlight/index.js +0 -1
- package/legacy/ChartsClipPath/ChartsClipPath.js +0 -48
- package/legacy/ChartsClipPath/index.js +0 -1
- package/legacy/ChartsLegend/ChartsLegend.js +0 -100
- package/legacy/ChartsLegend/DefaultChartsLegend.js +0 -302
- package/legacy/ChartsLegend/chartsLegendClasses.js +0 -5
- package/legacy/ChartsLegend/index.js +0 -4
- package/legacy/ChartsLegend/utils.js +0 -15
- package/legacy/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +0 -75
- package/legacy/ChartsOnAxisClickHandler/index.js +0 -1
- package/legacy/ChartsReferenceLine/ChartsReferenceLine.js +0 -72
- package/legacy/ChartsReferenceLine/ChartsXReferenceLine.js +0 -105
- package/legacy/ChartsReferenceLine/ChartsYReferenceLine.js +0 -105
- package/legacy/ChartsReferenceLine/chartsReferenceLineClasses.js +0 -6
- package/legacy/ChartsReferenceLine/common.js +0 -19
- package/legacy/ChartsReferenceLine/index.js +0 -2
- package/legacy/ChartsSurface.js +0 -76
- package/legacy/ChartsText/ChartsText.js +0 -95
- package/legacy/ChartsText/index.js +0 -1
- package/legacy/ChartsTooltip/ChartsAxisTooltipContent.js +0 -96
- package/legacy/ChartsTooltip/ChartsItemTooltipContent.js +0 -53
- package/legacy/ChartsTooltip/ChartsTooltip.js +0 -148
- package/legacy/ChartsTooltip/ChartsTooltipTable.js +0 -80
- package/legacy/ChartsTooltip/DefaultChartsAxisTooltipContent.js +0 -118
- package/legacy/ChartsTooltip/DefaultChartsItemTooltipContent.js +0 -78
- package/legacy/ChartsTooltip/chartsTooltipClasses.js +0 -5
- package/legacy/ChartsTooltip/index.js +0 -6
- package/legacy/ChartsTooltip/utils.js +0 -103
- package/legacy/ChartsVoronoiHandler/ChartsVoronoiHandler.js +0 -206
- package/legacy/ChartsVoronoiHandler/index.js +0 -1
- package/legacy/ChartsXAxis/ChartsXAxis.js +0 -339
- package/legacy/ChartsXAxis/index.js +0 -1
- package/legacy/ChartsYAxis/ChartsYAxis.js +0 -267
- package/legacy/ChartsYAxis/index.js +0 -1
- package/legacy/LineChart/AnimatedArea.js +0 -102
- package/legacy/LineChart/AnimatedLine.js +0 -104
- package/legacy/LineChart/AreaElement.js +0 -112
- package/legacy/LineChart/AreaPlot.js +0 -149
- package/legacy/LineChart/LineChart.js +0 -426
- package/legacy/LineChart/LineElement.js +0 -112
- package/legacy/LineChart/LineHighlightElement.js +0 -79
- package/legacy/LineChart/LineHighlightPlot.js +0 -97
- package/legacy/LineChart/LinePlot.js +0 -144
- package/legacy/LineChart/MarkElement.js +0 -153
- package/legacy/LineChart/MarkPlot.js +0 -178
- package/legacy/LineChart/extremums.js +0 -54
- package/legacy/LineChart/formatter.js +0 -82
- package/legacy/LineChart/index.js +0 -11
- package/legacy/LineChart/legend.js +0 -15
- package/legacy/PieChart/PieArc.js +0 -103
- package/legacy/PieChart/PieArcLabel.js +0 -112
- package/legacy/PieChart/PieArcLabelPlot.js +0 -193
- package/legacy/PieChart/PieArcPlot.js +0 -180
- package/legacy/PieChart/PieChart.js +0 -382
- package/legacy/PieChart/PiePlot.js +0 -137
- package/legacy/PieChart/dataTransform/transition.js +0 -149
- package/legacy/PieChart/dataTransform/useTransformData.js +0 -63
- package/legacy/PieChart/formatter.js +0 -55
- package/legacy/PieChart/index.js +0 -6
- package/legacy/PieChart/legend.js +0 -16
- package/legacy/ResponsiveChartContainer/ResponsiveChartContainer.js +0 -255
- package/legacy/ResponsiveChartContainer/index.js +0 -1
- package/legacy/ScatterChart/Scatter.js +0 -110
- package/legacy/ScatterChart/ScatterChart.js +0 -370
- package/legacy/ScatterChart/ScatterPlot.js +0 -80
- package/legacy/ScatterChart/extremums.js +0 -39
- package/legacy/ScatterChart/formatter.js +0 -12
- package/legacy/ScatterChart/index.js +0 -3
- package/legacy/ScatterChart/legend.js +0 -15
- package/legacy/SparkLineChart/SparkLineChart.js +0 -266
- package/legacy/SparkLineChart/index.js +0 -1
- package/legacy/colorPalettes/colorPalettes.js +0 -15
- package/legacy/colorPalettes/index.js +0 -1
- package/legacy/constants.js +0 -8
- package/legacy/context/CartesianContextProvider.js +0 -327
- package/legacy/context/DrawingProvider.js +0 -74
- package/legacy/context/HighlightProvider.js +0 -56
- package/legacy/context/InteractionProvider.js +0 -81
- package/legacy/context/SeriesContextProvider.js +0 -74
- package/legacy/context/index.js +0 -2
- package/legacy/hooks/index.js +0 -2
- package/legacy/hooks/useAxisEvents.js +0 -120
- package/legacy/hooks/useChartDimensions.js +0 -18
- package/legacy/hooks/useDrawingArea.js +0 -21
- package/legacy/hooks/useInteractionItemProps.js +0 -71
- package/legacy/hooks/useMounted.js +0 -21
- package/legacy/hooks/useReducedMotion.js +0 -27
- package/legacy/hooks/useScale.js +0 -33
- package/legacy/hooks/useTicks.js +0 -66
- package/legacy/index.js +0 -31
- package/legacy/internals/components/AxisSharedComponents.js +0 -25
- package/legacy/internals/defaultizeColor.js +0 -17
- package/legacy/internals/defaultizeValueFormatter.js +0 -12
- package/legacy/internals/domUtils.js +0 -121
- package/legacy/internals/geometry.js +0 -37
- package/legacy/internals/getCurve.js +0 -39
- package/legacy/internals/getScale.js +0 -17
- package/legacy/internals/getWordsByLines.js +0 -15
- package/legacy/internals/isBandScale.js +0 -3
- package/legacy/internals/stackSeries.js +0 -92
- package/legacy/internals/useAnimatedPath.js +0 -32
- package/legacy/internals/utils.js +0 -52
- package/legacy/models/axis.js +0 -6
- package/legacy/models/helpers.js +0 -1
- package/legacy/models/index.js +0 -4
- package/legacy/models/layout.js +0 -1
- package/legacy/models/seriesType/bar.js +0 -1
- package/legacy/models/seriesType/common.js +0 -1
- package/legacy/models/seriesType/config.js +0 -1
- package/legacy/models/seriesType/index.js +0 -5
- package/legacy/models/seriesType/line.js +0 -1
- package/legacy/models/seriesType/pie.js +0 -1
- package/legacy/models/seriesType/scatter.js +0 -1
- package/legacy/models/stacking.js +0 -1
- package/legacy/themeAugmentation/index.js +0 -3
|
@@ -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 = ["
|
|
3
|
+
const _excluded = ["arcLabel", "arcLabelMinAngle", "arcLabelRadius", "cornerRadius", "data", "faded", "highlighted", "highlightScope", "id", "innerRadius", "outerRadius", "paddingAngle", "skipAnimation", "slotProps", "slots"],
|
|
4
4
|
_excluded2 = ["startAngle", "endAngle", "paddingAngle", "innerRadius", "outerRadius", "arcLabelRadius", "cornerRadius"];
|
|
5
5
|
import * as React from 'react';
|
|
6
6
|
import PropTypes from 'prop-types';
|
|
@@ -27,23 +27,23 @@ function getItemLabel(arcLabel, arcLabelMinAngle, item) {
|
|
|
27
27
|
function PieArcLabelPlot(props) {
|
|
28
28
|
var _slots$pieArcLabel;
|
|
29
29
|
const {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
innerRadius,
|
|
33
|
-
outerRadius,
|
|
30
|
+
arcLabel,
|
|
31
|
+
arcLabelMinAngle = 0,
|
|
34
32
|
arcLabelRadius,
|
|
35
33
|
cornerRadius = 0,
|
|
36
|
-
|
|
37
|
-
id,
|
|
38
|
-
highlightScope,
|
|
39
|
-
highlighted,
|
|
34
|
+
data,
|
|
40
35
|
faded = {
|
|
41
36
|
additionalRadius: -5
|
|
42
37
|
},
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
38
|
+
highlighted,
|
|
39
|
+
highlightScope,
|
|
40
|
+
id,
|
|
41
|
+
innerRadius,
|
|
42
|
+
outerRadius,
|
|
43
|
+
paddingAngle = 0,
|
|
44
|
+
skipAnimation,
|
|
45
|
+
slotProps,
|
|
46
|
+
slots
|
|
47
47
|
} = props,
|
|
48
48
|
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
49
49
|
const transformedData = useTransformData({
|
package/esm/PieChart/PieChart.js
CHANGED
|
@@ -101,6 +101,11 @@ process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
|
|
|
101
101
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
102
102
|
// | To update them edit the TypeScript types and run "yarn proptypes" |
|
|
103
103
|
// ----------------------------------------------------------------------
|
|
104
|
+
/**
|
|
105
|
+
* The configuration of axes highlight.
|
|
106
|
+
* @see See {@link https://mui.com/x/react-charts/tooltip/#highlights highlight docs} for more details.
|
|
107
|
+
* @default { x: 'none', y: 'none' }
|
|
108
|
+
*/
|
|
104
109
|
axisHighlight: PropTypes.shape({
|
|
105
110
|
x: PropTypes.oneOf(['band', 'line', 'none']),
|
|
106
111
|
y: PropTypes.oneOf(['band', 'line', 'none'])
|
|
@@ -152,7 +157,6 @@ process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
|
|
|
152
157
|
disableAxisListener: PropTypes.bool,
|
|
153
158
|
/**
|
|
154
159
|
* The height of the chart in px. If not defined, it takes the height of the parent element.
|
|
155
|
-
* @default undefined
|
|
156
160
|
*/
|
|
157
161
|
height: PropTypes.number,
|
|
158
162
|
/**
|
|
@@ -183,6 +187,8 @@ process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
|
|
|
183
187
|
tickSize: PropTypes.number
|
|
184
188
|
}), PropTypes.string]),
|
|
185
189
|
/**
|
|
190
|
+
* The props of the legend.
|
|
191
|
+
* @default { direction: 'column', position: { vertical: 'middle', horizontal: 'right' } }
|
|
186
192
|
* @deprecated Consider using `slotProps.legend` instead.
|
|
187
193
|
*/
|
|
188
194
|
legend: PropTypes.shape({
|
|
@@ -208,6 +214,9 @@ process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
|
|
|
208
214
|
right: PropTypes.number,
|
|
209
215
|
top: PropTypes.number
|
|
210
216
|
}),
|
|
217
|
+
/**
|
|
218
|
+
* Callback fired when a pie arc is clicked.
|
|
219
|
+
*/
|
|
211
220
|
onItemClick: PropTypes.func,
|
|
212
221
|
/**
|
|
213
222
|
* Indicate which axis to display the right of the charts.
|
|
@@ -236,6 +245,9 @@ process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
|
|
|
236
245
|
tickNumber: PropTypes.number,
|
|
237
246
|
tickSize: PropTypes.number
|
|
238
247
|
}), PropTypes.string]),
|
|
248
|
+
/**
|
|
249
|
+
* The series to display in the pie chart.
|
|
250
|
+
*/
|
|
239
251
|
series: PropTypes.arrayOf(PropTypes.object).isRequired,
|
|
240
252
|
/**
|
|
241
253
|
* If `true`, animations are skipped.
|
|
@@ -247,9 +259,18 @@ process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
|
|
|
247
259
|
* @default {}
|
|
248
260
|
*/
|
|
249
261
|
slotProps: PropTypes.object,
|
|
262
|
+
/**
|
|
263
|
+
* Overridable component slots.
|
|
264
|
+
* @default {}
|
|
265
|
+
*/
|
|
250
266
|
slots: PropTypes.object,
|
|
251
267
|
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
|
|
252
268
|
title: PropTypes.string,
|
|
269
|
+
/**
|
|
270
|
+
* The configuration of the tooltip.
|
|
271
|
+
* @see See {@link https://mui.com/x/react-charts/tooltip/ tooltip docs} for more details.
|
|
272
|
+
* @default { trigger: 'item' }
|
|
273
|
+
*/
|
|
253
274
|
tooltip: PropTypes.shape({
|
|
254
275
|
axisContent: PropTypes.elementType,
|
|
255
276
|
classes: PropTypes.object,
|
|
@@ -293,7 +314,6 @@ process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
|
|
|
293
314
|
}),
|
|
294
315
|
/**
|
|
295
316
|
* The width of the chart in px. If not defined, it takes the width of the parent element.
|
|
296
|
-
* @default undefined
|
|
297
317
|
*/
|
|
298
318
|
width: PropTypes.number,
|
|
299
319
|
/**
|
|
@@ -3,74 +3,10 @@ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWith
|
|
|
3
3
|
const _excluded = ["width", "height"];
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
|
-
import useEnhancedEffect from '@mui/utils/useEnhancedEffect';
|
|
7
|
-
import ownerWindow from '@mui/utils/ownerWindow';
|
|
8
6
|
import { styled } from '@mui/material/styles';
|
|
9
7
|
import { ChartContainer } from '../ChartContainer';
|
|
8
|
+
import { useChartContainerDimensions } from './useChartContainerDimensions';
|
|
10
9
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
|
-
const useChartDimensions = (inWidth, inHeight) => {
|
|
12
|
-
const rootRef = React.useRef(null);
|
|
13
|
-
const displayError = React.useRef(false);
|
|
14
|
-
const [width, setWidth] = React.useState(0);
|
|
15
|
-
const [height, setHeight] = React.useState(0);
|
|
16
|
-
|
|
17
|
-
// Adaptation of the `computeSizeAndPublishResizeEvent` from the grid.
|
|
18
|
-
const computeSize = React.useCallback(() => {
|
|
19
|
-
const mainEl = rootRef == null ? void 0 : rootRef.current;
|
|
20
|
-
if (!mainEl) {
|
|
21
|
-
return;
|
|
22
|
-
}
|
|
23
|
-
const win = ownerWindow(mainEl);
|
|
24
|
-
const computedStyle = win.getComputedStyle(mainEl);
|
|
25
|
-
const newHeight = Math.floor(parseFloat(computedStyle.height)) || 0;
|
|
26
|
-
const newWidth = Math.floor(parseFloat(computedStyle.width)) || 0;
|
|
27
|
-
setWidth(newWidth);
|
|
28
|
-
setHeight(newHeight);
|
|
29
|
-
}, []);
|
|
30
|
-
React.useEffect(() => {
|
|
31
|
-
// Ensure the error detection occurs after the first rendering.
|
|
32
|
-
displayError.current = true;
|
|
33
|
-
}, []);
|
|
34
|
-
useEnhancedEffect(() => {
|
|
35
|
-
if (inWidth !== undefined && inHeight !== undefined) {
|
|
36
|
-
return () => {};
|
|
37
|
-
}
|
|
38
|
-
computeSize();
|
|
39
|
-
const elementToObserve = rootRef.current;
|
|
40
|
-
if (typeof ResizeObserver === 'undefined') {
|
|
41
|
-
return () => {};
|
|
42
|
-
}
|
|
43
|
-
let animationFrame;
|
|
44
|
-
const observer = new ResizeObserver(() => {
|
|
45
|
-
// See https://github.com/mui/mui-x/issues/8733
|
|
46
|
-
animationFrame = requestAnimationFrame(() => {
|
|
47
|
-
computeSize();
|
|
48
|
-
});
|
|
49
|
-
});
|
|
50
|
-
if (elementToObserve) {
|
|
51
|
-
observer.observe(elementToObserve);
|
|
52
|
-
}
|
|
53
|
-
return () => {
|
|
54
|
-
if (animationFrame) {
|
|
55
|
-
window.cancelAnimationFrame(animationFrame);
|
|
56
|
-
}
|
|
57
|
-
if (elementToObserve) {
|
|
58
|
-
observer.unobserve(elementToObserve);
|
|
59
|
-
}
|
|
60
|
-
};
|
|
61
|
-
}, [computeSize, inHeight, inWidth]);
|
|
62
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
63
|
-
if (displayError.current && inWidth === undefined && width === 0) {
|
|
64
|
-
console.error(`MUI X Charts: ChartContainer does not have \`width\` prop, and its container has no \`width\` defined.`);
|
|
65
|
-
displayError.current = false;
|
|
66
|
-
}
|
|
67
|
-
if (displayError.current && inHeight === undefined && height === 0) {
|
|
68
|
-
console.error(`MUI X Charts: ChartContainer does not have \`height\` prop, and its container has no \`height\` defined.`);
|
|
69
|
-
displayError.current = false;
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
return [rootRef, inWidth != null ? inWidth : width, inHeight != null ? inHeight : height];
|
|
73
|
-
};
|
|
74
10
|
const ResizableContainer = styled('div', {
|
|
75
11
|
name: 'MuiResponsiveChart',
|
|
76
12
|
slot: 'Container'
|
|
@@ -100,7 +36,7 @@ const ResponsiveChartContainer = /*#__PURE__*/React.forwardRef(function Responsi
|
|
|
100
36
|
height: inHeight
|
|
101
37
|
} = props,
|
|
102
38
|
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
103
|
-
const [containerRef, width, height] =
|
|
39
|
+
const [containerRef, width, height] = useChartContainerDimensions(inWidth, inHeight);
|
|
104
40
|
return /*#__PURE__*/_jsx(ResizableContainer, {
|
|
105
41
|
ref: containerRef,
|
|
106
42
|
ownerState: {
|
|
@@ -139,7 +75,6 @@ process.env.NODE_ENV !== "production" ? ResponsiveChartContainer.propTypes = {
|
|
|
139
75
|
disableAxisListener: PropTypes.bool,
|
|
140
76
|
/**
|
|
141
77
|
* The height of the chart in px. If not defined, it takes the height of the parent element.
|
|
142
|
-
* @default undefined
|
|
143
78
|
*/
|
|
144
79
|
height: PropTypes.number,
|
|
145
80
|
/**
|
|
@@ -170,7 +105,6 @@ process.env.NODE_ENV !== "production" ? ResponsiveChartContainer.propTypes = {
|
|
|
170
105
|
}),
|
|
171
106
|
/**
|
|
172
107
|
* The width of the chart in px. If not defined, it takes the width of the parent element.
|
|
173
|
-
* @default undefined
|
|
174
108
|
*/
|
|
175
109
|
width: PropTypes.number,
|
|
176
110
|
/**
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import useEnhancedEffect from '@mui/utils/useEnhancedEffect';
|
|
3
|
+
import ownerWindow from '@mui/utils/ownerWindow';
|
|
4
|
+
export const useChartContainerDimensions = (inWidth, inHeight) => {
|
|
5
|
+
const rootRef = React.useRef(null);
|
|
6
|
+
const displayError = React.useRef(false);
|
|
7
|
+
const [width, setWidth] = React.useState(0);
|
|
8
|
+
const [height, setHeight] = React.useState(0);
|
|
9
|
+
|
|
10
|
+
// Adaptation of the `computeSizeAndPublishResizeEvent` from the grid.
|
|
11
|
+
const computeSize = React.useCallback(() => {
|
|
12
|
+
const mainEl = rootRef == null ? void 0 : rootRef.current;
|
|
13
|
+
if (!mainEl) {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
const win = ownerWindow(mainEl);
|
|
17
|
+
const computedStyle = win.getComputedStyle(mainEl);
|
|
18
|
+
const newHeight = Math.floor(parseFloat(computedStyle.height)) || 0;
|
|
19
|
+
const newWidth = Math.floor(parseFloat(computedStyle.width)) || 0;
|
|
20
|
+
setWidth(newWidth);
|
|
21
|
+
setHeight(newHeight);
|
|
22
|
+
}, []);
|
|
23
|
+
React.useEffect(() => {
|
|
24
|
+
// Ensure the error detection occurs after the first rendering.
|
|
25
|
+
displayError.current = true;
|
|
26
|
+
}, []);
|
|
27
|
+
useEnhancedEffect(() => {
|
|
28
|
+
if (inWidth !== undefined && inHeight !== undefined) {
|
|
29
|
+
return () => {};
|
|
30
|
+
}
|
|
31
|
+
computeSize();
|
|
32
|
+
const elementToObserve = rootRef.current;
|
|
33
|
+
if (typeof ResizeObserver === 'undefined') {
|
|
34
|
+
return () => {};
|
|
35
|
+
}
|
|
36
|
+
let animationFrame;
|
|
37
|
+
const observer = new ResizeObserver(() => {
|
|
38
|
+
// See https://github.com/mui/mui-x/issues/8733
|
|
39
|
+
animationFrame = requestAnimationFrame(() => {
|
|
40
|
+
computeSize();
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
if (elementToObserve) {
|
|
44
|
+
observer.observe(elementToObserve);
|
|
45
|
+
}
|
|
46
|
+
return () => {
|
|
47
|
+
if (animationFrame) {
|
|
48
|
+
window.cancelAnimationFrame(animationFrame);
|
|
49
|
+
}
|
|
50
|
+
if (elementToObserve) {
|
|
51
|
+
observer.unobserve(elementToObserve);
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
}, [computeSize, inHeight, inWidth]);
|
|
55
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
56
|
+
if (displayError.current && inWidth === undefined && width === 0) {
|
|
57
|
+
console.error(`MUI X Charts: ChartContainer does not have \`width\` prop, and its container has no \`width\` defined.`);
|
|
58
|
+
displayError.current = false;
|
|
59
|
+
}
|
|
60
|
+
if (displayError.current && inHeight === undefined && height === 0) {
|
|
61
|
+
console.error(`MUI X Charts: ChartContainer does not have \`height\` prop, and its container has no \`height\` defined.`);
|
|
62
|
+
displayError.current = false;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
return [rootRef, inWidth != null ? inWidth : width, inHeight != null ? inHeight : height];
|
|
66
|
+
};
|
|
@@ -8,6 +8,7 @@ import { ChartsTooltip } from '../ChartsTooltip';
|
|
|
8
8
|
import { ChartsLegend } from '../ChartsLegend';
|
|
9
9
|
import { ChartsAxisHighlight } from '../ChartsAxisHighlight';
|
|
10
10
|
import { ChartsVoronoiHandler } from '../ChartsVoronoiHandler/ChartsVoronoiHandler';
|
|
11
|
+
import { ChartsGrid } from '../ChartsGrid';
|
|
11
12
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
12
13
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
14
|
/**
|
|
@@ -35,6 +36,7 @@ const ScatterChart = /*#__PURE__*/React.forwardRef(function ScatterChart(props,
|
|
|
35
36
|
margin,
|
|
36
37
|
colors,
|
|
37
38
|
sx,
|
|
39
|
+
grid,
|
|
38
40
|
topAxis,
|
|
39
41
|
leftAxis,
|
|
40
42
|
rightAxis,
|
|
@@ -66,6 +68,9 @@ const ScatterChart = /*#__PURE__*/React.forwardRef(function ScatterChart(props,
|
|
|
66
68
|
bottomAxis: bottomAxis,
|
|
67
69
|
slots: slots,
|
|
68
70
|
slotProps: slotProps
|
|
71
|
+
}), grid && /*#__PURE__*/_jsx(ChartsGrid, {
|
|
72
|
+
vertical: grid.vertical,
|
|
73
|
+
horizontal: grid.horizontal
|
|
69
74
|
}), /*#__PURE__*/_jsx(ScatterPlot, {
|
|
70
75
|
slots: slots,
|
|
71
76
|
slotProps: slotProps,
|
|
@@ -86,6 +91,11 @@ process.env.NODE_ENV !== "production" ? ScatterChart.propTypes = {
|
|
|
86
91
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
87
92
|
// | To update them edit the TypeScript types and run "yarn proptypes" |
|
|
88
93
|
// ----------------------------------------------------------------------
|
|
94
|
+
/**
|
|
95
|
+
* The configuration of axes highlight.
|
|
96
|
+
* @see See {@link https://mui.com/x/react-charts/tooltip/#highlights highlight docs} for more details.
|
|
97
|
+
* @default { x: 'none', y: 'none' }
|
|
98
|
+
*/
|
|
89
99
|
axisHighlight: PropTypes.shape({
|
|
90
100
|
x: PropTypes.oneOf(['band', 'line', 'none']),
|
|
91
101
|
y: PropTypes.oneOf(['band', 'line', 'none'])
|
|
@@ -140,9 +150,15 @@ process.env.NODE_ENV !== "production" ? ScatterChart.propTypes = {
|
|
|
140
150
|
* @default false
|
|
141
151
|
*/
|
|
142
152
|
disableVoronoi: PropTypes.bool,
|
|
153
|
+
/**
|
|
154
|
+
* Option to display a cartesian grid in the background.
|
|
155
|
+
*/
|
|
156
|
+
grid: PropTypes.shape({
|
|
157
|
+
horizontal: PropTypes.bool,
|
|
158
|
+
vertical: PropTypes.bool
|
|
159
|
+
}),
|
|
143
160
|
/**
|
|
144
161
|
* The height of the chart in px. If not defined, it takes the height of the parent element.
|
|
145
|
-
* @default undefined
|
|
146
162
|
*/
|
|
147
163
|
height: PropTypes.number,
|
|
148
164
|
/**
|
|
@@ -231,6 +247,9 @@ process.env.NODE_ENV !== "production" ? ScatterChart.propTypes = {
|
|
|
231
247
|
tickNumber: PropTypes.number,
|
|
232
248
|
tickSize: PropTypes.number
|
|
233
249
|
}), PropTypes.string]),
|
|
250
|
+
/**
|
|
251
|
+
* The series to display in the scatter chart.
|
|
252
|
+
*/
|
|
234
253
|
series: PropTypes.arrayOf(PropTypes.object).isRequired,
|
|
235
254
|
/**
|
|
236
255
|
* The props used for each component slot.
|
|
@@ -244,6 +263,11 @@ process.env.NODE_ENV !== "production" ? ScatterChart.propTypes = {
|
|
|
244
263
|
slots: PropTypes.object,
|
|
245
264
|
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
|
|
246
265
|
title: PropTypes.string,
|
|
266
|
+
/**
|
|
267
|
+
* The configuration of the tooltip.
|
|
268
|
+
* @see See {@link https://mui.com/x/react-charts/tooltip/ tooltip docs} for more details.
|
|
269
|
+
* @default { trigger: 'item' }
|
|
270
|
+
*/
|
|
247
271
|
tooltip: PropTypes.shape({
|
|
248
272
|
axisContent: PropTypes.elementType,
|
|
249
273
|
classes: PropTypes.object,
|
|
@@ -288,12 +312,10 @@ process.env.NODE_ENV !== "production" ? ScatterChart.propTypes = {
|
|
|
288
312
|
/**
|
|
289
313
|
* Defines the maximal distance between a scatter point and the pointer that triggers the interaction.
|
|
290
314
|
* If `undefined`, the radius is assumed to be infinite.
|
|
291
|
-
* @default undefined
|
|
292
315
|
*/
|
|
293
316
|
voronoiMaxRadius: PropTypes.number,
|
|
294
317
|
/**
|
|
295
318
|
* The width of the chart in px. If not defined, it takes the width of the parent element.
|
|
296
|
-
* @default undefined
|
|
297
319
|
*/
|
|
298
320
|
width: PropTypes.number,
|
|
299
321
|
/**
|
|
@@ -146,7 +146,6 @@ process.env.NODE_ENV !== "production" ? SparkLineChart.propTypes = {
|
|
|
146
146
|
disableAxisListener: PropTypes.bool,
|
|
147
147
|
/**
|
|
148
148
|
* The height of the chart in px. If not defined, it takes the height of the parent element.
|
|
149
|
-
* @default undefined
|
|
150
149
|
*/
|
|
151
150
|
height: PropTypes.number,
|
|
152
151
|
/**
|
|
@@ -218,7 +217,6 @@ process.env.NODE_ENV !== "production" ? SparkLineChart.propTypes = {
|
|
|
218
217
|
}),
|
|
219
218
|
/**
|
|
220
219
|
* The width of the chart in px. If not defined, it takes the width of the parent element.
|
|
221
|
-
* @default undefined
|
|
222
220
|
*/
|
|
223
221
|
width: PropTypes.number,
|
|
224
222
|
/**
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import { scaleBand, scalePoint } from 'd3-scale';
|
|
4
|
-
import PropTypes from 'prop-types';
|
|
5
4
|
import { getExtremumX as getBarExtremumX, getExtremumY as getBarExtremumY } from '../BarChart/extremums';
|
|
6
5
|
import { getExtremumX as getScatterExtremumX, getExtremumY as getScatterExtremumY } from '../ScatterChart/extremums';
|
|
7
6
|
import { getExtremumX as getLineExtremumX, getExtremumY as getLineExtremumY } from '../LineChart/extremums';
|
|
@@ -32,12 +31,9 @@ export const CartesianContext = /*#__PURE__*/React.createContext({
|
|
|
32
31
|
xAxisIds: [],
|
|
33
32
|
yAxisIds: []
|
|
34
33
|
});
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
*
|
|
39
|
-
* - [CartesianContextProvider API](https://mui.com/x/api/charts/cartesian-context-provider/)
|
|
40
|
-
*/
|
|
34
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
35
|
+
CartesianContext.displayName = 'CartesianContext';
|
|
36
|
+
}
|
|
41
37
|
function CartesianContextProvider(props) {
|
|
42
38
|
const {
|
|
43
39
|
xAxis: inXAxis,
|
|
@@ -216,85 +212,4 @@ function CartesianContextProvider(props) {
|
|
|
216
212
|
children: children
|
|
217
213
|
});
|
|
218
214
|
}
|
|
219
|
-
process.env.NODE_ENV !== "production" ? CartesianContextProvider.propTypes = {
|
|
220
|
-
// ----------------------------- Warning --------------------------------
|
|
221
|
-
// | These PropTypes are generated from the TypeScript type definitions |
|
|
222
|
-
// | To update them edit the TypeScript types and run "yarn proptypes" |
|
|
223
|
-
// ----------------------------------------------------------------------
|
|
224
|
-
children: PropTypes.node,
|
|
225
|
-
/**
|
|
226
|
-
* An array of objects that can be used to populate series and axes data using their `dataKey` property.
|
|
227
|
-
*/
|
|
228
|
-
dataset: PropTypes.arrayOf(PropTypes.object),
|
|
229
|
-
/**
|
|
230
|
-
* The configuration of the x-axes.
|
|
231
|
-
* If not provided, a default axis config is used with id set to `DEFAULT_X_AXIS_KEY`.
|
|
232
|
-
*/
|
|
233
|
-
xAxis: PropTypes.arrayOf(PropTypes.shape({
|
|
234
|
-
axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
235
|
-
classes: PropTypes.object,
|
|
236
|
-
data: PropTypes.array,
|
|
237
|
-
dataKey: PropTypes.string,
|
|
238
|
-
disableLine: PropTypes.bool,
|
|
239
|
-
disableTicks: PropTypes.bool,
|
|
240
|
-
fill: PropTypes.string,
|
|
241
|
-
hideTooltip: PropTypes.bool,
|
|
242
|
-
id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
243
|
-
label: PropTypes.string,
|
|
244
|
-
labelFontSize: PropTypes.number,
|
|
245
|
-
labelStyle: PropTypes.object,
|
|
246
|
-
max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
247
|
-
min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
248
|
-
position: PropTypes.oneOf(['bottom', 'left', 'right', 'top']),
|
|
249
|
-
reverse: PropTypes.bool,
|
|
250
|
-
scaleType: PropTypes.oneOf(['band', 'linear', 'log', 'point', 'pow', 'sqrt', 'time', 'utc']),
|
|
251
|
-
slotProps: PropTypes.object,
|
|
252
|
-
slots: PropTypes.object,
|
|
253
|
-
stroke: PropTypes.string,
|
|
254
|
-
tickFontSize: PropTypes.number,
|
|
255
|
-
tickInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.array, PropTypes.func]),
|
|
256
|
-
tickLabelInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.func]),
|
|
257
|
-
tickLabelStyle: PropTypes.object,
|
|
258
|
-
tickMaxStep: PropTypes.number,
|
|
259
|
-
tickMinStep: PropTypes.number,
|
|
260
|
-
tickNumber: PropTypes.number,
|
|
261
|
-
tickSize: PropTypes.number,
|
|
262
|
-
valueFormatter: PropTypes.func
|
|
263
|
-
})),
|
|
264
|
-
/**
|
|
265
|
-
* The configuration of the y-axes.
|
|
266
|
-
* If not provided, a default axis config is used with id set to `DEFAULT_Y_AXIS_KEY`.
|
|
267
|
-
*/
|
|
268
|
-
yAxis: PropTypes.arrayOf(PropTypes.shape({
|
|
269
|
-
axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
270
|
-
classes: PropTypes.object,
|
|
271
|
-
data: PropTypes.array,
|
|
272
|
-
dataKey: PropTypes.string,
|
|
273
|
-
disableLine: PropTypes.bool,
|
|
274
|
-
disableTicks: PropTypes.bool,
|
|
275
|
-
fill: PropTypes.string,
|
|
276
|
-
hideTooltip: PropTypes.bool,
|
|
277
|
-
id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
278
|
-
label: PropTypes.string,
|
|
279
|
-
labelFontSize: PropTypes.number,
|
|
280
|
-
labelStyle: PropTypes.object,
|
|
281
|
-
max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
282
|
-
min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
283
|
-
position: PropTypes.oneOf(['bottom', 'left', 'right', 'top']),
|
|
284
|
-
reverse: PropTypes.bool,
|
|
285
|
-
scaleType: PropTypes.oneOf(['band', 'linear', 'log', 'point', 'pow', 'sqrt', 'time', 'utc']),
|
|
286
|
-
slotProps: PropTypes.object,
|
|
287
|
-
slots: PropTypes.object,
|
|
288
|
-
stroke: PropTypes.string,
|
|
289
|
-
tickFontSize: PropTypes.number,
|
|
290
|
-
tickInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.array, PropTypes.func]),
|
|
291
|
-
tickLabelInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.func]),
|
|
292
|
-
tickLabelStyle: PropTypes.object,
|
|
293
|
-
tickMaxStep: PropTypes.number,
|
|
294
|
-
tickMinStep: PropTypes.number,
|
|
295
|
-
tickNumber: PropTypes.number,
|
|
296
|
-
tickSize: PropTypes.number,
|
|
297
|
-
valueFormatter: PropTypes.func
|
|
298
|
-
}))
|
|
299
|
-
} : void 0;
|
|
300
215
|
export { CartesianContextProvider };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import * as React from 'react';
|
|
3
|
-
import PropTypes from 'prop-types';
|
|
4
3
|
import useId from '@mui/utils/useId';
|
|
5
4
|
import useChartDimensions from '../hooks/useChartDimensions';
|
|
6
5
|
|
|
@@ -17,16 +16,16 @@ export const DrawingContext = /*#__PURE__*/React.createContext({
|
|
|
17
16
|
width: 400,
|
|
18
17
|
chartId: ''
|
|
19
18
|
});
|
|
20
|
-
|
|
19
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
20
|
+
DrawingContext.displayName = 'DrawingContext';
|
|
21
|
+
}
|
|
22
|
+
export const SvgContext = /*#__PURE__*/React.createContext({
|
|
21
23
|
current: null
|
|
22
24
|
});
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
* - [DrawingProvider API](https://mui.com/x/api/charts/drawing-provider/)
|
|
28
|
-
*/
|
|
29
|
-
function DrawingProvider(props) {
|
|
25
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
26
|
+
SvgContext.displayName = 'SvgContext';
|
|
27
|
+
}
|
|
28
|
+
export function DrawingProvider(props) {
|
|
30
29
|
const {
|
|
31
30
|
width,
|
|
32
31
|
height,
|
|
@@ -39,36 +38,11 @@ function DrawingProvider(props) {
|
|
|
39
38
|
const value = React.useMemo(() => _extends({
|
|
40
39
|
chartId: chartId != null ? chartId : ''
|
|
41
40
|
}, drawingArea), [chartId, drawingArea]);
|
|
42
|
-
return /*#__PURE__*/_jsx(
|
|
41
|
+
return /*#__PURE__*/_jsx(SvgContext.Provider, {
|
|
43
42
|
value: svgRef,
|
|
44
43
|
children: /*#__PURE__*/_jsx(DrawingContext.Provider, {
|
|
45
44
|
value: value,
|
|
46
45
|
children: children
|
|
47
46
|
})
|
|
48
47
|
});
|
|
49
|
-
}
|
|
50
|
-
process.env.NODE_ENV !== "production" ? DrawingProvider.propTypes = {
|
|
51
|
-
// ----------------------------- Warning --------------------------------
|
|
52
|
-
// | These PropTypes are generated from the TypeScript type definitions |
|
|
53
|
-
// | To update them edit the TypeScript types and run "yarn proptypes" |
|
|
54
|
-
// ----------------------------------------------------------------------
|
|
55
|
-
children: PropTypes.node,
|
|
56
|
-
height: PropTypes.number.isRequired,
|
|
57
|
-
/**
|
|
58
|
-
* The margin between the SVG and the drawing area.
|
|
59
|
-
* It's used for leaving some space for extra information such as the x- and y-axis or legend.
|
|
60
|
-
* Accepts an object with the optional properties: `top`, `bottom`, `left`, and `right`.
|
|
61
|
-
* @default object Depends on the charts type.
|
|
62
|
-
*/
|
|
63
|
-
margin: PropTypes.shape({
|
|
64
|
-
bottom: PropTypes.number,
|
|
65
|
-
left: PropTypes.number,
|
|
66
|
-
right: PropTypes.number,
|
|
67
|
-
top: PropTypes.number
|
|
68
|
-
}),
|
|
69
|
-
svgRef: PropTypes.shape({
|
|
70
|
-
current: PropTypes.object
|
|
71
|
-
}).isRequired,
|
|
72
|
-
width: PropTypes.number.isRequired
|
|
73
|
-
} : void 0;
|
|
74
|
-
export { DrawingProvider };
|
|
48
|
+
}
|
|
@@ -10,6 +10,9 @@ export const HighlighContext = /*#__PURE__*/React.createContext({
|
|
|
10
10
|
scope: defaultScope,
|
|
11
11
|
dispatch: () => null
|
|
12
12
|
});
|
|
13
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
14
|
+
HighlighContext.displayName = 'HighlighContext';
|
|
15
|
+
}
|
|
13
16
|
const dataReducer = (prevState, action) => {
|
|
14
17
|
switch (action.type) {
|
|
15
18
|
case 'enterItem':
|
|
@@ -10,6 +10,9 @@ export const InteractionContext = /*#__PURE__*/React.createContext({
|
|
|
10
10
|
useVoronoiInteraction: false,
|
|
11
11
|
dispatch: () => null
|
|
12
12
|
});
|
|
13
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
14
|
+
InteractionContext.displayName = 'InteractionContext';
|
|
15
|
+
}
|
|
13
16
|
const dataReducer = (prevState, action) => {
|
|
14
17
|
switch (action.type) {
|
|
15
18
|
case 'enterItem':
|
|
@@ -9,6 +9,9 @@ import { defaultizeColor } from '../internals/defaultizeColor';
|
|
|
9
9
|
import { blueberryTwilightPalette } from '../colorPalettes';
|
|
10
10
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
11
|
export const SeriesContext = /*#__PURE__*/React.createContext({});
|
|
12
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
13
|
+
SeriesContext.displayName = 'SeriesContext';
|
|
14
|
+
}
|
|
12
15
|
const seriesTypeFormatter = {
|
|
13
16
|
bar: barSeriesFormatter,
|
|
14
17
|
scatter: scatterSeriesFormatter,
|
package/esm/context/index.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export { DrawingProvider } from './DrawingProvider';
|
|
1
|
+
export {};
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { InteractionContext } from '../context/InteractionProvider';
|
|
3
3
|
import { CartesianContext } from '../context/CartesianContextProvider';
|
|
4
|
-
import {
|
|
4
|
+
import { SvgContext, DrawingContext } from '../context/DrawingProvider';
|
|
5
5
|
import { isBandScale } from '../internals/isBandScale';
|
|
6
6
|
import { getSVGPoint } from '../internals/utils';
|
|
7
7
|
function getAsANumber(value) {
|
|
8
8
|
return value instanceof Date ? value.getTime() : value;
|
|
9
9
|
}
|
|
10
10
|
export const useAxisEvents = disableAxisListener => {
|
|
11
|
-
const svgRef = React.useContext(
|
|
11
|
+
const svgRef = React.useContext(SvgContext);
|
|
12
12
|
const {
|
|
13
13
|
width,
|
|
14
14
|
height,
|
package/esm/hooks/useTicks.js
CHANGED
|
@@ -13,7 +13,7 @@ export function getTickNumber(params) {
|
|
|
13
13
|
const defaultizedTickNumber = tickNumber != null ? tickNumber : Math.floor(Math.abs(range[1] - range[0]) / 50);
|
|
14
14
|
return Math.min(maxTicks, Math.max(minTicks, defaultizedTickNumber));
|
|
15
15
|
}
|
|
16
|
-
function useTicks(options) {
|
|
16
|
+
export function useTicks(options) {
|
|
17
17
|
const {
|
|
18
18
|
scale,
|
|
19
19
|
tickNumber,
|
|
@@ -64,5 +64,4 @@ function useTicks(options) {
|
|
|
64
64
|
};
|
|
65
65
|
});
|
|
66
66
|
}, [tickNumber, scale, valueFormatter, tickInterval]);
|
|
67
|
-
}
|
|
68
|
-
export default useTicks;
|
|
67
|
+
}
|
package/esm/index.js
CHANGED
|
@@ -8,6 +8,7 @@ export * from './ChartsReferenceLine';
|
|
|
8
8
|
export * from './ChartsAxis';
|
|
9
9
|
export * from './ChartsXAxis';
|
|
10
10
|
export * from './ChartsYAxis';
|
|
11
|
+
export * from './ChartsGrid';
|
|
11
12
|
export * from './ChartsText';
|
|
12
13
|
export * from './ChartsTooltip';
|
|
13
14
|
export * from './ChartsLegend';
|
|
@@ -19,6 +20,7 @@ export * from './LineChart';
|
|
|
19
20
|
export * from './PieChart';
|
|
20
21
|
export * from './ScatterChart';
|
|
21
22
|
export * from './SparkLineChart';
|
|
23
|
+
export * from './Gauge';
|
|
22
24
|
export * from './ChartContainer';
|
|
23
25
|
export * from './ChartsSurface';
|
|
24
26
|
export * from './ResponsiveChartContainer';
|
package/hooks/useAxisEvents.js
CHANGED
|
@@ -16,7 +16,7 @@ function getAsANumber(value) {
|
|
|
16
16
|
return value instanceof Date ? value.getTime() : value;
|
|
17
17
|
}
|
|
18
18
|
const useAxisEvents = disableAxisListener => {
|
|
19
|
-
const svgRef = React.useContext(_DrawingProvider.
|
|
19
|
+
const svgRef = React.useContext(_DrawingProvider.SvgContext);
|
|
20
20
|
const {
|
|
21
21
|
width,
|
|
22
22
|
height,
|