@mui/x-charts 9.0.0 → 9.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/BarChart/BarChart.js +27 -9
- package/BarChart/BarChart.mjs +27 -9
- package/BarChart/BarElement.js +1 -5
- package/BarChart/BarElement.mjs +1 -5
- package/BarChart/seriesConfig/bar/getSeriesWithDefaultValues.d.mts +1 -0
- package/BarChart/seriesConfig/bar/getSeriesWithDefaultValues.d.ts +1 -0
- package/BarChart/seriesConfig/bar/seriesProcessor.js +37 -13
- package/BarChart/seriesConfig/bar/seriesProcessor.mjs +37 -13
- package/CHANGELOG.md +215 -6891
- package/ChartsContainer/ChartsContainer.js +59 -30
- package/ChartsContainer/ChartsContainer.mjs +59 -30
- package/ChartsDataProvider/useChartsDataProviderProps.js +1 -6
- package/ChartsDataProvider/useChartsDataProviderProps.mjs +1 -6
- package/ChartsGrid/styledComponents.js +2 -2
- package/ChartsGrid/styledComponents.mjs +2 -2
- package/ChartsRadialDataProvider/ChartsRadialDataProvider.d.mts +38 -0
- package/ChartsRadialDataProvider/ChartsRadialDataProvider.d.ts +38 -0
- package/ChartsRadialDataProvider/ChartsRadialDataProvider.js +115 -0
- package/ChartsRadialDataProvider/ChartsRadialDataProvider.mjs +109 -0
- package/ChartsRadialDataProvider/ChartsRadialDataProvider.plugins.d.mts +9 -0
- package/ChartsRadialDataProvider/ChartsRadialDataProvider.plugins.d.ts +9 -0
- package/ChartsRadialDataProvider/ChartsRadialDataProvider.plugins.js +13 -0
- package/ChartsRadialDataProvider/ChartsRadialDataProvider.plugins.mjs +7 -0
- package/ChartsRadialDataProvider/index.d.mts +2 -0
- package/ChartsRadialDataProvider/index.d.ts +2 -0
- package/ChartsRadialDataProvider/index.js +27 -0
- package/ChartsRadialDataProvider/index.mjs +2 -0
- package/ChartsRadialDataProvider/useChartsRadialDataProviderProps.d.mts +13 -0
- package/ChartsRadialDataProvider/useChartsRadialDataProviderProps.d.ts +13 -0
- package/ChartsRadialDataProvider/useChartsRadialDataProviderProps.js +46 -0
- package/ChartsRadialDataProvider/useChartsRadialDataProviderProps.mjs +39 -0
- package/ChartsRadialGrid/ChartsRadialGrid.d.mts +33 -0
- package/ChartsRadialGrid/ChartsRadialGrid.d.ts +33 -0
- package/ChartsRadialGrid/ChartsRadialGrid.js +99 -0
- package/ChartsRadialGrid/ChartsRadialGrid.mjs +94 -0
- package/ChartsRadialGrid/ChartsRadiusGrid.d.mts +13 -0
- package/ChartsRadialGrid/ChartsRadiusGrid.d.ts +13 -0
- package/ChartsRadialGrid/ChartsRadiusGrid.js +73 -0
- package/ChartsRadialGrid/ChartsRadiusGrid.mjs +66 -0
- package/ChartsRadialGrid/ChartsRotationGrid.d.mts +13 -0
- package/ChartsRadialGrid/ChartsRotationGrid.d.ts +13 -0
- package/ChartsRadialGrid/ChartsRotationGrid.js +65 -0
- package/ChartsRadialGrid/ChartsRotationGrid.mjs +58 -0
- package/ChartsRadialGrid/chartsRadialGridClasses.d.mts +13 -0
- package/ChartsRadialGrid/chartsRadialGridClasses.d.ts +13 -0
- package/ChartsRadialGrid/chartsRadialGridClasses.js +14 -0
- package/ChartsRadialGrid/chartsRadialGridClasses.mjs +6 -0
- package/ChartsRadialGrid/index.d.mts +3 -0
- package/ChartsRadialGrid/index.d.ts +3 -0
- package/ChartsRadialGrid/index.js +19 -0
- package/ChartsRadialGrid/index.mjs +2 -0
- package/ChartsRadialGrid/styledComponents.d.mts +4 -0
- package/ChartsRadialGrid/styledComponents.d.ts +4 -0
- package/ChartsRadialGrid/styledComponents.js +50 -0
- package/ChartsRadialGrid/styledComponents.mjs +44 -0
- package/ChartsXAxis/useAxisTicksProps.d.mts +407 -326
- package/ChartsXAxis/useAxisTicksProps.d.ts +407 -326
- package/ChartsYAxis/useAxisTicksProps.d.mts +407 -326
- package/ChartsYAxis/useAxisTicksProps.d.ts +407 -326
- package/LineChart/LineChart.d.mts +1 -2
- package/LineChart/LineChart.d.ts +1 -2
- package/LineChart/LineChart.js +27 -9
- package/LineChart/LineChart.mjs +27 -9
- package/LineChart/seriesConfig/seriesProcessor.js +37 -13
- package/LineChart/seriesConfig/seriesProcessor.mjs +37 -13
- package/RadarChart/RadarAxis/useRadarAxis.d.mts +1 -1
- package/RadarChart/RadarAxis/useRadarAxis.d.ts +1 -1
- package/RadarChart/RadarAxis/useRadarAxis.js +2 -2
- package/RadarChart/RadarAxis/useRadarAxis.mjs +2 -2
- package/ScatterChart/Scatter.d.mts +11 -0
- package/ScatterChart/Scatter.d.ts +11 -0
- package/ScatterChart/Scatter.js +11 -0
- package/ScatterChart/Scatter.mjs +14 -0
- package/ScatterChart/ScatterChart.js +29 -10
- package/ScatterChart/ScatterChart.mjs +29 -10
- package/ScatterChart/seriesConfig/seriesProcessor.js +9 -4
- package/ScatterChart/seriesConfig/seriesProcessor.mjs +9 -4
- package/SparkLineChart/SparkLineChart.js +27 -9
- package/SparkLineChart/SparkLineChart.mjs +27 -9
- package/hooks/useTicks.d.mts +1 -1
- package/hooks/useTicks.d.ts +1 -1
- package/hooks/useTicks.js +21 -3
- package/hooks/useTicks.mjs +21 -3
- package/index.d.mts +2 -0
- package/index.d.ts +2 -0
- package/index.js +25 -1
- package/index.mjs +3 -1
- package/internals/material/index.js +6 -1
- package/internals/material/index.mjs +6 -1
- package/internals/plugins/featurePlugins/useChartCartesianAxis/defaultizeAxis.js +8 -12
- package/internals/plugins/featurePlugins/useChartCartesianAxis/defaultizeAxis.mjs +8 -12
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.d.mts +1 -0
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.d.ts +1 -0
- package/internals/plugins/featurePlugins/useChartPolarAxis/computeAxisValue.js +7 -4
- package/internals/plugins/featurePlugins/useChartPolarAxis/computeAxisValue.mjs +8 -5
- package/internals/plugins/featurePlugins/useChartPolarAxis/defaultizeAxis.js +3 -3
- package/internals/plugins/featurePlugins/useChartPolarAxis/defaultizeAxis.mjs +3 -3
- package/internals/plugins/featurePlugins/useChartZAxis/useChartZAxis.js +3 -3
- package/internals/plugins/featurePlugins/useChartZAxis/useChartZAxis.mjs +3 -3
- package/models/axis.d.mts +11 -2
- package/models/axis.d.ts +11 -2
- package/models/seriesType/bar.d.mts +9 -0
- package/models/seriesType/bar.d.ts +9 -0
- package/models/seriesType/line.d.mts +9 -0
- package/models/seriesType/line.d.ts +9 -0
- package/models/seriesType/scatter.d.mts +9 -0
- package/models/seriesType/scatter.d.ts +9 -0
- package/models/slots/chartsBaseSlotProps.d.mts +17 -0
- package/models/slots/chartsBaseSlotProps.d.ts +17 -0
- package/models/slots/chartsBaseSlots.d.mts +7 -1
- package/models/slots/chartsBaseSlots.d.ts +7 -1
- package/models/z-axis.d.mts +9 -0
- package/models/z-axis.d.ts +9 -0
- package/package.json +31 -3
- package/themeAugmentation/components.d.mts +4 -0
- package/themeAugmentation/components.d.ts +4 -0
- package/themeAugmentation/overrides.d.mts +2 -0
- package/themeAugmentation/overrides.d.ts +2 -0
- package/themeAugmentation/props.d.mts +2 -0
- package/themeAugmentation/props.d.ts +2 -0
- package/utils/epsilon.d.mts +1 -0
- package/utils/epsilon.d.ts +1 -0
- package/utils/epsilon.js +7 -0
- package/utils/epsilon.mjs +1 -0
|
@@ -641,7 +641,8 @@ process.env.NODE_ENV !== "production" ? SparkLineChart.propTypes = {
|
|
|
641
641
|
tickPlacement: PropTypes.oneOf(['end', 'extremities', 'middle', 'start']),
|
|
642
642
|
tickSize: PropTypes.number,
|
|
643
643
|
tickSpacing: PropTypes.number,
|
|
644
|
-
valueFormatter: PropTypes.func
|
|
644
|
+
valueFormatter: PropTypes.func,
|
|
645
|
+
valueGetter: PropTypes.func
|
|
645
646
|
}), PropTypes.shape({
|
|
646
647
|
axis: PropTypes.oneOf(['x']),
|
|
647
648
|
classes: PropTypes.object,
|
|
@@ -700,7 +701,8 @@ process.env.NODE_ENV !== "production" ? SparkLineChart.propTypes = {
|
|
|
700
701
|
tickPlacement: PropTypes.oneOf(['end', 'extremities', 'middle', 'start']),
|
|
701
702
|
tickSize: PropTypes.number,
|
|
702
703
|
tickSpacing: PropTypes.number,
|
|
703
|
-
valueFormatter: PropTypes.func
|
|
704
|
+
valueFormatter: PropTypes.func,
|
|
705
|
+
valueGetter: PropTypes.func
|
|
704
706
|
}), PropTypes.shape({
|
|
705
707
|
axis: PropTypes.oneOf(['x']),
|
|
706
708
|
classes: PropTypes.object,
|
|
@@ -746,7 +748,8 @@ process.env.NODE_ENV !== "production" ? SparkLineChart.propTypes = {
|
|
|
746
748
|
tickPlacement: PropTypes.oneOf(['end', 'extremities', 'middle', 'start']),
|
|
747
749
|
tickSize: PropTypes.number,
|
|
748
750
|
tickSpacing: PropTypes.number,
|
|
749
|
-
valueFormatter: PropTypes.func
|
|
751
|
+
valueFormatter: PropTypes.func,
|
|
752
|
+
valueGetter: PropTypes.func
|
|
750
753
|
}), PropTypes.shape({
|
|
751
754
|
axis: PropTypes.oneOf(['x']),
|
|
752
755
|
classes: PropTypes.object,
|
|
@@ -793,7 +796,8 @@ process.env.NODE_ENV !== "production" ? SparkLineChart.propTypes = {
|
|
|
793
796
|
tickPlacement: PropTypes.oneOf(['end', 'extremities', 'middle', 'start']),
|
|
794
797
|
tickSize: PropTypes.number,
|
|
795
798
|
tickSpacing: PropTypes.number,
|
|
796
|
-
valueFormatter: PropTypes.func
|
|
799
|
+
valueFormatter: PropTypes.func,
|
|
800
|
+
valueGetter: PropTypes.func
|
|
797
801
|
}), PropTypes.shape({
|
|
798
802
|
axis: PropTypes.oneOf(['x']),
|
|
799
803
|
classes: PropTypes.object,
|
|
@@ -839,7 +843,8 @@ process.env.NODE_ENV !== "production" ? SparkLineChart.propTypes = {
|
|
|
839
843
|
tickPlacement: PropTypes.oneOf(['end', 'extremities', 'middle', 'start']),
|
|
840
844
|
tickSize: PropTypes.number,
|
|
841
845
|
tickSpacing: PropTypes.number,
|
|
842
|
-
valueFormatter: PropTypes.func
|
|
846
|
+
valueFormatter: PropTypes.func,
|
|
847
|
+
valueGetter: PropTypes.func
|
|
843
848
|
}), PropTypes.shape({
|
|
844
849
|
axis: PropTypes.oneOf(['x']),
|
|
845
850
|
classes: PropTypes.object,
|
|
@@ -885,7 +890,8 @@ process.env.NODE_ENV !== "production" ? SparkLineChart.propTypes = {
|
|
|
885
890
|
tickPlacement: PropTypes.oneOf(['end', 'extremities', 'middle', 'start']),
|
|
886
891
|
tickSize: PropTypes.number,
|
|
887
892
|
tickSpacing: PropTypes.number,
|
|
888
|
-
valueFormatter: PropTypes.func
|
|
893
|
+
valueFormatter: PropTypes.func,
|
|
894
|
+
valueGetter: PropTypes.func
|
|
889
895
|
}), PropTypes.shape({
|
|
890
896
|
axis: PropTypes.oneOf(['x']),
|
|
891
897
|
classes: PropTypes.object,
|
|
@@ -935,7 +941,8 @@ process.env.NODE_ENV !== "production" ? SparkLineChart.propTypes = {
|
|
|
935
941
|
tickPlacement: PropTypes.oneOf(['end', 'extremities', 'middle', 'start']),
|
|
936
942
|
tickSize: PropTypes.number,
|
|
937
943
|
tickSpacing: PropTypes.number,
|
|
938
|
-
valueFormatter: PropTypes.func
|
|
944
|
+
valueFormatter: PropTypes.func,
|
|
945
|
+
valueGetter: PropTypes.func
|
|
939
946
|
}), PropTypes.shape({
|
|
940
947
|
axis: PropTypes.oneOf(['x']),
|
|
941
948
|
classes: PropTypes.object,
|
|
@@ -985,7 +992,8 @@ process.env.NODE_ENV !== "production" ? SparkLineChart.propTypes = {
|
|
|
985
992
|
tickPlacement: PropTypes.oneOf(['end', 'extremities', 'middle', 'start']),
|
|
986
993
|
tickSize: PropTypes.number,
|
|
987
994
|
tickSpacing: PropTypes.number,
|
|
988
|
-
valueFormatter: PropTypes.func
|
|
995
|
+
valueFormatter: PropTypes.func,
|
|
996
|
+
valueGetter: PropTypes.func
|
|
989
997
|
}), PropTypes.shape({
|
|
990
998
|
axis: PropTypes.oneOf(['x']),
|
|
991
999
|
classes: PropTypes.object,
|
|
@@ -1031,7 +1039,8 @@ process.env.NODE_ENV !== "production" ? SparkLineChart.propTypes = {
|
|
|
1031
1039
|
tickPlacement: PropTypes.oneOf(['end', 'extremities', 'middle', 'start']),
|
|
1032
1040
|
tickSize: PropTypes.number,
|
|
1033
1041
|
tickSpacing: PropTypes.number,
|
|
1034
|
-
valueFormatter: PropTypes.func
|
|
1042
|
+
valueFormatter: PropTypes.func,
|
|
1043
|
+
valueGetter: PropTypes.func
|
|
1035
1044
|
})]),
|
|
1036
1045
|
/**
|
|
1037
1046
|
* The yAxis configuration.
|
|
@@ -1096,6 +1105,7 @@ process.env.NODE_ENV !== "production" ? SparkLineChart.propTypes = {
|
|
|
1096
1105
|
tickSize: PropTypes.number,
|
|
1097
1106
|
tickSpacing: PropTypes.number,
|
|
1098
1107
|
valueFormatter: PropTypes.func,
|
|
1108
|
+
valueGetter: PropTypes.func,
|
|
1099
1109
|
width: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number])
|
|
1100
1110
|
}), PropTypes.shape({
|
|
1101
1111
|
axis: PropTypes.oneOf(['y']),
|
|
@@ -1154,6 +1164,7 @@ process.env.NODE_ENV !== "production" ? SparkLineChart.propTypes = {
|
|
|
1154
1164
|
tickSize: PropTypes.number,
|
|
1155
1165
|
tickSpacing: PropTypes.number,
|
|
1156
1166
|
valueFormatter: PropTypes.func,
|
|
1167
|
+
valueGetter: PropTypes.func,
|
|
1157
1168
|
width: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number])
|
|
1158
1169
|
}), PropTypes.shape({
|
|
1159
1170
|
axis: PropTypes.oneOf(['y']),
|
|
@@ -1199,6 +1210,7 @@ process.env.NODE_ENV !== "production" ? SparkLineChart.propTypes = {
|
|
|
1199
1210
|
tickSize: PropTypes.number,
|
|
1200
1211
|
tickSpacing: PropTypes.number,
|
|
1201
1212
|
valueFormatter: PropTypes.func,
|
|
1213
|
+
valueGetter: PropTypes.func,
|
|
1202
1214
|
width: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number])
|
|
1203
1215
|
}), PropTypes.shape({
|
|
1204
1216
|
axis: PropTypes.oneOf(['y']),
|
|
@@ -1245,6 +1257,7 @@ process.env.NODE_ENV !== "production" ? SparkLineChart.propTypes = {
|
|
|
1245
1257
|
tickSize: PropTypes.number,
|
|
1246
1258
|
tickSpacing: PropTypes.number,
|
|
1247
1259
|
valueFormatter: PropTypes.func,
|
|
1260
|
+
valueGetter: PropTypes.func,
|
|
1248
1261
|
width: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number])
|
|
1249
1262
|
}), PropTypes.shape({
|
|
1250
1263
|
axis: PropTypes.oneOf(['y']),
|
|
@@ -1290,6 +1303,7 @@ process.env.NODE_ENV !== "production" ? SparkLineChart.propTypes = {
|
|
|
1290
1303
|
tickSize: PropTypes.number,
|
|
1291
1304
|
tickSpacing: PropTypes.number,
|
|
1292
1305
|
valueFormatter: PropTypes.func,
|
|
1306
|
+
valueGetter: PropTypes.func,
|
|
1293
1307
|
width: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number])
|
|
1294
1308
|
}), PropTypes.shape({
|
|
1295
1309
|
axis: PropTypes.oneOf(['y']),
|
|
@@ -1335,6 +1349,7 @@ process.env.NODE_ENV !== "production" ? SparkLineChart.propTypes = {
|
|
|
1335
1349
|
tickSize: PropTypes.number,
|
|
1336
1350
|
tickSpacing: PropTypes.number,
|
|
1337
1351
|
valueFormatter: PropTypes.func,
|
|
1352
|
+
valueGetter: PropTypes.func,
|
|
1338
1353
|
width: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number])
|
|
1339
1354
|
}), PropTypes.shape({
|
|
1340
1355
|
axis: PropTypes.oneOf(['y']),
|
|
@@ -1384,6 +1399,7 @@ process.env.NODE_ENV !== "production" ? SparkLineChart.propTypes = {
|
|
|
1384
1399
|
tickSize: PropTypes.number,
|
|
1385
1400
|
tickSpacing: PropTypes.number,
|
|
1386
1401
|
valueFormatter: PropTypes.func,
|
|
1402
|
+
valueGetter: PropTypes.func,
|
|
1387
1403
|
width: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number])
|
|
1388
1404
|
}), PropTypes.shape({
|
|
1389
1405
|
axis: PropTypes.oneOf(['y']),
|
|
@@ -1433,6 +1449,7 @@ process.env.NODE_ENV !== "production" ? SparkLineChart.propTypes = {
|
|
|
1433
1449
|
tickSize: PropTypes.number,
|
|
1434
1450
|
tickSpacing: PropTypes.number,
|
|
1435
1451
|
valueFormatter: PropTypes.func,
|
|
1452
|
+
valueGetter: PropTypes.func,
|
|
1436
1453
|
width: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number])
|
|
1437
1454
|
}), PropTypes.shape({
|
|
1438
1455
|
axis: PropTypes.oneOf(['y']),
|
|
@@ -1478,6 +1495,7 @@ process.env.NODE_ENV !== "production" ? SparkLineChart.propTypes = {
|
|
|
1478
1495
|
tickSize: PropTypes.number,
|
|
1479
1496
|
tickSpacing: PropTypes.number,
|
|
1480
1497
|
valueFormatter: PropTypes.func,
|
|
1498
|
+
valueGetter: PropTypes.func,
|
|
1481
1499
|
width: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number])
|
|
1482
1500
|
})])
|
|
1483
1501
|
} : void 0;
|
package/hooks/useTicks.d.mts
CHANGED
|
@@ -86,6 +86,6 @@ interface GetTicksOptions extends Pick<TickParams, 'tickInterval' | 'tickPlaceme
|
|
|
86
86
|
}
|
|
87
87
|
export declare function getTicks(options: GetTicksOptions): TickItem[];
|
|
88
88
|
export declare function useTicks(options: Omit<GetTicksOptions, 'isInside'> & {
|
|
89
|
-
direction: 'x' | 'y';
|
|
89
|
+
direction: 'x' | 'y' | 'rotation' | 'radius';
|
|
90
90
|
}): TickItem[];
|
|
91
91
|
export {};
|
package/hooks/useTicks.d.ts
CHANGED
|
@@ -86,6 +86,6 @@ interface GetTicksOptions extends Pick<TickParams, 'tickInterval' | 'tickPlaceme
|
|
|
86
86
|
}
|
|
87
87
|
export declare function getTicks(options: GetTicksOptions): TickItem[];
|
|
88
88
|
export declare function useTicks(options: Omit<GetTicksOptions, 'isInside'> & {
|
|
89
|
-
direction: 'x' | 'y';
|
|
89
|
+
direction: 'x' | 'y' | 'rotation' | 'radius';
|
|
90
90
|
}): TickItem[];
|
|
91
91
|
export {};
|
package/hooks/useTicks.js
CHANGED
|
@@ -14,6 +14,7 @@ var _isInfinity = require("../internals/isInfinity");
|
|
|
14
14
|
var _timeTicks = require("../utils/timeTicks");
|
|
15
15
|
var _dateHelpers = require("../internals/dateHelpers");
|
|
16
16
|
var _useChartsContext = require("../context/ChartsProvider/useChartsContext");
|
|
17
|
+
var _epsilon = require("../utils/epsilon");
|
|
17
18
|
const offsetRatio = {
|
|
18
19
|
start: 0,
|
|
19
20
|
extremities: 0,
|
|
@@ -238,6 +239,24 @@ function getDefaultTicks(scale, tickNumber) {
|
|
|
238
239
|
}
|
|
239
240
|
return scale.ticks(tickNumber);
|
|
240
241
|
}
|
|
242
|
+
const alwaysTrue = () => true;
|
|
243
|
+
|
|
244
|
+
// Avoid ticks on more than 360° for rotation axis.
|
|
245
|
+
const isInsideRotation = scale => rotation => Math.abs(scale.range()[0] - rotation) < Math.PI * 2 - _epsilon.EPSILON;
|
|
246
|
+
function getIsInside(scale, direction, instance) {
|
|
247
|
+
switch (direction) {
|
|
248
|
+
case 'rotation':
|
|
249
|
+
return isInsideRotation(scale);
|
|
250
|
+
case 'radius':
|
|
251
|
+
return radiusOffset => radiusOffset >= 1;
|
|
252
|
+
case 'x':
|
|
253
|
+
return instance.isXInside;
|
|
254
|
+
case 'y':
|
|
255
|
+
return instance.isYInside;
|
|
256
|
+
default:
|
|
257
|
+
return alwaysTrue;
|
|
258
|
+
}
|
|
259
|
+
}
|
|
241
260
|
function useTicks(options) {
|
|
242
261
|
const {
|
|
243
262
|
scale,
|
|
@@ -253,7 +272,6 @@ function useTicks(options) {
|
|
|
253
272
|
const {
|
|
254
273
|
instance
|
|
255
274
|
} = (0, _useChartsContext.useChartsContext)();
|
|
256
|
-
const isInside = direction === 'x' ? instance.isXInside : instance.isYInside;
|
|
257
275
|
return React.useMemo(() => getTicks({
|
|
258
276
|
scale,
|
|
259
277
|
tickNumber,
|
|
@@ -262,7 +280,7 @@ function useTicks(options) {
|
|
|
262
280
|
tickLabelPlacement,
|
|
263
281
|
tickSpacing,
|
|
264
282
|
valueFormatter,
|
|
265
|
-
isInside,
|
|
283
|
+
isInside: getIsInside(scale, direction, instance),
|
|
266
284
|
ordinalTimeTicks
|
|
267
|
-
}), [scale, tickNumber, tickPlacement, tickInterval, tickLabelPlacement, tickSpacing, valueFormatter,
|
|
285
|
+
}), [scale, tickNumber, tickPlacement, tickInterval, tickLabelPlacement, tickSpacing, valueFormatter, direction, instance, ordinalTimeTicks]);
|
|
268
286
|
}
|
package/hooks/useTicks.mjs
CHANGED
|
@@ -6,6 +6,7 @@ import { isInfinity } from "../internals/isInfinity.mjs";
|
|
|
6
6
|
import { tickFrequencies } from "../utils/timeTicks.mjs";
|
|
7
7
|
import { isDateData } from "../internals/dateHelpers.mjs";
|
|
8
8
|
import { useChartsContext } from "../context/ChartsProvider/useChartsContext.mjs";
|
|
9
|
+
import { EPSILON } from "../utils/epsilon.mjs";
|
|
9
10
|
const offsetRatio = {
|
|
10
11
|
start: 0,
|
|
11
12
|
extremities: 0,
|
|
@@ -230,6 +231,24 @@ function getDefaultTicks(scale, tickNumber) {
|
|
|
230
231
|
}
|
|
231
232
|
return scale.ticks(tickNumber);
|
|
232
233
|
}
|
|
234
|
+
const alwaysTrue = () => true;
|
|
235
|
+
|
|
236
|
+
// Avoid ticks on more than 360° for rotation axis.
|
|
237
|
+
const isInsideRotation = scale => rotation => Math.abs(scale.range()[0] - rotation) < Math.PI * 2 - EPSILON;
|
|
238
|
+
function getIsInside(scale, direction, instance) {
|
|
239
|
+
switch (direction) {
|
|
240
|
+
case 'rotation':
|
|
241
|
+
return isInsideRotation(scale);
|
|
242
|
+
case 'radius':
|
|
243
|
+
return radiusOffset => radiusOffset >= 1;
|
|
244
|
+
case 'x':
|
|
245
|
+
return instance.isXInside;
|
|
246
|
+
case 'y':
|
|
247
|
+
return instance.isYInside;
|
|
248
|
+
default:
|
|
249
|
+
return alwaysTrue;
|
|
250
|
+
}
|
|
251
|
+
}
|
|
233
252
|
export function useTicks(options) {
|
|
234
253
|
const {
|
|
235
254
|
scale,
|
|
@@ -245,7 +264,6 @@ export function useTicks(options) {
|
|
|
245
264
|
const {
|
|
246
265
|
instance
|
|
247
266
|
} = useChartsContext();
|
|
248
|
-
const isInside = direction === 'x' ? instance.isXInside : instance.isYInside;
|
|
249
267
|
return React.useMemo(() => getTicks({
|
|
250
268
|
scale,
|
|
251
269
|
tickNumber,
|
|
@@ -254,7 +272,7 @@ export function useTicks(options) {
|
|
|
254
272
|
tickLabelPlacement,
|
|
255
273
|
tickSpacing,
|
|
256
274
|
valueFormatter,
|
|
257
|
-
isInside,
|
|
275
|
+
isInside: getIsInside(scale, direction, instance),
|
|
258
276
|
ordinalTimeTicks
|
|
259
|
-
}), [scale, tickNumber, tickPlacement, tickInterval, tickLabelPlacement, tickSpacing, valueFormatter,
|
|
277
|
+
}), [scale, tickNumber, tickPlacement, tickInterval, tickLabelPlacement, tickSpacing, valueFormatter, direction, instance, ordinalTimeTicks]);
|
|
260
278
|
}
|
package/index.d.mts
CHANGED
|
@@ -27,6 +27,8 @@ export * from "./ChartsSurface/index.mjs";
|
|
|
27
27
|
export { ChartsContainer } from "./ChartsContainer/index.mjs";
|
|
28
28
|
export type { ChartsContainerProps, ChartsContainerSlots, ChartsContainerSlotProps } from "./ChartsContainer/index.mjs";
|
|
29
29
|
export * from "./ChartsDataProvider/index.mjs";
|
|
30
|
+
export * from "./ChartsRadialDataProvider/index.mjs";
|
|
31
|
+
export * from "./ChartsRadialGrid/index.mjs";
|
|
30
32
|
export * from "./Toolbar/index.mjs";
|
|
31
33
|
export * from "./ChartsWrapper/index.mjs";
|
|
32
34
|
export * from "./ChartsBrushOverlay/index.mjs";
|
package/index.d.ts
CHANGED
|
@@ -27,6 +27,8 @@ export * from "./ChartsSurface/index.js";
|
|
|
27
27
|
export { ChartsContainer } from "./ChartsContainer/index.js";
|
|
28
28
|
export type { ChartsContainerProps, ChartsContainerSlots, ChartsContainerSlotProps } from "./ChartsContainer/index.js";
|
|
29
29
|
export * from "./ChartsDataProvider/index.js";
|
|
30
|
+
export * from "./ChartsRadialDataProvider/index.js";
|
|
31
|
+
export * from "./ChartsRadialGrid/index.js";
|
|
30
32
|
export * from "./Toolbar/index.js";
|
|
31
33
|
export * from "./ChartsWrapper/index.js";
|
|
32
34
|
export * from "./ChartsBrushOverlay/index.js";
|
package/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @mui/x-charts v9.0.
|
|
2
|
+
* @mui/x-charts v9.0.2
|
|
3
3
|
*
|
|
4
4
|
* @license MIT
|
|
5
5
|
* This source code is licensed under the MIT license found in the
|
|
@@ -344,6 +344,30 @@ Object.keys(_ChartsDataProvider).forEach(function (key) {
|
|
|
344
344
|
}
|
|
345
345
|
});
|
|
346
346
|
});
|
|
347
|
+
var _ChartsRadialDataProvider = require("./ChartsRadialDataProvider");
|
|
348
|
+
Object.keys(_ChartsRadialDataProvider).forEach(function (key) {
|
|
349
|
+
if (key === "default" || key === "__esModule") return;
|
|
350
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
351
|
+
if (key in exports && exports[key] === _ChartsRadialDataProvider[key]) return;
|
|
352
|
+
Object.defineProperty(exports, key, {
|
|
353
|
+
enumerable: true,
|
|
354
|
+
get: function () {
|
|
355
|
+
return _ChartsRadialDataProvider[key];
|
|
356
|
+
}
|
|
357
|
+
});
|
|
358
|
+
});
|
|
359
|
+
var _ChartsRadialGrid = require("./ChartsRadialGrid");
|
|
360
|
+
Object.keys(_ChartsRadialGrid).forEach(function (key) {
|
|
361
|
+
if (key === "default" || key === "__esModule") return;
|
|
362
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
363
|
+
if (key in exports && exports[key] === _ChartsRadialGrid[key]) return;
|
|
364
|
+
Object.defineProperty(exports, key, {
|
|
365
|
+
enumerable: true,
|
|
366
|
+
get: function () {
|
|
367
|
+
return _ChartsRadialGrid[key];
|
|
368
|
+
}
|
|
369
|
+
});
|
|
370
|
+
});
|
|
347
371
|
var _Toolbar = require("./Toolbar");
|
|
348
372
|
Object.keys(_Toolbar).forEach(function (key) {
|
|
349
373
|
if (key === "default" || key === "__esModule") return;
|
package/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @mui/x-charts v9.0.
|
|
2
|
+
* @mui/x-charts v9.0.2
|
|
3
3
|
*
|
|
4
4
|
* @license MIT
|
|
5
5
|
* This source code is licensed under the MIT license found in the
|
|
@@ -33,6 +33,8 @@ export * from "./RadarChart/index.mjs";
|
|
|
33
33
|
export * from "./ChartsSurface/index.mjs";
|
|
34
34
|
export { ChartsContainer } from "./ChartsContainer/index.mjs";
|
|
35
35
|
export * from "./ChartsDataProvider/index.mjs";
|
|
36
|
+
export * from "./ChartsRadialDataProvider/index.mjs";
|
|
37
|
+
export * from "./ChartsRadialGrid/index.mjs";
|
|
36
38
|
export * from "./Toolbar/index.mjs";
|
|
37
39
|
export * from "./ChartsWrapper/index.mjs";
|
|
38
40
|
export * from "./ChartsBrushOverlay/index.mjs";
|
|
@@ -8,9 +8,14 @@ exports.defaultSlotsMaterial = void 0;
|
|
|
8
8
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
9
|
var _IconButton = _interopRequireDefault(require("@mui/material/IconButton"));
|
|
10
10
|
var _Button = _interopRequireDefault(require("@mui/material/Button"));
|
|
11
|
+
var _ToggleButton = _interopRequireDefault(require("@mui/material/ToggleButton"));
|
|
12
|
+
var _ToggleButtonGroup = _interopRequireDefault(require("@mui/material/ToggleButtonGroup"));
|
|
11
13
|
const baseSlots = {
|
|
12
14
|
baseButton: _Button.default,
|
|
13
|
-
baseIconButton: _IconButton.default
|
|
15
|
+
baseIconButton: _IconButton.default,
|
|
16
|
+
// MUI Toggle button has an `href` prop that is not compatible with our API.
|
|
17
|
+
baseToggleButton: _ToggleButton.default,
|
|
18
|
+
baseToggleButtonGroup: _ToggleButtonGroup.default
|
|
14
19
|
};
|
|
15
20
|
const iconSlots = {};
|
|
16
21
|
const defaultSlotsMaterial = exports.defaultSlotsMaterial = (0, _extends2.default)({}, baseSlots, iconSlots);
|
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import IconButton from '@mui/material/IconButton';
|
|
3
3
|
import Button from '@mui/material/Button';
|
|
4
|
+
import ToggleButton from '@mui/material/ToggleButton';
|
|
5
|
+
import ToggleButtonGroup from '@mui/material/ToggleButtonGroup';
|
|
4
6
|
const baseSlots = {
|
|
5
7
|
baseButton: Button,
|
|
6
|
-
baseIconButton: IconButton
|
|
8
|
+
baseIconButton: IconButton,
|
|
9
|
+
// MUI Toggle button has an `href` prop that is not compatible with our API.
|
|
10
|
+
baseToggleButton: ToggleButton,
|
|
11
|
+
baseToggleButtonGroup: ToggleButtonGroup
|
|
7
12
|
};
|
|
8
13
|
const iconSlots = {};
|
|
9
14
|
export const defaultSlotsMaterial = _extends({}, baseSlots, iconSlots);
|
|
@@ -49,17 +49,15 @@ function defaultizeXAxis(inAxes, dataset, axesGap) {
|
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
-
// If
|
|
53
|
-
if (dataKey === undefined
|
|
52
|
+
// If data is already provided or no dataset extraction is needed
|
|
53
|
+
if (axisConfig.data !== undefined || dataKey === undefined && !axisConfig.valueGetter) {
|
|
54
54
|
return sharedConfig;
|
|
55
55
|
}
|
|
56
56
|
if (dataset === undefined) {
|
|
57
|
-
throw new Error(process.env.NODE_ENV !== "production" ? 'MUI X Charts: The x-axis uses `dataKey` but no `dataset` is provided. ' + 'When using dataKey, a dataset must be provided to retrieve the axis data. ' + 'Either provide a dataset prop or use the data property directly on the x-axis.' : (0, _formatErrorMessage2.default)(37));
|
|
57
|
+
throw new Error(process.env.NODE_ENV !== "production" ? 'MUI X Charts: The x-axis uses `dataKey` or `valueGetter` but no `dataset` is provided. ' + 'When using dataKey or valueGetter, a dataset must be provided to retrieve the axis data. ' + 'Either provide a dataset prop or use the data property directly on the x-axis.' : (0, _formatErrorMessage2.default)(37));
|
|
58
58
|
}
|
|
59
|
-
|
|
60
|
-
// If `dataKey` is provided
|
|
61
59
|
return (0, _extends2.default)({}, sharedConfig, {
|
|
62
|
-
data: dataset.map(d => d[dataKey])
|
|
60
|
+
data: axisConfig.valueGetter ? dataset.map(d => axisConfig.valueGetter(d)) : dataset.map(d => d[dataKey])
|
|
63
61
|
});
|
|
64
62
|
});
|
|
65
63
|
return parsedAxes;
|
|
@@ -103,17 +101,15 @@ function defaultizeYAxis(inAxes, dataset, axesGap) {
|
|
|
103
101
|
}
|
|
104
102
|
}
|
|
105
103
|
|
|
106
|
-
// If
|
|
107
|
-
if (dataKey === undefined
|
|
104
|
+
// If data is already provided or no dataset extraction is needed
|
|
105
|
+
if (axisConfig.data !== undefined || dataKey === undefined && !axisConfig.valueGetter) {
|
|
108
106
|
return sharedConfig;
|
|
109
107
|
}
|
|
110
108
|
if (dataset === undefined) {
|
|
111
|
-
throw new Error(process.env.NODE_ENV !== "production" ? 'MUI X Charts: The y-axis uses `dataKey` but no `dataset` is provided. ' + 'When using dataKey, a dataset must be provided to retrieve the axis data. ' + 'Either provide a dataset prop or use the data property directly on the y-axis.' : (0, _formatErrorMessage2.default)(38));
|
|
109
|
+
throw new Error(process.env.NODE_ENV !== "production" ? 'MUI X Charts: The y-axis uses `dataKey` or `valueGetter` but no `dataset` is provided. ' + 'When using dataKey or valueGetter, a dataset must be provided to retrieve the axis data. ' + 'Either provide a dataset prop or use the data property directly on the y-axis.' : (0, _formatErrorMessage2.default)(38));
|
|
112
110
|
}
|
|
113
|
-
|
|
114
|
-
// If `dataKey` is provided
|
|
115
111
|
return (0, _extends2.default)({}, sharedConfig, {
|
|
116
|
-
data: dataset.map(d => d[dataKey])
|
|
112
|
+
data: axisConfig.valueGetter ? dataset.map(d => axisConfig.valueGetter(d)) : dataset.map(d => d[dataKey])
|
|
117
113
|
});
|
|
118
114
|
});
|
|
119
115
|
return parsedAxes;
|
|
@@ -41,17 +41,15 @@ export function defaultizeXAxis(inAxes, dataset, axesGap) {
|
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
// If
|
|
45
|
-
if (dataKey === undefined
|
|
44
|
+
// If data is already provided or no dataset extraction is needed
|
|
45
|
+
if (axisConfig.data !== undefined || dataKey === undefined && !axisConfig.valueGetter) {
|
|
46
46
|
return sharedConfig;
|
|
47
47
|
}
|
|
48
48
|
if (dataset === undefined) {
|
|
49
|
-
throw new Error(process.env.NODE_ENV !== "production" ? 'MUI X Charts: The x-axis uses `dataKey` but no `dataset` is provided. ' + 'When using dataKey, a dataset must be provided to retrieve the axis data. ' + 'Either provide a dataset prop or use the data property directly on the x-axis.' : _formatErrorMessage(37));
|
|
49
|
+
throw new Error(process.env.NODE_ENV !== "production" ? 'MUI X Charts: The x-axis uses `dataKey` or `valueGetter` but no `dataset` is provided. ' + 'When using dataKey or valueGetter, a dataset must be provided to retrieve the axis data. ' + 'Either provide a dataset prop or use the data property directly on the x-axis.' : _formatErrorMessage(37));
|
|
50
50
|
}
|
|
51
|
-
|
|
52
|
-
// If `dataKey` is provided
|
|
53
51
|
return _extends({}, sharedConfig, {
|
|
54
|
-
data: dataset.map(d => d[dataKey])
|
|
52
|
+
data: axisConfig.valueGetter ? dataset.map(d => axisConfig.valueGetter(d)) : dataset.map(d => d[dataKey])
|
|
55
53
|
});
|
|
56
54
|
});
|
|
57
55
|
return parsedAxes;
|
|
@@ -95,17 +93,15 @@ export function defaultizeYAxis(inAxes, dataset, axesGap) {
|
|
|
95
93
|
}
|
|
96
94
|
}
|
|
97
95
|
|
|
98
|
-
// If
|
|
99
|
-
if (dataKey === undefined
|
|
96
|
+
// If data is already provided or no dataset extraction is needed
|
|
97
|
+
if (axisConfig.data !== undefined || dataKey === undefined && !axisConfig.valueGetter) {
|
|
100
98
|
return sharedConfig;
|
|
101
99
|
}
|
|
102
100
|
if (dataset === undefined) {
|
|
103
|
-
throw new Error(process.env.NODE_ENV !== "production" ? 'MUI X Charts: The y-axis uses `dataKey` but no `dataset` is provided. ' + 'When using dataKey, a dataset must be provided to retrieve the axis data. ' + 'Either provide a dataset prop or use the data property directly on the y-axis.' : _formatErrorMessage(38));
|
|
101
|
+
throw new Error(process.env.NODE_ENV !== "production" ? 'MUI X Charts: The y-axis uses `dataKey` or `valueGetter` but no `dataset` is provided. ' + 'When using dataKey or valueGetter, a dataset must be provided to retrieve the axis data. ' + 'Either provide a dataset prop or use the data property directly on the y-axis.' : _formatErrorMessage(38));
|
|
104
102
|
}
|
|
105
|
-
|
|
106
|
-
// If `dataKey` is provided
|
|
107
103
|
return _extends({}, sharedConfig, {
|
|
108
|
-
data: dataset.map(d => d[dataKey])
|
|
104
|
+
data: axisConfig.valueGetter ? dataset.map(d => axisConfig.valueGetter(d)) : dataset.map(d => d[dataKey])
|
|
109
105
|
});
|
|
110
106
|
});
|
|
111
107
|
return parsedAxes;
|
|
@@ -83,6 +83,7 @@ export declare const selectorChartRawAxis: (args_0: import("../../corePlugins/us
|
|
|
83
83
|
id: AxisId;
|
|
84
84
|
data?: readonly any[] | undefined;
|
|
85
85
|
dataKey?: string;
|
|
86
|
+
valueGetter?: ((item: import("../../../index.mjs").DatasetElementType<unknown>) => any) | undefined;
|
|
86
87
|
valueFormatter?: (<TScaleName extends keyof import("../../../index.mjs").AxisScaleConfig>(value: any, context: import("../../../index.mjs").AxisValueFormatterContext<TScaleName>) => string) | undefined;
|
|
87
88
|
hideTooltip?: boolean;
|
|
88
89
|
reverse?: boolean;
|
|
@@ -83,6 +83,7 @@ export declare const selectorChartRawAxis: (args_0: import("../../corePlugins/us
|
|
|
83
83
|
id: AxisId;
|
|
84
84
|
data?: readonly any[] | undefined;
|
|
85
85
|
dataKey?: string;
|
|
86
|
+
valueGetter?: ((item: import("../../../index.js").DatasetElementType<unknown>) => any) | undefined;
|
|
86
87
|
valueFormatter?: (<TScaleName extends keyof import("../../../index.js").AxisScaleConfig>(value: any, context: import("../../../index.js").AxisValueFormatterContext<TScaleName>) => string) | undefined;
|
|
87
88
|
hideTooltip?: boolean;
|
|
88
89
|
reverse?: boolean;
|
|
@@ -28,7 +28,8 @@ function getRange(drawingArea, axisDirection, axis) {
|
|
|
28
28
|
}
|
|
29
29
|
return [(0, _angleConversion.deg2rad)(axis.startAngle, 0), (0, _angleConversion.deg2rad)(axis.endAngle, 2 * Math.PI)];
|
|
30
30
|
}
|
|
31
|
-
|
|
31
|
+
const availableRadius = Math.min(drawingArea.height, drawingArea.width) / 2;
|
|
32
|
+
return [axis.minRadius ?? 0, axis.maxRadius ?? availableRadius];
|
|
32
33
|
}
|
|
33
34
|
const DEFAULT_CATEGORY_GAP_RATIO = 0.2;
|
|
34
35
|
const DEFAULT_BAR_GAP_RATIO = 0.1;
|
|
@@ -106,10 +107,12 @@ function computeAxisValue({
|
|
|
106
107
|
axisExtremums[0] = min;
|
|
107
108
|
axisExtremums[1] = max;
|
|
108
109
|
}
|
|
109
|
-
|
|
110
|
-
|
|
110
|
+
|
|
111
|
+
// Use degrees to display more ticks by default
|
|
112
|
+
const ratio = axisDirection === 'rotation' ? 180 / 3 : 1;
|
|
113
|
+
const tickNumber = axis.tickNumber ?? (0, _ticks.getTickNumber)(axis, axisExtremums, (0, _ticks.getDefaultTickNumber)(ratio * Math.abs(range[1] - range[0])));
|
|
111
114
|
const scale = (0, _getScale.getScale)(scaleType, axisExtremums, range);
|
|
112
|
-
const finalScale = domainLimit === 'nice' ? scale.nice(
|
|
115
|
+
const finalScale = domainLimit === 'nice' ? scale.nice(tickNumber) : scale;
|
|
113
116
|
const [minDomain, maxDomain] = finalScale.domain();
|
|
114
117
|
const domain = [axis.min ?? minDomain, axis.max ?? maxDomain];
|
|
115
118
|
completeAxis[axis.id] = (0, _extends2.default)({
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import { isBandScaleConfig, isPointScaleConfig, isContinuousScaleConfig } from "../../../../models/axis.mjs";
|
|
3
3
|
import { getColorScale, getOrdinalColorScale } from "../../../colorScale.mjs";
|
|
4
|
-
import { getDefaultTickNumber, getTickNumber
|
|
4
|
+
import { getDefaultTickNumber, getTickNumber } from "../../../ticks.mjs";
|
|
5
5
|
import { getScale } from "../../../getScale.mjs";
|
|
6
6
|
import { isDateData, createDateFormatter } from "../../../dateHelpers.mjs";
|
|
7
7
|
import { getAxisExtremum } from "./getAxisExtremum.mjs";
|
|
@@ -21,7 +21,8 @@ function getRange(drawingArea, axisDirection, axis) {
|
|
|
21
21
|
}
|
|
22
22
|
return [deg2rad(axis.startAngle, 0), deg2rad(axis.endAngle, 2 * Math.PI)];
|
|
23
23
|
}
|
|
24
|
-
|
|
24
|
+
const availableRadius = Math.min(drawingArea.height, drawingArea.width) / 2;
|
|
25
|
+
return [axis.minRadius ?? 0, axis.maxRadius ?? availableRadius];
|
|
25
26
|
}
|
|
26
27
|
const DEFAULT_CATEGORY_GAP_RATIO = 0.2;
|
|
27
28
|
const DEFAULT_BAR_GAP_RATIO = 0.1;
|
|
@@ -99,10 +100,12 @@ export function computeAxisValue({
|
|
|
99
100
|
axisExtremums[0] = min;
|
|
100
101
|
axisExtremums[1] = max;
|
|
101
102
|
}
|
|
102
|
-
|
|
103
|
-
|
|
103
|
+
|
|
104
|
+
// Use degrees to display more ticks by default
|
|
105
|
+
const ratio = axisDirection === 'rotation' ? 180 / 3 : 1;
|
|
106
|
+
const tickNumber = axis.tickNumber ?? getTickNumber(axis, axisExtremums, getDefaultTickNumber(ratio * Math.abs(range[1] - range[0])));
|
|
104
107
|
const scale = getScale(scaleType, axisExtremums, range);
|
|
105
|
-
const finalScale = domainLimit === 'nice' ? scale.nice(
|
|
108
|
+
const finalScale = domainLimit === 'nice' ? scale.nice(tickNumber) : scale;
|
|
106
109
|
const [minDomain, maxDomain] = finalScale.domain();
|
|
107
110
|
const domain = [axis.min ?? minDomain, axis.max ?? maxDomain];
|
|
108
111
|
completeAxis[axis.id] = _extends({
|
|
@@ -16,17 +16,17 @@ function defaultizeAxis(inAxis, dataset, axisName) {
|
|
|
16
16
|
return inputAxes.map((axisConfig, index) => {
|
|
17
17
|
const id = `defaultized-${axisName}-axis-${index}`;
|
|
18
18
|
const dataKey = axisConfig.dataKey;
|
|
19
|
-
if (dataKey === undefined
|
|
19
|
+
if (axisConfig.data !== undefined || dataKey === undefined && !axisConfig.valueGetter) {
|
|
20
20
|
return (0, _extends2.default)({
|
|
21
21
|
id
|
|
22
22
|
}, axisConfig);
|
|
23
23
|
}
|
|
24
24
|
if (dataset === undefined) {
|
|
25
|
-
throw new Error(process.env.NODE_ENV !== "production" ? `MUI X Charts: The ${axisName}-axis uses \`dataKey\` but no \`dataset\` is provided. ` + 'When using dataKey, a dataset must be provided to retrieve the axis data. ' + `Either provide a dataset prop or use the data property directly on the ${axisName}-axis.` : (0, _formatErrorMessage2.default)(39, axisName, axisName));
|
|
25
|
+
throw new Error(process.env.NODE_ENV !== "production" ? `MUI X Charts: The ${axisName}-axis uses \`dataKey\` or \`valueGetter\` but no \`dataset\` is provided. ` + 'When using dataKey or valueGetter, a dataset must be provided to retrieve the axis data. ' + `Either provide a dataset prop or use the data property directly on the ${axisName}-axis.` : (0, _formatErrorMessage2.default)(39, axisName, axisName));
|
|
26
26
|
}
|
|
27
27
|
return (0, _extends2.default)({
|
|
28
28
|
id,
|
|
29
|
-
data: dataset.map(d => d[dataKey])
|
|
29
|
+
data: axisConfig.valueGetter ? dataset.map(d => axisConfig.valueGetter(d)) : dataset.map(d => d[dataKey])
|
|
30
30
|
}, axisConfig);
|
|
31
31
|
});
|
|
32
32
|
}
|
|
@@ -9,17 +9,17 @@ export function defaultizeAxis(inAxis, dataset, axisName) {
|
|
|
9
9
|
return inputAxes.map((axisConfig, index) => {
|
|
10
10
|
const id = `defaultized-${axisName}-axis-${index}`;
|
|
11
11
|
const dataKey = axisConfig.dataKey;
|
|
12
|
-
if (dataKey === undefined
|
|
12
|
+
if (axisConfig.data !== undefined || dataKey === undefined && !axisConfig.valueGetter) {
|
|
13
13
|
return _extends({
|
|
14
14
|
id
|
|
15
15
|
}, axisConfig);
|
|
16
16
|
}
|
|
17
17
|
if (dataset === undefined) {
|
|
18
|
-
throw new Error(process.env.NODE_ENV !== "production" ? `MUI X Charts: The ${axisName}-axis uses \`dataKey\` but no \`dataset\` is provided. ` + 'When using dataKey, a dataset must be provided to retrieve the axis data. ' + `Either provide a dataset prop or use the data property directly on the ${axisName}-axis.` : _formatErrorMessage(39, axisName, axisName));
|
|
18
|
+
throw new Error(process.env.NODE_ENV !== "production" ? `MUI X Charts: The ${axisName}-axis uses \`dataKey\` or \`valueGetter\` but no \`dataset\` is provided. ` + 'When using dataKey or valueGetter, a dataset must be provided to retrieve the axis data. ' + `Either provide a dataset prop or use the data property directly on the ${axisName}-axis.` : _formatErrorMessage(39, axisName, axisName));
|
|
19
19
|
}
|
|
20
20
|
return _extends({
|
|
21
21
|
id,
|
|
22
|
-
data: dataset.map(d => d[dataKey])
|
|
22
|
+
data: axisConfig.valueGetter ? dataset.map(d => axisConfig.valueGetter(d)) : dataset.map(d => d[dataKey])
|
|
23
23
|
}, axisConfig);
|
|
24
24
|
});
|
|
25
25
|
}
|
|
@@ -44,16 +44,16 @@ function getZAxisState(zAxis, dataset) {
|
|
|
44
44
|
zAxis.forEach((axisConfig, index) => {
|
|
45
45
|
const dataKey = axisConfig.dataKey;
|
|
46
46
|
const defaultizedId = axisConfig.id ?? `defaultized-z-axis-${index}`;
|
|
47
|
-
if (dataKey === undefined
|
|
47
|
+
if (axisConfig.data !== undefined || dataKey === undefined && !axisConfig.valueGetter) {
|
|
48
48
|
zAxisLookup[defaultizedId] = processColorMap(addDefaultId(axisConfig, defaultizedId));
|
|
49
49
|
axisIds.push(defaultizedId);
|
|
50
50
|
return;
|
|
51
51
|
}
|
|
52
52
|
if (dataset === undefined) {
|
|
53
|
-
throw new Error(process.env.NODE_ENV !== "production" ? 'MUI X Charts: The z-axis uses `dataKey` but no `dataset` is provided. ' + 'When using dataKey, a dataset must be provided to retrieve the axis data. ' + 'Either provide a dataset prop or use the data property directly on the z-axis.' : (0, _formatErrorMessage2.default)(41));
|
|
53
|
+
throw new Error(process.env.NODE_ENV !== "production" ? 'MUI X Charts: The z-axis uses `dataKey` or `valueGetter` but no `dataset` is provided. ' + 'When using dataKey or valueGetter, a dataset must be provided to retrieve the axis data. ' + 'Either provide a dataset prop or use the data property directly on the z-axis.' : (0, _formatErrorMessage2.default)(41));
|
|
54
54
|
}
|
|
55
55
|
zAxisLookup[defaultizedId] = processColorMap(addDefaultId((0, _extends2.default)({}, axisConfig, {
|
|
56
|
-
data: dataset.map(d => d[dataKey])
|
|
56
|
+
data: axisConfig.valueGetter ? dataset.map(d => axisConfig.valueGetter(d)) : dataset.map(d => d[dataKey])
|
|
57
57
|
}), defaultizedId));
|
|
58
58
|
axisIds.push(defaultizedId);
|
|
59
59
|
});
|
|
@@ -37,16 +37,16 @@ function getZAxisState(zAxis, dataset) {
|
|
|
37
37
|
zAxis.forEach((axisConfig, index) => {
|
|
38
38
|
const dataKey = axisConfig.dataKey;
|
|
39
39
|
const defaultizedId = axisConfig.id ?? `defaultized-z-axis-${index}`;
|
|
40
|
-
if (dataKey === undefined
|
|
40
|
+
if (axisConfig.data !== undefined || dataKey === undefined && !axisConfig.valueGetter) {
|
|
41
41
|
zAxisLookup[defaultizedId] = processColorMap(addDefaultId(axisConfig, defaultizedId));
|
|
42
42
|
axisIds.push(defaultizedId);
|
|
43
43
|
return;
|
|
44
44
|
}
|
|
45
45
|
if (dataset === undefined) {
|
|
46
|
-
throw new Error(process.env.NODE_ENV !== "production" ? 'MUI X Charts: The z-axis uses `dataKey` but no `dataset` is provided. ' + 'When using dataKey, a dataset must be provided to retrieve the axis data. ' + 'Either provide a dataset prop or use the data property directly on the z-axis.' : _formatErrorMessage(41));
|
|
46
|
+
throw new Error(process.env.NODE_ENV !== "production" ? 'MUI X Charts: The z-axis uses `dataKey` or `valueGetter` but no `dataset` is provided. ' + 'When using dataKey or valueGetter, a dataset must be provided to retrieve the axis data. ' + 'Either provide a dataset prop or use the data property directly on the z-axis.' : _formatErrorMessage(41));
|
|
47
47
|
}
|
|
48
48
|
zAxisLookup[defaultizedId] = processColorMap(addDefaultId(_extends({}, axisConfig, {
|
|
49
|
-
data: dataset.map(d => d[dataKey])
|
|
49
|
+
data: axisConfig.valueGetter ? dataset.map(d => axisConfig.valueGetter(d)) : dataset.map(d => d[dataKey])
|
|
50
50
|
}), defaultizedId));
|
|
51
51
|
axisIds.push(defaultizedId);
|
|
52
52
|
});
|