@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
package/esm/BarChart/BarChart.js
CHANGED
|
@@ -10,6 +10,7 @@ import { ChartsTooltip } from '../ChartsTooltip';
|
|
|
10
10
|
import { ChartsLegend } from '../ChartsLegend';
|
|
11
11
|
import { ChartsAxisHighlight } from '../ChartsAxisHighlight';
|
|
12
12
|
import { ChartsClipPath } from '../ChartsClipPath';
|
|
13
|
+
import { ChartsGrid } from '../ChartsGrid';
|
|
13
14
|
import { ChartsOnAxisClickHandler } from '../ChartsOnAxisClickHandler';
|
|
14
15
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
15
16
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
@@ -39,6 +40,7 @@ const BarChart = /*#__PURE__*/React.forwardRef(function BarChart(props, ref) {
|
|
|
39
40
|
tooltip,
|
|
40
41
|
axisHighlight,
|
|
41
42
|
legend,
|
|
43
|
+
grid,
|
|
42
44
|
topAxis,
|
|
43
45
|
leftAxis,
|
|
44
46
|
rightAxis,
|
|
@@ -89,6 +91,9 @@ const BarChart = /*#__PURE__*/React.forwardRef(function BarChart(props, ref) {
|
|
|
89
91
|
disableAxisListener: (tooltip == null ? void 0 : tooltip.trigger) !== 'axis' && (axisHighlight == null ? void 0 : axisHighlight.x) === 'none' && (axisHighlight == null ? void 0 : axisHighlight.y) === 'none' && !onAxisClick,
|
|
90
92
|
children: [onAxisClick && /*#__PURE__*/_jsx(ChartsOnAxisClickHandler, {
|
|
91
93
|
onAxisClick: onAxisClick
|
|
94
|
+
}), grid && /*#__PURE__*/_jsx(ChartsGrid, {
|
|
95
|
+
vertical: grid.vertical,
|
|
96
|
+
horizontal: grid.horizontal
|
|
92
97
|
}), /*#__PURE__*/_jsx("g", {
|
|
93
98
|
clipPath: `url(#${clipPathId})`,
|
|
94
99
|
children: /*#__PURE__*/_jsx(BarPlot, {
|
|
@@ -121,11 +126,10 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
|
|
|
121
126
|
// | To update them edit the TypeScript types and run "yarn proptypes" |
|
|
122
127
|
// ----------------------------------------------------------------------
|
|
123
128
|
/**
|
|
124
|
-
*
|
|
125
|
-
*
|
|
126
|
-
*
|
|
127
|
-
*
|
|
128
|
-
* - 'band': display a band at the current mouse position. Only available with band scale.
|
|
129
|
+
* The configuration of axes highlight.
|
|
130
|
+
* Default is set to 'band' in the bar direction.
|
|
131
|
+
* Depends on `layout` prop.
|
|
132
|
+
* @see See {@link https://mui.com/x/react-charts/tooltip/#highlights highlight docs} for more details.
|
|
129
133
|
*/
|
|
130
134
|
axisHighlight: PropTypes.shape({
|
|
131
135
|
x: PropTypes.oneOf(['band', 'line', 'none']),
|
|
@@ -176,11 +180,21 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
|
|
|
176
180
|
* @default false
|
|
177
181
|
*/
|
|
178
182
|
disableAxisListener: PropTypes.bool,
|
|
183
|
+
/**
|
|
184
|
+
* Option to display a cartesian grid in the background.
|
|
185
|
+
*/
|
|
186
|
+
grid: PropTypes.shape({
|
|
187
|
+
horizontal: PropTypes.bool,
|
|
188
|
+
vertical: PropTypes.bool
|
|
189
|
+
}),
|
|
179
190
|
/**
|
|
180
191
|
* The height of the chart in px. If not defined, it takes the height of the parent element.
|
|
181
|
-
* @default undefined
|
|
182
192
|
*/
|
|
183
193
|
height: PropTypes.number,
|
|
194
|
+
/**
|
|
195
|
+
* The direction of the bar elements.
|
|
196
|
+
* @default 'vertical'
|
|
197
|
+
*/
|
|
184
198
|
layout: PropTypes.oneOf(['horizontal', 'vertical']),
|
|
185
199
|
/**
|
|
186
200
|
* Indicate which axis to display the left of the charts.
|
|
@@ -275,6 +289,9 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
|
|
|
275
289
|
tickNumber: PropTypes.number,
|
|
276
290
|
tickSize: PropTypes.number
|
|
277
291
|
}), PropTypes.string]),
|
|
292
|
+
/**
|
|
293
|
+
* The series to display in the bar chart.
|
|
294
|
+
*/
|
|
278
295
|
series: PropTypes.arrayOf(PropTypes.object).isRequired,
|
|
279
296
|
/**
|
|
280
297
|
* If `true`, animations are skipped.
|
|
@@ -293,6 +310,10 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
|
|
|
293
310
|
slots: PropTypes.object,
|
|
294
311
|
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
|
|
295
312
|
title: PropTypes.string,
|
|
313
|
+
/**
|
|
314
|
+
* The configuration of the tooltip.
|
|
315
|
+
* @see See {@link https://mui.com/x/react-charts/tooltip/ tooltip docs} for more details.
|
|
316
|
+
*/
|
|
296
317
|
tooltip: PropTypes.shape({
|
|
297
318
|
axisContent: PropTypes.elementType,
|
|
298
319
|
classes: PropTypes.object,
|
|
@@ -336,7 +357,6 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
|
|
|
336
357
|
}),
|
|
337
358
|
/**
|
|
338
359
|
* The width of the chart in px. If not defined, it takes the width of the parent element.
|
|
339
|
-
* @default undefined
|
|
340
360
|
*/
|
|
341
361
|
width: PropTypes.number,
|
|
342
362
|
/**
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
|
+
const _excluded = ["vertical", "horizontal"];
|
|
4
|
+
import * as React from 'react';
|
|
5
|
+
import PropTypes from 'prop-types';
|
|
6
|
+
import composeClasses from '@mui/utils/composeClasses';
|
|
7
|
+
import { styled } from '@mui/material/styles';
|
|
8
|
+
import { CartesianContext } from '../context/CartesianContextProvider';
|
|
9
|
+
import { useTicks } from '../hooks/useTicks';
|
|
10
|
+
import { getChartsGridUtilityClass, chartsGridClasses } from './chartsGridClasses';
|
|
11
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
12
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
|
+
const GridRoot = styled('g', {
|
|
14
|
+
name: 'MuiChartsGrid',
|
|
15
|
+
slot: 'Root',
|
|
16
|
+
overridesResolver: (props, styles) => styles.root
|
|
17
|
+
})(({
|
|
18
|
+
theme
|
|
19
|
+
}) => ({
|
|
20
|
+
[`& .${chartsGridClasses.line}`]: {
|
|
21
|
+
stroke: (theme.vars || theme).palette.divider,
|
|
22
|
+
shapeRendering: 'crispEdges',
|
|
23
|
+
strokeWidth: 1
|
|
24
|
+
}
|
|
25
|
+
}));
|
|
26
|
+
const useUtilityClasses = ({
|
|
27
|
+
classes
|
|
28
|
+
}) => {
|
|
29
|
+
const slots = {
|
|
30
|
+
root: ['root'],
|
|
31
|
+
verticalLine: ['line', 'verticalLine'],
|
|
32
|
+
horizontalLine: ['line', 'horizontalLine']
|
|
33
|
+
};
|
|
34
|
+
return composeClasses(slots, getChartsGridUtilityClass, classes);
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* Demos:
|
|
38
|
+
*
|
|
39
|
+
* - [Axis](https://mui.com/x/react-charts/axis/)
|
|
40
|
+
*
|
|
41
|
+
* API:
|
|
42
|
+
*
|
|
43
|
+
* - [ChartsGrid API](https://mui.com/x/api/charts/charts-axis/)
|
|
44
|
+
*/
|
|
45
|
+
function ChartsGrid(props) {
|
|
46
|
+
const {
|
|
47
|
+
vertical,
|
|
48
|
+
horizontal
|
|
49
|
+
} = props,
|
|
50
|
+
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
51
|
+
const {
|
|
52
|
+
xAxis,
|
|
53
|
+
xAxisIds,
|
|
54
|
+
yAxis,
|
|
55
|
+
yAxisIds
|
|
56
|
+
} = React.useContext(CartesianContext);
|
|
57
|
+
const classes = useUtilityClasses(props);
|
|
58
|
+
const horizontalAxisId = yAxisIds[0];
|
|
59
|
+
const verticalAxisId = xAxisIds[0];
|
|
60
|
+
const {
|
|
61
|
+
scale: xScale,
|
|
62
|
+
tickNumber: xTickNumber,
|
|
63
|
+
tickInterval: xTickInterval
|
|
64
|
+
} = xAxis[verticalAxisId];
|
|
65
|
+
const {
|
|
66
|
+
scale: yScale,
|
|
67
|
+
tickNumber: yTickNumber,
|
|
68
|
+
tickInterval: yTickInterval
|
|
69
|
+
} = yAxis[horizontalAxisId];
|
|
70
|
+
const xTicks = useTicks({
|
|
71
|
+
scale: xScale,
|
|
72
|
+
tickNumber: xTickNumber,
|
|
73
|
+
tickInterval: xTickInterval
|
|
74
|
+
});
|
|
75
|
+
const yTicks = useTicks({
|
|
76
|
+
scale: yScale,
|
|
77
|
+
tickNumber: yTickNumber,
|
|
78
|
+
tickInterval: yTickInterval
|
|
79
|
+
});
|
|
80
|
+
return /*#__PURE__*/_jsxs(GridRoot, _extends({}, other, {
|
|
81
|
+
className: classes.root,
|
|
82
|
+
children: [vertical && xTicks.map(({
|
|
83
|
+
formattedValue,
|
|
84
|
+
offset
|
|
85
|
+
}) => /*#__PURE__*/_jsx("line", {
|
|
86
|
+
y1: yScale.range()[0],
|
|
87
|
+
y2: yScale.range()[1],
|
|
88
|
+
x1: offset,
|
|
89
|
+
x2: offset,
|
|
90
|
+
className: classes.verticalLine
|
|
91
|
+
}, formattedValue)), horizontal && yTicks.map(({
|
|
92
|
+
formattedValue,
|
|
93
|
+
offset
|
|
94
|
+
}) => /*#__PURE__*/_jsx("line", {
|
|
95
|
+
y1: offset,
|
|
96
|
+
y2: offset,
|
|
97
|
+
x1: xScale.range()[0],
|
|
98
|
+
x2: xScale.range()[1],
|
|
99
|
+
className: classes.horizontalLine
|
|
100
|
+
}, formattedValue))]
|
|
101
|
+
}));
|
|
102
|
+
}
|
|
103
|
+
process.env.NODE_ENV !== "production" ? ChartsGrid.propTypes = {
|
|
104
|
+
// ----------------------------- Warning --------------------------------
|
|
105
|
+
// | These PropTypes are generated from the TypeScript type definitions |
|
|
106
|
+
// | To update them edit the TypeScript types and run "yarn proptypes" |
|
|
107
|
+
// ----------------------------------------------------------------------
|
|
108
|
+
/**
|
|
109
|
+
* Override or extend the styles applied to the component.
|
|
110
|
+
*/
|
|
111
|
+
classes: PropTypes.object,
|
|
112
|
+
/**
|
|
113
|
+
* Displays horizontal grid.
|
|
114
|
+
*/
|
|
115
|
+
horizontal: PropTypes.bool,
|
|
116
|
+
/**
|
|
117
|
+
* Displays vertical grid.
|
|
118
|
+
*/
|
|
119
|
+
vertical: PropTypes.bool
|
|
120
|
+
} : void 0;
|
|
121
|
+
export { ChartsGrid };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import generateUtilityClass from '@mui/utils/generateUtilityClass';
|
|
2
|
+
import generateUtilityClasses from '@mui/utils/generateUtilityClasses';
|
|
3
|
+
export function getChartsGridUtilityClass(slot) {
|
|
4
|
+
return generateUtilityClass('MuiChartsGrid', slot);
|
|
5
|
+
}
|
|
6
|
+
export const chartsGridClasses = generateUtilityClasses('MuiChartsGrid', ['root', 'line', 'horizontalLine', 'verticalLine']);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
|
-
import {
|
|
3
|
+
import { SvgContext } from '../context/DrawingProvider';
|
|
4
4
|
import { InteractionContext } from '../context/InteractionProvider';
|
|
5
5
|
import { CartesianContext } from '../context/CartesianContextProvider';
|
|
6
6
|
import { SeriesContext } from '../context/SeriesContextProvider';
|
|
@@ -9,7 +9,7 @@ function ChartsOnAxisClickHandler(props) {
|
|
|
9
9
|
const {
|
|
10
10
|
onAxisClick
|
|
11
11
|
} = props;
|
|
12
|
-
const svgRef = React.useContext(
|
|
12
|
+
const svgRef = React.useContext(SvgContext);
|
|
13
13
|
const series = React.useContext(SeriesContext);
|
|
14
14
|
const {
|
|
15
15
|
axis
|
package/esm/ChartsSurface.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 = ["children", "width", "height", "viewBox", "disableAxisListener", "className"];
|
|
3
|
+
const _excluded = ["children", "width", "height", "viewBox", "disableAxisListener", "className", "title", "desc"];
|
|
4
4
|
import { styled } from '@mui/material/styles';
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
6
|
import * as React from 'react';
|
|
@@ -17,7 +17,9 @@ const ChartsSurface = /*#__PURE__*/React.forwardRef(function ChartsSurface(props
|
|
|
17
17
|
width,
|
|
18
18
|
height,
|
|
19
19
|
viewBox,
|
|
20
|
-
disableAxisListener = false
|
|
20
|
+
disableAxisListener = false,
|
|
21
|
+
title,
|
|
22
|
+
desc
|
|
21
23
|
} = props,
|
|
22
24
|
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
23
25
|
const svgView = _extends({
|
|
@@ -34,9 +36,9 @@ const ChartsSurface = /*#__PURE__*/React.forwardRef(function ChartsSurface(props
|
|
|
34
36
|
ref: ref
|
|
35
37
|
}, other, {
|
|
36
38
|
children: [/*#__PURE__*/_jsx("title", {
|
|
37
|
-
children:
|
|
39
|
+
children: title
|
|
38
40
|
}), /*#__PURE__*/_jsx("desc", {
|
|
39
|
-
children:
|
|
41
|
+
children: desc
|
|
40
42
|
}), children]
|
|
41
43
|
}));
|
|
42
44
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { SvgContext } from '../context/DrawingProvider';
|
|
3
3
|
export function generateVirtualElement(mousePosition) {
|
|
4
4
|
if (mousePosition === null) {
|
|
5
5
|
return {
|
|
@@ -44,7 +44,7 @@ export function generateVirtualElement(mousePosition) {
|
|
|
44
44
|
};
|
|
45
45
|
}
|
|
46
46
|
export function useMouseTracker() {
|
|
47
|
-
const svgRef = React.useContext(
|
|
47
|
+
const svgRef = React.useContext(SvgContext);
|
|
48
48
|
|
|
49
49
|
// Use a ref to avoid rerendering on every mousemove event.
|
|
50
50
|
const [mousePosition, setMousePosition] = React.useState(null);
|
|
@@ -4,7 +4,7 @@ import { Delaunay } from 'd3-delaunay';
|
|
|
4
4
|
import useEnhancedEffect from '@mui/utils/useEnhancedEffect';
|
|
5
5
|
import { InteractionContext } from '../context/InteractionProvider';
|
|
6
6
|
import { CartesianContext } from '../context/CartesianContextProvider';
|
|
7
|
-
import {
|
|
7
|
+
import { SvgContext, DrawingContext } from '../context/DrawingProvider';
|
|
8
8
|
import { SeriesContext } from '../context/SeriesContextProvider';
|
|
9
9
|
import { getValueToPositionMapper } from '../hooks/useScale';
|
|
10
10
|
import { getSVGPoint } from '../internals/utils';
|
|
@@ -15,7 +15,7 @@ function ChartsVoronoiHandler(props) {
|
|
|
15
15
|
voronoiMaxRadius,
|
|
16
16
|
onItemClick
|
|
17
17
|
} = props;
|
|
18
|
-
const svgRef = React.useContext(
|
|
18
|
+
const svgRef = React.useContext(SvgContext);
|
|
19
19
|
const {
|
|
20
20
|
width,
|
|
21
21
|
height,
|
|
@@ -209,7 +209,6 @@ process.env.NODE_ENV !== "production" ? ChartsVoronoiHandler.propTypes = {
|
|
|
209
209
|
/**
|
|
210
210
|
* Defines the maximal distance between a scatter point and the pointer that triggers the interaction.
|
|
211
211
|
* If `undefined`, the radius is assumed to be infinite.
|
|
212
|
-
* @default undefined
|
|
213
212
|
*/
|
|
214
213
|
voronoiMaxRadius: PropTypes.number
|
|
215
214
|
} : void 0;
|
|
@@ -8,7 +8,7 @@ import { unstable_composeClasses as composeClasses } from '@mui/utils';
|
|
|
8
8
|
import { useThemeProps, useTheme } from '@mui/material/styles';
|
|
9
9
|
import { CartesianContext } from '../context/CartesianContextProvider';
|
|
10
10
|
import { DrawingContext } from '../context/DrawingProvider';
|
|
11
|
-
import useTicks from '../hooks/useTicks';
|
|
11
|
+
import { useTicks } from '../hooks/useTicks';
|
|
12
12
|
import { getAxisUtilityClass } from '../ChartsAxis/axisClasses';
|
|
13
13
|
import { AxisRoot } from '../internals/components/AxisSharedComponents';
|
|
14
14
|
import { ChartsText } from '../ChartsText';
|
|
@@ -331,7 +331,7 @@ process.env.NODE_ENV !== "production" ? ChartsXAxis.propTypes = {
|
|
|
331
331
|
*/
|
|
332
332
|
tickMaxStep: PropTypes.number,
|
|
333
333
|
/**
|
|
334
|
-
*
|
|
334
|
+
* Minimal step between two ticks.
|
|
335
335
|
* When using time data, the value is assumed to be in ms.
|
|
336
336
|
* Not supported by categorical axis (band, points).
|
|
337
337
|
*/
|
|
@@ -8,7 +8,7 @@ import { unstable_composeClasses as composeClasses } from '@mui/utils';
|
|
|
8
8
|
import { useThemeProps, useTheme } from '@mui/material/styles';
|
|
9
9
|
import { CartesianContext } from '../context/CartesianContextProvider';
|
|
10
10
|
import { DrawingContext } from '../context/DrawingProvider';
|
|
11
|
-
import useTicks from '../hooks/useTicks';
|
|
11
|
+
import { useTicks } from '../hooks/useTicks';
|
|
12
12
|
import { AxisRoot } from '../internals/components/AxisSharedComponents';
|
|
13
13
|
import { ChartsText } from '../ChartsText';
|
|
14
14
|
import { getAxisUtilityClass } from '../ChartsAxis/axisClasses';
|
|
@@ -261,7 +261,7 @@ process.env.NODE_ENV !== "production" ? ChartsYAxis.propTypes = {
|
|
|
261
261
|
*/
|
|
262
262
|
tickMaxStep: PropTypes.number,
|
|
263
263
|
/**
|
|
264
|
-
*
|
|
264
|
+
* Minimal step between two ticks.
|
|
265
265
|
* When using time data, the value is assumed to be in ms.
|
|
266
266
|
* Not supported by categorical axis (band, points).
|
|
267
267
|
*/
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
|
+
const _excluded = ["text", "children", "classes"];
|
|
4
|
+
import * as React from 'react';
|
|
5
|
+
import PropTypes from 'prop-types';
|
|
6
|
+
import composeClasses from '@mui/utils/composeClasses';
|
|
7
|
+
import { GaugeContainer } from './GaugeContainer';
|
|
8
|
+
import { GaugeValueArc } from './GaugeValueArc';
|
|
9
|
+
import { GaugeReferenceArc } from './GaugeReferenceArc';
|
|
10
|
+
import { getGaugeUtilityClass } from './gaugeClasses';
|
|
11
|
+
import { GaugeValueText } from './GaugeValueText';
|
|
12
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
14
|
+
const useUtilityClasses = props => {
|
|
15
|
+
const {
|
|
16
|
+
classes
|
|
17
|
+
} = props;
|
|
18
|
+
const slots = {
|
|
19
|
+
root: ['root'],
|
|
20
|
+
valueArc: ['valueArc'],
|
|
21
|
+
referenceArc: ['referenceArc'],
|
|
22
|
+
valueText: ['valueText']
|
|
23
|
+
};
|
|
24
|
+
return composeClasses(slots, getGaugeUtilityClass, classes);
|
|
25
|
+
};
|
|
26
|
+
function Gauge(props) {
|
|
27
|
+
const {
|
|
28
|
+
text,
|
|
29
|
+
children
|
|
30
|
+
} = props,
|
|
31
|
+
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
32
|
+
const classes = useUtilityClasses(props);
|
|
33
|
+
return /*#__PURE__*/_jsxs(GaugeContainer, _extends({}, other, {
|
|
34
|
+
className: classes.root,
|
|
35
|
+
children: [/*#__PURE__*/_jsx(GaugeReferenceArc, {
|
|
36
|
+
className: classes.referenceArc
|
|
37
|
+
}), /*#__PURE__*/_jsx(GaugeValueArc, {
|
|
38
|
+
className: classes.valueArc
|
|
39
|
+
}), /*#__PURE__*/_jsx(GaugeValueText, {
|
|
40
|
+
className: classes.valueText,
|
|
41
|
+
text: text
|
|
42
|
+
}), children]
|
|
43
|
+
}));
|
|
44
|
+
}
|
|
45
|
+
process.env.NODE_ENV !== "production" ? Gauge.propTypes = {
|
|
46
|
+
// ----------------------------- Warning --------------------------------
|
|
47
|
+
// | These PropTypes are generated from the TypeScript type definitions |
|
|
48
|
+
// | To update them edit the TypeScript types and run "yarn proptypes" |
|
|
49
|
+
// ----------------------------------------------------------------------
|
|
50
|
+
children: PropTypes.node,
|
|
51
|
+
classes: PropTypes.object,
|
|
52
|
+
className: PropTypes.string,
|
|
53
|
+
/**
|
|
54
|
+
* The radius applied to arc corners (similar to border radius).
|
|
55
|
+
* Set it to '50%' to get rounded arc.
|
|
56
|
+
* @default 0
|
|
57
|
+
*/
|
|
58
|
+
cornerRadius: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
59
|
+
/**
|
|
60
|
+
* The x coordinate of the arc center.
|
|
61
|
+
* Can be a number (in px) or a string with a percentage such as '50%'.
|
|
62
|
+
* The '100%' is the width the drawing area.
|
|
63
|
+
*/
|
|
64
|
+
cx: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
65
|
+
/**
|
|
66
|
+
* The y coordinate of the arc center.
|
|
67
|
+
* Can be a number (in px) or a string with a percentage such as '50%'.
|
|
68
|
+
* The '100%' is the height the drawing area.
|
|
69
|
+
*/
|
|
70
|
+
cy: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
71
|
+
desc: PropTypes.string,
|
|
72
|
+
/**
|
|
73
|
+
* If `true`, the charts will not listen to the mouse move event.
|
|
74
|
+
* It might break interactive features, but will improve performance.
|
|
75
|
+
* @default false
|
|
76
|
+
*/
|
|
77
|
+
disableAxisListener: PropTypes.bool,
|
|
78
|
+
/**
|
|
79
|
+
* The end angle (deg).
|
|
80
|
+
* @default 360
|
|
81
|
+
*/
|
|
82
|
+
endAngle: PropTypes.number,
|
|
83
|
+
/**
|
|
84
|
+
* The height of the chart in px. If not defined, it takes the height of the parent element.
|
|
85
|
+
*/
|
|
86
|
+
height: PropTypes.number,
|
|
87
|
+
/**
|
|
88
|
+
* The radius between circle center and the begining of the arc.
|
|
89
|
+
* Can be a number (in px) or a string with a percentage such as '50%'.
|
|
90
|
+
* The '100%' is the maximal radius that fit into the drawing area.
|
|
91
|
+
* @default '80%'
|
|
92
|
+
*/
|
|
93
|
+
innerRadius: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
94
|
+
/**
|
|
95
|
+
* The margin between the SVG and the drawing area.
|
|
96
|
+
* It's used for leaving some space for extra information such as the x- and y-axis or legend.
|
|
97
|
+
* Accepts an object with the optional properties: `top`, `bottom`, `left`, and `right`.
|
|
98
|
+
* @default object Depends on the charts type.
|
|
99
|
+
*/
|
|
100
|
+
margin: PropTypes.shape({
|
|
101
|
+
bottom: PropTypes.number,
|
|
102
|
+
left: PropTypes.number,
|
|
103
|
+
right: PropTypes.number,
|
|
104
|
+
top: PropTypes.number
|
|
105
|
+
}),
|
|
106
|
+
/**
|
|
107
|
+
* The radius between circle center and the end of the arc.
|
|
108
|
+
* Can be a number (in px) or a string with a percentage such as '50%'.
|
|
109
|
+
* The '100%' is the maximal radius that fit into the drawing area.
|
|
110
|
+
* @default '100%'
|
|
111
|
+
*/
|
|
112
|
+
outerRadius: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
113
|
+
/**
|
|
114
|
+
* The start angle (deg).
|
|
115
|
+
* @default 0
|
|
116
|
+
*/
|
|
117
|
+
startAngle: PropTypes.number,
|
|
118
|
+
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
|
|
119
|
+
text: PropTypes.oneOfType([PropTypes.func, PropTypes.string]),
|
|
120
|
+
title: PropTypes.string,
|
|
121
|
+
/**
|
|
122
|
+
* The value of the gauge.
|
|
123
|
+
* Set to `null` to not display a value.
|
|
124
|
+
*/
|
|
125
|
+
value: PropTypes.number,
|
|
126
|
+
/**
|
|
127
|
+
* The maximal value of the gauge.
|
|
128
|
+
* @default 100
|
|
129
|
+
*/
|
|
130
|
+
valueMax: PropTypes.number,
|
|
131
|
+
/**
|
|
132
|
+
* The minimal value of the gauge.
|
|
133
|
+
* @default 0
|
|
134
|
+
*/
|
|
135
|
+
valueMin: PropTypes.number,
|
|
136
|
+
viewBox: PropTypes.shape({
|
|
137
|
+
height: PropTypes.number,
|
|
138
|
+
width: PropTypes.number,
|
|
139
|
+
x: PropTypes.number,
|
|
140
|
+
y: PropTypes.number
|
|
141
|
+
}),
|
|
142
|
+
/**
|
|
143
|
+
* The width of the chart in px. If not defined, it takes the width of the parent element.
|
|
144
|
+
*/
|
|
145
|
+
width: PropTypes.number
|
|
146
|
+
} : void 0;
|
|
147
|
+
export { Gauge };
|