@mui/x-charts 8.7.0 → 8.9.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.d.ts +4 -3
- package/BarChart/BarChart.js +17 -1
- package/BarChart/barClasses.d.ts +1 -1
- package/BarChart/seriesConfig/seriesProcessor.js +5 -3
- package/BarChart/useBarPlotData.js +32 -5
- package/CHANGELOG.md +199 -24
- package/ChartContainer/ChartContainer.js +22 -0
- package/ChartContainer/useChartContainerProps.js +8 -2
- package/ChartDataProvider/ChartDataProvider.js +6 -0
- package/ChartDataProvider/useChartDataProviderProps.d.ts +1 -1
- package/ChartDataProvider/useChartDataProviderProps.js +6 -1
- package/ChartsAxisHighlight/ChartsXAxisHighlight.d.ts +1 -1
- package/ChartsAxisHighlight/ChartsXAxisHighlight.js +34 -24
- package/ChartsAxisHighlight/ChartsYAxisHighlight.d.ts +1 -1
- package/ChartsAxisHighlight/ChartsYAxisHighlight.js +34 -24
- package/ChartsLabel/ChartsLabelMark.d.ts +2 -1
- package/ChartsLabel/index.d.ts +1 -0
- package/ChartsLabel/index.js +18 -0
- package/ChartsLegend/chartsLegendClasses.d.ts +1 -1
- package/ChartsLegend/piecewiseColorLegendClasses.d.ts +1 -1
- package/Gauge/GaugeContainer.d.ts +1 -1
- package/LineChart/LineChart.d.ts +3 -2
- package/LineChart/LineChart.js +23 -1
- package/LineChart/LineHighlightPlot.js +10 -4
- package/LineChart/MarkPlot.js +17 -3
- package/LineChart/useAreaPlotData.js +3 -2
- package/PieChart/PieArcLabelPlot.js +3 -0
- package/PieChart/PieArcPlot.js +3 -0
- package/PieChart/PieChart.d.ts +4 -3
- package/PieChart/PieChart.js +1 -1
- package/PieChart/pieClasses.d.ts +1 -1
- package/RadarChart/RadarAxisHighlight/RadarAxisHighlight.js +3 -5
- package/RadarChart/RadarAxisHighlight/useRadarAxisHighlight.d.ts +2 -13
- package/RadarChart/RadarAxisHighlight/useRadarAxisHighlight.js +8 -45
- package/RadarChart/RadarChart.d.ts +2 -1
- package/RadarChart/RadarChart.js +23 -2
- package/RadarChart/RadarDataProvider/RadarDataProvider.d.ts +4 -3
- package/RadarChart/RadarMetricLabels/useRadarMetricData.js +4 -2
- package/RadarChart/RadarSeriesPlot/RadarSeriesArea.js +19 -3
- package/RadarChart/RadarSeriesPlot/RadarSeriesMarks.js +20 -4
- package/RadarChart/RadarSeriesPlot/RadarSeriesPlot.js +38 -4
- package/RadarChart/RadarSeriesPlot/RadarSeriesPlot.types.d.ts +32 -3
- package/RadarChart/RadarSeriesPlot/useRadarRotationIndex.d.ts +8 -0
- package/RadarChart/RadarSeriesPlot/useRadarRotationIndex.js +38 -0
- package/RadarChart/RadarSeriesPlot/useRadarSeriesData.d.ts +2 -2
- package/RadarChart/index.d.ts +1 -1
- package/RadarChart/useRadarChartProps.d.ts +3 -0
- package/RadarChart/useRadarChartProps.js +15 -3
- package/ScatterChart/ScatterChart.d.ts +4 -3
- package/ScatterChart/ScatterChart.js +1 -1
- package/ScatterChart/ScatterPlot.js +2 -2
- package/ScatterChart/seriesConfig/seriesProcessor.js +3 -0
- package/SparkLineChart/SparkLineChart.d.ts +1 -1
- package/SparkLineChart/SparkLineChart.js +16 -0
- package/esm/BarChart/BarChart.d.ts +4 -3
- package/esm/BarChart/BarChart.js +17 -1
- package/esm/BarChart/barClasses.d.ts +1 -1
- package/esm/BarChart/seriesConfig/seriesProcessor.js +5 -3
- package/esm/BarChart/useBarPlotData.js +32 -5
- package/esm/ChartContainer/ChartContainer.js +22 -0
- package/esm/ChartContainer/useChartContainerProps.js +8 -2
- package/esm/ChartDataProvider/ChartDataProvider.js +6 -0
- package/esm/ChartDataProvider/useChartDataProviderProps.d.ts +1 -1
- package/esm/ChartDataProvider/useChartDataProviderProps.js +7 -2
- package/esm/ChartsAxisHighlight/ChartsXAxisHighlight.d.ts +1 -1
- package/esm/ChartsAxisHighlight/ChartsXAxisHighlight.js +36 -26
- package/esm/ChartsAxisHighlight/ChartsYAxisHighlight.d.ts +1 -1
- package/esm/ChartsAxisHighlight/ChartsYAxisHighlight.js +36 -26
- package/esm/ChartsLabel/ChartsLabelMark.d.ts +2 -1
- package/esm/ChartsLabel/index.d.ts +1 -0
- package/esm/ChartsLabel/index.js +1 -0
- package/esm/ChartsLegend/chartsLegendClasses.d.ts +1 -1
- package/esm/ChartsLegend/piecewiseColorLegendClasses.d.ts +1 -1
- package/esm/Gauge/GaugeContainer.d.ts +1 -1
- package/esm/LineChart/LineChart.d.ts +3 -2
- package/esm/LineChart/LineChart.js +23 -1
- package/esm/LineChart/LineHighlightPlot.js +11 -5
- package/esm/LineChart/MarkPlot.js +17 -3
- package/esm/LineChart/useAreaPlotData.js +3 -2
- package/esm/PieChart/PieArcLabelPlot.js +3 -0
- package/esm/PieChart/PieArcPlot.js +3 -0
- package/esm/PieChart/PieChart.d.ts +4 -3
- package/esm/PieChart/PieChart.js +1 -1
- package/esm/PieChart/pieClasses.d.ts +1 -1
- package/esm/RadarChart/RadarAxisHighlight/RadarAxisHighlight.js +3 -5
- package/esm/RadarChart/RadarAxisHighlight/useRadarAxisHighlight.d.ts +2 -13
- package/esm/RadarChart/RadarAxisHighlight/useRadarAxisHighlight.js +8 -45
- package/esm/RadarChart/RadarChart.d.ts +2 -1
- package/esm/RadarChart/RadarChart.js +23 -2
- package/esm/RadarChart/RadarDataProvider/RadarDataProvider.d.ts +4 -3
- package/esm/RadarChart/RadarMetricLabels/useRadarMetricData.js +4 -2
- package/esm/RadarChart/RadarSeriesPlot/RadarSeriesArea.js +19 -3
- package/esm/RadarChart/RadarSeriesPlot/RadarSeriesMarks.js +20 -4
- package/esm/RadarChart/RadarSeriesPlot/RadarSeriesPlot.js +38 -4
- package/esm/RadarChart/RadarSeriesPlot/RadarSeriesPlot.types.d.ts +32 -3
- package/esm/RadarChart/RadarSeriesPlot/useRadarRotationIndex.d.ts +8 -0
- package/esm/RadarChart/RadarSeriesPlot/useRadarRotationIndex.js +32 -0
- package/esm/RadarChart/RadarSeriesPlot/useRadarSeriesData.d.ts +2 -2
- package/esm/RadarChart/index.d.ts +1 -1
- package/esm/RadarChart/useRadarChartProps.d.ts +3 -0
- package/esm/RadarChart/useRadarChartProps.js +15 -3
- package/esm/ScatterChart/ScatterChart.d.ts +4 -3
- package/esm/ScatterChart/ScatterChart.js +1 -1
- package/esm/ScatterChart/ScatterPlot.js +2 -2
- package/esm/ScatterChart/seriesConfig/seriesProcessor.js +3 -0
- package/esm/SparkLineChart/SparkLineChart.d.ts +1 -1
- package/esm/SparkLineChart/SparkLineChart.js +16 -0
- package/esm/hooks/useAxis.d.ts +2 -2
- package/esm/hooks/useTicks.d.ts +6 -1
- package/esm/hooks/useTicks.js +94 -58
- package/esm/index.js +1 -1
- package/esm/internals/constants.d.ts +3 -0
- package/esm/internals/constants.js +4 -0
- package/esm/internals/getLabel.d.ts +1 -1
- package/esm/internals/index.d.ts +1 -0
- package/esm/internals/index.js +1 -0
- package/esm/internals/plugins/corePlugins/corePlugins.d.ts +3 -2
- package/esm/internals/plugins/corePlugins/corePlugins.js +2 -1
- package/esm/internals/plugins/corePlugins/useChartAnimation/useChartAnimation.selectors.d.ts +1 -1
- package/esm/internals/plugins/corePlugins/useChartDimensions/useChartDimensions.selectors.d.ts +3 -3
- package/esm/internals/plugins/corePlugins/useChartExperimentalFeature/index.d.ts +3 -0
- package/esm/internals/plugins/corePlugins/useChartExperimentalFeature/index.js +2 -0
- package/esm/internals/plugins/corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.d.ts +3 -0
- package/esm/internals/plugins/corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.js +27 -0
- package/esm/internals/plugins/corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.selectors.d.ts +8 -0
- package/esm/internals/plugins/corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.selectors.js +3 -0
- package/esm/internals/plugins/corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.types.d.ts +21 -0
- package/esm/internals/plugins/corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.types.js +1 -0
- package/esm/internals/plugins/corePlugins/useChartId/useChartId.selectors.d.ts +1 -1
- package/esm/internals/plugins/corePlugins/useChartSeries/useChartSeries.selectors.d.ts +2 -2
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/computeAxisValue.d.ts +5 -1
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/computeAxisValue.js +4 -2
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/defaultizeZoom.d.ts +1 -0
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/defaultizeZoom.js +5 -2
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisDomainLimit.d.ts +7 -0
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisDomainLimit.js +14 -0
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/index.d.ts +2 -0
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/index.js +2 -0
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartAxisSize.selectors.d.ts +4 -4
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxis.js +46 -3
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxis.types.d.ts +18 -1
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisPreview.selectors.d.ts +3 -0
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisPreview.selectors.js +76 -0
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.d.ts +10 -5
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.js +8 -5
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianHighlight.selectors.d.ts +47 -0
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianHighlight.selectors.js +48 -0
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianInteraction.selectors.d.ts +18 -12
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianInteraction.selectors.js +16 -2
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/zoom.types.d.ts +6 -1
- package/esm/internals/plugins/featurePlugins/useChartHighlight/createIsFaded.d.ts +1 -1
- package/esm/internals/plugins/featurePlugins/useChartHighlight/createIsFaded.js +19 -11
- package/esm/internals/plugins/featurePlugins/useChartHighlight/createIsHighlighted.d.ts +1 -1
- package/esm/internals/plugins/featurePlugins/useChartHighlight/createIsHighlighted.js +19 -11
- package/esm/internals/plugins/featurePlugins/useChartHighlight/useChartHighlight.selectors.d.ts +5 -5
- package/esm/internals/plugins/featurePlugins/useChartHighlight/useChartHighlight.selectors.js +10 -4
- package/esm/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.js +4 -4
- package/esm/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.selectors.d.ts +6 -6
- package/esm/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarAxis.js +44 -1
- package/esm/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarAxis.selectors.d.ts +5 -5
- package/esm/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarAxis.types.d.ts +8 -1
- package/esm/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarInteraction.selectors.d.ts +7 -8
- package/esm/internals/plugins/featurePlugins/useChartVoronoi/useChartVoronoi.selectors.d.ts +1 -1
- package/esm/internals/plugins/featurePlugins/useChartZAxis/useChartZAxis.selectors.d.ts +1 -1
- package/esm/internals/plugins/utils/useLazySelectorEffect.d.ts +7 -0
- package/esm/internals/plugins/utils/useLazySelectorEffect.js +70 -0
- package/esm/internals/store/useCharts.d.ts +1 -1
- package/esm/models/axis.d.ts +42 -1
- package/esm/models/axis.js +4 -0
- package/esm/models/index.d.ts +1 -1
- package/esm/models/seriesType/bar.d.ts +11 -1
- package/esm/models/seriesType/common.d.ts +9 -3
- package/esm/models/seriesType/line.d.ts +3 -1
- package/esm/models/seriesType/scatter.d.ts +14 -2
- package/esm/tests/web-components.js +49 -0
- package/esm/themeAugmentation/components.d.ts +3 -0
- package/esm/themeAugmentation/props.d.ts +2 -0
- package/hooks/useAxis.d.ts +2 -2
- package/hooks/useTicks.d.ts +6 -1
- package/hooks/useTicks.js +95 -58
- package/index.js +1 -1
- package/internals/constants.d.ts +3 -0
- package/internals/constants.js +5 -1
- package/internals/getLabel.d.ts +1 -1
- package/internals/index.d.ts +1 -0
- package/internals/index.js +8 -0
- package/internals/plugins/corePlugins/corePlugins.d.ts +3 -2
- package/internals/plugins/corePlugins/corePlugins.js +2 -1
- package/internals/plugins/corePlugins/useChartAnimation/useChartAnimation.selectors.d.ts +1 -1
- package/internals/plugins/corePlugins/useChartDimensions/useChartDimensions.selectors.d.ts +3 -3
- package/internals/plugins/corePlugins/useChartExperimentalFeature/index.d.ts +3 -0
- package/internals/plugins/corePlugins/useChartExperimentalFeature/index.js +27 -0
- package/internals/plugins/corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.d.ts +3 -0
- package/internals/plugins/corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.js +34 -0
- package/internals/plugins/corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.selectors.d.ts +8 -0
- package/internals/plugins/corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.selectors.js +10 -0
- package/internals/plugins/corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.types.d.ts +21 -0
- package/internals/plugins/corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.types.js +5 -0
- package/internals/plugins/corePlugins/useChartId/useChartId.selectors.d.ts +1 -1
- package/internals/plugins/corePlugins/useChartSeries/useChartSeries.selectors.d.ts +2 -2
- package/internals/plugins/featurePlugins/useChartCartesianAxis/computeAxisValue.d.ts +5 -1
- package/internals/plugins/featurePlugins/useChartCartesianAxis/computeAxisValue.js +4 -2
- package/internals/plugins/featurePlugins/useChartCartesianAxis/defaultizeZoom.d.ts +1 -0
- package/internals/plugins/featurePlugins/useChartCartesianAxis/defaultizeZoom.js +4 -1
- package/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisDomainLimit.d.ts +7 -0
- package/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisDomainLimit.js +21 -0
- package/internals/plugins/featurePlugins/useChartCartesianAxis/index.d.ts +2 -0
- package/internals/plugins/featurePlugins/useChartCartesianAxis/index.js +24 -0
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartAxisSize.selectors.d.ts +4 -4
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxis.js +46 -3
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxis.types.d.ts +18 -1
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisPreview.selectors.d.ts +3 -0
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisPreview.selectors.js +82 -0
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.d.ts +10 -5
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.js +9 -6
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianHighlight.selectors.d.ts +47 -0
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianHighlight.selectors.js +55 -0
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianInteraction.selectors.d.ts +18 -12
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianInteraction.selectors.js +18 -3
- package/internals/plugins/featurePlugins/useChartCartesianAxis/zoom.types.d.ts +6 -1
- package/internals/plugins/featurePlugins/useChartHighlight/createIsFaded.d.ts +1 -1
- package/internals/plugins/featurePlugins/useChartHighlight/createIsFaded.js +20 -13
- package/internals/plugins/featurePlugins/useChartHighlight/createIsHighlighted.d.ts +1 -1
- package/internals/plugins/featurePlugins/useChartHighlight/createIsHighlighted.js +20 -13
- package/internals/plugins/featurePlugins/useChartHighlight/useChartHighlight.selectors.d.ts +5 -5
- package/internals/plugins/featurePlugins/useChartHighlight/useChartHighlight.selectors.js +10 -4
- package/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.js +4 -4
- package/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.selectors.d.ts +6 -6
- package/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarAxis.js +44 -1
- package/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarAxis.selectors.d.ts +5 -5
- package/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarAxis.types.d.ts +8 -1
- package/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarInteraction.selectors.d.ts +7 -8
- package/internals/plugins/featurePlugins/useChartVoronoi/useChartVoronoi.selectors.d.ts +1 -1
- package/internals/plugins/featurePlugins/useChartZAxis/useChartZAxis.selectors.d.ts +1 -1
- package/internals/plugins/utils/useLazySelectorEffect.d.ts +7 -0
- package/internals/plugins/utils/useLazySelectorEffect.js +77 -0
- package/internals/store/useCharts.d.ts +1 -1
- package/models/axis.d.ts +42 -1
- package/models/axis.js +4 -0
- package/models/index.d.ts +1 -1
- package/models/seriesType/bar.d.ts +11 -1
- package/models/seriesType/common.d.ts +9 -3
- package/models/seriesType/line.d.ts +3 -1
- package/models/seriesType/scatter.d.ts +14 -2
- package/package.json +5 -5
- package/tests/web-components.js +55 -0
- package/themeAugmentation/components.d.ts +3 -0
- package/themeAugmentation/props.d.ts +2 -0
|
@@ -145,6 +145,9 @@ process.env.NODE_ENV !== "production" ? PieArcLabelPlot.propTypes = {
|
|
|
145
145
|
outerRadius: PropTypes.number,
|
|
146
146
|
paddingAngle: PropTypes.number
|
|
147
147
|
}),
|
|
148
|
+
/**
|
|
149
|
+
* The id of this series.
|
|
150
|
+
*/
|
|
148
151
|
id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired,
|
|
149
152
|
/**
|
|
150
153
|
* The radius between circle center and the beginning of the arc.
|
|
@@ -116,6 +116,9 @@ process.env.NODE_ENV !== "production" ? PieArcPlot.propTypes = {
|
|
|
116
116
|
outerRadius: PropTypes.number,
|
|
117
117
|
paddingAngle: PropTypes.number
|
|
118
118
|
}),
|
|
119
|
+
/**
|
|
120
|
+
* The id of this series.
|
|
121
|
+
*/
|
|
119
122
|
id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired,
|
|
120
123
|
/**
|
|
121
124
|
* The radius between circle center and the beginning of the arc.
|
|
@@ -12,12 +12,13 @@ import { ChartsOverlayProps, ChartsOverlaySlotProps, ChartsOverlaySlots } from "
|
|
|
12
12
|
import { PieChartPluginSignatures } from "./PieChart.plugins.js";
|
|
13
13
|
export interface PieChartSlots extends PiePlotSlots, ChartsLegendSlots, ChartsOverlaySlots, ChartsTooltipSlots, ChartsToolbarSlots, Partial<ChartsSlots> {}
|
|
14
14
|
export interface PieChartSlotProps extends PiePlotSlotProps, ChartsLegendSlotProps, ChartsOverlaySlotProps, ChartsTooltipSlotProps, ChartsToolbarSlotProps, Partial<ChartsSlotProps> {}
|
|
15
|
-
export
|
|
15
|
+
export type PieSeries = MakeOptional<PieSeriesType<MakeOptional<PieValueType, 'id'>>, 'type'>;
|
|
16
|
+
export interface PieChartProps extends Omit<ChartContainerProps<'pie', PieChartPluginSignatures>, 'series' | 'slots' | 'slotProps' | 'experimentalFeatures'>, Omit<ChartsOverlayProps, 'slots' | 'slotProps'>, Pick<PiePlotProps, 'skipAnimation'> {
|
|
16
17
|
/**
|
|
17
18
|
* The series to display in the pie chart.
|
|
18
|
-
* An array of [[
|
|
19
|
+
* An array of [[PieSeries]] objects.
|
|
19
20
|
*/
|
|
20
|
-
series: Readonly<
|
|
21
|
+
series: Readonly<PieSeries[]>;
|
|
21
22
|
/**
|
|
22
23
|
* If `true`, the legend is not rendered.
|
|
23
24
|
*/
|
package/esm/PieChart/PieChart.js
CHANGED
|
@@ -173,7 +173,7 @@ process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
|
|
|
173
173
|
onItemClick: PropTypes.func,
|
|
174
174
|
/**
|
|
175
175
|
* The series to display in the pie chart.
|
|
176
|
-
* An array of [[
|
|
176
|
+
* An array of [[PieSeries]] objects.
|
|
177
177
|
*/
|
|
178
178
|
series: PropTypes.arrayOf(PropTypes.object).isRequired,
|
|
179
179
|
/**
|
|
@@ -9,4 +9,4 @@ export interface PieClasses {
|
|
|
9
9
|
export type PieClassKey = keyof PieClasses;
|
|
10
10
|
export declare function getPieUtilityClass(slot: string): string;
|
|
11
11
|
export declare const pieClasses: PieClasses;
|
|
12
|
-
export declare const useUtilityClasses: (classes?: Partial<PieClasses>) => Record<"
|
|
12
|
+
export declare const useUtilityClasses: (classes?: Partial<PieClasses>) => Record<"series" | "root" | "seriesLabels", string>;
|
|
@@ -54,13 +54,11 @@ function RadarAxisHighlight(props) {
|
|
|
54
54
|
className: classes.line,
|
|
55
55
|
pointerEvents: "none",
|
|
56
56
|
strokeDasharray: "4 4"
|
|
57
|
-
}), points.map(({
|
|
58
|
-
highlighted
|
|
59
|
-
}, seriesIndex) => {
|
|
57
|
+
}), points.map((point, seriesIndex) => {
|
|
60
58
|
return /*#__PURE__*/_jsx("circle", _extends({
|
|
61
59
|
fill: series[seriesIndex].color,
|
|
62
|
-
cx:
|
|
63
|
-
cy:
|
|
60
|
+
cx: point.x,
|
|
61
|
+
cy: point.y,
|
|
64
62
|
className: classes.dot,
|
|
65
63
|
pointerEvents: "none"
|
|
66
64
|
}, series[seriesIndex].hideMark ? highlightMark : highlightMarkShadow), series[seriesIndex].id);
|
|
@@ -2,12 +2,6 @@ import { UseChartPolarAxisSignature } from "../../internals/plugins/featurePlugi
|
|
|
2
2
|
import { AxisId } from "../../models/axis.js";
|
|
3
3
|
import { DefaultizedRadarSeriesType } from "../../models/seriesType/radar.js";
|
|
4
4
|
import { ChartInstance } from "../../internals/plugins/models/index.js";
|
|
5
|
-
interface UseRadarAxisHighlightParams {
|
|
6
|
-
/**
|
|
7
|
-
* If true, coordinates of the previous/next point will be added.
|
|
8
|
-
*/
|
|
9
|
-
includesNeighbors?: boolean;
|
|
10
|
-
}
|
|
11
5
|
interface UseRadarAxisHighlightReturnValue {
|
|
12
6
|
/**
|
|
13
7
|
* The radar center.
|
|
@@ -40,7 +34,7 @@ interface UseRadarAxisHighlightReturnValue {
|
|
|
40
34
|
* The { x, y, value } values for the highlighted points in the same order as the `series` array.
|
|
41
35
|
* If `includesNeighbors` is set to `true` it also contains the information for `previous` and `next` data point.
|
|
42
36
|
*/
|
|
43
|
-
points:
|
|
37
|
+
points: Point[];
|
|
44
38
|
/**
|
|
45
39
|
* Charts instances giving access to `polar2svg` and `svg2polar` helpers.
|
|
46
40
|
*/
|
|
@@ -53,10 +47,5 @@ interface Point {
|
|
|
53
47
|
angle: number;
|
|
54
48
|
value: number;
|
|
55
49
|
}
|
|
56
|
-
|
|
57
|
-
highlighted: Point;
|
|
58
|
-
previous?: Point;
|
|
59
|
-
next?: Point;
|
|
60
|
-
}
|
|
61
|
-
export declare function useRadarAxisHighlight(params?: UseRadarAxisHighlightParams): UseRadarAxisHighlightReturnValue | null;
|
|
50
|
+
export declare function useRadarAxisHighlight(): UseRadarAxisHighlightReturnValue | null;
|
|
62
51
|
export {};
|
|
@@ -6,10 +6,7 @@ import { useStore } from "../../internals/store/useStore.js";
|
|
|
6
6
|
import { useChartContext } from "../../context/ChartProvider/useChartContext.js";
|
|
7
7
|
import { selectorChartPolarCenter } from "../../internals/plugins/featurePlugins/useChartPolarAxis/index.js";
|
|
8
8
|
import { selectorChartsInteractionRotationAxisIndex, selectorChartsInteractionRotationAxisValue } from "../../internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarInteraction.selectors.js";
|
|
9
|
-
export function useRadarAxisHighlight(
|
|
10
|
-
const {
|
|
11
|
-
includesNeighbors = false
|
|
12
|
-
} = params ?? {};
|
|
9
|
+
export function useRadarAxisHighlight() {
|
|
13
10
|
const radarSeries = useRadarSeries();
|
|
14
11
|
const rotationScale = useRotationScale();
|
|
15
12
|
const {
|
|
@@ -49,48 +46,14 @@ export function useRadarAxisHighlight(params) {
|
|
|
49
46
|
const value = series.data[highlightedIndex];
|
|
50
47
|
const r = radiusScale(value);
|
|
51
48
|
const [x, y] = instance.polar2svg(r, angle);
|
|
52
|
-
const
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
value
|
|
59
|
-
}
|
|
49
|
+
const returnedValue = {
|
|
50
|
+
x,
|
|
51
|
+
y,
|
|
52
|
+
r,
|
|
53
|
+
angle,
|
|
54
|
+
value
|
|
60
55
|
};
|
|
61
|
-
|
|
62
|
-
return retrunedValue;
|
|
63
|
-
}
|
|
64
|
-
const dataLength = series.data.length;
|
|
65
|
-
const prevIndex = (dataLength + highlightedIndex - 1) % dataLength;
|
|
66
|
-
const nextIndex = (highlightedIndex + 1) % dataLength;
|
|
67
|
-
const prevValue = series.data[prevIndex];
|
|
68
|
-
const nextValue = series.data[nextIndex];
|
|
69
|
-
if (prevValue != null) {
|
|
70
|
-
const prevR = radiusAxis[radiusAxisIds[prevIndex]].scale(prevValue);
|
|
71
|
-
const prevAngle = rotationScale(rotationScale.domain()[prevIndex]);
|
|
72
|
-
const [px, py] = instance.polar2svg(prevR, prevAngle);
|
|
73
|
-
retrunedValue.previous = {
|
|
74
|
-
x: px,
|
|
75
|
-
y: py,
|
|
76
|
-
r: prevR,
|
|
77
|
-
angle: prevAngle,
|
|
78
|
-
value: prevValue
|
|
79
|
-
};
|
|
80
|
-
}
|
|
81
|
-
if (nextValue != null) {
|
|
82
|
-
const nextR = radiusAxis[radiusAxisIds[nextIndex]].scale(nextValue);
|
|
83
|
-
const nextAngle = rotationScale(rotationScale.domain()[nextIndex]);
|
|
84
|
-
const [nx, ny] = instance.polar2svg(nextR, nextAngle);
|
|
85
|
-
retrunedValue.next = {
|
|
86
|
-
x: nx,
|
|
87
|
-
y: ny,
|
|
88
|
-
r: nextR,
|
|
89
|
-
angle: nextAngle,
|
|
90
|
-
value: nextValue
|
|
91
|
-
};
|
|
92
|
-
}
|
|
93
|
-
return retrunedValue;
|
|
56
|
+
return returnedValue;
|
|
94
57
|
})
|
|
95
58
|
};
|
|
96
59
|
}
|
|
@@ -5,13 +5,14 @@ import { ChartsSurfaceProps } from "../ChartsSurface/index.js";
|
|
|
5
5
|
import { ChartsWrapperProps } from "../internals/components/ChartsWrapper/index.js";
|
|
6
6
|
import { RadarGridProps } from "./RadarGrid/index.js";
|
|
7
7
|
import { RadarDataProviderProps } from "./RadarDataProvider/RadarDataProvider.js";
|
|
8
|
+
import { RadarSeriesPlotProps } from "./RadarSeriesPlot/index.js";
|
|
8
9
|
import { RadarAxisHighlightProps } from "./RadarAxisHighlight/index.js";
|
|
9
10
|
import { ChartsTooltipSlotProps, ChartsTooltipSlots } from "../ChartsTooltip/index.js";
|
|
10
11
|
import { ChartsSlotProps, ChartsSlots } from "../internals/material/index.js";
|
|
11
12
|
import { ChartsToolbarSlotProps, ChartsToolbarSlots } from "../Toolbar/index.js";
|
|
12
13
|
export interface RadarChartSlots extends ChartsTooltipSlots, ChartsOverlaySlots, ChartsLegendSlots, ChartsToolbarSlots, Partial<ChartsSlots> {}
|
|
13
14
|
export interface RadarChartSlotProps extends ChartsTooltipSlotProps, ChartsOverlaySlotProps, ChartsLegendSlotProps, ChartsToolbarSlotProps, Partial<ChartsSlotProps> {}
|
|
14
|
-
export interface RadarChartProps extends RadarDataProviderProps, Omit<RadarGridProps, 'classes'>, Omit<Partial<RadarAxisHighlightProps>, 'classes'>, Omit<ChartsOverlayProps, 'slots' | 'slotProps'>, Pick<ChartsWrapperProps, 'sx'>, Omit<ChartsSurfaceProps, 'sx'> {
|
|
15
|
+
export interface RadarChartProps extends RadarDataProviderProps, Omit<RadarGridProps, 'classes'>, Omit<Partial<RadarAxisHighlightProps>, 'classes'>, Omit<ChartsOverlayProps, 'slots' | 'slotProps'>, Pick<ChartsWrapperProps, 'sx'>, Omit<ChartsSurfaceProps, 'sx'>, Pick<RadarSeriesPlotProps, 'onAreaClick' | 'onMarkClick'> {
|
|
15
16
|
/**
|
|
16
17
|
* If `true`, the legend is not rendered.
|
|
17
18
|
*/
|
|
@@ -35,6 +35,8 @@ const RadarChart = /*#__PURE__*/React.forwardRef(function RadarChart(inProps, re
|
|
|
35
35
|
chartsSurfaceProps,
|
|
36
36
|
radarDataProviderProps,
|
|
37
37
|
radarGrid,
|
|
38
|
+
radarSeriesAreaProps,
|
|
39
|
+
radarSeriesMarksProps,
|
|
38
40
|
overlayProps,
|
|
39
41
|
legendProps,
|
|
40
42
|
highlight,
|
|
@@ -46,7 +48,7 @@ const RadarChart = /*#__PURE__*/React.forwardRef(function RadarChart(inProps, re
|
|
|
46
48
|
children: /*#__PURE__*/_jsxs(ChartsWrapper, _extends({}, chartsWrapperProps, {
|
|
47
49
|
children: [props.showToolbar && Toolbar ? /*#__PURE__*/_jsx(Toolbar, _extends({}, props.slotProps?.toolbar)) : null, !props.hideLegend && /*#__PURE__*/_jsx(ChartsLegend, _extends({}, legendProps)), /*#__PURE__*/_jsxs(ChartsSurface, _extends({}, chartsSurfaceProps, {
|
|
48
50
|
ref: ref,
|
|
49
|
-
children: [/*#__PURE__*/_jsx(RadarGrid, _extends({}, radarGrid)), /*#__PURE__*/_jsx(RadarMetricLabels, {}), /*#__PURE__*/_jsx(RadarSeriesArea, {}), highlight === 'axis' && /*#__PURE__*/_jsx(RadarAxisHighlight, {}), /*#__PURE__*/_jsx(RadarSeriesMarks, {}), /*#__PURE__*/_jsx(ChartsOverlay, _extends({}, overlayProps)), children]
|
|
51
|
+
children: [/*#__PURE__*/_jsx(RadarGrid, _extends({}, radarGrid)), /*#__PURE__*/_jsx(RadarMetricLabels, {}), /*#__PURE__*/_jsx(RadarSeriesArea, _extends({}, radarSeriesAreaProps)), highlight === 'axis' && /*#__PURE__*/_jsx(RadarAxisHighlight, {}), /*#__PURE__*/_jsx(RadarSeriesMarks, _extends({}, radarSeriesMarksProps)), /*#__PURE__*/_jsx(ChartsOverlay, _extends({}, overlayProps)), children]
|
|
50
52
|
})), !props.loading && /*#__PURE__*/_jsx(Tooltip, _extends({}, props.slotProps?.tooltip))]
|
|
51
53
|
}))
|
|
52
54
|
}));
|
|
@@ -125,12 +127,31 @@ process.env.NODE_ENV !== "production" ? RadarChart.propTypes = {
|
|
|
125
127
|
right: PropTypes.number,
|
|
126
128
|
top: PropTypes.number
|
|
127
129
|
})]),
|
|
130
|
+
/**
|
|
131
|
+
* Callback fired when an area is clicked.
|
|
132
|
+
* @param {React.MouseEvent<SVGPathElement, MouseEvent>} event The event source of the callback.
|
|
133
|
+
* @param {RadarItemIdentifier} radarItemIdentifier The radar item identifier.
|
|
134
|
+
*/
|
|
135
|
+
onAreaClick: PropTypes.func,
|
|
136
|
+
/**
|
|
137
|
+
* The function called for onClick events.
|
|
138
|
+
* The second argument contains information about all line/bar elements at the current mouse position.
|
|
139
|
+
* @param {MouseEvent} event The mouse event recorded on the `<svg/>` element.
|
|
140
|
+
* @param {null | ChartsAxisData} data The data about the clicked axis and items associated with it.
|
|
141
|
+
*/
|
|
142
|
+
onAxisClick: PropTypes.func,
|
|
128
143
|
/**
|
|
129
144
|
* The callback fired when the highlighted item changes.
|
|
130
145
|
*
|
|
131
146
|
* @param {HighlightItemData | null} highlightedItem The newly highlighted item.
|
|
132
147
|
*/
|
|
133
148
|
onHighlightChange: PropTypes.func,
|
|
149
|
+
/**
|
|
150
|
+
* Callback fired when a mark is clicked.
|
|
151
|
+
* @param {React.MouseEvent<SVGPathElement, MouseEvent>} event The event source of the callback.
|
|
152
|
+
* @param {RadarItemIdentifier} radarItemIdentifier The radar item identifier.
|
|
153
|
+
*/
|
|
154
|
+
onMarkClick: PropTypes.func,
|
|
134
155
|
/**
|
|
135
156
|
* The configuration of the radar scales.
|
|
136
157
|
*/
|
|
@@ -147,7 +168,7 @@ process.env.NODE_ENV !== "production" ? RadarChart.propTypes = {
|
|
|
147
168
|
}).isRequired,
|
|
148
169
|
/**
|
|
149
170
|
* The series to display in the bar chart.
|
|
150
|
-
* An array of [[
|
|
171
|
+
* An array of [[RadarSeries]] objects.
|
|
151
172
|
*/
|
|
152
173
|
series: PropTypes.arrayOf(PropTypes.object).isRequired,
|
|
153
174
|
/**
|
|
@@ -5,12 +5,13 @@ import { RadarSeriesType } from "../../models/seriesType/radar.js";
|
|
|
5
5
|
import { ChartDataProviderProps } from "../../ChartDataProvider/index.js";
|
|
6
6
|
import { RadarConfig } from "./radar.types.js";
|
|
7
7
|
import { ChartAnyPluginSignature } from "../../internals/plugins/models/plugin.js";
|
|
8
|
-
export type
|
|
8
|
+
export type RadarSeries = MakeOptional<RadarSeriesType, 'type'>;
|
|
9
|
+
export type RadarDataProviderProps<TSignatures extends readonly ChartAnyPluginSignature[] = RadarChartPluginsSignatures> = Omit<ChartDataProviderProps<'radar', TSignatures>, 'series' | 'rotationAxis' | 'radiusAxis' | 'dataset' | 'experimentalFeatures'> & {
|
|
9
10
|
/**
|
|
10
11
|
* The series to display in the bar chart.
|
|
11
|
-
* An array of [[
|
|
12
|
+
* An array of [[RadarSeries]] objects.
|
|
12
13
|
*/
|
|
13
|
-
series: Readonly<
|
|
14
|
+
series: Readonly<RadarSeries>[];
|
|
14
15
|
/**
|
|
15
16
|
* The configuration of the radar scales.
|
|
16
17
|
*/
|
|
@@ -21,14 +21,16 @@ export function useRadarMetricData() {
|
|
|
21
21
|
const radiusScale = radiusAxis[metric].scale;
|
|
22
22
|
const r = radiusScale.range()[1] + labelGap;
|
|
23
23
|
const angle = angles[dataIndex];
|
|
24
|
+
const defaultTickLabel = metric;
|
|
24
25
|
return {
|
|
25
26
|
x: cx + r * Math.sin(angle),
|
|
26
27
|
y: cy - r * Math.cos(angle),
|
|
27
28
|
angle: rad2deg(angle),
|
|
28
29
|
label: valueFormatter?.(metric, {
|
|
29
30
|
location: 'tick',
|
|
30
|
-
scale: rotationScale
|
|
31
|
-
|
|
31
|
+
scale: rotationScale,
|
|
32
|
+
defaultTickLabel
|
|
33
|
+
}) ?? defaultTickLabel
|
|
32
34
|
};
|
|
33
35
|
})
|
|
34
36
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
|
-
const _excluded = ["seriesId"];
|
|
3
|
+
const _excluded = ["seriesId", "onItemClick"];
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
6
|
import clsx from 'clsx';
|
|
@@ -9,6 +9,7 @@ import { getAreaPath } from "./getAreaPath.js";
|
|
|
9
9
|
import { useUtilityClasses } from "./radarSeriesPlotClasses.js";
|
|
10
10
|
import { useItemHighlightedGetter } from "../../hooks/useItemHighlightedGetter.js";
|
|
11
11
|
import { useInteractionAllItemProps } from "../../hooks/useInteractionItemProps.js";
|
|
12
|
+
import { useRadarRotationIndex } from "./useRadarRotationIndex.js";
|
|
12
13
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
14
|
export function getPathProps(params) {
|
|
14
15
|
const {
|
|
@@ -38,10 +39,12 @@ export function getPathProps(params) {
|
|
|
38
39
|
}
|
|
39
40
|
function RadarSeriesArea(props) {
|
|
40
41
|
const {
|
|
41
|
-
seriesId
|
|
42
|
+
seriesId,
|
|
43
|
+
onItemClick
|
|
42
44
|
} = props,
|
|
43
45
|
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
44
46
|
const seriesCoordinates = useRadarSeriesData(seriesId);
|
|
47
|
+
const getRotationIndex = useRadarRotationIndex();
|
|
45
48
|
const interactionProps = useInteractionAllItemProps(seriesCoordinates);
|
|
46
49
|
const {
|
|
47
50
|
isFaded,
|
|
@@ -63,7 +66,14 @@ function RadarSeriesArea(props) {
|
|
|
63
66
|
isFaded,
|
|
64
67
|
isHighlighted,
|
|
65
68
|
classes
|
|
66
|
-
}),
|
|
69
|
+
}), {
|
|
70
|
+
onClick: event => onItemClick?.(event, {
|
|
71
|
+
type: 'radar',
|
|
72
|
+
seriesId: id,
|
|
73
|
+
dataIndex: getRotationIndex(event)
|
|
74
|
+
}),
|
|
75
|
+
cursor: onItemClick ? 'pointer' : 'unset'
|
|
76
|
+
}, interactionProps[seriesIndex], other), id);
|
|
67
77
|
})
|
|
68
78
|
});
|
|
69
79
|
}
|
|
@@ -76,6 +86,12 @@ process.env.NODE_ENV !== "production" ? RadarSeriesArea.propTypes = {
|
|
|
76
86
|
* Override or extend the styles applied to the component.
|
|
77
87
|
*/
|
|
78
88
|
classes: PropTypes.object,
|
|
89
|
+
/**
|
|
90
|
+
* Callback fired when an area is clicked.
|
|
91
|
+
* @param {React.MouseEvent<SVGPathElement, MouseEvent>} event The event source of the callback.
|
|
92
|
+
* @param {RadarItemIdentifier} radarItemIdentifier The radar item identifier.
|
|
93
|
+
*/
|
|
94
|
+
onItemClick: PropTypes.func,
|
|
79
95
|
/**
|
|
80
96
|
* The id of the series to display.
|
|
81
97
|
* If undefined all series are displayed.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
|
-
const _excluded = ["seriesId"];
|
|
3
|
+
const _excluded = ["seriesId", "onItemClick"];
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import { clsx } from 'clsx';
|
|
6
6
|
import PropTypes from 'prop-types';
|
|
@@ -31,12 +31,14 @@ export function getCircleProps(params) {
|
|
|
31
31
|
fill: color,
|
|
32
32
|
stroke: color,
|
|
33
33
|
opacity: fillArea && isItemFaded ? 0.5 : 1,
|
|
34
|
-
pointerEvents: 'none',
|
|
35
34
|
className: clsx(classes.mark, isItemHighlighted && classes.highlighted || isItemFaded && classes.faded)
|
|
36
35
|
};
|
|
37
36
|
}
|
|
38
37
|
function RadarSeriesMarks(props) {
|
|
39
|
-
const
|
|
38
|
+
const {
|
|
39
|
+
onItemClick
|
|
40
|
+
} = props,
|
|
41
|
+
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
40
42
|
const seriesCoordinates = useRadarSeriesData(props.seriesId);
|
|
41
43
|
const classes = useUtilityClasses(props.classes);
|
|
42
44
|
const {
|
|
@@ -63,7 +65,15 @@ function RadarSeriesMarks(props) {
|
|
|
63
65
|
isFaded,
|
|
64
66
|
isHighlighted,
|
|
65
67
|
classes
|
|
66
|
-
}),
|
|
68
|
+
}), {
|
|
69
|
+
pointerEvents: onItemClick ? undefined : 'none',
|
|
70
|
+
onClick: event => onItemClick?.(event, {
|
|
71
|
+
type: 'radar',
|
|
72
|
+
seriesId: id,
|
|
73
|
+
dataIndex: index
|
|
74
|
+
}),
|
|
75
|
+
cursor: onItemClick ? 'pointer' : 'unset'
|
|
76
|
+
}, other), index))
|
|
67
77
|
}, id);
|
|
68
78
|
})
|
|
69
79
|
});
|
|
@@ -77,6 +87,12 @@ process.env.NODE_ENV !== "production" ? RadarSeriesMarks.propTypes = {
|
|
|
77
87
|
* Override or extend the styles applied to the component.
|
|
78
88
|
*/
|
|
79
89
|
classes: PropTypes.object,
|
|
90
|
+
/**
|
|
91
|
+
* Callback fired when a mark is clicked.
|
|
92
|
+
* @param {React.MouseEvent<SVGPathElement, MouseEvent>} event The event source of the callback.
|
|
93
|
+
* @param {RadarItemIdentifier} radarItemIdentifier The radar item identifier.
|
|
94
|
+
*/
|
|
95
|
+
onItemClick: PropTypes.func,
|
|
80
96
|
/**
|
|
81
97
|
* The id of the series to display.
|
|
82
98
|
* If undefined all series are displayed.
|
|
@@ -7,15 +7,23 @@ import { useItemHighlightedGetter } from "../../hooks/useItemHighlightedGetter.j
|
|
|
7
7
|
import { useUtilityClasses } from "./radarSeriesPlotClasses.js";
|
|
8
8
|
import { getPathProps } from "./RadarSeriesArea.js";
|
|
9
9
|
import { getCircleProps } from "./RadarSeriesMarks.js";
|
|
10
|
+
import { useRadarRotationIndex } from "./useRadarRotationIndex.js";
|
|
10
11
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
11
12
|
function RadarSeriesPlot(props) {
|
|
12
|
-
const
|
|
13
|
+
const {
|
|
14
|
+
seriesId: inSeriesId,
|
|
15
|
+
classes: inClasses,
|
|
16
|
+
onAreaClick,
|
|
17
|
+
onMarkClick
|
|
18
|
+
} = props;
|
|
19
|
+
const seriesCoordinates = useRadarSeriesData(inSeriesId);
|
|
20
|
+
const getRotationIndex = useRadarRotationIndex();
|
|
13
21
|
const interactionProps = useInteractionAllItemProps(seriesCoordinates);
|
|
14
22
|
const {
|
|
15
23
|
isFaded,
|
|
16
24
|
isHighlighted
|
|
17
25
|
} = useItemHighlightedGetter();
|
|
18
|
-
const classes = useUtilityClasses(
|
|
26
|
+
const classes = useUtilityClasses(inClasses);
|
|
19
27
|
return /*#__PURE__*/_jsx("g", {
|
|
20
28
|
className: classes.root,
|
|
21
29
|
children: seriesCoordinates?.map(({
|
|
@@ -34,7 +42,14 @@ function RadarSeriesPlot(props) {
|
|
|
34
42
|
isFaded,
|
|
35
43
|
isHighlighted,
|
|
36
44
|
classes
|
|
37
|
-
}),
|
|
45
|
+
}), {
|
|
46
|
+
onClick: event => onAreaClick?.(event, {
|
|
47
|
+
type: 'radar',
|
|
48
|
+
seriesId,
|
|
49
|
+
dataIndex: getRotationIndex(event)
|
|
50
|
+
}),
|
|
51
|
+
cursor: onAreaClick ? 'pointer' : 'unset'
|
|
52
|
+
}, interactionProps[seriesIndex]), seriesId), !hideMark && points.map((point, index) => /*#__PURE__*/_jsx("circle", _extends({}, getCircleProps({
|
|
38
53
|
seriesId,
|
|
39
54
|
point,
|
|
40
55
|
color,
|
|
@@ -42,7 +57,14 @@ function RadarSeriesPlot(props) {
|
|
|
42
57
|
isFaded,
|
|
43
58
|
isHighlighted,
|
|
44
59
|
classes
|
|
45
|
-
})
|
|
60
|
+
}), {
|
|
61
|
+
onClick: event => onMarkClick?.(event, {
|
|
62
|
+
type: 'radar',
|
|
63
|
+
seriesId,
|
|
64
|
+
dataIndex: index
|
|
65
|
+
}),
|
|
66
|
+
cursor: onMarkClick ? 'pointer' : 'unset'
|
|
67
|
+
}), index))]
|
|
46
68
|
}, seriesId);
|
|
47
69
|
})
|
|
48
70
|
});
|
|
@@ -56,6 +78,18 @@ process.env.NODE_ENV !== "production" ? RadarSeriesPlot.propTypes = {
|
|
|
56
78
|
* Override or extend the styles applied to the component.
|
|
57
79
|
*/
|
|
58
80
|
classes: PropTypes.object,
|
|
81
|
+
/**
|
|
82
|
+
* Callback fired when an area is clicked.
|
|
83
|
+
* @param {React.MouseEvent<SVGPathElement, MouseEvent>} event The event source of the callback.
|
|
84
|
+
* @param {RadarItemIdentifier} radarItemIdentifier The radar item identifier.
|
|
85
|
+
*/
|
|
86
|
+
onAreaClick: PropTypes.func,
|
|
87
|
+
/**
|
|
88
|
+
* Callback fired when a mark is clicked.
|
|
89
|
+
* @param {React.MouseEvent<SVGPathElement, MouseEvent>} event The event source of the callback.
|
|
90
|
+
* @param {RadarItemIdentifier} radarItemIdentifier The radar item identifier.
|
|
91
|
+
*/
|
|
92
|
+
onMarkClick: PropTypes.func,
|
|
59
93
|
/**
|
|
60
94
|
* The id of the series to display.
|
|
61
95
|
* If undefined all series are displayed.
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { RadarSeriesPlotClasses } from "./radarSeriesPlotClasses.js";
|
|
3
|
+
import { RadarItemIdentifier } from "../../models/seriesType/radar.js";
|
|
3
4
|
interface CommonRadarSeriesPlotProps {
|
|
4
5
|
/**
|
|
5
6
|
* The id of the series to display.
|
|
@@ -11,7 +12,35 @@ interface CommonRadarSeriesPlotProps {
|
|
|
11
12
|
*/
|
|
12
13
|
classes?: Partial<RadarSeriesPlotClasses>;
|
|
13
14
|
}
|
|
14
|
-
export interface RadarSeriesPlotProps extends CommonRadarSeriesPlotProps {
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
export interface RadarSeriesPlotProps extends CommonRadarSeriesPlotProps {
|
|
16
|
+
/**
|
|
17
|
+
* Callback fired when an area is clicked.
|
|
18
|
+
* @param {React.MouseEvent<SVGPathElement, MouseEvent>} event The event source of the callback.
|
|
19
|
+
* @param {RadarItemIdentifier} radarItemIdentifier The radar item identifier.
|
|
20
|
+
*/
|
|
21
|
+
onAreaClick?: RadarSeriesAreaProps['onItemClick'];
|
|
22
|
+
/**
|
|
23
|
+
* Callback fired when a mark is clicked.
|
|
24
|
+
* @param {React.MouseEvent<SVGPathElement, MouseEvent>} event The event source of the callback.
|
|
25
|
+
* @param {RadarItemIdentifier} radarItemIdentifier The radar item identifier.
|
|
26
|
+
*/
|
|
27
|
+
onMarkClick?: RadarSeriesMarksProps['onItemClick'];
|
|
28
|
+
}
|
|
29
|
+
type RadarClickIdentifier = Required<RadarItemIdentifier>;
|
|
30
|
+
export interface RadarSeriesMarksProps extends CommonRadarSeriesPlotProps, React.SVGAttributes<SVGCircleElement> {
|
|
31
|
+
/**
|
|
32
|
+
* Callback fired when a mark is clicked.
|
|
33
|
+
* @param {React.MouseEvent<SVGPathElement, MouseEvent>} event The event source of the callback.
|
|
34
|
+
* @param {RadarItemIdentifier} radarItemIdentifier The radar item identifier.
|
|
35
|
+
*/
|
|
36
|
+
onItemClick?: (event: React.MouseEvent<SVGElement, MouseEvent>, radarItemIdentifier: RadarClickIdentifier) => void;
|
|
37
|
+
}
|
|
38
|
+
export interface RadarSeriesAreaProps extends CommonRadarSeriesPlotProps, React.SVGAttributes<SVGPathElement> {
|
|
39
|
+
/**
|
|
40
|
+
* Callback fired when an area is clicked.
|
|
41
|
+
* @param {React.MouseEvent<SVGPathElement, MouseEvent>} event The event source of the callback.
|
|
42
|
+
* @param {RadarItemIdentifier} radarItemIdentifier The radar item identifier.
|
|
43
|
+
*/
|
|
44
|
+
onItemClick?: (event: React.MouseEvent<SVGElement, MouseEvent>, radarItemIdentifier: RadarClickIdentifier) => void;
|
|
45
|
+
}
|
|
17
46
|
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This hook provides a function that from pointer event returns the rotation index.
|
|
3
|
+
* @return {(event: { clientX: number; clientY: number }) => number | null} rotationIndexGetter Returns the rotation data index.
|
|
4
|
+
*/
|
|
5
|
+
export declare function useRadarRotationIndex(): (event: {
|
|
6
|
+
clientX: number;
|
|
7
|
+
clientY: number;
|
|
8
|
+
}) => number;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { selectorChartPolarCenter } from "../../internals/plugins/featurePlugins/useChartPolarAxis/index.js";
|
|
3
|
+
import { getSVGPoint } from "../../internals/getSVGPoint.js";
|
|
4
|
+
import { generateSvg2rotation } from "../../internals/plugins/featurePlugins/useChartPolarAxis/coordinateTransformation.js";
|
|
5
|
+
import { useSelector } from "../../internals/store/useSelector.js";
|
|
6
|
+
import { getAxisIndex } from "../../internals/plugins/featurePlugins/useChartPolarAxis/getAxisIndex.js";
|
|
7
|
+
import { useStore } from "../../internals/store/useStore.js";
|
|
8
|
+
import { useSvgRef } from "../../hooks/useSvgRef.js";
|
|
9
|
+
import { useRotationAxis } from "../../hooks/useAxis.js";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* This hook provides a function that from pointer event returns the rotation index.
|
|
13
|
+
* @return {(event: { clientX: number; clientY: number }) => number | null} rotationIndexGetter Returns the rotation data index.
|
|
14
|
+
*/
|
|
15
|
+
export function useRadarRotationIndex() {
|
|
16
|
+
const svgRef = useSvgRef();
|
|
17
|
+
const store = useStore();
|
|
18
|
+
const rotationAxis = useRotationAxis();
|
|
19
|
+
const center = useSelector(store, selectorChartPolarCenter);
|
|
20
|
+
const rotationIndexGetter = React.useCallback(function rotationIndexGetter(event) {
|
|
21
|
+
const element = svgRef.current;
|
|
22
|
+
if (!element || !rotationAxis) {
|
|
23
|
+
// Should never append
|
|
24
|
+
throw new Error(`MUI X Charts: The ${!element ? 'SVG' : 'rotation axis'} was not found to compute radar dataIndex.`);
|
|
25
|
+
}
|
|
26
|
+
const svgPoint = getSVGPoint(element, event);
|
|
27
|
+
const rotation = generateSvg2rotation(center)(svgPoint.x, svgPoint.y);
|
|
28
|
+
const rotationIndex = getAxisIndex(rotationAxis, rotation);
|
|
29
|
+
return rotationIndex;
|
|
30
|
+
}, [center, rotationAxis, svgRef]);
|
|
31
|
+
return rotationIndexGetter;
|
|
32
|
+
}
|
|
@@ -17,8 +17,8 @@ export declare function useRadarSeriesData(querySeriesId?: SeriesId): {
|
|
|
17
17
|
}[];
|
|
18
18
|
type: "radar";
|
|
19
19
|
label?: string | ((location: "tooltip" | "legend") => string) | undefined;
|
|
20
|
-
highlightScope?:
|
|
21
|
-
labelMarkType?:
|
|
20
|
+
highlightScope?: import("../../index.js").HighlightScope | undefined;
|
|
21
|
+
labelMarkType?: import("../../internals/index.js").ChartsLabelMarkType | undefined;
|
|
22
22
|
hideMark?: boolean | undefined;
|
|
23
23
|
fillArea?: boolean | undefined;
|
|
24
24
|
data: number[];
|
|
@@ -3,7 +3,7 @@ export { RadarChart } from "./RadarChart.js";
|
|
|
3
3
|
export { RadarDataProvider as Unstable_RadarDataProvider } from "./RadarDataProvider/index.js";
|
|
4
4
|
export { RadarDataProvider } from "./RadarDataProvider/index.js";
|
|
5
5
|
export type { RadarChartProps, RadarChartSlots, RadarChartSlotProps } from "./RadarChart.js";
|
|
6
|
-
export type { RadarDataProviderProps } from "./RadarDataProvider/index.js";
|
|
6
|
+
export type { RadarDataProviderProps, RadarSeries } from "./RadarDataProvider/index.js";
|
|
7
7
|
export * from "./RadarGrid/index.js";
|
|
8
8
|
export * from "./RadarAxisHighlight/index.js";
|
|
9
9
|
export * from "./RadarMetricLabels/index.js";
|
|
@@ -6,6 +6,7 @@ import { RadarDataProviderProps } from "./RadarDataProvider/RadarDataProvider.js
|
|
|
6
6
|
import { ChartsSurfaceProps } from "../ChartsSurface/index.js";
|
|
7
7
|
import { RadarGridProps } from "./RadarGrid/index.js";
|
|
8
8
|
import { RadarChartPluginsSignatures } from "./RadarChart.plugins.js";
|
|
9
|
+
import { RadarSeriesAreaProps, RadarSeriesMarksProps } from "./RadarSeriesPlot/index.js";
|
|
9
10
|
/**
|
|
10
11
|
* A helper function that extracts RadarChartProps from the input props
|
|
11
12
|
* and returns an object with props for the children components of RadarChart.
|
|
@@ -19,6 +20,8 @@ export declare const useRadarChartProps: (props: RadarChartProps) => {
|
|
|
19
20
|
chartsSurfaceProps: ChartsSurfaceProps;
|
|
20
21
|
radarDataProviderProps: RadarDataProviderProps<RadarChartPluginsSignatures>;
|
|
21
22
|
radarGrid: RadarGridProps;
|
|
23
|
+
radarSeriesAreaProps: RadarSeriesAreaProps;
|
|
24
|
+
radarSeriesMarksProps: RadarSeriesMarksProps;
|
|
22
25
|
overlayProps: ChartsOverlayProps;
|
|
23
26
|
legendProps: ChartsLegendSlotExtension;
|
|
24
27
|
children: import("react").ReactNode;
|