@mui/x-charts 9.9.0 → 9.10.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/barClasses.d.mts +1 -1
- package/BarChart/barClasses.d.ts +1 -1
- package/BarChart/seriesConfig/bar/getSeriesWithDefaultValues.d.mts +10 -10
- package/BarChart/seriesConfig/bar/getSeriesWithDefaultValues.d.ts +10 -10
- package/BarChart/seriesConfig/bar/keyboardFocusHandler.js +3 -1
- package/BarChart/seriesConfig/bar/keyboardFocusHandler.mjs +3 -1
- package/CHANGELOG.md +217 -0
- package/ChartsAxisHighlight/getSampledBandHighlight.d.mts +1 -1
- package/ChartsAxisHighlight/getSampledBandHighlight.d.ts +1 -1
- package/ChartsAxisHighlight/getSampledBandHighlight.js +15 -3
- package/ChartsAxisHighlight/getSampledBandHighlight.mjs +15 -3
- package/ChartsAxisHighlightValue/ChartsAxisHighlightValue.d.mts +1 -1
- package/ChartsAxisHighlightValue/ChartsAxisHighlightValue.d.ts +1 -1
- package/ChartsAxisHighlightValue/chartsAxisHighlightValueClasses.d.mts +1 -1
- package/ChartsAxisHighlightValue/chartsAxisHighlightValueClasses.d.ts +1 -1
- package/ChartsDataProvider/useChartsDataProviderProps.d.mts +1 -1
- package/ChartsDataProvider/useChartsDataProviderProps.d.ts +1 -1
- package/ChartsLabel/labelGradientClasses.d.mts +1 -1
- package/ChartsLabel/labelGradientClasses.d.ts +1 -1
- package/ChartsLabel/labelMarkClasses.d.mts +1 -1
- package/ChartsLabel/labelMarkClasses.d.ts +1 -1
- package/ChartsLegend/chartsLegend.types.d.mts +2 -1
- package/ChartsLegend/chartsLegend.types.d.ts +2 -1
- package/ChartsLegend/chartsLegendClasses.d.mts +1 -1
- package/ChartsLegend/chartsLegendClasses.d.ts +1 -1
- package/ChartsLegend/continuousColorLegendClasses.d.mts +1 -1
- package/ChartsLegend/continuousColorLegendClasses.d.ts +1 -1
- package/ChartsLegend/piecewiseColorLegendClasses.d.mts +1 -1
- package/ChartsLegend/piecewiseColorLegendClasses.d.ts +1 -1
- package/ChartsRadialDataProvider/useChartsRadialDataProviderProps.d.mts +1 -1
- package/ChartsRadialDataProvider/useChartsRadialDataProviderProps.d.ts +1 -1
- package/ChartsRadiusAxis/chartsRadiusAxisClasses.d.mts +1 -1
- package/ChartsRadiusAxis/chartsRadiusAxisClasses.d.ts +1 -1
- package/ChartsRadiusAxis/createGetLabelTextAnchors.d.mts +6 -6
- package/ChartsRadiusAxis/createGetLabelTextAnchors.d.ts +6 -6
- package/ChartsReferenceLine/ChartsXReferenceLine.d.mts +1 -1
- package/ChartsReferenceLine/ChartsXReferenceLine.d.ts +1 -1
- package/ChartsReferenceLine/ChartsYReferenceLine.d.mts +1 -1
- package/ChartsReferenceLine/ChartsYReferenceLine.d.ts +1 -1
- package/ChartsRotationAxis/chartsRotationAxisClasses.d.mts +1 -1
- package/ChartsRotationAxis/chartsRotationAxisClasses.d.ts +1 -1
- package/ChartsTooltip/ChartTooltip.types.d.mts +2 -1
- package/ChartsTooltip/ChartTooltip.types.d.ts +2 -1
- package/ChartsTooltip/ChartsTooltipContainer.d.mts +4 -1
- package/ChartsTooltip/ChartsTooltipContainer.d.ts +4 -1
- package/ChartsTooltip/ChartsTooltipTable.d.mts +1 -1
- package/ChartsTooltip/ChartsTooltipTable.d.ts +1 -1
- package/ChartsTooltip/chartsTooltipClasses.d.mts +1 -1
- package/ChartsTooltip/chartsTooltipClasses.d.ts +1 -1
- package/ChartsTooltip/useItemTooltip.d.mts +1 -1
- package/ChartsTooltip/useItemTooltip.d.ts +1 -1
- package/ChartsXAxis/useAxisTicksProps.d.mts +2573 -2573
- package/ChartsXAxis/useAxisTicksProps.d.ts +2573 -2573
- package/ChartsXAxis/utilities.d.mts +1 -1
- package/ChartsXAxis/utilities.d.ts +1 -1
- package/ChartsYAxis/useAxisTicksProps.d.mts +2573 -2573
- package/ChartsYAxis/useAxisTicksProps.d.ts +2573 -2573
- package/ChartsYAxis/utilities.d.mts +1 -1
- package/ChartsYAxis/utilities.d.ts +1 -1
- package/LineChart/AreaPlot.d.mts +3 -3
- package/LineChart/AreaPlot.d.ts +3 -3
- package/LineChart/AreaPlot.js +4 -5
- package/LineChart/AreaPlot.mjs +4 -5
- package/LineChart/LinePlot.d.mts +3 -3
- package/LineChart/LinePlot.d.ts +3 -3
- package/LineChart/LinePlot.js +4 -5
- package/LineChart/LinePlot.mjs +4 -5
- package/LineChart/MarkPlot.d.mts +5 -4
- package/LineChart/MarkPlot.d.ts +5 -4
- package/LineChart/MarkPlot.js +1 -1
- package/LineChart/MarkPlot.mjs +1 -1
- package/LineChart/lineClasses.d.mts +1 -1
- package/LineChart/lineClasses.d.ts +1 -1
- package/LineChart/seriesConfig/keyboardFocusHandler.js +3 -1
- package/LineChart/seriesConfig/keyboardFocusHandler.mjs +3 -1
- package/LineChart/useLineItemClickHandler.d.mts +12 -0
- package/LineChart/useLineItemClickHandler.d.ts +12 -0
- package/LineChart/useLineItemClickHandler.js +54 -0
- package/LineChart/useLineItemClickHandler.mjs +48 -0
- package/PieChart/PieArcLabelPlot.d.mts +2 -1
- package/PieChart/PieArcLabelPlot.d.ts +2 -1
- package/PieChart/PieArcPlot.d.mts +2 -1
- package/PieChart/PieArcPlot.d.ts +2 -1
- package/PieChart/pieClasses.d.mts +1 -1
- package/PieChart/pieClasses.d.ts +1 -1
- package/RadarChart/RadarAxis/RadarAxis.utils.d.mts +4 -4
- package/RadarChart/RadarAxis/RadarAxis.utils.d.ts +4 -4
- package/RadarChart/RadarSeriesPlot/useInteractionAllItemProps.d.mts +1 -1
- package/RadarChart/RadarSeriesPlot/useInteractionAllItemProps.d.ts +1 -1
- package/RadarChart/RadarSeriesPlot/useRadarSeriesData.d.mts +12 -12
- package/RadarChart/RadarSeriesPlot/useRadarSeriesData.d.ts +12 -12
- package/RadarChart/radarClasses.d.mts +1 -1
- package/RadarChart/radarClasses.d.ts +1 -1
- package/RadarChart/seriesConfig/keyboardFocusHandler.js +3 -1
- package/RadarChart/seriesConfig/keyboardFocusHandler.mjs +3 -1
- package/RadarChart/useRadarChartProps.d.mts +1 -1
- package/RadarChart/useRadarChartProps.d.ts +1 -1
- package/ScatterChart/ScatterChart.d.mts +2 -1
- package/ScatterChart/ScatterChart.d.ts +2 -1
- package/ScatterChart/ScatterMarker.types.d.mts +2 -1
- package/ScatterChart/ScatterMarker.types.d.ts +2 -1
- package/ScatterChart/scatterClasses.d.mts +1 -1
- package/ScatterChart/scatterClasses.d.ts +1 -1
- package/ScatterChart/useScatterPlotData.d.mts +1 -1
- package/ScatterChart/useScatterPlotData.d.ts +1 -1
- package/SparkLineChart/SparkLineChart.d.mts +1 -1
- package/SparkLineChart/SparkLineChart.d.ts +1 -1
- package/Toolbar/Toolbar.types.d.mts +2 -1
- package/Toolbar/Toolbar.types.d.ts +2 -1
- package/hooks/animation/useAnimatePieArc.js +2 -1
- package/hooks/animation/useAnimatePieArc.mjs +2 -1
- package/index.js +1 -1
- package/index.mjs +1 -1
- package/internals/colorScale.d.mts +1 -1
- package/internals/colorScale.d.ts +1 -1
- package/internals/commonNextFocusItem.d.mts +2 -2
- package/internals/commonNextFocusItem.d.ts +2 -2
- package/internals/commonNextFocusItem.js +4 -4
- package/internals/commonNextFocusItem.mjs +4 -4
- package/internals/components/ChartsAccessibilityProxy/ChartsAccessibilityProxy.js +1 -0
- package/internals/components/ChartsAccessibilityProxy/ChartsAccessibilityProxy.mjs +1 -0
- package/internals/configInit.d.mts +1 -1
- package/internals/configInit.d.ts +1 -1
- package/internals/consumeSlots.d.mts +1 -1
- package/internals/consumeSlots.d.ts +1 -1
- package/internals/consumeThemeProps.d.mts +1 -1
- package/internals/consumeThemeProps.d.ts +1 -1
- package/internals/createCommonKeyboardFocusHandler.d.mts +1 -1
- package/internals/createCommonKeyboardFocusHandler.d.ts +1 -1
- package/internals/createGetBarDimensions.js +10 -5
- package/internals/createGetBarDimensions.mjs +10 -5
- package/internals/getGraphemeCount.d.mts +2 -2
- package/internals/getGraphemeCount.d.ts +2 -2
- package/internals/getGroupingConfig.d.mts +1 -1
- package/internals/getGroupingConfig.d.ts +1 -1
- package/internals/getSampledBucketRegion.d.mts +12 -0
- package/internals/getSampledBucketRegion.d.ts +12 -0
- package/internals/getSampledBucketRegion.js +23 -0
- package/internals/getSampledBucketRegion.mjs +17 -0
- package/internals/identifierCleaner.d.mts +1 -1
- package/internals/identifierCleaner.d.ts +1 -1
- package/internals/invertScale.d.mts +1 -1
- package/internals/invertScale.d.ts +1 -1
- package/internals/plugins/corePlugins/useChartSeries/processSeries.d.mts +1 -1
- package/internals/plugins/corePlugins/useChartSeries/processSeries.d.ts +1 -1
- package/internals/plugins/corePlugins/useChartSeries/useChartSeries.selectors.d.mts +2 -2
- package/internals/plugins/corePlugins/useChartSeries/useChartSeries.selectors.d.ts +2 -2
- package/internals/plugins/featurePlugins/useChartBrush/useChartBrush.selectors.d.mts +3 -3
- package/internals/plugins/featurePlugins/useChartBrush/useChartBrush.selectors.d.ts +3 -3
- package/internals/plugins/featurePlugins/useChartCartesianAxis/createZoomLookup.d.mts +1 -1
- package/internals/plugins/featurePlugins/useChartCartesianAxis/createZoomLookup.d.ts +1 -1
- package/internals/plugins/featurePlugins/useChartCartesianAxis/defaultizeZoom.d.mts +2 -2
- package/internals/plugins/featurePlugins/useChartCartesianAxis/defaultizeZoom.d.ts +2 -2
- package/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisDomainLimit.d.mts +1 -1
- package/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisDomainLimit.d.ts +1 -1
- package/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisTriggerTooltip.d.mts +1 -1
- package/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisTriggerTooltip.d.ts +1 -1
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.d.mts +70 -70
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.d.ts +70 -70
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianHighlight.selectors.d.mts +78 -78
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianHighlight.selectors.d.ts +78 -78
- package/internals/plugins/featurePlugins/useChartHighlight/useChartHighlight.selectors.d.mts +7 -7
- package/internals/plugins/featurePlugins/useChartHighlight/useChartHighlight.selectors.d.ts +7 -7
- package/internals/plugins/featurePlugins/useChartItemClick/useChartItemClick.d.mts +1 -1
- package/internals/plugins/featurePlugins/useChartItemClick/useChartItemClick.d.ts +1 -1
- package/internals/plugins/featurePlugins/useChartKeyboardNavigation/utils/findVisibleDataIndex.d.mts +3 -0
- package/internals/plugins/featurePlugins/useChartKeyboardNavigation/utils/findVisibleDataIndex.d.ts +3 -0
- package/internals/plugins/featurePlugins/useChartKeyboardNavigation/utils/findVisibleDataIndex.js +3 -0
- package/internals/plugins/featurePlugins/useChartKeyboardNavigation/utils/findVisibleDataIndex.mjs +3 -0
- package/internals/plugins/featurePlugins/useChartPolarAxis/getAxisExtremum.d.mts +1 -1
- package/internals/plugins/featurePlugins/useChartPolarAxis/getAxisExtremum.d.ts +1 -1
- package/internals/plugins/featurePlugins/useChartPolarAxis/getAxisTriggerTooltip.d.mts +1 -1
- package/internals/plugins/featurePlugins/useChartPolarAxis/getAxisTriggerTooltip.d.ts +1 -1
- package/internals/plugins/featurePlugins/useChartTooltip/useChartTooltip.selectors.d.mts +1 -1
- package/internals/plugins/featurePlugins/useChartTooltip/useChartTooltip.selectors.d.ts +1 -1
- package/internals/plugins/featurePlugins/useProgressiveRendering/useProgressiveRendering.selectors.d.mts +1 -1
- package/internals/plugins/featurePlugins/useProgressiveRendering/useProgressiveRendering.selectors.d.ts +1 -1
- package/internals/seriesSelectorOfType.d.mts +6 -6
- package/internals/seriesSelectorOfType.d.ts +6 -6
- package/internals/sizeScale.d.mts +1 -1
- package/internals/sizeScale.d.ts +1 -1
- package/internals/sliceUntil.d.mts +2 -2
- package/internals/sliceUntil.d.ts +2 -2
- package/internals/snapEndAngleToFullCircle.d.mts +20 -0
- package/internals/snapEndAngleToFullCircle.d.ts +20 -0
- package/internals/snapEndAngleToFullCircle.js +47 -0
- package/internals/snapEndAngleToFullCircle.mjs +41 -0
- package/models/axis.d.mts +5 -4
- package/models/axis.d.ts +5 -4
- package/models/seriesType/config.d.mts +2 -2
- package/models/seriesType/config.d.ts +2 -2
- package/models/seriesType/index.d.mts +1 -1
- package/models/seriesType/index.d.ts +1 -1
- package/models/seriesType/line.d.mts +14 -1
- package/models/seriesType/line.d.ts +14 -1
- package/package.json +3 -3
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { AxisConfig, ChartsYAxisProps } from "../models/axis.mjs";
|
|
2
|
-
export declare const useUtilityClasses: (ownerState: AxisConfig<any, any, ChartsYAxisProps>) => Record<"
|
|
2
|
+
export declare const useUtilityClasses: (ownerState: AxisConfig<any, any, ChartsYAxisProps>) => Record<"label" | "line" | "root" | "tick" | "tickContainer" | "tickLabel", string>;
|
|
3
3
|
export declare const TICK_LABEL_GAP = 2;
|
|
4
4
|
export declare const AXIS_LABEL_TICK_LABEL_GAP = 2;
|
|
5
5
|
export declare const defaultProps: {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { AxisConfig, ChartsYAxisProps } from "../models/axis.js";
|
|
2
|
-
export declare const useUtilityClasses: (ownerState: AxisConfig<any, any, ChartsYAxisProps>) => Record<"
|
|
2
|
+
export declare const useUtilityClasses: (ownerState: AxisConfig<any, any, ChartsYAxisProps>) => Record<"label" | "line" | "root" | "tick" | "tickContainer" | "tickLabel", string>;
|
|
3
3
|
export declare const TICK_LABEL_GAP = 2;
|
|
4
4
|
export declare const AXIS_LABEL_TICK_LABEL_GAP = 2;
|
|
5
5
|
export declare const defaultProps: {
|
package/LineChart/AreaPlot.d.mts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import type { AreaElementProps, AreaElementSlotProps, AreaElementSlots } from "./AreaElement.mjs";
|
|
3
|
-
import type {
|
|
3
|
+
import type { LineItemClickIdentifier } from "../models/seriesType/line.mjs";
|
|
4
4
|
export interface AreaPlotSlots extends AreaElementSlots {}
|
|
5
5
|
export interface AreaPlotSlotProps extends AreaElementSlotProps {}
|
|
6
6
|
export interface AreaPlotProps extends React.SVGAttributes<SVGSVGElement>, Pick<AreaElementProps, 'slots' | 'slotProps' | 'skipAnimation'> {
|
|
7
7
|
/**
|
|
8
8
|
* Callback fired when a line area item is clicked.
|
|
9
9
|
* @param {React.MouseEvent<SVGPathElement, MouseEvent>} event The event source of the callback.
|
|
10
|
-
* @param {
|
|
10
|
+
* @param {LineItemClickIdentifier} lineItemIdentifier The line item identifier.
|
|
11
11
|
*/
|
|
12
|
-
onItemClick?: (event: React.MouseEvent<SVGElement, MouseEvent>, lineItemIdentifier:
|
|
12
|
+
onItemClick?: (event: React.MouseEvent<SVGElement, MouseEvent>, lineItemIdentifier: LineItemClickIdentifier) => void;
|
|
13
13
|
}
|
|
14
14
|
/**
|
|
15
15
|
* Demos:
|
package/LineChart/AreaPlot.d.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import type { AreaElementProps, AreaElementSlotProps, AreaElementSlots } from "./AreaElement.js";
|
|
3
|
-
import type {
|
|
3
|
+
import type { LineItemClickIdentifier } from "../models/seriesType/line.js";
|
|
4
4
|
export interface AreaPlotSlots extends AreaElementSlots {}
|
|
5
5
|
export interface AreaPlotSlotProps extends AreaElementSlotProps {}
|
|
6
6
|
export interface AreaPlotProps extends React.SVGAttributes<SVGSVGElement>, Pick<AreaElementProps, 'slots' | 'slotProps' | 'skipAnimation'> {
|
|
7
7
|
/**
|
|
8
8
|
* Callback fired when a line area item is clicked.
|
|
9
9
|
* @param {React.MouseEvent<SVGPathElement, MouseEvent>} event The event source of the callback.
|
|
10
|
-
* @param {
|
|
10
|
+
* @param {LineItemClickIdentifier} lineItemIdentifier The line item identifier.
|
|
11
11
|
*/
|
|
12
|
-
onItemClick?: (event: React.MouseEvent<SVGElement, MouseEvent>, lineItemIdentifier:
|
|
12
|
+
onItemClick?: (event: React.MouseEvent<SVGElement, MouseEvent>, lineItemIdentifier: LineItemClickIdentifier) => void;
|
|
13
13
|
}
|
|
14
14
|
/**
|
|
15
15
|
* Demos:
|
package/LineChart/AreaPlot.js
CHANGED
|
@@ -18,6 +18,7 @@ var _useSkipAnimation = require("../hooks/useSkipAnimation");
|
|
|
18
18
|
var _useAxis = require("../hooks/useAxis");
|
|
19
19
|
var _useInternalIsZoomInteracting = require("../internals/plugins/featurePlugins/useChartCartesianAxis/useInternalIsZoomInteracting");
|
|
20
20
|
var _useAreaPlotData = require("./useAreaPlotData");
|
|
21
|
+
var _useLineItemClickHandler = require("./useLineItemClickHandler");
|
|
21
22
|
var _animation = require("../internals/animation/animation");
|
|
22
23
|
var _lineClasses = require("./lineClasses");
|
|
23
24
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
@@ -66,6 +67,7 @@ function AreaPlot(props) {
|
|
|
66
67
|
const skipAnimation = (0, _useSkipAnimation.useSkipAnimation)(isZoomInteracting || inSkipAnimation);
|
|
67
68
|
const completedData = useAggregatedData();
|
|
68
69
|
const classes = (0, _lineClasses.useUtilityClasses)();
|
|
70
|
+
const onAreaItemClick = (0, _useLineItemClickHandler.useLineItemClickHandler)(onItemClick);
|
|
69
71
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(AreaPlotRoot, (0, _extends2.default)({
|
|
70
72
|
className: (0, _clsx.default)(classes.areaPlot, className)
|
|
71
73
|
}, other, {
|
|
@@ -82,10 +84,7 @@ function AreaPlot(props) {
|
|
|
82
84
|
gradientId: gradientId,
|
|
83
85
|
slots: slots,
|
|
84
86
|
slotProps: slotProps,
|
|
85
|
-
onClick:
|
|
86
|
-
type: 'line',
|
|
87
|
-
seriesId
|
|
88
|
-
})),
|
|
87
|
+
onClick: onAreaItemClick && (event => onAreaItemClick(event, seriesId)),
|
|
89
88
|
skipAnimation: skipAnimation
|
|
90
89
|
}, seriesId))
|
|
91
90
|
}));
|
|
@@ -98,7 +97,7 @@ process.env.NODE_ENV !== "production" ? AreaPlot.propTypes /* remove-proptypes *
|
|
|
98
97
|
/**
|
|
99
98
|
* Callback fired when a line area item is clicked.
|
|
100
99
|
* @param {React.MouseEvent<SVGPathElement, MouseEvent>} event The event source of the callback.
|
|
101
|
-
* @param {
|
|
100
|
+
* @param {LineItemClickIdentifier} lineItemIdentifier The line item identifier.
|
|
102
101
|
*/
|
|
103
102
|
onItemClick: _propTypes.default.func,
|
|
104
103
|
/**
|
package/LineChart/AreaPlot.mjs
CHANGED
|
@@ -12,6 +12,7 @@ import { useSkipAnimation } from "../hooks/useSkipAnimation.mjs";
|
|
|
12
12
|
import { useXAxes, useYAxes } from "../hooks/useAxis.mjs";
|
|
13
13
|
import { useInternalIsZoomInteracting } from "../internals/plugins/featurePlugins/useChartCartesianAxis/useInternalIsZoomInteracting.mjs";
|
|
14
14
|
import { useAreaPlotData } from "./useAreaPlotData.mjs";
|
|
15
|
+
import { useLineItemClickHandler } from "./useLineItemClickHandler.mjs";
|
|
15
16
|
import { ANIMATION_DURATION_MS, ANIMATION_TIMING_FUNCTION } from "../internals/animation/animation.mjs";
|
|
16
17
|
import { lineClasses, useUtilityClasses } from "./lineClasses.mjs";
|
|
17
18
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
@@ -59,6 +60,7 @@ function AreaPlot(props) {
|
|
|
59
60
|
const skipAnimation = useSkipAnimation(isZoomInteracting || inSkipAnimation);
|
|
60
61
|
const completedData = useAggregatedData();
|
|
61
62
|
const classes = useUtilityClasses();
|
|
63
|
+
const onAreaItemClick = useLineItemClickHandler(onItemClick);
|
|
62
64
|
return /*#__PURE__*/_jsx(AreaPlotRoot, _extends({
|
|
63
65
|
className: clsx(classes.areaPlot, className)
|
|
64
66
|
}, other, {
|
|
@@ -75,10 +77,7 @@ function AreaPlot(props) {
|
|
|
75
77
|
gradientId: gradientId,
|
|
76
78
|
slots: slots,
|
|
77
79
|
slotProps: slotProps,
|
|
78
|
-
onClick:
|
|
79
|
-
type: 'line',
|
|
80
|
-
seriesId
|
|
81
|
-
})),
|
|
80
|
+
onClick: onAreaItemClick && (event => onAreaItemClick(event, seriesId)),
|
|
82
81
|
skipAnimation: skipAnimation
|
|
83
82
|
}, seriesId))
|
|
84
83
|
}));
|
|
@@ -91,7 +90,7 @@ process.env.NODE_ENV !== "production" ? AreaPlot.propTypes /* remove-proptypes *
|
|
|
91
90
|
/**
|
|
92
91
|
* Callback fired when a line area item is clicked.
|
|
93
92
|
* @param {React.MouseEvent<SVGPathElement, MouseEvent>} event The event source of the callback.
|
|
94
|
-
* @param {
|
|
93
|
+
* @param {LineItemClickIdentifier} lineItemIdentifier The line item identifier.
|
|
95
94
|
*/
|
|
96
95
|
onItemClick: PropTypes.func,
|
|
97
96
|
/**
|
package/LineChart/LinePlot.d.mts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import type { LineElementProps, LineElementSlotProps, LineElementSlots } from "./LineElement.mjs";
|
|
3
|
-
import type {
|
|
3
|
+
import type { LineItemClickIdentifier } from "../models/seriesType/line.mjs";
|
|
4
4
|
export interface LinePlotSlots extends LineElementSlots {}
|
|
5
5
|
export interface LinePlotSlotProps extends LineElementSlotProps {}
|
|
6
6
|
export interface LinePlotProps extends React.SVGAttributes<SVGSVGElement>, Pick<LineElementProps, 'slots' | 'slotProps' | 'skipAnimation'> {
|
|
7
7
|
/**
|
|
8
8
|
* Callback fired when a line item is clicked.
|
|
9
9
|
* @param {React.MouseEvent<SVGPathElement, MouseEvent>} event The event source of the callback.
|
|
10
|
-
* @param {
|
|
10
|
+
* @param {LineItemClickIdentifier} lineItemIdentifier The line item identifier.
|
|
11
11
|
*/
|
|
12
|
-
onItemClick?: (event: React.MouseEvent<SVGElement, MouseEvent>, lineItemIdentifier:
|
|
12
|
+
onItemClick?: (event: React.MouseEvent<SVGElement, MouseEvent>, lineItemIdentifier: LineItemClickIdentifier) => void;
|
|
13
13
|
}
|
|
14
14
|
/**
|
|
15
15
|
* Demos:
|
package/LineChart/LinePlot.d.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import type { LineElementProps, LineElementSlotProps, LineElementSlots } from "./LineElement.js";
|
|
3
|
-
import type {
|
|
3
|
+
import type { LineItemClickIdentifier } from "../models/seriesType/line.js";
|
|
4
4
|
export interface LinePlotSlots extends LineElementSlots {}
|
|
5
5
|
export interface LinePlotSlotProps extends LineElementSlotProps {}
|
|
6
6
|
export interface LinePlotProps extends React.SVGAttributes<SVGSVGElement>, Pick<LineElementProps, 'slots' | 'slotProps' | 'skipAnimation'> {
|
|
7
7
|
/**
|
|
8
8
|
* Callback fired when a line item is clicked.
|
|
9
9
|
* @param {React.MouseEvent<SVGPathElement, MouseEvent>} event The event source of the callback.
|
|
10
|
-
* @param {
|
|
10
|
+
* @param {LineItemClickIdentifier} lineItemIdentifier The line item identifier.
|
|
11
11
|
*/
|
|
12
|
-
onItemClick?: (event: React.MouseEvent<SVGElement, MouseEvent>, lineItemIdentifier:
|
|
12
|
+
onItemClick?: (event: React.MouseEvent<SVGElement, MouseEvent>, lineItemIdentifier: LineItemClickIdentifier) => void;
|
|
13
13
|
}
|
|
14
14
|
/**
|
|
15
15
|
* Demos:
|
package/LineChart/LinePlot.js
CHANGED
|
@@ -18,6 +18,7 @@ var _useSkipAnimation = require("../hooks/useSkipAnimation");
|
|
|
18
18
|
var _hooks = require("../hooks");
|
|
19
19
|
var _useInternalIsZoomInteracting = require("../internals/plugins/featurePlugins/useChartCartesianAxis/useInternalIsZoomInteracting");
|
|
20
20
|
var _useLinePlotData = require("./useLinePlotData");
|
|
21
|
+
var _useLineItemClickHandler = require("./useLineItemClickHandler");
|
|
21
22
|
var _animation = require("../internals/animation/animation");
|
|
22
23
|
var _lineClasses = require("./lineClasses");
|
|
23
24
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
@@ -65,6 +66,7 @@ function LinePlot(props) {
|
|
|
65
66
|
const skipAnimation = (0, _useSkipAnimation.useSkipAnimation)(isZoomInteracting || inSkipAnimation);
|
|
66
67
|
const completedData = useAggregatedData();
|
|
67
68
|
const classes = (0, _lineClasses.useUtilityClasses)();
|
|
69
|
+
const onLineItemClick = (0, _useLineItemClickHandler.useLineItemClickHandler)(onItemClick);
|
|
68
70
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(LinePlotRoot, (0, _extends2.default)({
|
|
69
71
|
className: (0, _clsx.default)(classes.linePlot, className)
|
|
70
72
|
}, other, {
|
|
@@ -85,10 +87,7 @@ function LinePlot(props) {
|
|
|
85
87
|
skipAnimation: skipAnimation || isSampled,
|
|
86
88
|
slots: slots,
|
|
87
89
|
slotProps: slotProps,
|
|
88
|
-
onClick:
|
|
89
|
-
type: 'line',
|
|
90
|
-
seriesId
|
|
91
|
-
}))
|
|
90
|
+
onClick: onLineItemClick && (event => onLineItemClick(event, seriesId))
|
|
92
91
|
}, seriesId);
|
|
93
92
|
})
|
|
94
93
|
}));
|
|
@@ -101,7 +100,7 @@ process.env.NODE_ENV !== "production" ? LinePlot.propTypes /* remove-proptypes *
|
|
|
101
100
|
/**
|
|
102
101
|
* Callback fired when a line item is clicked.
|
|
103
102
|
* @param {React.MouseEvent<SVGPathElement, MouseEvent>} event The event source of the callback.
|
|
104
|
-
* @param {
|
|
103
|
+
* @param {LineItemClickIdentifier} lineItemIdentifier The line item identifier.
|
|
105
104
|
*/
|
|
106
105
|
onItemClick: _propTypes.default.func,
|
|
107
106
|
/**
|
package/LineChart/LinePlot.mjs
CHANGED
|
@@ -12,6 +12,7 @@ import { useSkipAnimation } from "../hooks/useSkipAnimation.mjs";
|
|
|
12
12
|
import { useXAxes, useYAxes } from "../hooks/index.mjs";
|
|
13
13
|
import { useInternalIsZoomInteracting } from "../internals/plugins/featurePlugins/useChartCartesianAxis/useInternalIsZoomInteracting.mjs";
|
|
14
14
|
import { useLinePlotData } from "./useLinePlotData.mjs";
|
|
15
|
+
import { useLineItemClickHandler } from "./useLineItemClickHandler.mjs";
|
|
15
16
|
import { ANIMATION_DURATION_MS, ANIMATION_TIMING_FUNCTION } from "../internals/animation/animation.mjs";
|
|
16
17
|
import { lineClasses, useUtilityClasses } from "./lineClasses.mjs";
|
|
17
18
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
@@ -58,6 +59,7 @@ function LinePlot(props) {
|
|
|
58
59
|
const skipAnimation = useSkipAnimation(isZoomInteracting || inSkipAnimation);
|
|
59
60
|
const completedData = useAggregatedData();
|
|
60
61
|
const classes = useUtilityClasses();
|
|
62
|
+
const onLineItemClick = useLineItemClickHandler(onItemClick);
|
|
61
63
|
return /*#__PURE__*/_jsx(LinePlotRoot, _extends({
|
|
62
64
|
className: clsx(classes.linePlot, className)
|
|
63
65
|
}, other, {
|
|
@@ -78,10 +80,7 @@ function LinePlot(props) {
|
|
|
78
80
|
skipAnimation: skipAnimation || isSampled,
|
|
79
81
|
slots: slots,
|
|
80
82
|
slotProps: slotProps,
|
|
81
|
-
onClick:
|
|
82
|
-
type: 'line',
|
|
83
|
-
seriesId
|
|
84
|
-
}))
|
|
83
|
+
onClick: onLineItemClick && (event => onLineItemClick(event, seriesId))
|
|
85
84
|
}, seriesId);
|
|
86
85
|
})
|
|
87
86
|
}));
|
|
@@ -94,7 +93,7 @@ process.env.NODE_ENV !== "production" ? LinePlot.propTypes /* remove-proptypes *
|
|
|
94
93
|
/**
|
|
95
94
|
* Callback fired when a line item is clicked.
|
|
96
95
|
* @param {React.MouseEvent<SVGPathElement, MouseEvent>} event The event source of the callback.
|
|
97
|
-
* @param {
|
|
96
|
+
* @param {LineItemClickIdentifier} lineItemIdentifier The line item identifier.
|
|
98
97
|
*/
|
|
99
98
|
onItemClick: PropTypes.func,
|
|
100
99
|
/**
|
package/LineChart/MarkPlot.d.mts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import type {
|
|
2
|
+
import type { WithDataAttributes } from '@mui/utils/types';
|
|
3
|
+
import type { LineItemClickIdentifier } from "../models/seriesType/line.mjs";
|
|
3
4
|
import type { MarkElementProps } from "./MarkElement.mjs";
|
|
4
5
|
import type { MarkPropsOverrides } from "../models/chartsSlotsComponentsProps.mjs";
|
|
5
6
|
export interface MarkPlotSlots {
|
|
6
7
|
mark?: React.JSXElementConstructor<MarkElementProps & MarkPropsOverrides>;
|
|
7
8
|
}
|
|
8
9
|
export interface MarkPlotSlotProps {
|
|
9
|
-
mark?: Partial<MarkElementProps> & MarkPropsOverrides
|
|
10
|
+
mark?: WithDataAttributes<Partial<MarkElementProps> & MarkPropsOverrides>;
|
|
10
11
|
}
|
|
11
12
|
export interface MarkPlotProps extends React.SVGAttributes<SVGSVGElement>, Pick<MarkElementProps, 'skipAnimation'> {
|
|
12
13
|
/**
|
|
@@ -22,9 +23,9 @@ export interface MarkPlotProps extends React.SVGAttributes<SVGSVGElement>, Pick<
|
|
|
22
23
|
/**
|
|
23
24
|
* Callback fired when a line mark item is clicked.
|
|
24
25
|
* @param {React.MouseEvent<SVGPathElement, MouseEvent>} event The event source of the callback.
|
|
25
|
-
* @param {
|
|
26
|
+
* @param {LineItemClickIdentifier} lineItemIdentifier The line mark item identifier.
|
|
26
27
|
*/
|
|
27
|
-
onItemClick?: (event: React.MouseEvent<SVGElement, MouseEvent>, lineItemIdentifier:
|
|
28
|
+
onItemClick?: (event: React.MouseEvent<SVGElement, MouseEvent>, lineItemIdentifier: LineItemClickIdentifier) => void;
|
|
28
29
|
}
|
|
29
30
|
/**
|
|
30
31
|
* Demos:
|
package/LineChart/MarkPlot.d.ts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import type {
|
|
2
|
+
import type { WithDataAttributes } from '@mui/utils/types';
|
|
3
|
+
import type { LineItemClickIdentifier } from "../models/seriesType/line.js";
|
|
3
4
|
import type { MarkElementProps } from "./MarkElement.js";
|
|
4
5
|
import type { MarkPropsOverrides } from "../models/chartsSlotsComponentsProps.js";
|
|
5
6
|
export interface MarkPlotSlots {
|
|
6
7
|
mark?: React.JSXElementConstructor<MarkElementProps & MarkPropsOverrides>;
|
|
7
8
|
}
|
|
8
9
|
export interface MarkPlotSlotProps {
|
|
9
|
-
mark?: Partial<MarkElementProps> & MarkPropsOverrides
|
|
10
|
+
mark?: WithDataAttributes<Partial<MarkElementProps> & MarkPropsOverrides>;
|
|
10
11
|
}
|
|
11
12
|
export interface MarkPlotProps extends React.SVGAttributes<SVGSVGElement>, Pick<MarkElementProps, 'skipAnimation'> {
|
|
12
13
|
/**
|
|
@@ -22,9 +23,9 @@ export interface MarkPlotProps extends React.SVGAttributes<SVGSVGElement>, Pick<
|
|
|
22
23
|
/**
|
|
23
24
|
* Callback fired when a line mark item is clicked.
|
|
24
25
|
* @param {React.MouseEvent<SVGPathElement, MouseEvent>} event The event source of the callback.
|
|
25
|
-
* @param {
|
|
26
|
+
* @param {LineItemClickIdentifier} lineItemIdentifier The line mark item identifier.
|
|
26
27
|
*/
|
|
27
|
-
onItemClick?: (event: React.MouseEvent<SVGElement, MouseEvent>, lineItemIdentifier:
|
|
28
|
+
onItemClick?: (event: React.MouseEvent<SVGElement, MouseEvent>, lineItemIdentifier: LineItemClickIdentifier) => void;
|
|
28
29
|
}
|
|
29
30
|
/**
|
|
30
31
|
* Demos:
|
package/LineChart/MarkPlot.js
CHANGED
|
@@ -135,7 +135,7 @@ process.env.NODE_ENV !== "production" ? MarkPlot.propTypes /* remove-proptypes *
|
|
|
135
135
|
/**
|
|
136
136
|
* Callback fired when a line mark item is clicked.
|
|
137
137
|
* @param {React.MouseEvent<SVGPathElement, MouseEvent>} event The event source of the callback.
|
|
138
|
-
* @param {
|
|
138
|
+
* @param {LineItemClickIdentifier} lineItemIdentifier The line mark item identifier.
|
|
139
139
|
*/
|
|
140
140
|
onItemClick: _propTypes.default.func,
|
|
141
141
|
/**
|
package/LineChart/MarkPlot.mjs
CHANGED
|
@@ -128,7 +128,7 @@ process.env.NODE_ENV !== "production" ? MarkPlot.propTypes /* remove-proptypes *
|
|
|
128
128
|
/**
|
|
129
129
|
* Callback fired when a line mark item is clicked.
|
|
130
130
|
* @param {React.MouseEvent<SVGPathElement, MouseEvent>} event The event source of the callback.
|
|
131
|
-
* @param {
|
|
131
|
+
* @param {LineItemClickIdentifier} lineItemIdentifier The line mark item identifier.
|
|
132
132
|
*/
|
|
133
133
|
onItemClick: PropTypes.func,
|
|
134
134
|
/**
|
|
@@ -22,4 +22,4 @@ export interface UseUtilityClassesOptions {
|
|
|
22
22
|
skipAnimation?: boolean;
|
|
23
23
|
classes?: Partial<LineClasses>;
|
|
24
24
|
}
|
|
25
|
-
export declare const useUtilityClasses: (options?: UseUtilityClassesOptions) => Record<"
|
|
25
|
+
export declare const useUtilityClasses: (options?: UseUtilityClassesOptions) => Record<"area" | "areaPlot" | "highlight" | "line" | "linePlot" | "mark" | "markPlot", string>;
|
|
@@ -22,4 +22,4 @@ export interface UseUtilityClassesOptions {
|
|
|
22
22
|
skipAnimation?: boolean;
|
|
23
23
|
classes?: Partial<LineClasses>;
|
|
24
24
|
}
|
|
25
|
-
export declare const useUtilityClasses: (options?: UseUtilityClassesOptions) => Record<"
|
|
25
|
+
export declare const useUtilityClasses: (options?: UseUtilityClassesOptions) => Record<"area" | "areaPlot" | "highlight" | "line" | "linePlot" | "mark" | "markPlot", string>;
|
|
@@ -6,5 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var _createCommonKeyboardFocusHandler = require("../../internals/createCommonKeyboardFocusHandler");
|
|
8
8
|
var _composition = require("../../models/seriesType/composition");
|
|
9
|
-
const
|
|
9
|
+
const allowCycles = false;
|
|
10
|
+
const useCurrentSeriesMaxLength = false;
|
|
11
|
+
const keyboardFocusHandler = (0, _createCommonKeyboardFocusHandler.createCommonKeyboardFocusHandler)(_composition.composableCartesianSeriesTypes, allowCycles, useCurrentSeriesMaxLength);
|
|
10
12
|
var _default = exports.default = keyboardFocusHandler;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { createCommonKeyboardFocusHandler } from "../../internals/createCommonKeyboardFocusHandler.mjs";
|
|
2
2
|
import { composableCartesianSeriesTypes } from "../../models/seriesType/composition.mjs";
|
|
3
|
-
const
|
|
3
|
+
const allowCycles = false;
|
|
4
|
+
const useCurrentSeriesMaxLength = false;
|
|
5
|
+
const keyboardFocusHandler = createCommonKeyboardFocusHandler(composableCartesianSeriesTypes, allowCycles, useCurrentSeriesMaxLength);
|
|
4
6
|
export default keyboardFocusHandler;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { LineItemClickIdentifier } from "../models/seriesType/line.mjs";
|
|
3
|
+
import type { SeriesId } from "../models/seriesType/common.mjs";
|
|
4
|
+
/**
|
|
5
|
+
* Creates a click handler for line and area paths that enriches the item
|
|
6
|
+
* identifier with the `dataIndex` of the closest data point along the x-axis.
|
|
7
|
+
*
|
|
8
|
+
* The index is derived from the click position, using the same logic as the
|
|
9
|
+
* axis interaction (tooltip, highlight, `onAxisClick`). The callback is not
|
|
10
|
+
* fired when the click position cannot be associated with a data point.
|
|
11
|
+
*/
|
|
12
|
+
export declare function useLineItemClickHandler(onItemClick?: (event: React.MouseEvent<SVGElement, MouseEvent>, lineItemIdentifier: LineItemClickIdentifier) => void): ((event: React.MouseEvent<SVGElement, MouseEvent>, seriesId: SeriesId) => void) | undefined;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { LineItemClickIdentifier } from "../models/seriesType/line.js";
|
|
3
|
+
import type { SeriesId } from "../models/seriesType/common.js";
|
|
4
|
+
/**
|
|
5
|
+
* Creates a click handler for line and area paths that enriches the item
|
|
6
|
+
* identifier with the `dataIndex` of the closest data point along the x-axis.
|
|
7
|
+
*
|
|
8
|
+
* The index is derived from the click position, using the same logic as the
|
|
9
|
+
* axis interaction (tooltip, highlight, `onAxisClick`). The callback is not
|
|
10
|
+
* fired when the click position cannot be associated with a data point.
|
|
11
|
+
*/
|
|
12
|
+
export declare function useLineItemClickHandler(onItemClick?: (event: React.MouseEvent<SVGElement, MouseEvent>, lineItemIdentifier: LineItemClickIdentifier) => void): ((event: React.MouseEvent<SVGElement, MouseEvent>, seriesId: SeriesId) => void) | undefined;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
'use client';
|
|
3
|
+
|
|
4
|
+
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.useLineItemClickHandler = useLineItemClickHandler;
|
|
9
|
+
var React = _interopRequireWildcard(require("react"));
|
|
10
|
+
var _useChartsLayerContainerRef = require("../hooks/useChartsLayerContainerRef");
|
|
11
|
+
var _useAxis = require("../hooks/useAxis");
|
|
12
|
+
var _useLineSeries = require("../hooks/useLineSeries");
|
|
13
|
+
var _getChartPoint = require("../internals/getChartPoint");
|
|
14
|
+
var _getAxisValue = require("../internals/plugins/featurePlugins/useChartCartesianAxis/getAxisValue");
|
|
15
|
+
/**
|
|
16
|
+
* Creates a click handler for line and area paths that enriches the item
|
|
17
|
+
* identifier with the `dataIndex` of the closest data point along the x-axis.
|
|
18
|
+
*
|
|
19
|
+
* The index is derived from the click position, using the same logic as the
|
|
20
|
+
* axis interaction (tooltip, highlight, `onAxisClick`). The callback is not
|
|
21
|
+
* fired when the click position cannot be associated with a data point.
|
|
22
|
+
*/
|
|
23
|
+
function useLineItemClickHandler(onItemClick) {
|
|
24
|
+
const chartsLayerContainerRef = (0, _useChartsLayerContainerRef.useChartsLayerContainerRef)();
|
|
25
|
+
const {
|
|
26
|
+
xAxis: xAxes,
|
|
27
|
+
xAxisIds
|
|
28
|
+
} = (0, _useAxis.useXAxes)();
|
|
29
|
+
const seriesData = (0, _useLineSeries.useLineSeriesContext)();
|
|
30
|
+
const defaultXAxisId = xAxisIds[0];
|
|
31
|
+
return React.useMemo(() => {
|
|
32
|
+
if (!onItemClick) {
|
|
33
|
+
return undefined;
|
|
34
|
+
}
|
|
35
|
+
return (event, seriesId) => {
|
|
36
|
+
const element = chartsLayerContainerRef.current;
|
|
37
|
+
const xAxisId = seriesData?.series[seriesId]?.xAxisId ?? defaultXAxisId;
|
|
38
|
+
const xAxis = xAxisId === undefined ? undefined : xAxes[xAxisId];
|
|
39
|
+
if (element === null || xAxis === undefined) {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
const point = (0, _getChartPoint.getChartPoint)(element, event);
|
|
43
|
+
const dataIndex = (0, _getAxisValue.getAxisIndex)(xAxis, point.x);
|
|
44
|
+
if (dataIndex === -1) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
onItemClick(event, {
|
|
48
|
+
type: 'line',
|
|
49
|
+
seriesId,
|
|
50
|
+
dataIndex
|
|
51
|
+
});
|
|
52
|
+
};
|
|
53
|
+
}, [onItemClick, chartsLayerContainerRef, seriesData, defaultXAxisId, xAxes]);
|
|
54
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import { useChartsLayerContainerRef } from "../hooks/useChartsLayerContainerRef.mjs";
|
|
5
|
+
import { useXAxes } from "../hooks/useAxis.mjs";
|
|
6
|
+
import { useLineSeriesContext } from "../hooks/useLineSeries.mjs";
|
|
7
|
+
import { getChartPoint } from "../internals/getChartPoint.mjs";
|
|
8
|
+
import { getAxisIndex } from "../internals/plugins/featurePlugins/useChartCartesianAxis/getAxisValue.mjs";
|
|
9
|
+
/**
|
|
10
|
+
* Creates a click handler for line and area paths that enriches the item
|
|
11
|
+
* identifier with the `dataIndex` of the closest data point along the x-axis.
|
|
12
|
+
*
|
|
13
|
+
* The index is derived from the click position, using the same logic as the
|
|
14
|
+
* axis interaction (tooltip, highlight, `onAxisClick`). The callback is not
|
|
15
|
+
* fired when the click position cannot be associated with a data point.
|
|
16
|
+
*/
|
|
17
|
+
export function useLineItemClickHandler(onItemClick) {
|
|
18
|
+
const chartsLayerContainerRef = useChartsLayerContainerRef();
|
|
19
|
+
const {
|
|
20
|
+
xAxis: xAxes,
|
|
21
|
+
xAxisIds
|
|
22
|
+
} = useXAxes();
|
|
23
|
+
const seriesData = useLineSeriesContext();
|
|
24
|
+
const defaultXAxisId = xAxisIds[0];
|
|
25
|
+
return React.useMemo(() => {
|
|
26
|
+
if (!onItemClick) {
|
|
27
|
+
return undefined;
|
|
28
|
+
}
|
|
29
|
+
return (event, seriesId) => {
|
|
30
|
+
const element = chartsLayerContainerRef.current;
|
|
31
|
+
const xAxisId = seriesData?.series[seriesId]?.xAxisId ?? defaultXAxisId;
|
|
32
|
+
const xAxis = xAxisId === undefined ? undefined : xAxes[xAxisId];
|
|
33
|
+
if (element === null || xAxis === undefined) {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
const point = getChartPoint(element, event);
|
|
37
|
+
const dataIndex = getAxisIndex(xAxis, point.x);
|
|
38
|
+
if (dataIndex === -1) {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
onItemClick(event, {
|
|
42
|
+
type: 'line',
|
|
43
|
+
seriesId,
|
|
44
|
+
dataIndex
|
|
45
|
+
});
|
|
46
|
+
};
|
|
47
|
+
}, [onItemClick, chartsLayerContainerRef, seriesData, defaultXAxisId, xAxes]);
|
|
48
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
+
import type { WithDataAttributes } from '@mui/utils/types';
|
|
2
3
|
import type { ComputedPieRadius, DefaultizedPieSeriesType } from "../models/seriesType/pie.mjs";
|
|
3
4
|
import type { PieArcLabelProps } from "./PieArcLabel.mjs";
|
|
4
5
|
import type { PieArcLabelPropsOverrides } from "../models/chartsSlotsComponentsProps.mjs";
|
|
@@ -6,7 +7,7 @@ export interface PieArcLabelPlotSlots {
|
|
|
6
7
|
pieArcLabel?: React.JSXElementConstructor<PieArcLabelProps & PieArcLabelPropsOverrides>;
|
|
7
8
|
}
|
|
8
9
|
export interface PieArcLabelPlotSlotProps {
|
|
9
|
-
pieArcLabel?: Partial<PieArcLabelProps> & PieArcLabelPropsOverrides
|
|
10
|
+
pieArcLabel?: WithDataAttributes<Partial<PieArcLabelProps> & PieArcLabelPropsOverrides>;
|
|
10
11
|
}
|
|
11
12
|
export interface PieArcLabelPlotProps extends Pick<DefaultizedPieSeriesType, 'data' | 'faded' | 'highlighted' | 'cornerRadius' | 'paddingAngle' | 'arcLabel' | 'arcLabelMinAngle'>, ComputedPieRadius {
|
|
12
13
|
/**
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
+
import type { WithDataAttributes } from '@mui/utils/types';
|
|
2
3
|
import type { ComputedPieRadius, DefaultizedPieSeriesType } from "../models/seriesType/pie.js";
|
|
3
4
|
import type { PieArcLabelProps } from "./PieArcLabel.js";
|
|
4
5
|
import type { PieArcLabelPropsOverrides } from "../models/chartsSlotsComponentsProps.js";
|
|
@@ -6,7 +7,7 @@ export interface PieArcLabelPlotSlots {
|
|
|
6
7
|
pieArcLabel?: React.JSXElementConstructor<PieArcLabelProps & PieArcLabelPropsOverrides>;
|
|
7
8
|
}
|
|
8
9
|
export interface PieArcLabelPlotSlotProps {
|
|
9
|
-
pieArcLabel?: Partial<PieArcLabelProps> & PieArcLabelPropsOverrides
|
|
10
|
+
pieArcLabel?: WithDataAttributes<Partial<PieArcLabelProps> & PieArcLabelPropsOverrides>;
|
|
10
11
|
}
|
|
11
12
|
export interface PieArcLabelPlotProps extends Pick<DefaultizedPieSeriesType, 'data' | 'faded' | 'highlighted' | 'cornerRadius' | 'paddingAngle' | 'arcLabel' | 'arcLabelMinAngle'>, ComputedPieRadius {
|
|
12
13
|
/**
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
+
import type { WithDataAttributes } from '@mui/utils/types';
|
|
2
3
|
import type { PieArcProps } from "./PieArc.mjs";
|
|
3
4
|
import type { ComputedPieRadius, DefaultizedPieSeriesType, DefaultizedPieValueType, PieItemIdentifier } from "../models/seriesType/pie.mjs";
|
|
4
5
|
import type { PieArcPropsOverrides } from "../models/chartsSlotsComponentsProps.mjs";
|
|
@@ -6,7 +7,7 @@ export interface PieArcPlotSlots {
|
|
|
6
7
|
pieArc?: React.JSXElementConstructor<PieArcProps & PieArcPropsOverrides>;
|
|
7
8
|
}
|
|
8
9
|
export interface PieArcPlotSlotProps {
|
|
9
|
-
pieArc?: Partial<PieArcProps> & PieArcPropsOverrides
|
|
10
|
+
pieArc?: WithDataAttributes<Partial<PieArcProps> & PieArcPropsOverrides>;
|
|
10
11
|
}
|
|
11
12
|
export interface PieArcPlotProps extends Pick<DefaultizedPieSeriesType, 'data' | 'faded' | 'highlighted' | 'cornerRadius' | 'paddingAngle'>, ComputedPieRadius {
|
|
12
13
|
/**
|
package/PieChart/PieArcPlot.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
+
import type { WithDataAttributes } from '@mui/utils/types';
|
|
2
3
|
import type { PieArcProps } from "./PieArc.js";
|
|
3
4
|
import type { ComputedPieRadius, DefaultizedPieSeriesType, DefaultizedPieValueType, PieItemIdentifier } from "../models/seriesType/pie.js";
|
|
4
5
|
import type { PieArcPropsOverrides } from "../models/chartsSlotsComponentsProps.js";
|
|
@@ -6,7 +7,7 @@ export interface PieArcPlotSlots {
|
|
|
6
7
|
pieArc?: React.JSXElementConstructor<PieArcProps & PieArcPropsOverrides>;
|
|
7
8
|
}
|
|
8
9
|
export interface PieArcPlotSlotProps {
|
|
9
|
-
pieArc?: Partial<PieArcProps> & PieArcPropsOverrides
|
|
10
|
+
pieArc?: WithDataAttributes<Partial<PieArcProps> & PieArcPropsOverrides>;
|
|
10
11
|
}
|
|
11
12
|
export interface PieArcPlotProps extends Pick<DefaultizedPieSeriesType, 'data' | 'faded' | 'highlighted' | 'cornerRadius' | 'paddingAngle'>, ComputedPieRadius {
|
|
12
13
|
/**
|
|
@@ -30,4 +30,4 @@ export declare const pieClasses: PieClasses;
|
|
|
30
30
|
export declare const useUtilityClasses: (options?: {
|
|
31
31
|
classes?: Partial<PieClasses>;
|
|
32
32
|
skipAnimation?: boolean;
|
|
33
|
-
}) => Record<"
|
|
33
|
+
}) => Record<"arc" | "arcLabel" | "focusIndicator" | "root" | "series" | "seriesLabels", string>;
|
package/PieChart/pieClasses.d.ts
CHANGED
|
@@ -30,4 +30,4 @@ export declare const pieClasses: PieClasses;
|
|
|
30
30
|
export declare const useUtilityClasses: (options?: {
|
|
31
31
|
classes?: Partial<PieClasses>;
|
|
32
32
|
skipAnimation?: boolean;
|
|
33
|
-
}) => Record<"
|
|
33
|
+
}) => Record<"arc" | "arcLabel" | "focusIndicator" | "root" | "series" | "seriesLabels", string>;
|
|
@@ -7,14 +7,14 @@ interface GetLabelAttributesParams extends Required<Pick<RadarAxisProps, 'labelO
|
|
|
7
7
|
export declare function getLabelAttributes(params: GetLabelAttributesParams): {
|
|
8
8
|
x: number;
|
|
9
9
|
y: number;
|
|
10
|
-
textAnchor: "
|
|
11
|
-
dominantBaseline: "
|
|
10
|
+
textAnchor: "end" | "inherit" | "middle" | "start" | undefined;
|
|
11
|
+
dominantBaseline: "alphabetic" | "auto" | "central" | "hanging" | "ideographic" | "inherit" | "mathematical" | "middle" | "no-change" | "reset-size" | "text-after-edge" | "text-before-edge" | "use-script" | undefined;
|
|
12
12
|
transform?: undefined;
|
|
13
13
|
} | {
|
|
14
14
|
x: number;
|
|
15
15
|
y: number;
|
|
16
|
-
textAnchor: "
|
|
17
|
-
dominantBaseline: "
|
|
16
|
+
textAnchor: "end" | "inherit" | "middle" | "start" | undefined;
|
|
17
|
+
dominantBaseline: "alphabetic" | "auto" | "central" | "hanging" | "ideographic" | "inherit" | "mathematical" | "middle" | "no-change" | "reset-size" | "text-after-edge" | "text-before-edge" | "use-script" | undefined;
|
|
18
18
|
transform: string;
|
|
19
19
|
};
|
|
20
20
|
export {};
|
|
@@ -7,14 +7,14 @@ interface GetLabelAttributesParams extends Required<Pick<RadarAxisProps, 'labelO
|
|
|
7
7
|
export declare function getLabelAttributes(params: GetLabelAttributesParams): {
|
|
8
8
|
x: number;
|
|
9
9
|
y: number;
|
|
10
|
-
textAnchor: "
|
|
11
|
-
dominantBaseline: "
|
|
10
|
+
textAnchor: "end" | "inherit" | "middle" | "start" | undefined;
|
|
11
|
+
dominantBaseline: "alphabetic" | "auto" | "central" | "hanging" | "ideographic" | "inherit" | "mathematical" | "middle" | "no-change" | "reset-size" | "text-after-edge" | "text-before-edge" | "use-script" | undefined;
|
|
12
12
|
transform?: undefined;
|
|
13
13
|
} | {
|
|
14
14
|
x: number;
|
|
15
15
|
y: number;
|
|
16
|
-
textAnchor: "
|
|
17
|
-
dominantBaseline: "
|
|
16
|
+
textAnchor: "end" | "inherit" | "middle" | "start" | undefined;
|
|
17
|
+
dominantBaseline: "alphabetic" | "auto" | "central" | "hanging" | "ideographic" | "inherit" | "mathematical" | "middle" | "no-change" | "reset-size" | "text-after-edge" | "text-before-edge" | "use-script" | undefined;
|
|
18
18
|
transform: string;
|
|
19
19
|
};
|
|
20
20
|
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import type { SeriesItemIdentifierWithData } from "../../models/seriesType/index.mjs";
|
|
3
|
-
export declare const useInteractionAllItemProps: (data: SeriesItemIdentifierWithData<
|
|
3
|
+
export declare const useInteractionAllItemProps: (data: SeriesItemIdentifierWithData<'radar'>[], skip?: boolean) => {
|
|
4
4
|
onPointerEnter?: () => void;
|
|
5
5
|
onPointerLeave?: () => void;
|
|
6
6
|
onPointerDown?: (event: React.PointerEvent) => void;
|