@mui/x-charts 9.10.1 → 9.11.1
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 +4 -2
- package/BarChart/BarChart.mjs +4 -2
- package/BarChart/BarPlot.d.mts +3 -3
- package/BarChart/BarPlot.d.ts +3 -3
- package/BarChart/BarPlot.js +1 -1
- package/BarChart/BarPlot.mjs +1 -1
- package/BarChart/BatchBarPlot/BatchBarPlot.d.mts +2 -2
- package/BarChart/BatchBarPlot/BatchBarPlot.d.ts +2 -2
- package/BarChart/IndividualBarPlot.d.mts +2 -2
- package/BarChart/IndividualBarPlot.d.ts +2 -2
- package/BarChart/seriesConfig/bar/getSeriesWithDefaultValues.d.mts +4 -4
- package/BarChart/seriesConfig/bar/getSeriesWithDefaultValues.d.ts +4 -4
- package/BarChart/useRegisterItemClickHandlers.d.mts +2 -1
- package/BarChart/useRegisterItemClickHandlers.d.ts +2 -1
- package/BarChart/useRegisterItemClickHandlers.js +8 -0
- package/BarChart/useRegisterItemClickHandlers.mjs +8 -1
- package/CHANGELOG.md +157 -0
- package/ChartsContainer/ChartsContainer.js +4 -2
- package/ChartsContainer/ChartsContainer.mjs +4 -2
- package/ChartsDataProvider/ChartsDataProvider.js +3 -1
- package/ChartsDataProvider/ChartsDataProvider.mjs +3 -1
- package/ChartsRadialDataProvider/ChartsRadialDataProvider.js +3 -1
- package/ChartsRadialDataProvider/ChartsRadialDataProvider.mjs +3 -1
- package/ChartsXAxis/useAxisTicksProps.d.mts +101 -101
- package/ChartsXAxis/useAxisTicksProps.d.ts +101 -101
- package/ChartsYAxis/useAxisTicksProps.d.mts +101 -101
- package/ChartsYAxis/useAxisTicksProps.d.ts +101 -101
- package/LineChart/AreaPlot.d.mts +3 -2
- package/LineChart/AreaPlot.d.ts +3 -2
- package/LineChart/AreaPlot.js +8 -2
- package/LineChart/AreaPlot.mjs +9 -3
- package/LineChart/LineChart.js +2 -1
- package/LineChart/LineChart.mjs +2 -1
- package/LineChart/LinePlot.d.mts +3 -2
- package/LineChart/LinePlot.d.ts +3 -2
- package/LineChart/LinePlot.js +2 -2
- package/LineChart/LinePlot.mjs +3 -3
- package/LineChart/MarkPlot.d.mts +5 -4
- package/LineChart/MarkPlot.d.ts +5 -4
- package/LineChart/MarkPlot.js +17 -8
- package/LineChart/MarkPlot.mjs +17 -8
- package/LineChart/useLineItemClickHandler.d.mts +25 -1
- package/LineChart/useLineItemClickHandler.d.ts +25 -1
- package/LineChart/useLineItemClickHandler.js +48 -1
- package/LineChart/useLineItemClickHandler.mjs +47 -1
- package/PieChart/PieArcPlot.d.mts +3 -2
- package/PieChart/PieArcPlot.d.ts +3 -2
- package/PieChart/PieArcPlot.js +16 -1
- package/PieChart/PieArcPlot.mjs +16 -1
- package/PieChart/PieChart.js +3 -1
- package/PieChart/PieChart.mjs +3 -1
- package/PieChart/PiePlot.js +1 -1
- package/PieChart/PiePlot.mjs +1 -1
- package/README.md +1 -11
- package/RadarChart/RadarAxis/RadarAxis.utils.d.mts +1 -1
- package/RadarChart/RadarAxis/RadarAxis.utils.d.ts +1 -1
- package/RadarChart/RadarChart.js +3 -1
- package/RadarChart/RadarChart.mjs +3 -1
- package/RadarChart/RadarSeriesPlot/RadarSeriesArea.js +3 -1
- package/RadarChart/RadarSeriesPlot/RadarSeriesArea.mjs +3 -1
- package/RadarChart/RadarSeriesPlot/RadarSeriesMarks.js +4 -1
- package/RadarChart/RadarSeriesPlot/RadarSeriesMarks.mjs +4 -1
- package/RadarChart/RadarSeriesPlot/RadarSeriesPlot.types.d.mts +5 -4
- package/RadarChart/RadarSeriesPlot/RadarSeriesPlot.types.d.ts +5 -4
- package/RadarChart/RadarSeriesPlot/useRegisterRadarItemActivation.d.mts +15 -0
- package/RadarChart/RadarSeriesPlot/useRegisterRadarItemActivation.d.ts +15 -0
- package/RadarChart/RadarSeriesPlot/useRegisterRadarItemActivation.js +32 -0
- package/RadarChart/RadarSeriesPlot/useRegisterRadarItemActivation.mjs +26 -0
- package/RadarChart/useRadarChartProps.js +5 -1
- package/RadarChart/useRadarChartProps.mjs +5 -1
- package/ScatterChart/Scatter.d.mts +3 -2
- package/ScatterChart/Scatter.d.ts +3 -2
- package/ScatterChart/Scatter.js +10 -1
- package/ScatterChart/Scatter.mjs +10 -1
- package/ScatterChart/ScatterChart.js +1 -0
- package/ScatterChart/ScatterChart.mjs +1 -0
- package/ScatterChart/async/ScatterAsync.js +9 -0
- package/ScatterChart/async/ScatterAsync.mjs +9 -0
- package/SparkLineChart/SparkLineChart.js +2 -1
- package/SparkLineChart/SparkLineChart.mjs +2 -1
- package/Toolbar/ToolbarButton.js +1 -1
- package/Toolbar/ToolbarButton.mjs +1 -1
- package/hooks/useFocusedItem.d.mts +1 -1
- package/hooks/useFocusedItem.d.ts +1 -1
- package/hooks/useItemHighlightStateGetter.d.mts +1 -1
- package/hooks/useItemHighlightStateGetter.d.ts +1 -1
- package/index.js +1 -1
- package/index.mjs +1 -1
- package/internals/createCommonKeyboardFocusHandler.d.mts +2 -2
- package/internals/createCommonKeyboardFocusHandler.d.ts +2 -2
- package/internals/index.d.mts +1 -0
- package/internals/index.d.ts +1 -0
- package/internals/index.js +8 -0
- package/internals/index.mjs +1 -0
- package/internals/plugins/corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.types.d.mts +8 -1
- package/internals/plugins/corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.types.d.ts +8 -1
- package/internals/plugins/corePlugins/useChartInteractionListener/useChartInteractionListener.js +11 -3
- package/internals/plugins/corePlugins/useChartInteractionListener/useChartInteractionListener.mjs +11 -3
- package/internals/plugins/corePlugins/useChartSeries/useChartSeries.selectors.d.mts +1 -0
- package/internals/plugins/corePlugins/useChartSeries/useChartSeries.selectors.d.ts +1 -0
- package/internals/plugins/corePlugins/useChartSeriesConfig/types/getItemWithData.types.d.mts +12 -0
- package/internals/plugins/corePlugins/useChartSeriesConfig/types/getItemWithData.types.d.ts +12 -0
- package/internals/plugins/corePlugins/useChartSeriesConfig/types/getItemWithData.types.js +5 -0
- package/internals/plugins/corePlugins/useChartSeriesConfig/types/getItemWithData.types.mjs +1 -0
- package/internals/plugins/corePlugins/useChartSeriesConfig/types/index.d.mts +1 -0
- package/internals/plugins/corePlugins/useChartSeriesConfig/types/index.d.ts +1 -0
- package/internals/plugins/corePlugins/useChartSeriesConfig/types/index.js +11 -0
- package/internals/plugins/corePlugins/useChartSeriesConfig/types/index.mjs +1 -0
- package/internals/plugins/corePlugins/useChartSeriesConfig/types/seriesConfig.types.d.mts +6 -0
- package/internals/plugins/corePlugins/useChartSeriesConfig/types/seriesConfig.types.d.ts +6 -0
- package/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisClickPayload.d.mts +21 -0
- package/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisClickPayload.d.ts +21 -0
- package/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisClickPayload.js +46 -0
- package/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisClickPayload.mjs +40 -0
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxis.js +13 -31
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxis.mjs +13 -31
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisPreview.selectors.d.mts +2 -2
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisPreview.selectors.d.ts +2 -2
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.d.mts +11 -11
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.d.ts +11 -11
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianHighlight.selectors.d.mts +4 -4
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianHighlight.selectors.d.ts +4 -4
- package/internals/plugins/featurePlugins/useChartClosestPoint/useChartClosestPoint.js +19 -0
- package/internals/plugins/featurePlugins/useChartClosestPoint/useChartClosestPoint.mjs +19 -0
- package/internals/plugins/featurePlugins/useChartClosestPoint/useChartClosestPoint.types.d.mts +5 -3
- package/internals/plugins/featurePlugins/useChartClosestPoint/useChartClosestPoint.types.d.ts +5 -3
- package/internals/plugins/featurePlugins/useChartItemClick/useChartItemClick.js +15 -0
- package/internals/plugins/featurePlugins/useChartItemClick/useChartItemClick.mjs +14 -0
- package/internals/plugins/featurePlugins/useChartItemClick/useChartItemClick.types.d.mts +5 -2
- package/internals/plugins/featurePlugins/useChartItemClick/useChartItemClick.types.d.ts +5 -2
- package/internals/plugins/featurePlugins/useChartKeyboardNavigation/index.d.mts +2 -1
- package/internals/plugins/featurePlugins/useChartKeyboardNavigation/index.d.ts +2 -1
- package/internals/plugins/featurePlugins/useChartKeyboardNavigation/index.js +10 -2
- package/internals/plugins/featurePlugins/useChartKeyboardNavigation/index.mjs +2 -1
- package/internals/plugins/featurePlugins/useChartKeyboardNavigation/itemActivation.d.mts +13 -0
- package/internals/plugins/featurePlugins/useChartKeyboardNavigation/itemActivation.d.ts +13 -0
- package/internals/plugins/featurePlugins/useChartKeyboardNavigation/itemActivation.js +39 -0
- package/internals/plugins/featurePlugins/useChartKeyboardNavigation/itemActivation.mjs +32 -0
- package/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.js +47 -7
- package/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.mjs +47 -7
- package/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.selectors.d.mts +3 -0
- package/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.selectors.d.ts +3 -0
- package/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.selectors.js +3 -1
- package/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.selectors.mjs +2 -0
- package/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.types.d.mts +39 -2
- package/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.types.d.ts +39 -2
- package/internals/plugins/featurePlugins/useChartPolarAxis/getPolarAxisClickPayload.d.mts +27 -0
- package/internals/plugins/featurePlugins/useChartPolarAxis/getPolarAxisClickPayload.d.ts +27 -0
- package/internals/plugins/featurePlugins/useChartPolarAxis/getPolarAxisClickPayload.js +36 -0
- package/internals/plugins/featurePlugins/useChartPolarAxis/getPolarAxisClickPayload.mjs +30 -0
- package/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarAxis.js +19 -20
- package/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarAxis.mjs +19 -20
- package/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarAxis.selectors.d.mts +2 -2
- package/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarAxis.selectors.d.ts +2 -2
- package/internals/plugins/featurePlugins/useChartTooltip/useChartTooltip.selectors.d.mts +1 -1
- package/internals/plugins/featurePlugins/useChartTooltip/useChartTooltip.selectors.d.ts +1 -1
- package/internals/seriesSelectorOfType.d.mts +4 -4
- package/internals/seriesSelectorOfType.d.ts +4 -4
- package/internals/useRegisterItemActivation.d.mts +23 -0
- package/internals/useRegisterItemActivation.d.ts +23 -0
- package/internals/useRegisterItemActivation.js +53 -0
- package/internals/useRegisterItemActivation.mjs +46 -0
- package/models/axis.d.mts +1 -1
- package/models/axis.d.ts +1 -1
- package/models/events.d.mts +11 -0
- package/models/events.d.ts +11 -0
- package/models/events.js +5 -0
- package/models/events.mjs +1 -0
- package/models/index.d.mts +1 -0
- package/models/index.d.ts +1 -0
- package/moduleAugmentation/barChartBatchRendererOnItemClick.d.mts +3 -4
- package/moduleAugmentation/barChartBatchRendererOnItemClick.d.ts +3 -4
- package/moduleAugmentation/keyboardActivation.d.mts +7 -0
- package/moduleAugmentation/keyboardActivation.d.ts +7 -0
- package/moduleAugmentation/keyboardActivation.js +8 -0
- package/moduleAugmentation/keyboardActivation.mjs +2 -0
- package/package.json +18 -4
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { ChartsAxisData } from "../../../../models/axis.mjs";
|
|
2
|
+
import type { ProcessedSeries } from "../../corePlugins/useChartSeries/index.mjs";
|
|
3
|
+
import type { ChartSeriesType } from "../../../../models/seriesType/config.mjs";
|
|
4
|
+
type PolarAxes = {
|
|
5
|
+
axis: Record<string, {
|
|
6
|
+
data?: readonly any[];
|
|
7
|
+
}>;
|
|
8
|
+
axisIds: string[];
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Builds the `onAxisClick` payload for a data index on a polar axis.
|
|
12
|
+
* Returns `null` when the axis has no value at this index.
|
|
13
|
+
*/
|
|
14
|
+
export declare function getPolarAxisClickPayload({
|
|
15
|
+
dataIndex,
|
|
16
|
+
isRotationAxis,
|
|
17
|
+
rotationAxes,
|
|
18
|
+
radiusAxes,
|
|
19
|
+
processedSeries
|
|
20
|
+
}: {
|
|
21
|
+
dataIndex: number;
|
|
22
|
+
isRotationAxis: boolean;
|
|
23
|
+
rotationAxes: PolarAxes;
|
|
24
|
+
radiusAxes: PolarAxes;
|
|
25
|
+
processedSeries: ProcessedSeries<ChartSeriesType>;
|
|
26
|
+
}): ChartsAxisData | null;
|
|
27
|
+
export {};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { ChartsAxisData } from "../../../../models/axis.js";
|
|
2
|
+
import type { ProcessedSeries } from "../../corePlugins/useChartSeries/index.js";
|
|
3
|
+
import type { ChartSeriesType } from "../../../../models/seriesType/config.js";
|
|
4
|
+
type PolarAxes = {
|
|
5
|
+
axis: Record<string, {
|
|
6
|
+
data?: readonly any[];
|
|
7
|
+
}>;
|
|
8
|
+
axisIds: string[];
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Builds the `onAxisClick` payload for a data index on a polar axis.
|
|
12
|
+
* Returns `null` when the axis has no value at this index.
|
|
13
|
+
*/
|
|
14
|
+
export declare function getPolarAxisClickPayload({
|
|
15
|
+
dataIndex,
|
|
16
|
+
isRotationAxis,
|
|
17
|
+
rotationAxes,
|
|
18
|
+
radiusAxes,
|
|
19
|
+
processedSeries
|
|
20
|
+
}: {
|
|
21
|
+
dataIndex: number;
|
|
22
|
+
isRotationAxis: boolean;
|
|
23
|
+
rotationAxes: PolarAxes;
|
|
24
|
+
radiusAxes: PolarAxes;
|
|
25
|
+
processedSeries: ProcessedSeries<ChartSeriesType>;
|
|
26
|
+
}): ChartsAxisData | null;
|
|
27
|
+
export {};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getPolarAxisClickPayload = getPolarAxisClickPayload;
|
|
7
|
+
var _isPolar = require("../../../isPolar");
|
|
8
|
+
/**
|
|
9
|
+
* Builds the `onAxisClick` payload for a data index on a polar axis.
|
|
10
|
+
* Returns `null` when the axis has no value at this index.
|
|
11
|
+
*/
|
|
12
|
+
function getPolarAxisClickPayload({
|
|
13
|
+
dataIndex,
|
|
14
|
+
isRotationAxis,
|
|
15
|
+
rotationAxes,
|
|
16
|
+
radiusAxes,
|
|
17
|
+
processedSeries
|
|
18
|
+
}) {
|
|
19
|
+
const axes = isRotationAxis ? rotationAxes : radiusAxes;
|
|
20
|
+
const axisValue = axes.axis[axes.axisIds[0]]?.data?.[dataIndex];
|
|
21
|
+
if (axisValue === undefined) {
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
const seriesValues = {};
|
|
25
|
+
Object.keys(processedSeries).filter(_isPolar.isPolarSeriesType).forEach(seriesType => {
|
|
26
|
+
processedSeries[seriesType]?.seriesOrder.forEach(seriesId => {
|
|
27
|
+
const seriesItem = processedSeries[seriesType].series[seriesId];
|
|
28
|
+
seriesValues[seriesId] = seriesItem.data[dataIndex];
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
return {
|
|
32
|
+
dataIndex,
|
|
33
|
+
axisValue,
|
|
34
|
+
seriesValues
|
|
35
|
+
};
|
|
36
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { isPolarSeriesType } from "../../../isPolar.mjs";
|
|
2
|
+
/**
|
|
3
|
+
* Builds the `onAxisClick` payload for a data index on a polar axis.
|
|
4
|
+
* Returns `null` when the axis has no value at this index.
|
|
5
|
+
*/
|
|
6
|
+
export function getPolarAxisClickPayload({
|
|
7
|
+
dataIndex,
|
|
8
|
+
isRotationAxis,
|
|
9
|
+
rotationAxes,
|
|
10
|
+
radiusAxes,
|
|
11
|
+
processedSeries
|
|
12
|
+
}) {
|
|
13
|
+
const axes = isRotationAxis ? rotationAxes : radiusAxes;
|
|
14
|
+
const axisValue = axes.axis[axes.axisIds[0]]?.data?.[dataIndex];
|
|
15
|
+
if (axisValue === undefined) {
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
const seriesValues = {};
|
|
19
|
+
Object.keys(processedSeries).filter(isPolarSeriesType).forEach(seriesType => {
|
|
20
|
+
processedSeries[seriesType]?.seriesOrder.forEach(seriesId => {
|
|
21
|
+
const seriesItem = processedSeries[seriesType].series[seriesId];
|
|
22
|
+
seriesValues[seriesId] = seriesItem.data[dataIndex];
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
return {
|
|
26
|
+
dataIndex,
|
|
27
|
+
axisValue,
|
|
28
|
+
seriesValues
|
|
29
|
+
};
|
|
30
|
+
}
|
|
@@ -19,7 +19,7 @@ var _coordinateTransformation = require("./coordinateTransformation");
|
|
|
19
19
|
var _getAxisIndex = require("./getAxisIndex");
|
|
20
20
|
var _useChartSeries = require("../../corePlugins/useChartSeries");
|
|
21
21
|
var _checkHasInteractionPlugin = require("../useChartInteraction/checkHasInteractionPlugin");
|
|
22
|
-
var
|
|
22
|
+
var _getPolarAxisClickPayload = require("./getPolarAxisClickPayload");
|
|
23
23
|
const useChartPolarAxis = ({
|
|
24
24
|
params,
|
|
25
25
|
store,
|
|
@@ -174,34 +174,33 @@ const useChartPolarAxis = ({
|
|
|
174
174
|
return () => {};
|
|
175
175
|
}
|
|
176
176
|
const axisClickHandler = instance.addInteractionListener('tap', event => {
|
|
177
|
-
let dataIndex = null;
|
|
178
|
-
let isRotationAxis = false;
|
|
179
177
|
const svgPoint = (0, _getChartPoint.getChartPoint)(element, event.detail.srcEvent);
|
|
180
178
|
const rotation = (0, _coordinateTransformation.generateSvg2rotation)(center)(svgPoint.x, svgPoint.y);
|
|
181
179
|
const rotationIndex = (0, _getAxisIndex.getRotationAxisIndex)(rotationAxisWithScale[usedRotationAxisId], rotation);
|
|
182
180
|
const radius = (0, _coordinateTransformation.generateSvg2radius)(center)(svgPoint.x, svgPoint.y);
|
|
183
181
|
const radiusIndex = (0, _getAxisIndex.getRadiusAxisIndex)(radiusAxisWithScale[usedRadiusAxisId], radius);
|
|
184
|
-
isRotationAxis = rotationIndex !== -1;
|
|
185
|
-
dataIndex = isRotationAxis ? rotationIndex : radiusIndex;
|
|
186
|
-
|
|
187
|
-
if (dataIndex == null || dataIndex === -1) {
|
|
182
|
+
const isRotationAxis = rotationIndex !== -1;
|
|
183
|
+
const dataIndex = isRotationAxis ? rotationIndex : radiusIndex;
|
|
184
|
+
if (dataIndex === -1) {
|
|
188
185
|
return;
|
|
189
186
|
}
|
|
190
|
-
|
|
191
|
-
// The .data exist because otherwise the dataIndex would be null or -1.
|
|
192
|
-
const axisValue = (isRotationAxis ? rotationAxisWithScale : radiusAxisWithScale)[USED_AXIS_ID].data[dataIndex];
|
|
193
|
-
const seriesValues = {};
|
|
194
|
-
Object.keys(processedSeries).filter(_isPolar.isPolarSeriesType).forEach(seriesType => {
|
|
195
|
-
processedSeries[seriesType]?.seriesOrder.forEach(seriesId => {
|
|
196
|
-
const seriesItem = processedSeries[seriesType].series[seriesId];
|
|
197
|
-
seriesValues[seriesId] = seriesItem.data[dataIndex];
|
|
198
|
-
});
|
|
199
|
-
});
|
|
200
|
-
onAxisClick(event.detail.srcEvent, {
|
|
187
|
+
const payload = (0, _getPolarAxisClickPayload.getPolarAxisClickPayload)({
|
|
201
188
|
dataIndex,
|
|
202
|
-
|
|
203
|
-
|
|
189
|
+
isRotationAxis,
|
|
190
|
+
rotationAxes: {
|
|
191
|
+
axis: rotationAxisWithScale,
|
|
192
|
+
axisIds: [usedRotationAxisId]
|
|
193
|
+
},
|
|
194
|
+
radiusAxes: {
|
|
195
|
+
axis: radiusAxisWithScale,
|
|
196
|
+
axisIds: [usedRadiusAxisId]
|
|
197
|
+
},
|
|
198
|
+
processedSeries
|
|
204
199
|
});
|
|
200
|
+
if (payload === null) {
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
onAxisClick(event.detail.srcEvent, payload);
|
|
205
204
|
});
|
|
206
205
|
return () => {
|
|
207
206
|
axisClickHandler.cleanup();
|
|
@@ -12,7 +12,7 @@ import { generatePolar2svg, generateSvg2polar, generateSvg2radius, generateSvg2r
|
|
|
12
12
|
import { getRadiusAxisIndex, getRotationAxisIndex } from "./getAxisIndex.mjs";
|
|
13
13
|
import { selectorChartSeriesProcessed } from "../../corePlugins/useChartSeries/index.mjs";
|
|
14
14
|
import { checkHasInteractionPlugin } from "../useChartInteraction/checkHasInteractionPlugin.mjs";
|
|
15
|
-
import {
|
|
15
|
+
import { getPolarAxisClickPayload } from "./getPolarAxisClickPayload.mjs";
|
|
16
16
|
export const useChartPolarAxis = ({
|
|
17
17
|
params,
|
|
18
18
|
store,
|
|
@@ -167,34 +167,33 @@ export const useChartPolarAxis = ({
|
|
|
167
167
|
return () => {};
|
|
168
168
|
}
|
|
169
169
|
const axisClickHandler = instance.addInteractionListener('tap', event => {
|
|
170
|
-
let dataIndex = null;
|
|
171
|
-
let isRotationAxis = false;
|
|
172
170
|
const svgPoint = getChartPoint(element, event.detail.srcEvent);
|
|
173
171
|
const rotation = generateSvg2rotation(center)(svgPoint.x, svgPoint.y);
|
|
174
172
|
const rotationIndex = getRotationAxisIndex(rotationAxisWithScale[usedRotationAxisId], rotation);
|
|
175
173
|
const radius = generateSvg2radius(center)(svgPoint.x, svgPoint.y);
|
|
176
174
|
const radiusIndex = getRadiusAxisIndex(radiusAxisWithScale[usedRadiusAxisId], radius);
|
|
177
|
-
isRotationAxis = rotationIndex !== -1;
|
|
178
|
-
dataIndex = isRotationAxis ? rotationIndex : radiusIndex;
|
|
179
|
-
|
|
180
|
-
if (dataIndex == null || dataIndex === -1) {
|
|
175
|
+
const isRotationAxis = rotationIndex !== -1;
|
|
176
|
+
const dataIndex = isRotationAxis ? rotationIndex : radiusIndex;
|
|
177
|
+
if (dataIndex === -1) {
|
|
181
178
|
return;
|
|
182
179
|
}
|
|
183
|
-
|
|
184
|
-
// The .data exist because otherwise the dataIndex would be null or -1.
|
|
185
|
-
const axisValue = (isRotationAxis ? rotationAxisWithScale : radiusAxisWithScale)[USED_AXIS_ID].data[dataIndex];
|
|
186
|
-
const seriesValues = {};
|
|
187
|
-
Object.keys(processedSeries).filter(isPolarSeriesType).forEach(seriesType => {
|
|
188
|
-
processedSeries[seriesType]?.seriesOrder.forEach(seriesId => {
|
|
189
|
-
const seriesItem = processedSeries[seriesType].series[seriesId];
|
|
190
|
-
seriesValues[seriesId] = seriesItem.data[dataIndex];
|
|
191
|
-
});
|
|
192
|
-
});
|
|
193
|
-
onAxisClick(event.detail.srcEvent, {
|
|
180
|
+
const payload = getPolarAxisClickPayload({
|
|
194
181
|
dataIndex,
|
|
195
|
-
|
|
196
|
-
|
|
182
|
+
isRotationAxis,
|
|
183
|
+
rotationAxes: {
|
|
184
|
+
axis: rotationAxisWithScale,
|
|
185
|
+
axisIds: [usedRotationAxisId]
|
|
186
|
+
},
|
|
187
|
+
radiusAxes: {
|
|
188
|
+
axis: radiusAxisWithScale,
|
|
189
|
+
axisIds: [usedRadiusAxisId]
|
|
190
|
+
},
|
|
191
|
+
processedSeries
|
|
197
192
|
});
|
|
193
|
+
if (payload === null) {
|
|
194
|
+
return;
|
|
195
|
+
}
|
|
196
|
+
onAxisClick(event.detail.srcEvent, payload);
|
|
198
197
|
});
|
|
199
198
|
return () => {
|
|
200
199
|
axisClickHandler.cleanup();
|
package/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarAxis.selectors.d.mts
CHANGED
|
@@ -2,8 +2,8 @@ import type { UseChartPolarAxisSignature } from "./useChartPolarAxis.types.mjs";
|
|
|
2
2
|
import type { ChartState } from "../../models/chart.mjs";
|
|
3
3
|
import type { ChartDrawingArea } from "../../../../hooks/useDrawingArea.mjs";
|
|
4
4
|
export declare const selectorChartPolarAxisState: (state: ChartState<[], [UseChartPolarAxisSignature]>) => {
|
|
5
|
-
rotation: import("../../../index.mjs").PolarAxisConfig<import("
|
|
6
|
-
radius: import("../../../index.mjs").PolarAxisConfig<import("
|
|
5
|
+
rotation: import("../../../index.mjs").PolarAxisConfig<import("@mui/x-charts/models").ScaleName, any, import("../../../index.mjs").ChartsRotationAxisProps>[];
|
|
6
|
+
radius: import("../../../index.mjs").PolarAxisConfig<import("@mui/x-charts/models").ScaleName, any, import("../../../index.mjs").ChartsRadiusAxisProps>[];
|
|
7
7
|
} | undefined;
|
|
8
8
|
export declare const selectorChartRawRotationAxis: (args_0: import("../../corePlugins/useChartId/useChartId.types.mjs").UseChartIdState & import("../../corePlugins/useChartSeriesConfig/useChartSeriesConfig.types.mjs").UseChartSeriesConfigState<keyof import("../../../index.mjs").ChartsSeriesConfig> & import("../../corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.types.mjs").UseChartExperimentalFeaturesState & import("../../corePlugins/useChartDimensions/useChartDimensions.types.mjs").UseChartDimensionsState & import("../../corePlugins/useChartSeries/useChartSeries.types.mjs").UseChartSeriesState<keyof import("../../../index.mjs").ChartsSeriesConfig> & import("../../corePlugins/useChartAnimation/useChartAnimation.types.mjs").UseChartAnimationState & import("../../../index.mjs").UseChartInteractionListenerState & Partial<import("./useChartPolarAxis.types.mjs").UseChartPolarAxisState> & {
|
|
9
9
|
cacheKey: import("../../models/index.mjs").ChartStateCacheKey;
|
|
@@ -2,8 +2,8 @@ import type { UseChartPolarAxisSignature } from "./useChartPolarAxis.types.js";
|
|
|
2
2
|
import type { ChartState } from "../../models/chart.js";
|
|
3
3
|
import type { ChartDrawingArea } from "../../../../hooks/useDrawingArea.js";
|
|
4
4
|
export declare const selectorChartPolarAxisState: (state: ChartState<[], [UseChartPolarAxisSignature]>) => {
|
|
5
|
-
rotation: import("../../../index.js").PolarAxisConfig<import("
|
|
6
|
-
radius: import("../../../index.js").PolarAxisConfig<import("
|
|
5
|
+
rotation: import("../../../index.js").PolarAxisConfig<import("@mui/x-charts/models").ScaleName, any, import("../../../index.js").ChartsRotationAxisProps>[];
|
|
6
|
+
radius: import("../../../index.js").PolarAxisConfig<import("@mui/x-charts/models").ScaleName, any, import("../../../index.js").ChartsRadiusAxisProps>[];
|
|
7
7
|
} | undefined;
|
|
8
8
|
export declare const selectorChartRawRotationAxis: (args_0: import("../../corePlugins/useChartId/useChartId.types.js").UseChartIdState & import("../../corePlugins/useChartSeriesConfig/useChartSeriesConfig.types.js").UseChartSeriesConfigState<keyof import("../../../index.js").ChartsSeriesConfig> & import("../../corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.types.js").UseChartExperimentalFeaturesState & import("../../corePlugins/useChartDimensions/useChartDimensions.types.js").UseChartDimensionsState & import("../../corePlugins/useChartSeries/useChartSeries.types.js").UseChartSeriesState<keyof import("../../../index.js").ChartsSeriesConfig> & import("../../corePlugins/useChartAnimation/useChartAnimation.types.js").UseChartAnimationState & import("../../../index.js").UseChartInteractionListenerState & Partial<import("./useChartPolarAxis.types.js").UseChartPolarAxisState> & {
|
|
9
9
|
cacheKey: import("../../models/index.js").ChartStateCacheKey;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { SeriesItemIdentifierWithType } from "../../../../models/index.mjs";
|
|
2
2
|
export declare const selectorChartsTooltipPointerItem: (args_0: import("../../corePlugins/useChartId/useChartId.types.mjs").UseChartIdState & import("../../corePlugins/useChartSeriesConfig/useChartSeriesConfig.types.mjs").UseChartSeriesConfigState<keyof import("../../../index.mjs").ChartsSeriesConfig> & import("../../corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.types.mjs").UseChartExperimentalFeaturesState & import("../../corePlugins/useChartDimensions/useChartDimensions.types.mjs").UseChartDimensionsState & import("../../corePlugins/useChartSeries/useChartSeries.types.mjs").UseChartSeriesState<keyof import("../../../index.mjs").ChartsSeriesConfig> & import("../../corePlugins/useChartAnimation/useChartAnimation.types.mjs").UseChartAnimationState & import("../../../index.mjs").UseChartInteractionListenerState & Partial<import("./useChartTooltip.types.mjs").UseChartTooltipState<keyof import("../../../index.mjs").ChartsSeriesConfig>> & {
|
|
3
3
|
cacheKey: import("../../models/index.mjs").ChartStateCacheKey;
|
|
4
|
-
}) => import("
|
|
4
|
+
}) => import("@mui/x-charts/models").BarItemIdentifier | import("@mui/x-charts/models").LineItemIdentifier | import("@mui/x-charts/models").PieItemIdentifier | import("@mui/x-charts/models").RadarItemIdentifier | import("@mui/x-charts/models").ScatterItemIdentifier | null;
|
|
5
5
|
export declare const selectorChartsTooltipPointerItemIsDefined: (args_0: import("../../corePlugins/useChartId/useChartId.types.mjs").UseChartIdState & import("../../corePlugins/useChartSeriesConfig/useChartSeriesConfig.types.mjs").UseChartSeriesConfigState<keyof import("../../../index.mjs").ChartsSeriesConfig> & import("../../corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.types.mjs").UseChartExperimentalFeaturesState & import("../../corePlugins/useChartDimensions/useChartDimensions.types.mjs").UseChartDimensionsState & import("../../corePlugins/useChartSeries/useChartSeries.types.mjs").UseChartSeriesState<keyof import("../../../index.mjs").ChartsSeriesConfig> & import("../../corePlugins/useChartAnimation/useChartAnimation.types.mjs").UseChartAnimationState & import("../../../index.mjs").UseChartInteractionListenerState & Partial<import("./useChartTooltip.types.mjs").UseChartTooltipState<keyof import("../../../index.mjs").ChartsSeriesConfig>> & {
|
|
6
6
|
cacheKey: import("../../models/index.mjs").ChartStateCacheKey;
|
|
7
7
|
}) => boolean;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { SeriesItemIdentifierWithType } from "../../../../models/index.js";
|
|
2
2
|
export declare const selectorChartsTooltipPointerItem: (args_0: import("../../corePlugins/useChartId/useChartId.types.js").UseChartIdState & import("../../corePlugins/useChartSeriesConfig/useChartSeriesConfig.types.js").UseChartSeriesConfigState<keyof import("../../../index.js").ChartsSeriesConfig> & import("../../corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.types.js").UseChartExperimentalFeaturesState & import("../../corePlugins/useChartDimensions/useChartDimensions.types.js").UseChartDimensionsState & import("../../corePlugins/useChartSeries/useChartSeries.types.js").UseChartSeriesState<keyof import("../../../index.js").ChartsSeriesConfig> & import("../../corePlugins/useChartAnimation/useChartAnimation.types.js").UseChartAnimationState & import("../../../index.js").UseChartInteractionListenerState & Partial<import("./useChartTooltip.types.js").UseChartTooltipState<keyof import("../../../index.js").ChartsSeriesConfig>> & {
|
|
3
3
|
cacheKey: import("../../models/index.js").ChartStateCacheKey;
|
|
4
|
-
}) => import("
|
|
4
|
+
}) => import("@mui/x-charts/models").BarItemIdentifier | import("@mui/x-charts/models").LineItemIdentifier | import("@mui/x-charts/models").PieItemIdentifier | import("@mui/x-charts/models").RadarItemIdentifier | import("@mui/x-charts/models").ScatterItemIdentifier | null;
|
|
5
5
|
export declare const selectorChartsTooltipPointerItemIsDefined: (args_0: import("../../corePlugins/useChartId/useChartId.types.js").UseChartIdState & import("../../corePlugins/useChartSeriesConfig/useChartSeriesConfig.types.js").UseChartSeriesConfigState<keyof import("../../../index.js").ChartsSeriesConfig> & import("../../corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.types.js").UseChartExperimentalFeaturesState & import("../../corePlugins/useChartDimensions/useChartDimensions.types.js").UseChartDimensionsState & import("../../corePlugins/useChartSeries/useChartSeries.types.js").UseChartSeriesState<keyof import("../../../index.js").ChartsSeriesConfig> & import("../../corePlugins/useChartAnimation/useChartAnimation.types.js").UseChartAnimationState & import("../../../index.js").UseChartInteractionListenerState & Partial<import("./useChartTooltip.types.js").UseChartTooltipState<keyof import("../../../index.js").ChartsSeriesConfig>> & {
|
|
6
6
|
cacheKey: import("../../models/index.js").ChartStateCacheKey;
|
|
7
7
|
}) => boolean;
|
|
@@ -4,17 +4,17 @@ import type { ProcessedSeries } from "./plugins/corePlugins/useChartSeries/index
|
|
|
4
4
|
export declare const selectorAllSeriesOfType: (args_0: import("./plugins/corePlugins/useChartId/useChartId.types.mjs").UseChartIdState & import("./plugins/corePlugins/useChartSeriesConfig/useChartSeriesConfig.types.mjs").UseChartSeriesConfigState<keyof ChartsSeriesConfig> & import("./plugins/corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.types.mjs").UseChartExperimentalFeaturesState & import("./plugins/corePlugins/useChartDimensions/useChartDimensions.types.mjs").UseChartDimensionsState & import("./plugins/corePlugins/useChartSeries/useChartSeries.types.mjs").UseChartSeriesState<keyof ChartsSeriesConfig> & import("./plugins/corePlugins/useChartAnimation/useChartAnimation.types.mjs").UseChartAnimationState & import("./index.mjs").UseChartInteractionListenerState & Partial<{}> & {
|
|
5
5
|
cacheKey: import("./index.mjs").ChartStateCacheKey;
|
|
6
6
|
}, seriesType: keyof ChartsSeriesConfig) => {
|
|
7
|
-
series: Record<string, import("
|
|
7
|
+
series: Record<string, import("@mui/x-charts/models").DefaultizedPieSeriesType>;
|
|
8
8
|
seriesOrder: SeriesId[];
|
|
9
9
|
} | {
|
|
10
|
-
series: Record<string, import("
|
|
10
|
+
series: Record<string, import("@mui/x-charts/models").DefaultizedRadarSeriesType>;
|
|
11
11
|
seriesOrder: SeriesId[];
|
|
12
12
|
} | {
|
|
13
|
-
series: Record<string, import("
|
|
13
|
+
series: Record<string, import("@mui/x-charts/models").DefaultizedScatterSeriesType>;
|
|
14
14
|
seriesOrder: SeriesId[];
|
|
15
15
|
} | import("./index.mjs").SeriesProcessorResult<"bar"> | import("./index.mjs").SeriesProcessorResult<"line"> | undefined;
|
|
16
16
|
export declare const selectorSeriesOfType: (args_0: import("./plugins/corePlugins/useChartId/useChartId.types.mjs").UseChartIdState & import("./plugins/corePlugins/useChartSeriesConfig/useChartSeriesConfig.types.mjs").UseChartSeriesConfigState<keyof ChartsSeriesConfig> & import("./plugins/corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.types.mjs").UseChartExperimentalFeaturesState & import("./plugins/corePlugins/useChartDimensions/useChartDimensions.types.mjs").UseChartDimensionsState & import("./plugins/corePlugins/useChartSeries/useChartSeries.types.mjs").UseChartSeriesState<keyof ChartsSeriesConfig> & import("./plugins/corePlugins/useChartAnimation/useChartAnimation.types.mjs").UseChartAnimationState & import("./index.mjs").UseChartInteractionListenerState & Partial<{}> & {
|
|
17
17
|
cacheKey: import("./index.mjs").ChartStateCacheKey;
|
|
18
|
-
}, seriesType: keyof ChartsSeriesConfig, ids: string | string[] | undefined) => (import("
|
|
18
|
+
}, seriesType: keyof ChartsSeriesConfig, ids: string | string[] | undefined) => (import("@mui/x-charts/models").DefaultizedBarSeriesType | import("@mui/x-charts/models").DefaultizedLineSeriesType | import("@mui/x-charts/models").DefaultizedPieSeriesType | import("@mui/x-charts/models").DefaultizedRadarSeriesType | import("@mui/x-charts/models").DefaultizedScatterSeriesType | undefined)[] | import("@mui/x-charts/models").DefaultizedBarSeriesType | import("@mui/x-charts/models").DefaultizedLineSeriesType | import("@mui/x-charts/models").DefaultizedPieSeriesType | import("@mui/x-charts/models").DefaultizedRadarSeriesType | import("@mui/x-charts/models").DefaultizedScatterSeriesType | undefined;
|
|
19
19
|
export declare const useAllSeriesOfType: <T extends keyof ChartsSeriesConfig>(seriesType: T) => ProcessedSeries[T];
|
|
20
20
|
export declare const useSeriesOfType: <T extends keyof ChartsSeriesConfig>(seriesType: T, seriesId?: SeriesId | SeriesId[]) => ChartSeriesDefaultized<T> | ChartSeriesDefaultized<T>[] | undefined;
|
|
@@ -4,17 +4,17 @@ import type { ProcessedSeries } from "./plugins/corePlugins/useChartSeries/index
|
|
|
4
4
|
export declare const selectorAllSeriesOfType: (args_0: import("./plugins/corePlugins/useChartId/useChartId.types.js").UseChartIdState & import("./plugins/corePlugins/useChartSeriesConfig/useChartSeriesConfig.types.js").UseChartSeriesConfigState<keyof ChartsSeriesConfig> & import("./plugins/corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.types.js").UseChartExperimentalFeaturesState & import("./plugins/corePlugins/useChartDimensions/useChartDimensions.types.js").UseChartDimensionsState & import("./plugins/corePlugins/useChartSeries/useChartSeries.types.js").UseChartSeriesState<keyof ChartsSeriesConfig> & import("./plugins/corePlugins/useChartAnimation/useChartAnimation.types.js").UseChartAnimationState & import("./index.js").UseChartInteractionListenerState & Partial<{}> & {
|
|
5
5
|
cacheKey: import("./index.js").ChartStateCacheKey;
|
|
6
6
|
}, seriesType: keyof ChartsSeriesConfig) => {
|
|
7
|
-
series: Record<string, import("
|
|
7
|
+
series: Record<string, import("@mui/x-charts/models").DefaultizedPieSeriesType>;
|
|
8
8
|
seriesOrder: SeriesId[];
|
|
9
9
|
} | {
|
|
10
|
-
series: Record<string, import("
|
|
10
|
+
series: Record<string, import("@mui/x-charts/models").DefaultizedRadarSeriesType>;
|
|
11
11
|
seriesOrder: SeriesId[];
|
|
12
12
|
} | {
|
|
13
|
-
series: Record<string, import("
|
|
13
|
+
series: Record<string, import("@mui/x-charts/models").DefaultizedScatterSeriesType>;
|
|
14
14
|
seriesOrder: SeriesId[];
|
|
15
15
|
} | import("./index.js").SeriesProcessorResult<"bar"> | import("./index.js").SeriesProcessorResult<"line"> | undefined;
|
|
16
16
|
export declare const selectorSeriesOfType: (args_0: import("./plugins/corePlugins/useChartId/useChartId.types.js").UseChartIdState & import("./plugins/corePlugins/useChartSeriesConfig/useChartSeriesConfig.types.js").UseChartSeriesConfigState<keyof ChartsSeriesConfig> & import("./plugins/corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.types.js").UseChartExperimentalFeaturesState & import("./plugins/corePlugins/useChartDimensions/useChartDimensions.types.js").UseChartDimensionsState & import("./plugins/corePlugins/useChartSeries/useChartSeries.types.js").UseChartSeriesState<keyof ChartsSeriesConfig> & import("./plugins/corePlugins/useChartAnimation/useChartAnimation.types.js").UseChartAnimationState & import("./index.js").UseChartInteractionListenerState & Partial<{}> & {
|
|
17
17
|
cacheKey: import("./index.js").ChartStateCacheKey;
|
|
18
|
-
}, seriesType: keyof ChartsSeriesConfig, ids: string | string[] | undefined) => (import("
|
|
18
|
+
}, seriesType: keyof ChartsSeriesConfig, ids: string | string[] | undefined) => (import("@mui/x-charts/models").DefaultizedBarSeriesType | import("@mui/x-charts/models").DefaultizedLineSeriesType | import("@mui/x-charts/models").DefaultizedPieSeriesType | import("@mui/x-charts/models").DefaultizedRadarSeriesType | import("@mui/x-charts/models").DefaultizedScatterSeriesType | undefined)[] | import("@mui/x-charts/models").DefaultizedBarSeriesType | import("@mui/x-charts/models").DefaultizedLineSeriesType | import("@mui/x-charts/models").DefaultizedPieSeriesType | import("@mui/x-charts/models").DefaultizedRadarSeriesType | import("@mui/x-charts/models").DefaultizedScatterSeriesType | undefined;
|
|
19
19
|
export declare const useAllSeriesOfType: <T extends keyof ChartsSeriesConfig>(seriesType: T) => ProcessedSeries[T];
|
|
20
20
|
export declare const useSeriesOfType: <T extends keyof ChartsSeriesConfig>(seriesType: T, seriesId?: SeriesId | SeriesId[]) => ChartSeriesDefaultized<T> | ChartSeriesDefaultized<T>[] | undefined;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { ChartSeriesType } from "../models/seriesType/config.mjs";
|
|
2
|
+
import type { SeriesId } from "../models/seriesType/common.mjs";
|
|
3
|
+
import type { FocusedItemIdentifier } from "../models/seriesType/index.mjs";
|
|
4
|
+
/**
|
|
5
|
+
* Registers a handler fired when the keyboard-focused item is activated with <kbd>Enter</kbd> or
|
|
6
|
+
* <kbd>Space</kbd>. It is a no-op when the `keyboardActivation` experimental feature is off.
|
|
7
|
+
*
|
|
8
|
+
* Scope the registration as tightly as the caller knows: when several plots handle the same item,
|
|
9
|
+
* the most specific scope wins, `priority` breaks ties, `canActivate` can decline an item, and the
|
|
10
|
+
* handler runs once.
|
|
11
|
+
*
|
|
12
|
+
* The handler receives the `KeyboardEvent`, typed as `any` because the click callbacks it forwards
|
|
13
|
+
* to only describe the pointer event unless the user augments `keyboardActivationOverride`.
|
|
14
|
+
*
|
|
15
|
+
* @param scope The items covered by the handler. Omit `seriesId` to cover a whole series type.
|
|
16
|
+
* @param handler The handler to call on activation, or `undefined` to register nothing.
|
|
17
|
+
*/
|
|
18
|
+
export declare function useRegisterItemActivation<SeriesType extends ChartSeriesType = ChartSeriesType>(scope: {
|
|
19
|
+
type?: SeriesType;
|
|
20
|
+
seriesId?: SeriesId;
|
|
21
|
+
priority?: number;
|
|
22
|
+
canActivate?: (item: FocusedItemIdentifier<SeriesType>) => boolean;
|
|
23
|
+
}, handler: ((event: any, item: FocusedItemIdentifier<SeriesType>) => void) | undefined): void;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { ChartSeriesType } from "../models/seriesType/config.js";
|
|
2
|
+
import type { SeriesId } from "../models/seriesType/common.js";
|
|
3
|
+
import type { FocusedItemIdentifier } from "../models/seriesType/index.js";
|
|
4
|
+
/**
|
|
5
|
+
* Registers a handler fired when the keyboard-focused item is activated with <kbd>Enter</kbd> or
|
|
6
|
+
* <kbd>Space</kbd>. It is a no-op when the `keyboardActivation` experimental feature is off.
|
|
7
|
+
*
|
|
8
|
+
* Scope the registration as tightly as the caller knows: when several plots handle the same item,
|
|
9
|
+
* the most specific scope wins, `priority` breaks ties, `canActivate` can decline an item, and the
|
|
10
|
+
* handler runs once.
|
|
11
|
+
*
|
|
12
|
+
* The handler receives the `KeyboardEvent`, typed as `any` because the click callbacks it forwards
|
|
13
|
+
* to only describe the pointer event unless the user augments `keyboardActivationOverride`.
|
|
14
|
+
*
|
|
15
|
+
* @param scope The items covered by the handler. Omit `seriesId` to cover a whole series type.
|
|
16
|
+
* @param handler The handler to call on activation, or `undefined` to register nothing.
|
|
17
|
+
*/
|
|
18
|
+
export declare function useRegisterItemActivation<SeriesType extends ChartSeriesType = ChartSeriesType>(scope: {
|
|
19
|
+
type?: SeriesType;
|
|
20
|
+
seriesId?: SeriesId;
|
|
21
|
+
priority?: number;
|
|
22
|
+
canActivate?: (item: FocusedItemIdentifier<SeriesType>) => boolean;
|
|
23
|
+
}, handler: ((event: any, item: FocusedItemIdentifier<SeriesType>) => void) | undefined): void;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
'use client';
|
|
3
|
+
|
|
4
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
5
|
+
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
6
|
+
Object.defineProperty(exports, "__esModule", {
|
|
7
|
+
value: true
|
|
8
|
+
});
|
|
9
|
+
exports.useRegisterItemActivation = useRegisterItemActivation;
|
|
10
|
+
var React = _interopRequireWildcard(require("react"));
|
|
11
|
+
var _useEventCallback = _interopRequireDefault(require("@mui/utils/useEventCallback"));
|
|
12
|
+
var _ChartsProvider = require("../context/ChartsProvider");
|
|
13
|
+
/**
|
|
14
|
+
* Registers a handler fired when the keyboard-focused item is activated with <kbd>Enter</kbd> or
|
|
15
|
+
* <kbd>Space</kbd>. It is a no-op when the `keyboardActivation` experimental feature is off.
|
|
16
|
+
*
|
|
17
|
+
* Scope the registration as tightly as the caller knows: when several plots handle the same item,
|
|
18
|
+
* the most specific scope wins, `priority` breaks ties, `canActivate` can decline an item, and the
|
|
19
|
+
* handler runs once.
|
|
20
|
+
*
|
|
21
|
+
* The handler receives the `KeyboardEvent`, typed as `any` because the click callbacks it forwards
|
|
22
|
+
* to only describe the pointer event unless the user augments `keyboardActivationOverride`.
|
|
23
|
+
*
|
|
24
|
+
* @param scope The items covered by the handler. Omit `seriesId` to cover a whole series type.
|
|
25
|
+
* @param handler The handler to call on activation, or `undefined` to register nothing.
|
|
26
|
+
*/
|
|
27
|
+
function useRegisterItemActivation(scope, handler) {
|
|
28
|
+
const {
|
|
29
|
+
instance
|
|
30
|
+
} = (0, _ChartsProvider.useChartsContext)();
|
|
31
|
+
const {
|
|
32
|
+
type,
|
|
33
|
+
seriesId,
|
|
34
|
+
priority,
|
|
35
|
+
canActivate
|
|
36
|
+
} = scope;
|
|
37
|
+
const hasHandler = handler !== undefined;
|
|
38
|
+
const stableHandler = (0, _useEventCallback.default)((event, item) => handler?.(event, item));
|
|
39
|
+
const hasCanActivate = canActivate !== undefined;
|
|
40
|
+
const stableCanActivate = (0, _useEventCallback.default)(item => canActivate ? canActivate(item) : true);
|
|
41
|
+
const registerItemActivationHandler = instance.registerItemActivationHandler;
|
|
42
|
+
React.useEffect(() => {
|
|
43
|
+
if (!hasHandler || !registerItemActivationHandler) {
|
|
44
|
+
return undefined;
|
|
45
|
+
}
|
|
46
|
+
return registerItemActivationHandler({
|
|
47
|
+
type,
|
|
48
|
+
seriesId,
|
|
49
|
+
priority,
|
|
50
|
+
canActivate: hasCanActivate ? stableCanActivate : undefined
|
|
51
|
+
}, stableHandler);
|
|
52
|
+
}, [registerItemActivationHandler, hasHandler, type, seriesId, priority, hasCanActivate, stableCanActivate, stableHandler]);
|
|
53
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import useEventCallback from '@mui/utils/useEventCallback';
|
|
5
|
+
import { useChartsContext } from "../context/ChartsProvider/index.mjs";
|
|
6
|
+
/**
|
|
7
|
+
* Registers a handler fired when the keyboard-focused item is activated with <kbd>Enter</kbd> or
|
|
8
|
+
* <kbd>Space</kbd>. It is a no-op when the `keyboardActivation` experimental feature is off.
|
|
9
|
+
*
|
|
10
|
+
* Scope the registration as tightly as the caller knows: when several plots handle the same item,
|
|
11
|
+
* the most specific scope wins, `priority` breaks ties, `canActivate` can decline an item, and the
|
|
12
|
+
* handler runs once.
|
|
13
|
+
*
|
|
14
|
+
* The handler receives the `KeyboardEvent`, typed as `any` because the click callbacks it forwards
|
|
15
|
+
* to only describe the pointer event unless the user augments `keyboardActivationOverride`.
|
|
16
|
+
*
|
|
17
|
+
* @param scope The items covered by the handler. Omit `seriesId` to cover a whole series type.
|
|
18
|
+
* @param handler The handler to call on activation, or `undefined` to register nothing.
|
|
19
|
+
*/
|
|
20
|
+
export function useRegisterItemActivation(scope, handler) {
|
|
21
|
+
const {
|
|
22
|
+
instance
|
|
23
|
+
} = useChartsContext();
|
|
24
|
+
const {
|
|
25
|
+
type,
|
|
26
|
+
seriesId,
|
|
27
|
+
priority,
|
|
28
|
+
canActivate
|
|
29
|
+
} = scope;
|
|
30
|
+
const hasHandler = handler !== undefined;
|
|
31
|
+
const stableHandler = useEventCallback((event, item) => handler?.(event, item));
|
|
32
|
+
const hasCanActivate = canActivate !== undefined;
|
|
33
|
+
const stableCanActivate = useEventCallback(item => canActivate ? canActivate(item) : true);
|
|
34
|
+
const registerItemActivationHandler = instance.registerItemActivationHandler;
|
|
35
|
+
React.useEffect(() => {
|
|
36
|
+
if (!hasHandler || !registerItemActivationHandler) {
|
|
37
|
+
return undefined;
|
|
38
|
+
}
|
|
39
|
+
return registerItemActivationHandler({
|
|
40
|
+
type,
|
|
41
|
+
seriesId,
|
|
42
|
+
priority,
|
|
43
|
+
canActivate: hasCanActivate ? stableCanActivate : undefined
|
|
44
|
+
}, stableHandler);
|
|
45
|
+
}, [registerItemActivationHandler, hasHandler, type, seriesId, priority, hasCanActivate, stableCanActivate, stableHandler]);
|
|
46
|
+
}
|
package/models/axis.d.mts
CHANGED
|
@@ -627,7 +627,7 @@ export interface ChartsAxisData {
|
|
|
627
627
|
/**
|
|
628
628
|
* The mapping of series ids to their value for this particular axis index.
|
|
629
629
|
*/
|
|
630
|
-
seriesValues: Record<string, HasProperty<ChartsTypeFeatureFlags, '
|
|
630
|
+
seriesValues: Record<string, HasProperty<ChartsTypeFeatureFlags, 'seriesValuesOverride'> extends true ? ChartsTypeFeatureFlags['seriesValuesOverride'] : number | null | undefined>;
|
|
631
631
|
}
|
|
632
632
|
export type CartesianDirection = 'x' | 'y';
|
|
633
633
|
export type PolarDirection = 'rotation' | 'radius';
|
package/models/axis.d.ts
CHANGED
|
@@ -627,7 +627,7 @@ export interface ChartsAxisData {
|
|
|
627
627
|
/**
|
|
628
628
|
* The mapping of series ids to their value for this particular axis index.
|
|
629
629
|
*/
|
|
630
|
-
seriesValues: Record<string, HasProperty<ChartsTypeFeatureFlags, '
|
|
630
|
+
seriesValues: Record<string, HasProperty<ChartsTypeFeatureFlags, 'seriesValuesOverride'> extends true ? ChartsTypeFeatureFlags['seriesValuesOverride'] : number | null | undefined>;
|
|
631
631
|
}
|
|
632
632
|
export type CartesianDirection = 'x' | 'y';
|
|
633
633
|
export type PolarDirection = 'rotation' | 'radius';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type * as React from 'react';
|
|
2
|
+
import type { HasProperty } from '@mui/x-internals/types';
|
|
3
|
+
import type { ChartsTypeFeatureFlags } from "./featureFlags.mjs";
|
|
4
|
+
/**
|
|
5
|
+
* The event a click callback receives.
|
|
6
|
+
*
|
|
7
|
+
* It only describes the pointer event by default. Add
|
|
8
|
+
* `import type {} from '@mui/x-charts/moduleAugmentation/keyboardActivation'` to also get the
|
|
9
|
+
* `KeyboardEvent` fired by the `keyboardActivation` experimental feature.
|
|
10
|
+
*/
|
|
11
|
+
export type ChartsActivationEvent<Element = never> = ([Element] extends [never] ? MouseEvent : React.MouseEvent<Element, MouseEvent>) | (HasProperty<ChartsTypeFeatureFlags, 'keyboardActivationOverride'> extends true ? ChartsTypeFeatureFlags['keyboardActivationOverride'] : never);
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type * as React from 'react';
|
|
2
|
+
import type { HasProperty } from '@mui/x-internals/types';
|
|
3
|
+
import type { ChartsTypeFeatureFlags } from "./featureFlags.js";
|
|
4
|
+
/**
|
|
5
|
+
* The event a click callback receives.
|
|
6
|
+
*
|
|
7
|
+
* It only describes the pointer event by default. Add
|
|
8
|
+
* `import type {} from '@mui/x-charts/moduleAugmentation/keyboardActivation'` to also get the
|
|
9
|
+
* `KeyboardEvent` fired by the `keyboardActivation` experimental feature.
|
|
10
|
+
*/
|
|
11
|
+
export type ChartsActivationEvent<Element = never> = ([Element] extends [never] ? MouseEvent : React.MouseEvent<Element, MouseEvent>) | (HasProperty<ChartsTypeFeatureFlags, 'keyboardActivationOverride'> extends true ? ChartsTypeFeatureFlags['keyboardActivationOverride'] : never);
|
package/models/events.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/models/index.d.mts
CHANGED
|
@@ -2,6 +2,7 @@ export * from "./seriesType/index.mjs";
|
|
|
2
2
|
export * from "./stacking.mjs";
|
|
3
3
|
export * from "./slots/index.mjs";
|
|
4
4
|
export * from "./featureFlags.mjs";
|
|
5
|
+
export type { ChartsActivationEvent } from "./events.mjs";
|
|
5
6
|
export * from "./chartsSlotsComponentsProps.mjs";
|
|
6
7
|
export type { AxisConfig, ChartsYAxisProps, ChartsXAxisProps, ScaleName, ContinuousScaleName, ChartsAxisData, XAxis, YAxis, RadiusAxis, RotationAxis, AxisItemIdentifier, AxisValueFormatterContext } from "./axis.mjs";
|
|
7
8
|
export type { NumberValue } from '@mui/x-charts-vendor/d3-scale';
|
package/models/index.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ export * from "./seriesType/index.js";
|
|
|
2
2
|
export * from "./stacking.js";
|
|
3
3
|
export * from "./slots/index.js";
|
|
4
4
|
export * from "./featureFlags.js";
|
|
5
|
+
export type { ChartsActivationEvent } from "./events.js";
|
|
5
6
|
export * from "./chartsSlotsComponentsProps.js";
|
|
6
7
|
export type { AxisConfig, ChartsYAxisProps, ChartsXAxisProps, ScaleName, ContinuousScaleName, ChartsAxisData, XAxis, YAxis, RadiusAxis, RotationAxis, AxisItemIdentifier, AxisValueFormatterContext } from "./axis.js";
|
|
7
8
|
export type { NumberValue } from '@mui/x-charts-vendor/d3-scale';
|
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
import type
|
|
2
|
-
import type { BarItemIdentifier } from "../models/index.mjs";
|
|
1
|
+
import type { BarItemIdentifier, ChartsActivationEvent } from "../models/index.mjs";
|
|
3
2
|
declare module '@mui/x-charts/BarChart' {
|
|
4
3
|
interface BarPlotProps {
|
|
5
4
|
/**
|
|
6
5
|
* Callback fired when a bar item is clicked.
|
|
7
|
-
* @param {
|
|
6
|
+
* @param {ChartsActivationEvent | ChartsActivationEvent<SVGElement>} event The event source of the callback.
|
|
8
7
|
* It is a native MouseEvent for `svg-batch` renderer and a React MouseEvent for `svg-single` renderer.
|
|
9
8
|
* @param {BarItemIdentifier} barItemIdentifier The bar item identifier.
|
|
10
9
|
*/
|
|
11
|
-
onItemClick?(event:
|
|
10
|
+
onItemClick?(event: ChartsActivationEvent | ChartsActivationEvent<SVGElement>, barItemIdentifier: BarItemIdentifier): void;
|
|
12
11
|
}
|
|
13
12
|
}
|