@mui/x-charts 7.0.0-beta.1 → 7.0.0-beta.3
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 +37 -13
- package/BarChart/BarElement.d.ts +20 -13
- package/BarChart/BarElement.js +1 -0
- package/BarChart/BarPlot.d.ts +3 -5
- package/BarChart/BarPlot.js +9 -10
- package/CHANGELOG.md +223 -1
- package/ChartContainer/ChartContainer.js +6 -4
- package/ChartsAxis/ChartsAxis.js +4 -4
- 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/ChartsLegend/ChartsLegend.d.ts +5 -54
- package/ChartsLegend/ChartsLegend.js +2 -307
- package/ChartsLegend/DefaultChartsLegend.d.ts +60 -0
- package/ChartsLegend/DefaultChartsLegend.js +294 -0
- package/ChartsLegend/index.d.ts +1 -0
- package/ChartsLegend/index.js +11 -0
- package/ChartsReferenceLine/ChartsReferenceLine.js +2 -2
- package/ChartsReferenceLine/common.d.ts +2 -1
- package/ChartsSurface.js +6 -4
- package/ChartsTooltip/ChartsItemTooltipContent.js +2 -2
- package/ChartsTooltip/DefaultChartsAxisTooltipContent.js +1 -1
- package/ChartsTooltip/DefaultChartsItemTooltipContent.js +1 -1
- package/ChartsTooltip/utils.d.ts +1 -0
- package/ChartsTooltip/utils.js +7 -0
- package/ChartsXAxis/ChartsXAxis.js +15 -11
- package/ChartsYAxis/ChartsYAxis.js +3 -3
- package/Gauge/Gauge.d.ts +13 -0
- package/Gauge/Gauge.js +156 -0
- package/Gauge/GaugeContainer.d.ts +19 -0
- package/Gauge/GaugeContainer.js +216 -0
- package/Gauge/GaugeProvider.d.ts +117 -0
- package/Gauge/GaugeProvider.js +96 -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/AnimatedArea.js +1 -1
- package/LineChart/AnimatedLine.js +1 -1
- package/LineChart/AreaElement.d.ts +2 -1
- package/LineChart/AreaElement.js +1 -1
- package/LineChart/LineChart.d.ts +24 -5
- package/LineChart/LineChart.js +41 -13
- package/LineChart/LineElement.d.ts +2 -1
- package/LineChart/LineElement.js +1 -1
- package/LineChart/LineHighlightElement.d.ts +3 -2
- package/LineChart/LineHighlightElement.js +2 -1
- package/LineChart/MarkElement.d.ts +3 -2
- package/LineChart/MarkElement.js +1 -0
- package/PieChart/PieArc.d.ts +7 -6
- package/PieChart/PieArc.js +10 -9
- package/PieChart/PieArcLabel.d.ts +3 -2
- package/PieChart/PieArcLabel.js +1 -0
- package/PieChart/PieArcLabelPlot.js +14 -14
- package/PieChart/PieArcPlot.js +1 -1
- package/PieChart/PieChart.d.ts +22 -0
- package/PieChart/PieChart.js +32 -8
- package/ResponsiveChartContainer/ResponsiveChartContainer.js +8 -70
- package/ResponsiveChartContainer/useChartContainerDimensions.d.ts +2 -0
- package/ResponsiveChartContainer/useChartContainerDimensions.js +76 -0
- package/ScatterChart/ScatterChart.d.ts +18 -0
- package/ScatterChart/ScatterChart.js +35 -8
- package/SparkLineChart/SparkLineChart.d.ts +1 -1
- package/SparkLineChart/SparkLineChart.js +5 -4
- package/context/CartesianContextProvider.js +8 -6
- package/esm/BarChart/BarChart.js +37 -13
- package/esm/BarChart/BarElement.js +1 -0
- package/esm/BarChart/BarPlot.js +8 -10
- package/esm/ChartContainer/ChartContainer.js +6 -4
- package/esm/ChartsAxis/ChartsAxis.js +4 -4
- package/esm/ChartsGrid/ChartsGrid.js +121 -0
- package/esm/ChartsGrid/chartsGridClasses.js +6 -0
- package/esm/ChartsGrid/index.js +2 -0
- package/esm/ChartsLegend/ChartsLegend.js +2 -307
- package/esm/ChartsLegend/DefaultChartsLegend.js +286 -0
- package/esm/ChartsLegend/index.js +1 -0
- package/esm/ChartsReferenceLine/ChartsReferenceLine.js +2 -2
- package/esm/ChartsSurface.js +6 -4
- package/esm/ChartsTooltip/ChartsItemTooltipContent.js +2 -2
- package/esm/ChartsTooltip/DefaultChartsAxisTooltipContent.js +2 -2
- package/esm/ChartsTooltip/DefaultChartsItemTooltipContent.js +1 -1
- package/esm/ChartsTooltip/utils.js +6 -0
- package/esm/ChartsXAxis/ChartsXAxis.js +14 -10
- package/esm/ChartsYAxis/ChartsYAxis.js +2 -2
- package/esm/Gauge/Gauge.js +149 -0
- package/esm/Gauge/GaugeContainer.js +211 -0
- package/esm/Gauge/GaugeProvider.js +85 -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/AnimatedArea.js +1 -1
- package/esm/LineChart/AnimatedLine.js +1 -1
- package/esm/LineChart/AreaElement.js +1 -1
- package/esm/LineChart/LineChart.js +41 -13
- package/esm/LineChart/LineElement.js +1 -1
- package/esm/LineChart/LineHighlightElement.js +2 -1
- package/esm/LineChart/MarkElement.js +1 -0
- package/esm/PieChart/PieArc.js +10 -9
- package/esm/PieChart/PieArcLabel.js +1 -0
- package/esm/PieChart/PieArcLabelPlot.js +14 -14
- package/esm/PieChart/PieArcPlot.js +1 -1
- package/esm/PieChart/PieChart.js +32 -8
- package/esm/ResponsiveChartContainer/ResponsiveChartContainer.js +8 -70
- package/esm/ResponsiveChartContainer/useChartContainerDimensions.js +66 -0
- package/esm/ScatterChart/ScatterChart.js +35 -8
- package/esm/SparkLineChart/SparkLineChart.js +5 -4
- package/esm/context/CartesianContextProvider.js +8 -6
- package/esm/hooks/useTicks.js +2 -3
- package/esm/index.js +2 -0
- package/hooks/useTicks.d.ts +1 -2
- package/hooks/useTicks.js +2 -3
- package/index.d.ts +2 -0
- package/index.js +23 -1
- package/internals/defaultizeColor.d.ts +16 -16
- package/internals/defaultizeValueFormatter.d.ts +4 -7
- package/internals/stackSeries.d.ts +4 -7
- package/legacy/BarChart/BarChart.js +37 -13
- package/legacy/BarChart/BarElement.js +1 -0
- package/legacy/BarChart/BarPlot.js +10 -10
- package/legacy/ChartContainer/ChartContainer.js +6 -4
- package/legacy/ChartsAxis/ChartsAxis.js +4 -4
- package/legacy/ChartsGrid/ChartsGrid.js +119 -0
- package/legacy/ChartsGrid/chartsGridClasses.js +6 -0
- package/legacy/ChartsGrid/index.js +2 -0
- package/legacy/ChartsLegend/ChartsLegend.js +2 -323
- package/legacy/ChartsLegend/DefaultChartsLegend.js +302 -0
- package/legacy/ChartsLegend/index.js +1 -0
- package/legacy/ChartsReferenceLine/ChartsReferenceLine.js +2 -2
- package/legacy/ChartsSurface.js +5 -3
- package/legacy/ChartsTooltip/ChartsItemTooltipContent.js +2 -2
- package/legacy/ChartsTooltip/DefaultChartsAxisTooltipContent.js +2 -2
- package/legacy/ChartsTooltip/DefaultChartsItemTooltipContent.js +1 -1
- package/legacy/ChartsTooltip/utils.js +6 -0
- package/legacy/ChartsXAxis/ChartsXAxis.js +13 -9
- package/legacy/ChartsYAxis/ChartsYAxis.js +2 -2
- package/legacy/Gauge/Gauge.js +146 -0
- package/legacy/Gauge/GaugeContainer.js +215 -0
- package/legacy/Gauge/GaugeProvider.js +87 -0
- package/legacy/Gauge/GaugeReferenceArc.js +37 -0
- package/legacy/Gauge/GaugeValueArc.js +44 -0
- package/legacy/Gauge/GaugeValueText.js +66 -0
- package/legacy/Gauge/gaugeClasses.js +7 -0
- package/legacy/Gauge/index.js +7 -0
- package/legacy/Gauge/utils.js +84 -0
- package/legacy/LineChart/AnimatedArea.js +1 -1
- package/legacy/LineChart/AnimatedLine.js +1 -1
- package/legacy/LineChart/AreaElement.js +1 -1
- package/legacy/LineChart/LineChart.js +41 -13
- package/legacy/LineChart/LineElement.js +1 -1
- package/legacy/LineChart/LineHighlightElement.js +2 -1
- package/legacy/LineChart/MarkElement.js +1 -0
- package/legacy/PieChart/PieArc.js +11 -10
- package/legacy/PieChart/PieArcLabel.js +1 -0
- package/legacy/PieChart/PieArcLabelPlot.js +15 -15
- package/legacy/PieChart/PieArcPlot.js +1 -1
- package/legacy/PieChart/PieChart.js +32 -8
- package/legacy/ResponsiveChartContainer/ResponsiveChartContainer.js +13 -81
- package/legacy/ResponsiveChartContainer/useChartContainerDimensions.js +73 -0
- package/legacy/ScatterChart/ScatterChart.js +35 -8
- package/legacy/SparkLineChart/SparkLineChart.js +6 -5
- package/legacy/context/CartesianContextProvider.js +8 -6
- package/legacy/hooks/useTicks.js +2 -3
- package/legacy/index.js +3 -1
- package/models/axis.d.ts +7 -2
- package/models/seriesType/common.d.ts +2 -1
- package/models/seriesType/config.d.ts +7 -12
- package/models/seriesType/line.d.ts +2 -2
- package/models/seriesType/pie.d.ts +7 -3
- package/models/seriesType/scatter.d.ts +5 -2
- package/modern/BarChart/BarChart.js +37 -13
- package/modern/BarChart/BarElement.js +1 -0
- package/modern/BarChart/BarPlot.js +8 -10
- package/modern/ChartContainer/ChartContainer.js +6 -4
- package/modern/ChartsAxis/ChartsAxis.js +4 -4
- package/modern/ChartsGrid/ChartsGrid.js +121 -0
- package/modern/ChartsGrid/chartsGridClasses.js +6 -0
- package/modern/ChartsGrid/index.js +2 -0
- package/modern/ChartsLegend/ChartsLegend.js +2 -307
- package/modern/ChartsLegend/DefaultChartsLegend.js +286 -0
- package/modern/ChartsLegend/index.js +1 -0
- package/modern/ChartsReferenceLine/ChartsReferenceLine.js +2 -2
- package/modern/ChartsSurface.js +6 -4
- package/modern/ChartsTooltip/ChartsItemTooltipContent.js +2 -2
- package/modern/ChartsTooltip/DefaultChartsAxisTooltipContent.js +2 -2
- package/modern/ChartsTooltip/DefaultChartsItemTooltipContent.js +1 -1
- package/modern/ChartsTooltip/utils.js +6 -0
- package/modern/ChartsXAxis/ChartsXAxis.js +14 -10
- package/modern/ChartsYAxis/ChartsYAxis.js +2 -2
- package/modern/Gauge/Gauge.js +149 -0
- package/modern/Gauge/GaugeContainer.js +208 -0
- package/modern/Gauge/GaugeProvider.js +85 -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/AnimatedArea.js +1 -1
- package/modern/LineChart/AnimatedLine.js +1 -1
- package/modern/LineChart/AreaElement.js +1 -1
- package/modern/LineChart/LineChart.js +41 -13
- package/modern/LineChart/LineElement.js +1 -1
- package/modern/LineChart/LineHighlightElement.js +2 -1
- package/modern/LineChart/MarkElement.js +1 -0
- package/modern/PieChart/PieArc.js +10 -9
- package/modern/PieChart/PieArcLabel.js +1 -0
- package/modern/PieChart/PieArcLabelPlot.js +14 -14
- package/modern/PieChart/PieArcPlot.js +1 -1
- package/modern/PieChart/PieChart.js +32 -8
- package/modern/ResponsiveChartContainer/ResponsiveChartContainer.js +8 -70
- package/modern/ResponsiveChartContainer/useChartContainerDimensions.js +66 -0
- package/modern/ScatterChart/ScatterChart.js +35 -8
- package/modern/SparkLineChart/SparkLineChart.js +5 -4
- package/modern/context/CartesianContextProvider.js +8 -6
- package/modern/hooks/useTicks.js +2 -3
- package/modern/index.js +3 -1
- package/package.json +4 -4
|
@@ -11,6 +11,7 @@ import { ChartsTooltip } from '../ChartsTooltip';
|
|
|
11
11
|
import { ChartsLegend } from '../ChartsLegend';
|
|
12
12
|
import { ChartsAxisHighlight } from '../ChartsAxisHighlight';
|
|
13
13
|
import { ChartsClipPath } from '../ChartsClipPath';
|
|
14
|
+
import { ChartsGrid } from '../ChartsGrid';
|
|
14
15
|
import { ChartsOnAxisClickHandler } from '../ChartsOnAxisClickHandler';
|
|
15
16
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
16
17
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
@@ -39,6 +40,7 @@ var BarChart = /*#__PURE__*/React.forwardRef(function BarChart(props, ref) {
|
|
|
39
40
|
tooltip = props.tooltip,
|
|
40
41
|
axisHighlight = props.axisHighlight,
|
|
41
42
|
legend = props.legend,
|
|
43
|
+
grid = props.grid,
|
|
42
44
|
topAxis = props.topAxis,
|
|
43
45
|
leftAxis = props.leftAxis,
|
|
44
46
|
rightAxis = props.rightAxis,
|
|
@@ -94,6 +96,9 @@ var BarChart = /*#__PURE__*/React.forwardRef(function BarChart(props, ref) {
|
|
|
94
96
|
disableAxisListener: (tooltip == null ? void 0 : tooltip.trigger) !== 'axis' && (axisHighlight == null ? void 0 : axisHighlight.x) === 'none' && (axisHighlight == null ? void 0 : axisHighlight.y) === 'none' && !onAxisClick,
|
|
95
97
|
children: [onAxisClick && /*#__PURE__*/_jsx(ChartsOnAxisClickHandler, {
|
|
96
98
|
onAxisClick: onAxisClick
|
|
99
|
+
}), grid && /*#__PURE__*/_jsx(ChartsGrid, {
|
|
100
|
+
vertical: grid.vertical,
|
|
101
|
+
horizontal: grid.horizontal
|
|
97
102
|
}), /*#__PURE__*/_jsx("g", {
|
|
98
103
|
clipPath: "url(#".concat(clipPathId, ")"),
|
|
99
104
|
children: /*#__PURE__*/_jsx(BarPlot, {
|
|
@@ -126,11 +131,10 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
|
|
|
126
131
|
// | To update them edit the TypeScript types and run "yarn proptypes" |
|
|
127
132
|
// ----------------------------------------------------------------------
|
|
128
133
|
/**
|
|
129
|
-
*
|
|
130
|
-
*
|
|
131
|
-
*
|
|
132
|
-
*
|
|
133
|
-
* - 'band': display a band at the current mouse position. Only available with band scale.
|
|
134
|
+
* The configuration of axes highlight.
|
|
135
|
+
* Default is set to 'band' in the bar direction.
|
|
136
|
+
* Depends on `layout` prop.
|
|
137
|
+
* @see See {@link https://mui.com/x/react-charts/tooltip/#highlights highlight docs} for more details.
|
|
134
138
|
*/
|
|
135
139
|
axisHighlight: PropTypes.shape({
|
|
136
140
|
x: PropTypes.oneOf(['band', 'line', 'none']),
|
|
@@ -142,7 +146,7 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
|
|
|
142
146
|
* @default xAxisIds[0] The id of the first provided axis
|
|
143
147
|
*/
|
|
144
148
|
bottomAxis: PropTypes.oneOfType([PropTypes.shape({
|
|
145
|
-
axisId: PropTypes.string,
|
|
149
|
+
axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
146
150
|
classes: PropTypes.object,
|
|
147
151
|
disableLine: PropTypes.bool,
|
|
148
152
|
disableTicks: PropTypes.bool,
|
|
@@ -181,11 +185,22 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
|
|
|
181
185
|
* @default false
|
|
182
186
|
*/
|
|
183
187
|
disableAxisListener: PropTypes.bool,
|
|
188
|
+
/**
|
|
189
|
+
* Option to display a cartesian grid in the background.
|
|
190
|
+
*/
|
|
191
|
+
grid: PropTypes.shape({
|
|
192
|
+
horizontal: PropTypes.bool,
|
|
193
|
+
vertical: PropTypes.bool
|
|
194
|
+
}),
|
|
184
195
|
/**
|
|
185
196
|
* The height of the chart in px. If not defined, it takes the height of the parent element.
|
|
186
197
|
* @default undefined
|
|
187
198
|
*/
|
|
188
199
|
height: PropTypes.number,
|
|
200
|
+
/**
|
|
201
|
+
* The direction of the bar elements.
|
|
202
|
+
* @default 'vertical'
|
|
203
|
+
*/
|
|
189
204
|
layout: PropTypes.oneOf(['horizontal', 'vertical']),
|
|
190
205
|
/**
|
|
191
206
|
* Indicate which axis to display the left of the charts.
|
|
@@ -193,7 +208,7 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
|
|
|
193
208
|
* @default yAxisIds[0] The id of the first provided axis
|
|
194
209
|
*/
|
|
195
210
|
leftAxis: PropTypes.oneOfType([PropTypes.shape({
|
|
196
|
-
axisId: PropTypes.string,
|
|
211
|
+
axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
197
212
|
classes: PropTypes.object,
|
|
198
213
|
disableLine: PropTypes.bool,
|
|
199
214
|
disableTicks: PropTypes.bool,
|
|
@@ -259,7 +274,7 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
|
|
|
259
274
|
* @default null
|
|
260
275
|
*/
|
|
261
276
|
rightAxis: PropTypes.oneOfType([PropTypes.shape({
|
|
262
|
-
axisId: PropTypes.string,
|
|
277
|
+
axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
263
278
|
classes: PropTypes.object,
|
|
264
279
|
disableLine: PropTypes.bool,
|
|
265
280
|
disableTicks: PropTypes.bool,
|
|
@@ -280,6 +295,9 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
|
|
|
280
295
|
tickNumber: PropTypes.number,
|
|
281
296
|
tickSize: PropTypes.number
|
|
282
297
|
}), PropTypes.string]),
|
|
298
|
+
/**
|
|
299
|
+
* The series to display in the bar chart.
|
|
300
|
+
*/
|
|
283
301
|
series: PropTypes.arrayOf(PropTypes.object).isRequired,
|
|
284
302
|
/**
|
|
285
303
|
* If `true`, animations are skipped.
|
|
@@ -298,6 +316,10 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
|
|
|
298
316
|
slots: PropTypes.object,
|
|
299
317
|
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
|
|
300
318
|
title: PropTypes.string,
|
|
319
|
+
/**
|
|
320
|
+
* The configuration of the tooltip.
|
|
321
|
+
* @see See {@link https://mui.com/x/react-charts/tooltip/ tooltip docs} for more details.
|
|
322
|
+
*/
|
|
301
323
|
tooltip: PropTypes.shape({
|
|
302
324
|
axisContent: PropTypes.elementType,
|
|
303
325
|
classes: PropTypes.object,
|
|
@@ -312,7 +334,7 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
|
|
|
312
334
|
* @default null
|
|
313
335
|
*/
|
|
314
336
|
topAxis: PropTypes.oneOfType([PropTypes.shape({
|
|
315
|
-
axisId: PropTypes.string,
|
|
337
|
+
axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
316
338
|
classes: PropTypes.object,
|
|
317
339
|
disableLine: PropTypes.bool,
|
|
318
340
|
disableTicks: PropTypes.bool,
|
|
@@ -349,7 +371,7 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
|
|
|
349
371
|
* If not provided, a default axis config is used with id set to `DEFAULT_X_AXIS_KEY`.
|
|
350
372
|
*/
|
|
351
373
|
xAxis: PropTypes.arrayOf(PropTypes.shape({
|
|
352
|
-
axisId: PropTypes.string,
|
|
374
|
+
axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
353
375
|
classes: PropTypes.object,
|
|
354
376
|
data: PropTypes.array,
|
|
355
377
|
dataKey: PropTypes.string,
|
|
@@ -357,13 +379,14 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
|
|
|
357
379
|
disableTicks: PropTypes.bool,
|
|
358
380
|
fill: PropTypes.string,
|
|
359
381
|
hideTooltip: PropTypes.bool,
|
|
360
|
-
id: PropTypes.string,
|
|
382
|
+
id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
361
383
|
label: PropTypes.string,
|
|
362
384
|
labelFontSize: PropTypes.number,
|
|
363
385
|
labelStyle: PropTypes.object,
|
|
364
386
|
max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
365
387
|
min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
366
388
|
position: PropTypes.oneOf(['bottom', 'left', 'right', 'top']),
|
|
389
|
+
reverse: PropTypes.bool,
|
|
367
390
|
scaleType: PropTypes.oneOf(['band', 'linear', 'log', 'point', 'pow', 'sqrt', 'time', 'utc']),
|
|
368
391
|
slotProps: PropTypes.object,
|
|
369
392
|
slots: PropTypes.object,
|
|
@@ -383,7 +406,7 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
|
|
|
383
406
|
* If not provided, a default axis config is used with id set to `DEFAULT_Y_AXIS_KEY`.
|
|
384
407
|
*/
|
|
385
408
|
yAxis: PropTypes.arrayOf(PropTypes.shape({
|
|
386
|
-
axisId: PropTypes.string,
|
|
409
|
+
axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
387
410
|
classes: PropTypes.object,
|
|
388
411
|
data: PropTypes.array,
|
|
389
412
|
dataKey: PropTypes.string,
|
|
@@ -391,13 +414,14 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
|
|
|
391
414
|
disableTicks: PropTypes.bool,
|
|
392
415
|
fill: PropTypes.string,
|
|
393
416
|
hideTooltip: PropTypes.bool,
|
|
394
|
-
id: PropTypes.string,
|
|
417
|
+
id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
395
418
|
label: PropTypes.string,
|
|
396
419
|
labelFontSize: PropTypes.number,
|
|
397
420
|
labelStyle: PropTypes.object,
|
|
398
421
|
max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
399
422
|
min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
400
423
|
position: PropTypes.oneOf(['bottom', 'left', 'right', 'top']),
|
|
424
|
+
reverse: PropTypes.bool,
|
|
401
425
|
scaleType: PropTypes.oneOf(['band', 'linear', 'log', 'point', 'pow', 'sqrt', 'time', 'utc']),
|
|
402
426
|
slotProps: PropTypes.object,
|
|
403
427
|
slots: PropTypes.object,
|
|
@@ -104,6 +104,7 @@ process.env.NODE_ENV !== "production" ? BarElement.propTypes = {
|
|
|
104
104
|
faded: PropTypes.oneOf(['global', 'none', 'series']),
|
|
105
105
|
highlighted: PropTypes.oneOf(['item', 'none', 'series'])
|
|
106
106
|
}),
|
|
107
|
+
id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired,
|
|
107
108
|
/**
|
|
108
109
|
* The props used for each component slot.
|
|
109
110
|
* @default {}
|
|
@@ -10,7 +10,7 @@ import { CartesianContext } from '../context/CartesianContextProvider';
|
|
|
10
10
|
import { BarElement } from './BarElement';
|
|
11
11
|
import { isBandScaleConfig } from '../models/axis';
|
|
12
12
|
import { DEFAULT_X_AXIS_KEY, DEFAULT_Y_AXIS_KEY } from '../constants';
|
|
13
|
-
|
|
13
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
14
|
/**
|
|
15
15
|
* Solution of the equations
|
|
16
16
|
* W = barWidth * N + offset * (N-1)
|
|
@@ -20,7 +20,6 @@ import { DEFAULT_X_AXIS_KEY, DEFAULT_Y_AXIS_KEY } from '../constants';
|
|
|
20
20
|
* @param gapRatio The ratio of the gap between bars over the bar width.
|
|
21
21
|
* @returns The bar width and the offset between bars.
|
|
22
22
|
*/
|
|
23
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
24
23
|
function getBandSize(_ref) {
|
|
25
24
|
var W = _ref.bandWidth,
|
|
26
25
|
N = _ref.numberOfGroups,
|
|
@@ -97,20 +96,21 @@ var useAggregatedData = function useAggregatedData() {
|
|
|
97
96
|
color = _series$seriesId.color;
|
|
98
97
|
return stackedData.map(function (values, dataIndex) {
|
|
99
98
|
var _xAxis$xAxisKey$data, _yAxis$yAxisKey$data;
|
|
100
|
-
var
|
|
101
|
-
|
|
99
|
+
var valueCoordinates = values.map(function (v) {
|
|
100
|
+
return verticalLayout ? yScale(v) : xScale(v);
|
|
101
|
+
});
|
|
102
|
+
var minValueCoord = Math.min.apply(Math, _toConsumableArray(valueCoordinates));
|
|
103
|
+
var maxValueCoord = Math.max.apply(Math, _toConsumableArray(valueCoordinates));
|
|
102
104
|
return {
|
|
103
|
-
bottom: bottom,
|
|
104
|
-
top: top,
|
|
105
105
|
seriesId: seriesId,
|
|
106
106
|
dataIndex: dataIndex,
|
|
107
107
|
layout: series[seriesId].layout,
|
|
108
|
-
x: verticalLayout ? xScale((_xAxis$xAxisKey$data = xAxis[xAxisKey].data) == null ? void 0 : _xAxis$xAxisKey$data[dataIndex]) + barOffset :
|
|
109
|
-
y: verticalLayout ?
|
|
108
|
+
x: verticalLayout ? xScale((_xAxis$xAxisKey$data = xAxis[xAxisKey].data) == null ? void 0 : _xAxis$xAxisKey$data[dataIndex]) + barOffset : minValueCoord,
|
|
109
|
+
y: verticalLayout ? minValueCoord : yScale((_yAxis$yAxisKey$data = yAxis[yAxisKey].data) == null ? void 0 : _yAxis$yAxisKey$data[dataIndex]) + barOffset,
|
|
110
110
|
xOrigin: xScale(0),
|
|
111
111
|
yOrigin: yScale(0),
|
|
112
|
-
height: verticalLayout ?
|
|
113
|
-
width: verticalLayout ? barWidth :
|
|
112
|
+
height: verticalLayout ? maxValueCoord - minValueCoord : barWidth,
|
|
113
|
+
width: verticalLayout ? barWidth : maxValueCoord - minValueCoord,
|
|
114
114
|
color: color,
|
|
115
115
|
highlightScope: series[seriesId].highlightScope
|
|
116
116
|
};
|
|
@@ -120,7 +120,7 @@ process.env.NODE_ENV !== "production" ? ChartContainer.propTypes = {
|
|
|
120
120
|
* If not provided, a default axis config is used with id set to `DEFAULT_X_AXIS_KEY`.
|
|
121
121
|
*/
|
|
122
122
|
xAxis: PropTypes.arrayOf(PropTypes.shape({
|
|
123
|
-
axisId: PropTypes.string,
|
|
123
|
+
axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
124
124
|
classes: PropTypes.object,
|
|
125
125
|
data: PropTypes.array,
|
|
126
126
|
dataKey: PropTypes.string,
|
|
@@ -128,13 +128,14 @@ process.env.NODE_ENV !== "production" ? ChartContainer.propTypes = {
|
|
|
128
128
|
disableTicks: PropTypes.bool,
|
|
129
129
|
fill: PropTypes.string,
|
|
130
130
|
hideTooltip: PropTypes.bool,
|
|
131
|
-
id: PropTypes.string,
|
|
131
|
+
id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
132
132
|
label: PropTypes.string,
|
|
133
133
|
labelFontSize: PropTypes.number,
|
|
134
134
|
labelStyle: PropTypes.object,
|
|
135
135
|
max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
136
136
|
min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
137
137
|
position: PropTypes.oneOf(['bottom', 'left', 'right', 'top']),
|
|
138
|
+
reverse: PropTypes.bool,
|
|
138
139
|
scaleType: PropTypes.oneOf(['band', 'linear', 'log', 'point', 'pow', 'sqrt', 'time', 'utc']),
|
|
139
140
|
slotProps: PropTypes.object,
|
|
140
141
|
slots: PropTypes.object,
|
|
@@ -154,7 +155,7 @@ process.env.NODE_ENV !== "production" ? ChartContainer.propTypes = {
|
|
|
154
155
|
* If not provided, a default axis config is used with id set to `DEFAULT_Y_AXIS_KEY`.
|
|
155
156
|
*/
|
|
156
157
|
yAxis: PropTypes.arrayOf(PropTypes.shape({
|
|
157
|
-
axisId: PropTypes.string,
|
|
158
|
+
axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
158
159
|
classes: PropTypes.object,
|
|
159
160
|
data: PropTypes.array,
|
|
160
161
|
dataKey: PropTypes.string,
|
|
@@ -162,13 +163,14 @@ process.env.NODE_ENV !== "production" ? ChartContainer.propTypes = {
|
|
|
162
163
|
disableTicks: PropTypes.bool,
|
|
163
164
|
fill: PropTypes.string,
|
|
164
165
|
hideTooltip: PropTypes.bool,
|
|
165
|
-
id: PropTypes.string,
|
|
166
|
+
id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
166
167
|
label: PropTypes.string,
|
|
167
168
|
labelFontSize: PropTypes.number,
|
|
168
169
|
labelStyle: PropTypes.object,
|
|
169
170
|
max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
170
171
|
min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
171
172
|
position: PropTypes.oneOf(['bottom', 'left', 'right', 'top']),
|
|
173
|
+
reverse: PropTypes.bool,
|
|
172
174
|
scaleType: PropTypes.oneOf(['band', 'linear', 'log', 'point', 'pow', 'sqrt', 'time', 'utc']),
|
|
173
175
|
slotProps: PropTypes.object,
|
|
174
176
|
slots: PropTypes.object,
|
|
@@ -99,7 +99,7 @@ process.env.NODE_ENV !== "production" ? ChartsAxis.propTypes = {
|
|
|
99
99
|
* @default xAxisIds[0] The id of the first provided axis
|
|
100
100
|
*/
|
|
101
101
|
bottomAxis: PropTypes.oneOfType([PropTypes.shape({
|
|
102
|
-
axisId: PropTypes.string,
|
|
102
|
+
axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
103
103
|
classes: PropTypes.object,
|
|
104
104
|
disableLine: PropTypes.bool,
|
|
105
105
|
disableTicks: PropTypes.bool,
|
|
@@ -126,7 +126,7 @@ process.env.NODE_ENV !== "production" ? ChartsAxis.propTypes = {
|
|
|
126
126
|
* @default yAxisIds[0] The id of the first provided axis
|
|
127
127
|
*/
|
|
128
128
|
leftAxis: PropTypes.oneOfType([PropTypes.shape({
|
|
129
|
-
axisId: PropTypes.string,
|
|
129
|
+
axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
130
130
|
classes: PropTypes.object,
|
|
131
131
|
disableLine: PropTypes.bool,
|
|
132
132
|
disableTicks: PropTypes.bool,
|
|
@@ -153,7 +153,7 @@ process.env.NODE_ENV !== "production" ? ChartsAxis.propTypes = {
|
|
|
153
153
|
* @default null
|
|
154
154
|
*/
|
|
155
155
|
rightAxis: PropTypes.oneOfType([PropTypes.shape({
|
|
156
|
-
axisId: PropTypes.string,
|
|
156
|
+
axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
157
157
|
classes: PropTypes.object,
|
|
158
158
|
disableLine: PropTypes.bool,
|
|
159
159
|
disableTicks: PropTypes.bool,
|
|
@@ -190,7 +190,7 @@ process.env.NODE_ENV !== "production" ? ChartsAxis.propTypes = {
|
|
|
190
190
|
* @default null
|
|
191
191
|
*/
|
|
192
192
|
topAxis: PropTypes.oneOfType([PropTypes.shape({
|
|
193
|
-
axisId: PropTypes.string,
|
|
193
|
+
axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
194
194
|
classes: PropTypes.object,
|
|
195
195
|
disableLine: PropTypes.bool,
|
|
196
196
|
disableTicks: PropTypes.bool,
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
3
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
4
|
+
var _excluded = ["vertical", "horizontal"];
|
|
5
|
+
import * as React from 'react';
|
|
6
|
+
import PropTypes from 'prop-types';
|
|
7
|
+
import composeClasses from '@mui/utils/composeClasses';
|
|
8
|
+
import { styled } from '@mui/material/styles';
|
|
9
|
+
import { CartesianContext } from '../context/CartesianContextProvider';
|
|
10
|
+
import { useTicks } from '../hooks/useTicks';
|
|
11
|
+
import { getChartsGridUtilityClass, chartsGridClasses } from './chartsGridClasses';
|
|
12
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
14
|
+
var GridRoot = styled('g', {
|
|
15
|
+
name: 'MuiChartsGrid',
|
|
16
|
+
slot: 'Root',
|
|
17
|
+
overridesResolver: function overridesResolver(props, styles) {
|
|
18
|
+
return styles.root;
|
|
19
|
+
}
|
|
20
|
+
})(function (_ref) {
|
|
21
|
+
var theme = _ref.theme;
|
|
22
|
+
return _defineProperty({}, "& .".concat(chartsGridClasses.line), {
|
|
23
|
+
stroke: (theme.vars || theme).palette.divider,
|
|
24
|
+
shapeRendering: 'crispEdges',
|
|
25
|
+
strokeWidth: 1
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
var useUtilityClasses = function useUtilityClasses(_ref3) {
|
|
29
|
+
var classes = _ref3.classes;
|
|
30
|
+
var slots = {
|
|
31
|
+
root: ['root'],
|
|
32
|
+
verticalLine: ['line', 'verticalLine'],
|
|
33
|
+
horizontalLine: ['line', 'horizontalLine']
|
|
34
|
+
};
|
|
35
|
+
return composeClasses(slots, getChartsGridUtilityClass, classes);
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* Demos:
|
|
39
|
+
*
|
|
40
|
+
* - [Axis](https://mui.com/x/react-charts/axis/)
|
|
41
|
+
*
|
|
42
|
+
* API:
|
|
43
|
+
*
|
|
44
|
+
* - [ChartsGrid API](https://mui.com/x/api/charts/charts-axis/)
|
|
45
|
+
*/
|
|
46
|
+
function ChartsGrid(props) {
|
|
47
|
+
var vertical = props.vertical,
|
|
48
|
+
horizontal = props.horizontal,
|
|
49
|
+
other = _objectWithoutProperties(props, _excluded);
|
|
50
|
+
var _React$useContext = React.useContext(CartesianContext),
|
|
51
|
+
xAxis = _React$useContext.xAxis,
|
|
52
|
+
xAxisIds = _React$useContext.xAxisIds,
|
|
53
|
+
yAxis = _React$useContext.yAxis,
|
|
54
|
+
yAxisIds = _React$useContext.yAxisIds;
|
|
55
|
+
var classes = useUtilityClasses(props);
|
|
56
|
+
var horizontalAxisId = yAxisIds[0];
|
|
57
|
+
var verticalAxisId = xAxisIds[0];
|
|
58
|
+
var _xAxis$verticalAxisId = xAxis[verticalAxisId],
|
|
59
|
+
xScale = _xAxis$verticalAxisId.scale,
|
|
60
|
+
xTickNumber = _xAxis$verticalAxisId.tickNumber,
|
|
61
|
+
xTickInterval = _xAxis$verticalAxisId.tickInterval;
|
|
62
|
+
var _yAxis$horizontalAxis = yAxis[horizontalAxisId],
|
|
63
|
+
yScale = _yAxis$horizontalAxis.scale,
|
|
64
|
+
yTickNumber = _yAxis$horizontalAxis.tickNumber,
|
|
65
|
+
yTickInterval = _yAxis$horizontalAxis.tickInterval;
|
|
66
|
+
var xTicks = useTicks({
|
|
67
|
+
scale: xScale,
|
|
68
|
+
tickNumber: xTickNumber,
|
|
69
|
+
tickInterval: xTickInterval
|
|
70
|
+
});
|
|
71
|
+
var yTicks = useTicks({
|
|
72
|
+
scale: yScale,
|
|
73
|
+
tickNumber: yTickNumber,
|
|
74
|
+
tickInterval: yTickInterval
|
|
75
|
+
});
|
|
76
|
+
return /*#__PURE__*/_jsxs(GridRoot, _extends({}, other, {
|
|
77
|
+
className: classes.root,
|
|
78
|
+
children: [vertical && xTicks.map(function (_ref4) {
|
|
79
|
+
var formattedValue = _ref4.formattedValue,
|
|
80
|
+
offset = _ref4.offset;
|
|
81
|
+
return /*#__PURE__*/_jsx("line", {
|
|
82
|
+
y1: yScale.range()[0],
|
|
83
|
+
y2: yScale.range()[1],
|
|
84
|
+
x1: offset,
|
|
85
|
+
x2: offset,
|
|
86
|
+
className: classes.verticalLine
|
|
87
|
+
}, formattedValue);
|
|
88
|
+
}), horizontal && yTicks.map(function (_ref5) {
|
|
89
|
+
var formattedValue = _ref5.formattedValue,
|
|
90
|
+
offset = _ref5.offset;
|
|
91
|
+
return /*#__PURE__*/_jsx("line", {
|
|
92
|
+
y1: offset,
|
|
93
|
+
y2: offset,
|
|
94
|
+
x1: xScale.range()[0],
|
|
95
|
+
x2: xScale.range()[1],
|
|
96
|
+
className: classes.horizontalLine
|
|
97
|
+
}, formattedValue);
|
|
98
|
+
})]
|
|
99
|
+
}));
|
|
100
|
+
}
|
|
101
|
+
process.env.NODE_ENV !== "production" ? ChartsGrid.propTypes = {
|
|
102
|
+
// ----------------------------- Warning --------------------------------
|
|
103
|
+
// | These PropTypes are generated from the TypeScript type definitions |
|
|
104
|
+
// | To update them edit the TypeScript types and run "yarn proptypes" |
|
|
105
|
+
// ----------------------------------------------------------------------
|
|
106
|
+
/**
|
|
107
|
+
* Override or extend the styles applied to the component.
|
|
108
|
+
*/
|
|
109
|
+
classes: PropTypes.object,
|
|
110
|
+
/**
|
|
111
|
+
* Displays horizontal grid.
|
|
112
|
+
*/
|
|
113
|
+
horizontal: PropTypes.bool,
|
|
114
|
+
/**
|
|
115
|
+
* Displays vertical grid.
|
|
116
|
+
*/
|
|
117
|
+
vertical: PropTypes.bool
|
|
118
|
+
} : void 0;
|
|
119
|
+
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 var chartsGridClasses = generateUtilityClasses('MuiChartsGrid', ['root', 'line', 'horizontalLine', 'verticalLine']);
|