@mui/x-charts 8.10.2 → 8.11.0
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 +0 -36
- package/CHANGELOG.md +140 -13
- package/ChartContainer/ChartContainer.js +0 -56
- package/ChartsLabel/labelGradientClasses.d.ts +1 -1
- package/ChartsLabel/labelMarkClasses.d.ts +1 -1
- package/ChartsOverlay/ChartsOverlay.js +11 -1
- package/ChartsReferenceLine/ChartsXReferenceLine.d.ts +1 -1
- package/ChartsReferenceLine/ChartsYReferenceLine.d.ts +1 -1
- package/ChartsTooltip/ChartsTooltipTable.d.ts +1 -1
- package/ChartsTooltip/chartsTooltipClasses.d.ts +1 -1
- package/ChartsXAxis/ChartsXAxis.js +0 -10
- package/ChartsXAxis/useAxisProps.d.ts +9 -171
- package/ChartsXAxis/utilities.d.ts +1 -1
- package/ChartsYAxis/ChartsYAxis.js +0 -10
- package/ChartsYAxis/useAxisProps.d.ts +9 -171
- package/ChartsYAxis/utilities.d.ts +1 -1
- package/LineChart/LineChart.js +0 -36
- package/PieChart/PieChart.js +2 -2
- package/RadarChart/RadarAxis/RadarAxis.d.ts +29 -0
- package/RadarChart/RadarAxis/RadarAxis.js +101 -0
- package/RadarChart/RadarAxis/RadarAxis.utils.d.ts +20 -0
- package/RadarChart/RadarAxis/RadarAxis.utils.js +66 -0
- package/RadarChart/RadarAxis/index.d.ts +3 -0
- package/RadarChart/RadarAxis/index.js +39 -0
- package/RadarChart/RadarAxis/radarAxisClasses.d.ts +12 -0
- package/RadarChart/RadarAxis/radarAxisClasses.js +25 -0
- package/RadarChart/RadarAxis/useRadarAxis.d.ts +34 -0
- package/RadarChart/RadarAxis/useRadarAxis.js +82 -0
- package/RadarChart/RadarGrid/useRadarGridData.js +8 -5
- package/RadarChart/RadarSeriesPlot/useRadarSeriesData.js +1 -1
- package/RadarChart/index.d.ts +1 -0
- package/RadarChart/index.js +12 -0
- package/ScatterChart/ScatterChart.js +0 -36
- package/SparkLineChart/SparkLineChart.js +0 -36
- package/esm/BarChart/BarChart.js +0 -36
- package/esm/ChartContainer/ChartContainer.js +0 -56
- package/esm/ChartsLabel/labelGradientClasses.d.ts +1 -1
- package/esm/ChartsLabel/labelMarkClasses.d.ts +1 -1
- package/esm/ChartsOverlay/ChartsOverlay.js +11 -1
- package/esm/ChartsReferenceLine/ChartsXReferenceLine.d.ts +1 -1
- package/esm/ChartsReferenceLine/ChartsYReferenceLine.d.ts +1 -1
- package/esm/ChartsTooltip/ChartsTooltipTable.d.ts +1 -1
- package/esm/ChartsTooltip/chartsTooltipClasses.d.ts +1 -1
- package/esm/ChartsXAxis/ChartsXAxis.js +0 -10
- package/esm/ChartsXAxis/useAxisProps.d.ts +9 -171
- package/esm/ChartsXAxis/utilities.d.ts +1 -1
- package/esm/ChartsYAxis/ChartsYAxis.js +0 -10
- package/esm/ChartsYAxis/useAxisProps.d.ts +9 -171
- package/esm/ChartsYAxis/utilities.d.ts +1 -1
- package/esm/LineChart/LineChart.js +0 -36
- package/esm/PieChart/PieChart.js +2 -2
- package/esm/RadarChart/RadarAxis/RadarAxis.d.ts +29 -0
- package/esm/RadarChart/RadarAxis/RadarAxis.js +94 -0
- package/esm/RadarChart/RadarAxis/RadarAxis.utils.d.ts +20 -0
- package/esm/RadarChart/RadarAxis/RadarAxis.utils.js +60 -0
- package/esm/RadarChart/RadarAxis/index.d.ts +3 -0
- package/esm/RadarChart/RadarAxis/index.js +3 -0
- package/esm/RadarChart/RadarAxis/radarAxisClasses.d.ts +12 -0
- package/esm/RadarChart/RadarAxis/radarAxisClasses.js +15 -0
- package/esm/RadarChart/RadarAxis/useRadarAxis.d.ts +34 -0
- package/esm/RadarChart/RadarAxis/useRadarAxis.js +76 -0
- package/esm/RadarChart/RadarGrid/useRadarGridData.js +8 -5
- package/esm/RadarChart/RadarSeriesPlot/useRadarSeriesData.js +1 -1
- package/esm/RadarChart/index.d.ts +1 -0
- package/esm/RadarChart/index.js +1 -0
- package/esm/ScatterChart/ScatterChart.js +0 -36
- package/esm/SparkLineChart/SparkLineChart.js +0 -36
- package/esm/hooks/animation/useAnimatePieArcLabel.js +2 -2
- package/esm/hooks/useInteractionItemProps.d.ts +5 -5
- package/esm/hooks/useInteractionItemProps.js +6 -20
- package/esm/index.js +1 -1
- package/esm/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.types.d.ts +3 -3
- package/esm/internals/plugins/models/seriesConfig/tooltipGetter.types.d.ts +3 -3
- package/esm/models/axis.d.ts +0 -10
- package/esm/models/seriesType/config.d.ts +6 -0
- package/esm/models/seriesType/index.d.ts +1 -0
- package/hooks/animation/useAnimatePieArcLabel.js +2 -2
- package/hooks/useInteractionItemProps.d.ts +5 -5
- package/hooks/useInteractionItemProps.js +6 -20
- package/index.js +1 -1
- package/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.types.d.ts +3 -3
- package/internals/plugins/models/seriesConfig/tooltipGetter.types.d.ts +3 -3
- package/models/axis.d.ts +0 -10
- package/models/seriesType/config.d.ts +6 -0
- package/models/seriesType/index.d.ts +1 -0
- package/package.json +4 -4
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AxisConfig, ChartsYAxisProps } from "../models/axis.js";
|
|
2
|
-
export declare const useUtilityClasses: (ownerState: AxisConfig<any, any, ChartsYAxisProps>) => Record<"
|
|
2
|
+
export declare const useUtilityClasses: (ownerState: AxisConfig<any, any, ChartsYAxisProps>) => Record<"root" | "line" | "label" | "tickContainer" | "tick" | "tickLabel", string>;
|
|
3
3
|
export declare const TICK_LABEL_GAP = 2;
|
|
4
4
|
export declare const AXIS_LABEL_TICK_LABEL_GAP = 2;
|
|
5
5
|
export declare const YAxisRoot: import("@emotion/styled").StyledComponent<Pick<import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme> & Pick<import("react").SVGProps<SVGGElement>, keyof import("react").SVGProps<SVGGElement>>, keyof import("react").SVGProps<SVGGElement> | keyof import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme>> & import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme>, {}, {}>;
|
|
@@ -269,7 +269,6 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
|
|
|
269
269
|
disableLine: PropTypes.bool,
|
|
270
270
|
disableTicks: PropTypes.bool,
|
|
271
271
|
domainLimit: PropTypes.oneOfType([PropTypes.oneOf(['nice', 'strict']), PropTypes.func]),
|
|
272
|
-
fill: PropTypes.string,
|
|
273
272
|
groups: PropTypes.arrayOf(PropTypes.shape({
|
|
274
273
|
getValue: PropTypes.func.isRequired,
|
|
275
274
|
tickLabelStyle: PropTypes.object,
|
|
@@ -289,7 +288,6 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
|
|
|
289
288
|
scaleType: PropTypes.oneOf(['band']),
|
|
290
289
|
slotProps: PropTypes.object,
|
|
291
290
|
slots: PropTypes.object,
|
|
292
|
-
stroke: PropTypes.string,
|
|
293
291
|
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
|
|
294
292
|
tickInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.array, PropTypes.func]),
|
|
295
293
|
tickLabelInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.func]),
|
|
@@ -325,7 +323,6 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
|
|
|
325
323
|
disableLine: PropTypes.bool,
|
|
326
324
|
disableTicks: PropTypes.bool,
|
|
327
325
|
domainLimit: PropTypes.oneOfType([PropTypes.oneOf(['nice', 'strict']), PropTypes.func]),
|
|
328
|
-
fill: PropTypes.string,
|
|
329
326
|
groups: PropTypes.arrayOf(PropTypes.shape({
|
|
330
327
|
getValue: PropTypes.func.isRequired,
|
|
331
328
|
tickLabelStyle: PropTypes.object,
|
|
@@ -345,7 +342,6 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
|
|
|
345
342
|
scaleType: PropTypes.oneOf(['point']),
|
|
346
343
|
slotProps: PropTypes.object,
|
|
347
344
|
slots: PropTypes.object,
|
|
348
|
-
stroke: PropTypes.string,
|
|
349
345
|
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
|
|
350
346
|
tickInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.array, PropTypes.func]),
|
|
351
347
|
tickLabelInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.func]),
|
|
@@ -376,7 +372,6 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
|
|
|
376
372
|
disableLine: PropTypes.bool,
|
|
377
373
|
disableTicks: PropTypes.bool,
|
|
378
374
|
domainLimit: PropTypes.oneOfType([PropTypes.oneOf(['nice', 'strict']), PropTypes.func]),
|
|
379
|
-
fill: PropTypes.string,
|
|
380
375
|
height: PropTypes.number,
|
|
381
376
|
hideTooltip: PropTypes.bool,
|
|
382
377
|
id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
@@ -391,7 +386,6 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
|
|
|
391
386
|
scaleType: PropTypes.oneOf(['log']),
|
|
392
387
|
slotProps: PropTypes.object,
|
|
393
388
|
slots: PropTypes.object,
|
|
394
|
-
stroke: PropTypes.string,
|
|
395
389
|
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
|
|
396
390
|
tickInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.array, PropTypes.func]),
|
|
397
391
|
tickLabelInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.func]),
|
|
@@ -423,7 +417,6 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
|
|
|
423
417
|
disableLine: PropTypes.bool,
|
|
424
418
|
disableTicks: PropTypes.bool,
|
|
425
419
|
domainLimit: PropTypes.oneOfType([PropTypes.oneOf(['nice', 'strict']), PropTypes.func]),
|
|
426
|
-
fill: PropTypes.string,
|
|
427
420
|
height: PropTypes.number,
|
|
428
421
|
hideTooltip: PropTypes.bool,
|
|
429
422
|
id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
@@ -438,7 +431,6 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
|
|
|
438
431
|
scaleType: PropTypes.oneOf(['symlog']),
|
|
439
432
|
slotProps: PropTypes.object,
|
|
440
433
|
slots: PropTypes.object,
|
|
441
|
-
stroke: PropTypes.string,
|
|
442
434
|
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
|
|
443
435
|
tickInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.array, PropTypes.func]),
|
|
444
436
|
tickLabelInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.func]),
|
|
@@ -469,7 +461,6 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
|
|
|
469
461
|
disableLine: PropTypes.bool,
|
|
470
462
|
disableTicks: PropTypes.bool,
|
|
471
463
|
domainLimit: PropTypes.oneOfType([PropTypes.oneOf(['nice', 'strict']), PropTypes.func]),
|
|
472
|
-
fill: PropTypes.string,
|
|
473
464
|
height: PropTypes.number,
|
|
474
465
|
hideTooltip: PropTypes.bool,
|
|
475
466
|
id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
@@ -484,7 +475,6 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
|
|
|
484
475
|
scaleType: PropTypes.oneOf(['pow']),
|
|
485
476
|
slotProps: PropTypes.object,
|
|
486
477
|
slots: PropTypes.object,
|
|
487
|
-
stroke: PropTypes.string,
|
|
488
478
|
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
|
|
489
479
|
tickInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.array, PropTypes.func]),
|
|
490
480
|
tickLabelInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.func]),
|
|
@@ -515,7 +505,6 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
|
|
|
515
505
|
disableLine: PropTypes.bool,
|
|
516
506
|
disableTicks: PropTypes.bool,
|
|
517
507
|
domainLimit: PropTypes.oneOfType([PropTypes.oneOf(['nice', 'strict']), PropTypes.func]),
|
|
518
|
-
fill: PropTypes.string,
|
|
519
508
|
height: PropTypes.number,
|
|
520
509
|
hideTooltip: PropTypes.bool,
|
|
521
510
|
id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
@@ -530,7 +519,6 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
|
|
|
530
519
|
scaleType: PropTypes.oneOf(['sqrt']),
|
|
531
520
|
slotProps: PropTypes.object,
|
|
532
521
|
slots: PropTypes.object,
|
|
533
|
-
stroke: PropTypes.string,
|
|
534
522
|
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
|
|
535
523
|
tickInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.array, PropTypes.func]),
|
|
536
524
|
tickLabelInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.func]),
|
|
@@ -561,7 +549,6 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
|
|
|
561
549
|
disableLine: PropTypes.bool,
|
|
562
550
|
disableTicks: PropTypes.bool,
|
|
563
551
|
domainLimit: PropTypes.oneOfType([PropTypes.oneOf(['nice', 'strict']), PropTypes.func]),
|
|
564
|
-
fill: PropTypes.string,
|
|
565
552
|
height: PropTypes.number,
|
|
566
553
|
hideTooltip: PropTypes.bool,
|
|
567
554
|
id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
@@ -576,7 +563,6 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
|
|
|
576
563
|
scaleType: PropTypes.oneOf(['time']),
|
|
577
564
|
slotProps: PropTypes.object,
|
|
578
565
|
slots: PropTypes.object,
|
|
579
|
-
stroke: PropTypes.string,
|
|
580
566
|
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
|
|
581
567
|
tickInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.array, PropTypes.func]),
|
|
582
568
|
tickLabelInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.func]),
|
|
@@ -607,7 +593,6 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
|
|
|
607
593
|
disableLine: PropTypes.bool,
|
|
608
594
|
disableTicks: PropTypes.bool,
|
|
609
595
|
domainLimit: PropTypes.oneOfType([PropTypes.oneOf(['nice', 'strict']), PropTypes.func]),
|
|
610
|
-
fill: PropTypes.string,
|
|
611
596
|
height: PropTypes.number,
|
|
612
597
|
hideTooltip: PropTypes.bool,
|
|
613
598
|
id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
@@ -622,7 +607,6 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
|
|
|
622
607
|
scaleType: PropTypes.oneOf(['utc']),
|
|
623
608
|
slotProps: PropTypes.object,
|
|
624
609
|
slots: PropTypes.object,
|
|
625
|
-
stroke: PropTypes.string,
|
|
626
610
|
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
|
|
627
611
|
tickInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.array, PropTypes.func]),
|
|
628
612
|
tickLabelInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.func]),
|
|
@@ -653,7 +637,6 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
|
|
|
653
637
|
disableLine: PropTypes.bool,
|
|
654
638
|
disableTicks: PropTypes.bool,
|
|
655
639
|
domainLimit: PropTypes.oneOfType([PropTypes.oneOf(['nice', 'strict']), PropTypes.func]),
|
|
656
|
-
fill: PropTypes.string,
|
|
657
640
|
height: PropTypes.number,
|
|
658
641
|
hideTooltip: PropTypes.bool,
|
|
659
642
|
id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
@@ -668,7 +651,6 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
|
|
|
668
651
|
scaleType: PropTypes.oneOf(['linear']),
|
|
669
652
|
slotProps: PropTypes.object,
|
|
670
653
|
slots: PropTypes.object,
|
|
671
|
-
stroke: PropTypes.string,
|
|
672
654
|
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
|
|
673
655
|
tickInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.array, PropTypes.func]),
|
|
674
656
|
tickLabelInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.func]),
|
|
@@ -712,7 +694,6 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
|
|
|
712
694
|
disableLine: PropTypes.bool,
|
|
713
695
|
disableTicks: PropTypes.bool,
|
|
714
696
|
domainLimit: PropTypes.oneOfType([PropTypes.oneOf(['nice', 'strict']), PropTypes.func]),
|
|
715
|
-
fill: PropTypes.string,
|
|
716
697
|
groups: PropTypes.arrayOf(PropTypes.shape({
|
|
717
698
|
getValue: PropTypes.func.isRequired,
|
|
718
699
|
tickLabelStyle: PropTypes.object,
|
|
@@ -731,7 +712,6 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
|
|
|
731
712
|
scaleType: PropTypes.oneOf(['band']),
|
|
732
713
|
slotProps: PropTypes.object,
|
|
733
714
|
slots: PropTypes.object,
|
|
734
|
-
stroke: PropTypes.string,
|
|
735
715
|
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
|
|
736
716
|
tickInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.array, PropTypes.func]),
|
|
737
717
|
tickLabelInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.func]),
|
|
@@ -767,7 +747,6 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
|
|
|
767
747
|
disableLine: PropTypes.bool,
|
|
768
748
|
disableTicks: PropTypes.bool,
|
|
769
749
|
domainLimit: PropTypes.oneOfType([PropTypes.oneOf(['nice', 'strict']), PropTypes.func]),
|
|
770
|
-
fill: PropTypes.string,
|
|
771
750
|
groups: PropTypes.arrayOf(PropTypes.shape({
|
|
772
751
|
getValue: PropTypes.func.isRequired,
|
|
773
752
|
tickLabelStyle: PropTypes.object,
|
|
@@ -786,7 +765,6 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
|
|
|
786
765
|
scaleType: PropTypes.oneOf(['point']),
|
|
787
766
|
slotProps: PropTypes.object,
|
|
788
767
|
slots: PropTypes.object,
|
|
789
|
-
stroke: PropTypes.string,
|
|
790
768
|
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
|
|
791
769
|
tickInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.array, PropTypes.func]),
|
|
792
770
|
tickLabelInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.func]),
|
|
@@ -817,7 +795,6 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
|
|
|
817
795
|
disableLine: PropTypes.bool,
|
|
818
796
|
disableTicks: PropTypes.bool,
|
|
819
797
|
domainLimit: PropTypes.oneOfType([PropTypes.oneOf(['nice', 'strict']), PropTypes.func]),
|
|
820
|
-
fill: PropTypes.string,
|
|
821
798
|
hideTooltip: PropTypes.bool,
|
|
822
799
|
id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
823
800
|
ignoreTooltip: PropTypes.bool,
|
|
@@ -831,7 +808,6 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
|
|
|
831
808
|
scaleType: PropTypes.oneOf(['log']),
|
|
832
809
|
slotProps: PropTypes.object,
|
|
833
810
|
slots: PropTypes.object,
|
|
834
|
-
stroke: PropTypes.string,
|
|
835
811
|
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
|
|
836
812
|
tickInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.array, PropTypes.func]),
|
|
837
813
|
tickLabelInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.func]),
|
|
@@ -863,7 +839,6 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
|
|
|
863
839
|
disableLine: PropTypes.bool,
|
|
864
840
|
disableTicks: PropTypes.bool,
|
|
865
841
|
domainLimit: PropTypes.oneOfType([PropTypes.oneOf(['nice', 'strict']), PropTypes.func]),
|
|
866
|
-
fill: PropTypes.string,
|
|
867
842
|
hideTooltip: PropTypes.bool,
|
|
868
843
|
id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
869
844
|
ignoreTooltip: PropTypes.bool,
|
|
@@ -877,7 +852,6 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
|
|
|
877
852
|
scaleType: PropTypes.oneOf(['symlog']),
|
|
878
853
|
slotProps: PropTypes.object,
|
|
879
854
|
slots: PropTypes.object,
|
|
880
|
-
stroke: PropTypes.string,
|
|
881
855
|
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
|
|
882
856
|
tickInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.array, PropTypes.func]),
|
|
883
857
|
tickLabelInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.func]),
|
|
@@ -908,7 +882,6 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
|
|
|
908
882
|
disableLine: PropTypes.bool,
|
|
909
883
|
disableTicks: PropTypes.bool,
|
|
910
884
|
domainLimit: PropTypes.oneOfType([PropTypes.oneOf(['nice', 'strict']), PropTypes.func]),
|
|
911
|
-
fill: PropTypes.string,
|
|
912
885
|
hideTooltip: PropTypes.bool,
|
|
913
886
|
id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
914
887
|
ignoreTooltip: PropTypes.bool,
|
|
@@ -922,7 +895,6 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
|
|
|
922
895
|
scaleType: PropTypes.oneOf(['pow']),
|
|
923
896
|
slotProps: PropTypes.object,
|
|
924
897
|
slots: PropTypes.object,
|
|
925
|
-
stroke: PropTypes.string,
|
|
926
898
|
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
|
|
927
899
|
tickInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.array, PropTypes.func]),
|
|
928
900
|
tickLabelInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.func]),
|
|
@@ -953,7 +925,6 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
|
|
|
953
925
|
disableLine: PropTypes.bool,
|
|
954
926
|
disableTicks: PropTypes.bool,
|
|
955
927
|
domainLimit: PropTypes.oneOfType([PropTypes.oneOf(['nice', 'strict']), PropTypes.func]),
|
|
956
|
-
fill: PropTypes.string,
|
|
957
928
|
hideTooltip: PropTypes.bool,
|
|
958
929
|
id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
959
930
|
ignoreTooltip: PropTypes.bool,
|
|
@@ -967,7 +938,6 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
|
|
|
967
938
|
scaleType: PropTypes.oneOf(['sqrt']),
|
|
968
939
|
slotProps: PropTypes.object,
|
|
969
940
|
slots: PropTypes.object,
|
|
970
|
-
stroke: PropTypes.string,
|
|
971
941
|
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
|
|
972
942
|
tickInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.array, PropTypes.func]),
|
|
973
943
|
tickLabelInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.func]),
|
|
@@ -998,7 +968,6 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
|
|
|
998
968
|
disableLine: PropTypes.bool,
|
|
999
969
|
disableTicks: PropTypes.bool,
|
|
1000
970
|
domainLimit: PropTypes.oneOfType([PropTypes.oneOf(['nice', 'strict']), PropTypes.func]),
|
|
1001
|
-
fill: PropTypes.string,
|
|
1002
971
|
hideTooltip: PropTypes.bool,
|
|
1003
972
|
id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
1004
973
|
ignoreTooltip: PropTypes.bool,
|
|
@@ -1012,7 +981,6 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
|
|
|
1012
981
|
scaleType: PropTypes.oneOf(['time']),
|
|
1013
982
|
slotProps: PropTypes.object,
|
|
1014
983
|
slots: PropTypes.object,
|
|
1015
|
-
stroke: PropTypes.string,
|
|
1016
984
|
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
|
|
1017
985
|
tickInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.array, PropTypes.func]),
|
|
1018
986
|
tickLabelInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.func]),
|
|
@@ -1043,7 +1011,6 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
|
|
|
1043
1011
|
disableLine: PropTypes.bool,
|
|
1044
1012
|
disableTicks: PropTypes.bool,
|
|
1045
1013
|
domainLimit: PropTypes.oneOfType([PropTypes.oneOf(['nice', 'strict']), PropTypes.func]),
|
|
1046
|
-
fill: PropTypes.string,
|
|
1047
1014
|
hideTooltip: PropTypes.bool,
|
|
1048
1015
|
id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
1049
1016
|
ignoreTooltip: PropTypes.bool,
|
|
@@ -1057,7 +1024,6 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
|
|
|
1057
1024
|
scaleType: PropTypes.oneOf(['utc']),
|
|
1058
1025
|
slotProps: PropTypes.object,
|
|
1059
1026
|
slots: PropTypes.object,
|
|
1060
|
-
stroke: PropTypes.string,
|
|
1061
1027
|
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
|
|
1062
1028
|
tickInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.array, PropTypes.func]),
|
|
1063
1029
|
tickLabelInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.func]),
|
|
@@ -1088,7 +1054,6 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
|
|
|
1088
1054
|
disableLine: PropTypes.bool,
|
|
1089
1055
|
disableTicks: PropTypes.bool,
|
|
1090
1056
|
domainLimit: PropTypes.oneOfType([PropTypes.oneOf(['nice', 'strict']), PropTypes.func]),
|
|
1091
|
-
fill: PropTypes.string,
|
|
1092
1057
|
hideTooltip: PropTypes.bool,
|
|
1093
1058
|
id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
1094
1059
|
ignoreTooltip: PropTypes.bool,
|
|
@@ -1102,7 +1067,6 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
|
|
|
1102
1067
|
scaleType: PropTypes.oneOf(['linear']),
|
|
1103
1068
|
slotProps: PropTypes.object,
|
|
1104
1069
|
slots: PropTypes.object,
|
|
1105
|
-
stroke: PropTypes.string,
|
|
1106
1070
|
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
|
|
1107
1071
|
tickInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.array, PropTypes.func]),
|
|
1108
1072
|
tickLabelInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.func]),
|
package/esm/PieChart/PieChart.js
CHANGED
|
@@ -76,10 +76,10 @@ const PieChart = /*#__PURE__*/React.forwardRef(function PieChart(inProps, ref) {
|
|
|
76
76
|
return /*#__PURE__*/_jsx(ChartDataProvider, _extends({}, chartDataProviderProps, {
|
|
77
77
|
children: /*#__PURE__*/_jsxs(ChartsWrapper, {
|
|
78
78
|
legendPosition: props.slotProps?.legend?.position,
|
|
79
|
-
legendDirection: props
|
|
79
|
+
legendDirection: props.slotProps?.legend?.direction ?? 'vertical',
|
|
80
80
|
sx: sx,
|
|
81
81
|
children: [showToolbar && Toolbar ? /*#__PURE__*/_jsx(Toolbar, _extends({}, props.slotProps?.toolbar)) : null, !hideLegend && /*#__PURE__*/_jsx(ChartsLegend, {
|
|
82
|
-
direction: props
|
|
82
|
+
direction: props.slotProps?.legend?.direction ?? 'vertical',
|
|
83
83
|
slots: slots,
|
|
84
84
|
slotProps: slotProps
|
|
85
85
|
}), /*#__PURE__*/_jsxs(ChartsSurface, _extends({}, chartsSurfaceProps, {
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { UseRadarAxisParams } from "./useRadarAxis.js";
|
|
3
|
+
import { RadarAxisClasses } from "./radarAxisClasses.js";
|
|
4
|
+
export interface RadarAxisProps extends UseRadarAxisParams {
|
|
5
|
+
/**
|
|
6
|
+
* Defines how label align with the axis.
|
|
7
|
+
* - 'horizontal': labels stay horizontal and their placement change with the axis angle.
|
|
8
|
+
* - 'rotated': labels are rotated 90deg relatively to their axis.
|
|
9
|
+
* @default 'horizontal'
|
|
10
|
+
*/
|
|
11
|
+
labelOrientation?: 'horizontal' | 'rotated';
|
|
12
|
+
/**
|
|
13
|
+
* The labels text anchor or a function returning the text anchor for a given axis angle (in degree).
|
|
14
|
+
*/
|
|
15
|
+
textAnchor?: string | ((angle: number) => string);
|
|
16
|
+
/**
|
|
17
|
+
* The labels dominant baseline or a function returning the dominant baseline for a given axis angle (in degree).
|
|
18
|
+
*/
|
|
19
|
+
dominantBaseline?: string | ((angle: number) => string);
|
|
20
|
+
/**
|
|
21
|
+
* Override or extend the styles applied to the component.
|
|
22
|
+
*/
|
|
23
|
+
classes?: Partial<RadarAxisClasses>;
|
|
24
|
+
}
|
|
25
|
+
declare function RadarAxis(props: RadarAxisProps): React.JSX.Element | null;
|
|
26
|
+
declare namespace RadarAxis {
|
|
27
|
+
var propTypes: any;
|
|
28
|
+
}
|
|
29
|
+
export { RadarAxis };
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import PropTypes from 'prop-types';
|
|
4
|
+
import { useTheme } from '@mui/material/styles';
|
|
5
|
+
import { useRadarAxis } from "./useRadarAxis.js";
|
|
6
|
+
import { getLabelAttributes } from "./RadarAxis.utils.js";
|
|
7
|
+
import { useUtilityClasses } from "./radarAxisClasses.js";
|
|
8
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
9
|
+
function RadarAxis(props) {
|
|
10
|
+
const {
|
|
11
|
+
labelOrientation = 'horizontal',
|
|
12
|
+
textAnchor,
|
|
13
|
+
dominantBaseline
|
|
14
|
+
} = props;
|
|
15
|
+
const classes = useUtilityClasses(props.classes);
|
|
16
|
+
const theme = useTheme();
|
|
17
|
+
const data = useRadarAxis(props);
|
|
18
|
+
if (data === null) {
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
const {
|
|
22
|
+
center,
|
|
23
|
+
angle,
|
|
24
|
+
labels
|
|
25
|
+
} = data;
|
|
26
|
+
return /*#__PURE__*/_jsxs("g", {
|
|
27
|
+
className: classes.root,
|
|
28
|
+
children: [/*#__PURE__*/_jsx("path", {
|
|
29
|
+
d: `M ${center.x} ${center.y} L ${labels[labels.length - 1].x} ${labels[labels.length - 1].y}`,
|
|
30
|
+
stroke: (theme.vars ?? theme).palette.text.primary,
|
|
31
|
+
strokeOpacity: 0.3,
|
|
32
|
+
className: classes.line
|
|
33
|
+
}), labels.map(({
|
|
34
|
+
x,
|
|
35
|
+
y,
|
|
36
|
+
formattedValue
|
|
37
|
+
}) => /*#__PURE__*/_jsx("text", _extends({
|
|
38
|
+
fontSize: 12,
|
|
39
|
+
fill: (theme.vars ?? theme).palette.text.primary,
|
|
40
|
+
stroke: "none",
|
|
41
|
+
className: classes.label
|
|
42
|
+
}, getLabelAttributes({
|
|
43
|
+
labelOrientation,
|
|
44
|
+
x,
|
|
45
|
+
y,
|
|
46
|
+
angle,
|
|
47
|
+
textAnchor,
|
|
48
|
+
dominantBaseline
|
|
49
|
+
}), {
|
|
50
|
+
children: formattedValue
|
|
51
|
+
}), formattedValue))]
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
process.env.NODE_ENV !== "production" ? RadarAxis.propTypes = {
|
|
55
|
+
// ----------------------------- Warning --------------------------------
|
|
56
|
+
// | These PropTypes are generated from the TypeScript type definitions |
|
|
57
|
+
// | To update them edit the TypeScript types and run "pnpm proptypes" |
|
|
58
|
+
// ----------------------------------------------------------------------
|
|
59
|
+
/**
|
|
60
|
+
* The absolute rotation angle of the metrics (in degree)
|
|
61
|
+
* If not defined the metric angle will be used.
|
|
62
|
+
*/
|
|
63
|
+
angle: PropTypes.number,
|
|
64
|
+
/**
|
|
65
|
+
* Override or extend the styles applied to the component.
|
|
66
|
+
*/
|
|
67
|
+
classes: PropTypes.object,
|
|
68
|
+
/**
|
|
69
|
+
* The number of divisions with label.
|
|
70
|
+
* @default 1
|
|
71
|
+
*/
|
|
72
|
+
divisions: PropTypes.number,
|
|
73
|
+
/**
|
|
74
|
+
* The labels dominant baseline or a function returning the dominant baseline for a given axis angle (in degree).
|
|
75
|
+
*/
|
|
76
|
+
dominantBaseline: PropTypes.oneOfType([PropTypes.func, PropTypes.string]),
|
|
77
|
+
/**
|
|
78
|
+
* Defines how label align with the axis.
|
|
79
|
+
* - 'horizontal': labels stay horizontal and their placement change with the axis angle.
|
|
80
|
+
* - 'rotated': labels are rotated 90deg relatively to their axis.
|
|
81
|
+
* @default 'horizontal'
|
|
82
|
+
*/
|
|
83
|
+
labelOrientation: PropTypes.oneOf(['horizontal', 'rotated']),
|
|
84
|
+
/**
|
|
85
|
+
* The metric to get.
|
|
86
|
+
* If `undefined`, the hook returns `null`
|
|
87
|
+
*/
|
|
88
|
+
metric: PropTypes.string,
|
|
89
|
+
/**
|
|
90
|
+
* The labels text anchor or a function returning the text anchor for a given axis angle (in degree).
|
|
91
|
+
*/
|
|
92
|
+
textAnchor: PropTypes.oneOfType([PropTypes.func, PropTypes.string])
|
|
93
|
+
} : void 0;
|
|
94
|
+
export { RadarAxis };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { RadarAxisProps } from "./RadarAxis.js";
|
|
2
|
+
interface GetLabelAttributesParams extends Required<Pick<RadarAxisProps, 'labelOrientation'>>, Partial<Pick<RadarAxisProps, 'textAnchor' | 'dominantBaseline'>> {
|
|
3
|
+
x: number;
|
|
4
|
+
y: number;
|
|
5
|
+
angle: number;
|
|
6
|
+
}
|
|
7
|
+
export declare function getLabelAttributes(params: GetLabelAttributesParams): {
|
|
8
|
+
x: number;
|
|
9
|
+
y: number;
|
|
10
|
+
textAnchor: string;
|
|
11
|
+
dominantBaseline: string;
|
|
12
|
+
transform?: undefined;
|
|
13
|
+
} | {
|
|
14
|
+
x: number;
|
|
15
|
+
y: number;
|
|
16
|
+
textAnchor: string;
|
|
17
|
+
dominantBaseline: string;
|
|
18
|
+
transform: string;
|
|
19
|
+
};
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Return text anchor of labels.
|
|
3
|
+
* @param angle The axis angle (in rad) with clock direction and 0 at the top
|
|
4
|
+
*/
|
|
5
|
+
function getTextAnchor(angle) {
|
|
6
|
+
if (angle < 20) {
|
|
7
|
+
return 'start';
|
|
8
|
+
}
|
|
9
|
+
if (angle < 90 - 10) {
|
|
10
|
+
return 'end';
|
|
11
|
+
}
|
|
12
|
+
if (angle < 270 - 10) {
|
|
13
|
+
return 'start';
|
|
14
|
+
}
|
|
15
|
+
if (angle < 360 - 20) {
|
|
16
|
+
return 'end';
|
|
17
|
+
}
|
|
18
|
+
return 'start';
|
|
19
|
+
}
|
|
20
|
+
function getDominantBaseline(angle) {
|
|
21
|
+
if (angle < 160) {
|
|
22
|
+
return 'baseline';
|
|
23
|
+
}
|
|
24
|
+
if (angle < 360 - 20) {
|
|
25
|
+
return 'hanging';
|
|
26
|
+
}
|
|
27
|
+
return 'baseline';
|
|
28
|
+
}
|
|
29
|
+
const LABEL_MARGIN = 2;
|
|
30
|
+
export function getLabelAttributes(params) {
|
|
31
|
+
const {
|
|
32
|
+
x,
|
|
33
|
+
y,
|
|
34
|
+
angle
|
|
35
|
+
} = params;
|
|
36
|
+
if (params.labelOrientation === 'horizontal') {
|
|
37
|
+
const textAnchor = typeof params.textAnchor === 'function' ? params.textAnchor(angle) : params.textAnchor ?? getTextAnchor(angle);
|
|
38
|
+
const dominantBaseline = typeof params.dominantBaseline === 'function' ? params.dominantBaseline(angle) : params.dominantBaseline ?? getDominantBaseline(angle);
|
|
39
|
+
const marginX = textAnchor === 'start' ? LABEL_MARGIN : -LABEL_MARGIN;
|
|
40
|
+
const marginY = dominantBaseline === 'baseline' ? -LABEL_MARGIN : LABEL_MARGIN;
|
|
41
|
+
return {
|
|
42
|
+
x: x + marginX,
|
|
43
|
+
y: y + marginY,
|
|
44
|
+
textAnchor,
|
|
45
|
+
dominantBaseline
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// orientation='rotated'
|
|
50
|
+
|
|
51
|
+
const textAnchor = typeof params.textAnchor === 'function' ? params.textAnchor(angle) : params.textAnchor ?? 'start';
|
|
52
|
+
const dominantBaseline = typeof params.dominantBaseline === 'function' ? params.dominantBaseline(angle) : params.dominantBaseline ?? 'baseline';
|
|
53
|
+
return {
|
|
54
|
+
x,
|
|
55
|
+
y,
|
|
56
|
+
textAnchor,
|
|
57
|
+
dominantBaseline,
|
|
58
|
+
transform: `rotate(${angle}, ${x}, ${y})`
|
|
59
|
+
};
|
|
60
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export interface RadarAxisClasses {
|
|
2
|
+
/** Styles applied to the root element. */
|
|
3
|
+
root: string;
|
|
4
|
+
/** Styles applied to the line element. */
|
|
5
|
+
line: string;
|
|
6
|
+
/** Styles applied to every label element. */
|
|
7
|
+
label: string;
|
|
8
|
+
}
|
|
9
|
+
export type RadarAxisClassKey = keyof RadarAxisClasses;
|
|
10
|
+
export declare function getRadarAxisUtilityClass(slot: string): string;
|
|
11
|
+
export declare const chartsAxisClasses: RadarAxisClasses;
|
|
12
|
+
export declare const useUtilityClasses: (classes?: Partial<RadarAxisClasses>) => Record<"root" | "line" | "label", string>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import composeClasses from '@mui/utils/composeClasses';
|
|
2
|
+
import generateUtilityClass from '@mui/utils/generateUtilityClass';
|
|
3
|
+
import generateUtilityClasses from '@mui/utils/generateUtilityClasses';
|
|
4
|
+
export function getRadarAxisUtilityClass(slot) {
|
|
5
|
+
return generateUtilityClass('MuiRadarAxis', slot);
|
|
6
|
+
}
|
|
7
|
+
export const chartsAxisClasses = generateUtilityClasses('MuiRadarAxis', ['root', 'line', 'label']);
|
|
8
|
+
export const useUtilityClasses = classes => {
|
|
9
|
+
const slots = {
|
|
10
|
+
root: ['root'],
|
|
11
|
+
line: ['line'],
|
|
12
|
+
label: ['label']
|
|
13
|
+
};
|
|
14
|
+
return composeClasses(slots, getRadarAxisUtilityClass, classes);
|
|
15
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export interface UseRadarAxisParams {
|
|
2
|
+
/**
|
|
3
|
+
* The metric to get.
|
|
4
|
+
* If `undefined`, the hook returns `null`
|
|
5
|
+
*/
|
|
6
|
+
metric?: string;
|
|
7
|
+
/**
|
|
8
|
+
* The absolute rotation angle of the metrics (in degree)
|
|
9
|
+
* If not defined the metric angle will be used.
|
|
10
|
+
*/
|
|
11
|
+
angle?: number;
|
|
12
|
+
/**
|
|
13
|
+
* The number of divisions with label.
|
|
14
|
+
* @default 1
|
|
15
|
+
*/
|
|
16
|
+
divisions?: number;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Returns an array with on item par metrics with the different point to label.
|
|
20
|
+
*/
|
|
21
|
+
export declare function useRadarAxis(params: UseRadarAxisParams): {
|
|
22
|
+
metric: string;
|
|
23
|
+
angle: number;
|
|
24
|
+
center: {
|
|
25
|
+
x: number;
|
|
26
|
+
y: number;
|
|
27
|
+
};
|
|
28
|
+
labels: {
|
|
29
|
+
x: number;
|
|
30
|
+
y: number;
|
|
31
|
+
value: number | Date;
|
|
32
|
+
formattedValue: string;
|
|
33
|
+
}[];
|
|
34
|
+
} | null;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { warnOnce } from '@mui/x-internals/warning';
|
|
2
|
+
import { useRadiusAxes } from "../../hooks/useAxis.js";
|
|
3
|
+
import { useRotationScale } from "../../hooks/useScale.js";
|
|
4
|
+
import { useChartContext } from "../../context/ChartProvider/useChartContext.js";
|
|
5
|
+
import { selectorChartPolarCenter } from "../../internals/plugins/featurePlugins/useChartPolarAxis/index.js";
|
|
6
|
+
import { isBandScale } from "../../internals/isBandScale.js";
|
|
7
|
+
import { degToRad } from "../../internals/degToRad.js";
|
|
8
|
+
import { clampAngle } from "../../internals/clampAngle.js";
|
|
9
|
+
import { useSelector } from "../../internals/store/useSelector.js";
|
|
10
|
+
import { rad2deg } from "../../internals/angleConversion.js";
|
|
11
|
+
/**
|
|
12
|
+
* Returns an array with on item par metrics with the different point to label.
|
|
13
|
+
*/
|
|
14
|
+
export function useRadarAxis(params) {
|
|
15
|
+
const {
|
|
16
|
+
metric,
|
|
17
|
+
angle,
|
|
18
|
+
divisions = 1
|
|
19
|
+
} = params;
|
|
20
|
+
const {
|
|
21
|
+
instance,
|
|
22
|
+
store
|
|
23
|
+
} = useChartContext();
|
|
24
|
+
const rotationScale = useRotationScale();
|
|
25
|
+
const {
|
|
26
|
+
radiusAxis
|
|
27
|
+
} = useRadiusAxes();
|
|
28
|
+
const {
|
|
29
|
+
cx,
|
|
30
|
+
cy
|
|
31
|
+
} = useSelector(store, selectorChartPolarCenter);
|
|
32
|
+
if (metric === undefined || !rotationScale || rotationScale.domain().length === 0) {
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
const existingMetrics = rotationScale.domain();
|
|
36
|
+
if (!existingMetrics.includes(metric)) {
|
|
37
|
+
warnOnce([`MUI X Charts: You radar axis try displaying values for the metric "${metric}" which does nto exist.`, `either add this metric to your radar, or pick one from the existing metrics: ${existingMetrics.join(', ')}`]);
|
|
38
|
+
}
|
|
39
|
+
const anglesWithDefault = angle !== undefined ? degToRad(angle) : rotationScale(metric) ?? 0;
|
|
40
|
+
const radiusRatio = Array.from({
|
|
41
|
+
length: divisions
|
|
42
|
+
}, (_, index) => (index + 1) / divisions);
|
|
43
|
+
const radiusScale = radiusAxis[metric].scale;
|
|
44
|
+
const R = radiusScale.range()[1];
|
|
45
|
+
if (isBandScale(radiusScale)) {
|
|
46
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
47
|
+
console.error('MUI X Charts: Radar chart does not support ordinal axes');
|
|
48
|
+
}
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
51
|
+
return {
|
|
52
|
+
metric,
|
|
53
|
+
angle: clampAngle(rad2deg(anglesWithDefault)),
|
|
54
|
+
center: {
|
|
55
|
+
x: cx,
|
|
56
|
+
y: cy
|
|
57
|
+
},
|
|
58
|
+
labels: radiusRatio.map(ratio => {
|
|
59
|
+
const radius = ratio * R;
|
|
60
|
+
const [x, y] = instance.polar2svg(radius, anglesWithDefault);
|
|
61
|
+
const value = radiusScale.invert(radius);
|
|
62
|
+
const defaultTickLabel = value.toString();
|
|
63
|
+
return {
|
|
64
|
+
x,
|
|
65
|
+
y,
|
|
66
|
+
value,
|
|
67
|
+
formattedValue: radiusAxis[metric].valueFormatter?.(radiusScale.invert(radius), {
|
|
68
|
+
location: 'tick',
|
|
69
|
+
scale: radiusScale,
|
|
70
|
+
defaultTickLabel,
|
|
71
|
+
tickNumber: divisions
|
|
72
|
+
}) ?? defaultTickLabel
|
|
73
|
+
};
|
|
74
|
+
})
|
|
75
|
+
};
|
|
76
|
+
}
|