@mui/x-charts 8.15.0 → 8.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/BarChart/BarChart.plugins.d.ts +1 -1
- package/BarChart/BarChart.plugins.js +1 -1
- package/BarChart/seriesConfig/getSeriesWithDefaultValues.js +3 -3
- package/BarChart/seriesConfig/index.js +2 -0
- package/BarChart/seriesConfig/tooltipPosition.d.ts +3 -0
- package/BarChart/seriesConfig/tooltipPosition.js +67 -0
- package/BarChart/useBarPlotData.d.ts +17 -2
- package/BarChart/useBarPlotData.js +59 -34
- package/CHANGELOG.md +100 -0
- package/ChartsAxisHighlight/ChartsXAxisHighlight.js +2 -1
- package/ChartsAxisHighlight/ChartsYAxisHighlight.js +2 -1
- package/ChartsTooltip/ChartsTooltip.js +9 -0
- package/ChartsTooltip/ChartsTooltipContainer.d.ts +9 -0
- package/ChartsTooltip/ChartsTooltipContainer.js +48 -22
- package/ChartsTooltip/useItemTooltip.js +7 -14
- package/ChartsWrapper/ChartsWrapper.js +2 -1
- package/ChartsXAxis/useAxisTicksProps.d.ts +81 -81
- package/ChartsYAxis/useAxisTicksProps.d.ts +81 -81
- package/LineChart/LineChart.plugins.d.ts +1 -1
- package/LineChart/LineChart.plugins.js +1 -1
- package/LineChart/seriesConfig/getSeriesWithDefaultValues.js +3 -3
- package/LineChart/seriesConfig/index.js +2 -0
- package/LineChart/seriesConfig/tooltipPosition.d.ts +3 -0
- package/LineChart/seriesConfig/tooltipPosition.js +33 -0
- package/PieChart/seriesConfig/getSeriesWithDefaultValues.js +5 -6
- package/PieChart/seriesConfig/index.js +2 -0
- package/PieChart/seriesConfig/seriesProcessor.js +2 -1
- package/PieChart/seriesConfig/tooltipPosition.d.ts +3 -0
- package/PieChart/seriesConfig/tooltipPosition.js +75 -0
- package/RadarChart/RadarChart.plugins.d.ts +2 -2
- package/RadarChart/RadarChart.plugins.js +1 -1
- package/RadarChart/RadarSeriesPlot/useRadarSeriesData.d.ts +1 -1
- package/RadarChart/seriesConfig/getSeriesWithDefaultValues.js +3 -3
- package/ScatterChart/ScatterChart.plugins.d.ts +1 -1
- package/ScatterChart/ScatterChart.plugins.js +1 -1
- package/ScatterChart/seriesConfig/getSeriesWithDefaultValues.js +3 -3
- package/ScatterChart/seriesConfig/index.js +2 -0
- package/ScatterChart/seriesConfig/tooltipPosition.d.ts +3 -0
- package/ScatterChart/seriesConfig/tooltipPosition.js +33 -0
- package/context/ChartProvider/ChartProvider.js +1 -1
- package/esm/BarChart/BarChart.plugins.d.ts +1 -1
- package/esm/BarChart/BarChart.plugins.js +1 -1
- package/esm/BarChart/seriesConfig/getSeriesWithDefaultValues.js +3 -3
- package/esm/BarChart/seriesConfig/index.js +2 -0
- package/esm/BarChart/seriesConfig/tooltipPosition.d.ts +3 -0
- package/esm/BarChart/seriesConfig/tooltipPosition.js +61 -0
- package/esm/BarChart/useBarPlotData.d.ts +17 -2
- package/esm/BarChart/useBarPlotData.js +58 -34
- package/esm/ChartsAxisHighlight/ChartsXAxisHighlight.js +1 -2
- package/esm/ChartsAxisHighlight/ChartsYAxisHighlight.js +1 -2
- package/esm/ChartsTooltip/ChartsTooltip.js +9 -0
- package/esm/ChartsTooltip/ChartsTooltipContainer.d.ts +9 -0
- package/esm/ChartsTooltip/ChartsTooltipContainer.js +49 -23
- package/esm/ChartsTooltip/useItemTooltip.js +9 -16
- package/esm/ChartsWrapper/ChartsWrapper.js +2 -1
- package/esm/ChartsXAxis/useAxisTicksProps.d.ts +81 -81
- package/esm/ChartsYAxis/useAxisTicksProps.d.ts +81 -81
- package/esm/LineChart/LineChart.plugins.d.ts +1 -1
- package/esm/LineChart/LineChart.plugins.js +1 -1
- package/esm/LineChart/seriesConfig/getSeriesWithDefaultValues.js +3 -3
- package/esm/LineChart/seriesConfig/index.js +2 -0
- package/esm/LineChart/seriesConfig/tooltipPosition.d.ts +3 -0
- package/esm/LineChart/seriesConfig/tooltipPosition.js +27 -0
- package/esm/PieChart/seriesConfig/getSeriesWithDefaultValues.js +5 -6
- package/esm/PieChart/seriesConfig/index.js +2 -0
- package/esm/PieChart/seriesConfig/seriesProcessor.js +2 -1
- package/esm/PieChart/seriesConfig/tooltipPosition.d.ts +3 -0
- package/esm/PieChart/seriesConfig/tooltipPosition.js +69 -0
- package/esm/RadarChart/RadarChart.plugins.d.ts +2 -2
- package/esm/RadarChart/RadarChart.plugins.js +1 -1
- package/esm/RadarChart/RadarSeriesPlot/useRadarSeriesData.d.ts +1 -1
- package/esm/RadarChart/seriesConfig/getSeriesWithDefaultValues.js +3 -3
- package/esm/ScatterChart/ScatterChart.plugins.d.ts +1 -1
- package/esm/ScatterChart/ScatterChart.plugins.js +1 -1
- package/esm/ScatterChart/seriesConfig/getSeriesWithDefaultValues.js +3 -3
- package/esm/ScatterChart/seriesConfig/index.js +2 -0
- package/esm/ScatterChart/seriesConfig/tooltipPosition.d.ts +3 -0
- package/esm/ScatterChart/seriesConfig/tooltipPosition.js +27 -0
- package/esm/context/ChartProvider/ChartProvider.js +1 -1
- package/esm/hooks/useFocusedItem.d.ts +1 -1
- package/esm/hooks/useInteractionItemProps.js +6 -2
- package/esm/index.js +1 -1
- package/esm/internals/configInit.d.ts +1 -1
- package/esm/internals/getScale.js +1 -1
- package/esm/internals/index.d.ts +2 -1
- package/esm/internals/index.js +2 -1
- package/esm/internals/isCartesian.d.ts +3 -2
- package/esm/internals/isCartesian.js +3 -0
- package/esm/internals/plugins/allPlugins.d.ts +2 -2
- package/esm/internals/plugins/allPlugins.js +1 -1
- package/esm/internals/plugins/corePlugins/useChartInteractionListener/useChartInteractionListener.js +4 -1
- package/esm/internals/plugins/corePlugins/useChartInteractionListener/useChartInteractionListener.types.d.ts +5 -3
- package/esm/internals/plugins/featurePlugins/useChartBrush/useChartBrush.js +20 -3
- package/esm/internals/plugins/featurePlugins/useChartBrush/useChartBrush.selectors.js +3 -3
- package/esm/internals/plugins/featurePlugins/useChartBrush/useChartBrush.types.d.ts +11 -2
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisScale.js +1 -1
- package/esm/internals/plugins/featurePlugins/useChartClosestPoint/useChartClosestPoint.js +2 -0
- package/esm/internals/plugins/featurePlugins/useChartInteraction/index.d.ts +1 -0
- package/esm/internals/plugins/featurePlugins/useChartInteraction/index.js +2 -1
- package/esm/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.js +2 -1
- package/esm/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.selectors.d.ts +1 -1
- package/esm/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.types.d.ts +5 -1
- package/esm/internals/plugins/featurePlugins/useChartInteraction/useChartTooltip.selectors.d.ts +14 -0
- package/esm/internals/plugins/featurePlugins/useChartInteraction/useChartTooltip.selectors.js +40 -0
- package/esm/internals/plugins/featurePlugins/useChartKeyboardNavigation/isFocusableSeriesType.d.ts +3 -0
- package/esm/internals/plugins/featurePlugins/useChartKeyboardNavigation/isFocusableSeriesType.js +4 -0
- package/esm/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.helpers.d.ts +5 -4
- package/esm/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.helpers.js +8 -4
- package/esm/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.selectors.d.ts +21 -3
- package/esm/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.selectors.js +13 -6
- package/esm/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.types.d.ts +4 -3
- package/esm/internals/plugins/featurePlugins/useChartPolarAxis/computeAxisValue.js +1 -1
- package/esm/internals/plugins/models/seriesConfig/index.d.ts +1 -0
- package/esm/internals/plugins/models/seriesConfig/index.js +1 -0
- package/esm/internals/plugins/models/seriesConfig/seriesConfig.types.d.ts +2 -0
- package/esm/internals/plugins/models/seriesConfig/tooltipItemPositionGetter.types.d.ts +24 -0
- package/esm/internals/plugins/models/seriesConfig/tooltipItemPositionGetter.types.js +1 -0
- package/esm/internals/scales/index.d.ts +3 -0
- package/esm/internals/scales/index.js +3 -0
- package/esm/internals/scales/scaleBand.d.ts +25 -0
- package/esm/internals/scales/scaleBand.js +159 -0
- package/esm/internals/scales/scalePoint.d.ts +25 -0
- package/esm/internals/scales/scalePoint.js +41 -0
- package/esm/internals/scales/scaleSymlog.d.ts +38 -0
- package/esm/internals/{symlogScale.js → scales/scaleSymlog.js} +40 -2
- package/esm/models/seriesType/common.d.ts +3 -2
- package/hooks/useFocusedItem.d.ts +1 -1
- package/hooks/useInteractionItemProps.js +6 -2
- package/index.js +1 -1
- package/internals/configInit.d.ts +1 -1
- package/internals/getScale.js +2 -2
- package/internals/index.d.ts +2 -1
- package/internals/index.js +12 -0
- package/internals/isCartesian.d.ts +3 -2
- package/internals/isCartesian.js +4 -0
- package/internals/plugins/allPlugins.d.ts +2 -2
- package/internals/plugins/allPlugins.js +1 -1
- package/internals/plugins/corePlugins/useChartInteractionListener/useChartInteractionListener.js +4 -1
- package/internals/plugins/corePlugins/useChartInteractionListener/useChartInteractionListener.types.d.ts +5 -3
- package/internals/plugins/featurePlugins/useChartBrush/useChartBrush.js +20 -3
- package/internals/plugins/featurePlugins/useChartBrush/useChartBrush.selectors.js +3 -3
- package/internals/plugins/featurePlugins/useChartBrush/useChartBrush.types.d.ts +11 -2
- package/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisScale.js +3 -3
- package/internals/plugins/featurePlugins/useChartClosestPoint/useChartClosestPoint.js +2 -0
- package/internals/plugins/featurePlugins/useChartInteraction/index.d.ts +1 -0
- package/internals/plugins/featurePlugins/useChartInteraction/index.js +12 -0
- package/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.js +2 -1
- package/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.selectors.d.ts +1 -1
- package/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.types.d.ts +5 -1
- package/internals/plugins/featurePlugins/useChartInteraction/useChartTooltip.selectors.d.ts +14 -0
- package/internals/plugins/featurePlugins/useChartInteraction/useChartTooltip.selectors.js +46 -0
- package/internals/plugins/featurePlugins/useChartKeyboardNavigation/isFocusableSeriesType.d.ts +3 -0
- package/internals/plugins/featurePlugins/useChartKeyboardNavigation/isFocusableSeriesType.js +10 -0
- package/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.helpers.d.ts +5 -4
- package/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.helpers.js +7 -4
- package/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.selectors.d.ts +21 -3
- package/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.selectors.js +14 -7
- package/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.types.d.ts +4 -3
- package/internals/plugins/featurePlugins/useChartPolarAxis/computeAxisValue.js +3 -3
- package/internals/plugins/models/seriesConfig/index.d.ts +1 -0
- package/internals/plugins/models/seriesConfig/index.js +11 -0
- package/internals/plugins/models/seriesConfig/seriesConfig.types.d.ts +2 -0
- package/internals/plugins/models/seriesConfig/tooltipItemPositionGetter.types.d.ts +24 -0
- package/internals/plugins/models/seriesConfig/tooltipItemPositionGetter.types.js +5 -0
- package/internals/scales/index.d.ts +3 -0
- package/internals/scales/index.js +38 -0
- package/internals/scales/scaleBand.d.ts +25 -0
- package/internals/scales/scaleBand.js +167 -0
- package/internals/scales/scalePoint.d.ts +25 -0
- package/internals/scales/scalePoint.js +46 -0
- package/internals/scales/scaleSymlog.d.ts +38 -0
- package/internals/{symlogScale.js → scales/scaleSymlog.js} +39 -2
- package/models/seriesType/common.d.ts +3 -2
- package/package.json +4 -4
- package/esm/internals/symlogScale.d.ts +0 -2
- package/internals/symlogScale.d.ts +0 -2
|
@@ -5,5 +5,5 @@ import { UseChartHighlightSignature } from "../internals/plugins/featurePlugins/
|
|
|
5
5
|
import { UseChartKeyboardNavigationSignature } from "../internals/plugins/featurePlugins/useChartKeyboardNavigation/index.js";
|
|
6
6
|
import { ConvertSignaturesIntoPlugins } from "../internals/plugins/models/helpers.js";
|
|
7
7
|
import { UseChartBrushSignature } from "../internals/plugins/featurePlugins/useChartBrush/index.js";
|
|
8
|
-
export type LineChartPluginSignatures = [UseChartZAxisSignature, UseChartBrushSignature, UseChartCartesianAxisSignature<'line'>,
|
|
8
|
+
export type LineChartPluginSignatures = [UseChartZAxisSignature, UseChartBrushSignature, UseChartInteractionSignature, UseChartCartesianAxisSignature<'line'>, UseChartHighlightSignature, UseChartKeyboardNavigationSignature];
|
|
9
9
|
export declare const LINE_CHART_PLUGINS: ConvertSignaturesIntoPlugins<LineChartPluginSignatures>;
|
|
@@ -4,4 +4,4 @@ import { useChartInteraction } from "../internals/plugins/featurePlugins/useChar
|
|
|
4
4
|
import { useChartHighlight } from "../internals/plugins/featurePlugins/useChartHighlight/index.js";
|
|
5
5
|
import { useChartKeyboardNavigation } from "../internals/plugins/featurePlugins/useChartKeyboardNavigation/index.js";
|
|
6
6
|
import { useChartBrush } from "../internals/plugins/featurePlugins/useChartBrush/index.js";
|
|
7
|
-
export const LINE_CHART_PLUGINS = [useChartZAxis, useChartBrush,
|
|
7
|
+
export const LINE_CHART_PLUGINS = [useChartZAxis, useChartBrush, useChartInteraction, useChartCartesianAxis, useChartHighlight, useChartKeyboardNavigation];
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
const getSeriesWithDefaultValues = (seriesData, seriesIndex, colors) => {
|
|
3
|
-
return _extends({
|
|
3
|
+
return _extends({}, seriesData, {
|
|
4
4
|
id: seriesData.id ?? `auto-generated-id-${seriesIndex}`,
|
|
5
|
-
color: colors[seriesIndex % colors.length]
|
|
6
|
-
}
|
|
5
|
+
color: seriesData.color ?? colors[seriesIndex % colors.length]
|
|
6
|
+
});
|
|
7
7
|
};
|
|
8
8
|
export default getSeriesWithDefaultValues;
|
|
@@ -4,11 +4,13 @@ import getColor from "./getColor.js";
|
|
|
4
4
|
import legendGetter from "./legend.js";
|
|
5
5
|
import tooltipGetter, { axisTooltipGetter } from "./tooltip.js";
|
|
6
6
|
import getSeriesWithDefaultValues from "./getSeriesWithDefaultValues.js";
|
|
7
|
+
import tooltipItemPositionGetter from "./tooltipPosition.js";
|
|
7
8
|
export const seriesConfig = {
|
|
8
9
|
colorProcessor: getColor,
|
|
9
10
|
seriesProcessor,
|
|
10
11
|
legendGetter,
|
|
11
12
|
tooltipGetter,
|
|
13
|
+
tooltipItemPositionGetter,
|
|
12
14
|
axisTooltipGetter,
|
|
13
15
|
xExtremumGetter: getExtremumX,
|
|
14
16
|
yExtremumGetter: getExtremumY,
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
const tooltipItemPositionGetter = params => {
|
|
2
|
+
const {
|
|
3
|
+
series,
|
|
4
|
+
identifier,
|
|
5
|
+
axesConfig
|
|
6
|
+
} = params;
|
|
7
|
+
if (!identifier || identifier.dataIndex === undefined) {
|
|
8
|
+
return null;
|
|
9
|
+
}
|
|
10
|
+
const itemSeries = series.line?.series[identifier.seriesId];
|
|
11
|
+
if (itemSeries == null) {
|
|
12
|
+
return null;
|
|
13
|
+
}
|
|
14
|
+
if (axesConfig.x === undefined || axesConfig.y === undefined) {
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
const xValue = axesConfig.x.data?.[identifier.dataIndex];
|
|
18
|
+
const yValue = itemSeries.data[identifier.dataIndex];
|
|
19
|
+
if (xValue == null || yValue == null) {
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
return {
|
|
23
|
+
x: axesConfig.x.scale(xValue),
|
|
24
|
+
y: axesConfig.y.scale(yValue)
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
export default tooltipItemPositionGetter;
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
const getSeriesWithDefaultValues = (seriesData, seriesIndex, colors) => {
|
|
3
|
-
return _extends({
|
|
4
|
-
id: seriesData.id ?? `auto-generated-id-${seriesIndex}
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}, d))
|
|
3
|
+
return _extends({}, seriesData, {
|
|
4
|
+
id: seriesData.id ?? `auto-generated-id-${seriesIndex}`,
|
|
5
|
+
data: seriesData.data.map((d, index) => _extends({}, d, {
|
|
6
|
+
color: d.color ?? colors[index % colors.length]
|
|
7
|
+
}))
|
|
9
8
|
});
|
|
10
9
|
};
|
|
11
10
|
export default getSeriesWithDefaultValues;
|
|
@@ -3,10 +3,12 @@ import getColor from "./getColor.js";
|
|
|
3
3
|
import legendGetter from "./legend.js";
|
|
4
4
|
import tooltipGetter from "./tooltip.js";
|
|
5
5
|
import getSeriesWithDefaultValues from "./getSeriesWithDefaultValues.js";
|
|
6
|
+
import tooltipItemPositionGetter from "./tooltipPosition.js";
|
|
6
7
|
export const seriesConfig = {
|
|
7
8
|
colorProcessor: getColor,
|
|
8
9
|
seriesProcessor,
|
|
9
10
|
legendGetter,
|
|
10
11
|
tooltipGetter,
|
|
12
|
+
tooltipItemPositionGetter,
|
|
11
13
|
getSeriesWithDefaultValues
|
|
12
14
|
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import { pie as d3Pie } from '@mui/x-charts-vendor/d3-shape';
|
|
3
3
|
import { getLabel } from "../../internals/getLabel.js";
|
|
4
|
+
import { deg2rad } from "../../internals/angleConversion.js";
|
|
4
5
|
const getSortingComparator = (comparator = 'none') => {
|
|
5
6
|
if (typeof comparator === 'function') {
|
|
6
7
|
return comparator;
|
|
@@ -23,7 +24,7 @@ const seriesProcessor = params => {
|
|
|
23
24
|
} = params;
|
|
24
25
|
const defaultizedSeries = {};
|
|
25
26
|
seriesOrder.forEach(seriesId => {
|
|
26
|
-
const arcs = d3Pie().startAngle(
|
|
27
|
+
const arcs = d3Pie().startAngle(deg2rad(series[seriesId].startAngle ?? 0)).endAngle(deg2rad(series[seriesId].endAngle ?? 360)).padAngle(deg2rad(series[seriesId].paddingAngle ?? 0)).sortValues(getSortingComparator(series[seriesId].sortingValues ?? 'none'))(series[seriesId].data.map(piePoint => piePoint.value));
|
|
27
28
|
defaultizedSeries[seriesId] = _extends({
|
|
28
29
|
labelMarkType: 'circle',
|
|
29
30
|
valueFormatter: item => item.value.toLocaleString()
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { findMinMax } from "../../internals/findMinMax.js";
|
|
2
|
+
import { getPercentageValue } from "../../internals/getPercentageValue.js";
|
|
3
|
+
import { getPieCoordinates } from "../getPieCoordinates.js";
|
|
4
|
+
const tooltipItemPositionGetter = params => {
|
|
5
|
+
const {
|
|
6
|
+
series,
|
|
7
|
+
drawingArea,
|
|
8
|
+
identifier,
|
|
9
|
+
placement
|
|
10
|
+
} = params;
|
|
11
|
+
if (!identifier || identifier.dataIndex === undefined) {
|
|
12
|
+
return null;
|
|
13
|
+
}
|
|
14
|
+
const itemSeries = series.pie?.series[identifier.seriesId];
|
|
15
|
+
if (itemSeries == null) {
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
const {
|
|
19
|
+
cx,
|
|
20
|
+
cy,
|
|
21
|
+
availableRadius
|
|
22
|
+
} = getPieCoordinates({
|
|
23
|
+
cx: itemSeries.cx,
|
|
24
|
+
cy: itemSeries.cy
|
|
25
|
+
}, drawingArea);
|
|
26
|
+
const {
|
|
27
|
+
data,
|
|
28
|
+
innerRadius: baseInnerRadius = 0,
|
|
29
|
+
outerRadius: baseOuterRadius
|
|
30
|
+
} = itemSeries;
|
|
31
|
+
const innerRadius = Math.max(0, getPercentageValue(baseInnerRadius ?? 0, availableRadius));
|
|
32
|
+
const outerRadius = Math.max(0, getPercentageValue(baseOuterRadius ?? availableRadius, availableRadius));
|
|
33
|
+
const dataItem = data[identifier.dataIndex];
|
|
34
|
+
if (!dataItem) {
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// Compute the 4 corner points of the arc to get the bounding box.
|
|
39
|
+
const points = [[innerRadius, dataItem.startAngle], [innerRadius, dataItem.endAngle], [outerRadius, dataItem.startAngle], [outerRadius, dataItem.endAngle]].map(([radius, angle]) => ({
|
|
40
|
+
x: cx + radius * Math.sin(angle),
|
|
41
|
+
y: cy - radius * Math.cos(angle)
|
|
42
|
+
}));
|
|
43
|
+
const [x0, x1] = findMinMax(points.map(p => p.x));
|
|
44
|
+
const [y0, y1] = findMinMax(points.map(p => p.y));
|
|
45
|
+
switch (placement) {
|
|
46
|
+
case 'bottom':
|
|
47
|
+
return {
|
|
48
|
+
x: (x1 + x0) / 2,
|
|
49
|
+
y: y1
|
|
50
|
+
};
|
|
51
|
+
case 'left':
|
|
52
|
+
return {
|
|
53
|
+
x: x0,
|
|
54
|
+
y: (y1 + y0) / 2
|
|
55
|
+
};
|
|
56
|
+
case 'right':
|
|
57
|
+
return {
|
|
58
|
+
x: x1,
|
|
59
|
+
y: (y1 + y0) / 2
|
|
60
|
+
};
|
|
61
|
+
case 'top':
|
|
62
|
+
default:
|
|
63
|
+
return {
|
|
64
|
+
x: (x1 + x0) / 2,
|
|
65
|
+
y: y0
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
export default tooltipItemPositionGetter;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { UseChartPolarAxisSignature } from "../internals/plugins/featurePlugins/useChartPolarAxis/index.js";
|
|
2
2
|
import { UseChartInteractionSignature } from "../internals/plugins/featurePlugins/useChartInteraction/index.js";
|
|
3
3
|
import { UseChartHighlightSignature } from "../internals/plugins/featurePlugins/useChartHighlight/index.js";
|
|
4
|
-
export declare const RADAR_PLUGINS: readonly [import("../internals/index.js").ChartPlugin<
|
|
5
|
-
export type RadarChartPluginSignatures = [
|
|
4
|
+
export declare const RADAR_PLUGINS: readonly [import("../internals/index.js").ChartPlugin<UseChartInteractionSignature>, import("../internals/index.js").ChartPlugin<UseChartPolarAxisSignature<any>>, import("../internals/index.js").ChartPlugin<UseChartHighlightSignature>];
|
|
5
|
+
export type RadarChartPluginSignatures = [UseChartInteractionSignature, UseChartPolarAxisSignature, UseChartHighlightSignature];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { useChartPolarAxis } from "../internals/plugins/featurePlugins/useChartPolarAxis/index.js";
|
|
2
2
|
import { useChartInteraction } from "../internals/plugins/featurePlugins/useChartInteraction/index.js";
|
|
3
3
|
import { useChartHighlight } from "../internals/plugins/featurePlugins/useChartHighlight/index.js";
|
|
4
|
-
export const RADAR_PLUGINS = [
|
|
4
|
+
export const RADAR_PLUGINS = [useChartInteraction, useChartPolarAxis, useChartHighlight];
|
|
@@ -17,8 +17,8 @@ export declare function useRadarSeriesData(querySeriesId?: SeriesId): {
|
|
|
17
17
|
}[];
|
|
18
18
|
type: "radar";
|
|
19
19
|
label?: string | ((location: "tooltip" | "legend") => string) | undefined;
|
|
20
|
-
highlightScope?: import("../../index.js").HighlightScope | undefined;
|
|
21
20
|
labelMarkType?: import("../../internals/index.js").ChartsLabelMarkType | undefined;
|
|
21
|
+
highlightScope?: import("../../index.js").HighlightScope | undefined;
|
|
22
22
|
hideMark?: boolean | undefined;
|
|
23
23
|
fillArea?: boolean | undefined;
|
|
24
24
|
data: number[];
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
const getSeriesWithDefaultValues = (seriesData, seriesIndex, colors) => {
|
|
3
|
-
return _extends({
|
|
3
|
+
return _extends({}, seriesData, {
|
|
4
4
|
id: seriesData.id ?? `auto-generated-id-${seriesIndex}`,
|
|
5
|
-
color: colors[seriesIndex % colors.length]
|
|
6
|
-
}
|
|
5
|
+
color: seriesData.color ?? colors[seriesIndex % colors.length]
|
|
6
|
+
});
|
|
7
7
|
};
|
|
8
8
|
export default getSeriesWithDefaultValues;
|
|
@@ -6,5 +6,5 @@ import { ConvertSignaturesIntoPlugins } from "../internals/plugins/models/helper
|
|
|
6
6
|
import { UseChartClosestPointSignature } from "../internals/plugins/featurePlugins/useChartClosestPoint/index.js";
|
|
7
7
|
import { UseChartKeyboardNavigationSignature } from "../internals/plugins/featurePlugins/useChartKeyboardNavigation/index.js";
|
|
8
8
|
import { UseChartBrushSignature } from "../internals/plugins/featurePlugins/useChartBrush/index.js";
|
|
9
|
-
export type ScatterChartPluginSignatures = [UseChartZAxisSignature, UseChartBrushSignature, UseChartCartesianAxisSignature<'scatter'>,
|
|
9
|
+
export type ScatterChartPluginSignatures = [UseChartZAxisSignature, UseChartBrushSignature, UseChartInteractionSignature, UseChartCartesianAxisSignature<'scatter'>, UseChartHighlightSignature, UseChartClosestPointSignature, UseChartKeyboardNavigationSignature];
|
|
10
10
|
export declare const SCATTER_CHART_PLUGINS: ConvertSignaturesIntoPlugins<ScatterChartPluginSignatures>;
|
|
@@ -5,4 +5,4 @@ import { useChartHighlight } from "../internals/plugins/featurePlugins/useChartH
|
|
|
5
5
|
import { useChartClosestPoint } from "../internals/plugins/featurePlugins/useChartClosestPoint/index.js";
|
|
6
6
|
import { useChartKeyboardNavigation } from "../internals/plugins/featurePlugins/useChartKeyboardNavigation/index.js";
|
|
7
7
|
import { useChartBrush } from "../internals/plugins/featurePlugins/useChartBrush/index.js";
|
|
8
|
-
export const SCATTER_CHART_PLUGINS = [useChartZAxis, useChartBrush,
|
|
8
|
+
export const SCATTER_CHART_PLUGINS = [useChartZAxis, useChartBrush, useChartInteraction, useChartCartesianAxis, useChartHighlight, useChartClosestPoint, useChartKeyboardNavigation];
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
const getSeriesWithDefaultValues = (seriesData, seriesIndex, colors) => {
|
|
3
|
-
return _extends({
|
|
3
|
+
return _extends({}, seriesData, {
|
|
4
4
|
id: seriesData.id ?? `auto-generated-id-${seriesIndex}`,
|
|
5
|
-
color: colors[seriesIndex % colors.length]
|
|
6
|
-
}
|
|
5
|
+
color: seriesData.color ?? colors[seriesIndex % colors.length]
|
|
6
|
+
});
|
|
7
7
|
};
|
|
8
8
|
export default getSeriesWithDefaultValues;
|
|
@@ -4,11 +4,13 @@ import getColor from "./getColor.js";
|
|
|
4
4
|
import legendGetter from "./legend.js";
|
|
5
5
|
import tooltipGetter from "./tooltip.js";
|
|
6
6
|
import getSeriesWithDefaultValues from "./getSeriesWithDefaultValues.js";
|
|
7
|
+
import tooltipItemPositionGetter from "./tooltipPosition.js";
|
|
7
8
|
export const seriesConfig = {
|
|
8
9
|
seriesProcessor,
|
|
9
10
|
colorProcessor: getColor,
|
|
10
11
|
legendGetter,
|
|
11
12
|
tooltipGetter,
|
|
13
|
+
tooltipItemPositionGetter,
|
|
12
14
|
xExtremumGetter: getExtremumX,
|
|
13
15
|
yExtremumGetter: getExtremumY,
|
|
14
16
|
getSeriesWithDefaultValues
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
const tooltipItemPositionGetter = params => {
|
|
2
|
+
const {
|
|
3
|
+
series,
|
|
4
|
+
identifier,
|
|
5
|
+
axesConfig
|
|
6
|
+
} = params;
|
|
7
|
+
if (!identifier || identifier.dataIndex === undefined) {
|
|
8
|
+
return null;
|
|
9
|
+
}
|
|
10
|
+
const itemSeries = series.scatter?.series[identifier.seriesId];
|
|
11
|
+
if (itemSeries == null) {
|
|
12
|
+
return null;
|
|
13
|
+
}
|
|
14
|
+
if (axesConfig.x === undefined || axesConfig.y === undefined) {
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
const xValue = itemSeries.data?.[identifier.dataIndex].x;
|
|
18
|
+
const yValue = itemSeries.data?.[identifier.dataIndex].y;
|
|
19
|
+
if (xValue == null || yValue == null) {
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
return {
|
|
23
|
+
x: axesConfig.x.scale(xValue),
|
|
24
|
+
y: axesConfig.y.scale(yValue)
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
export default tooltipItemPositionGetter;
|
|
@@ -21,7 +21,7 @@ export const defaultSeriesConfig = {
|
|
|
21
21
|
|
|
22
22
|
// For consistency with the v7, the cartesian axes are set by default.
|
|
23
23
|
// To remove them, you can provide a `plugins` props.
|
|
24
|
-
const defaultPlugins = [useChartZAxis,
|
|
24
|
+
const defaultPlugins = [useChartZAxis, useChartInteraction, useChartCartesianAxis, useChartHighlight];
|
|
25
25
|
function ChartProvider(props) {
|
|
26
26
|
const {
|
|
27
27
|
children,
|
|
@@ -9,7 +9,7 @@ export type FocusedItemData = {
|
|
|
9
9
|
* Get the focused item from keyboard navigation.
|
|
10
10
|
*/
|
|
11
11
|
export declare function useFocusedItem(): {
|
|
12
|
-
seriesType:
|
|
12
|
+
seriesType: "line" | "bar" | "scatter" | "pie";
|
|
13
13
|
seriesId: SeriesId;
|
|
14
14
|
dataIndex: number;
|
|
15
15
|
} | null;
|
|
@@ -15,7 +15,9 @@ export const useInteractionItemProps = (data, skip) => {
|
|
|
15
15
|
const interactionActive = React.useRef(false);
|
|
16
16
|
const onPointerEnter = useEventCallback(() => {
|
|
17
17
|
interactionActive.current = true;
|
|
18
|
-
instance.setItemInteraction(data
|
|
18
|
+
instance.setItemInteraction(data, {
|
|
19
|
+
interaction: 'pointer'
|
|
20
|
+
});
|
|
19
21
|
instance.setHighlight(data);
|
|
20
22
|
});
|
|
21
23
|
const onPointerLeave = useEventCallback(() => {
|
|
@@ -56,7 +58,9 @@ export function getInteractionItemProps(instance, item) {
|
|
|
56
58
|
if (!item) {
|
|
57
59
|
return;
|
|
58
60
|
}
|
|
59
|
-
instance.setItemInteraction(item
|
|
61
|
+
instance.setItemInteraction(item, {
|
|
62
|
+
interaction: 'pointer'
|
|
63
|
+
});
|
|
60
64
|
instance.setHighlight(item);
|
|
61
65
|
}
|
|
62
66
|
function onPointerLeave() {
|
package/esm/index.js
CHANGED
|
@@ -3,7 +3,7 @@ declare class CartesianSeriesTypes {
|
|
|
3
3
|
types: Set<CartesianChartSeriesType>;
|
|
4
4
|
constructor();
|
|
5
5
|
addType(value: CartesianChartSeriesType): void;
|
|
6
|
-
getTypes(): Set<"line" | "
|
|
6
|
+
getTypes(): Set<"line" | "bar" | "scatter">;
|
|
7
7
|
}
|
|
8
8
|
declare class PolarSeriesTypes {
|
|
9
9
|
types: Set<PolarChartSeriesType>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { scaleLog, scalePow, scaleSqrt, scaleTime, scaleUtc, scaleLinear } from '@mui/x-charts-vendor/d3-scale';
|
|
2
|
-
import { scaleSymlog } from "./
|
|
2
|
+
import { scaleSymlog } from "./scales/index.js";
|
|
3
3
|
export function getScale(scaleType, domain, range) {
|
|
4
4
|
switch (scaleType) {
|
|
5
5
|
case 'log':
|
package/esm/internals/index.d.ts
CHANGED
|
@@ -66,4 +66,5 @@ export * from "../models/axis.js";
|
|
|
66
66
|
export * from "./plugins/models/index.js";
|
|
67
67
|
export * from "./material/index.js";
|
|
68
68
|
export * from "./createSvgIcon.js";
|
|
69
|
-
export * from "./constants.js";
|
|
69
|
+
export * from "./constants.js";
|
|
70
|
+
export * from "./scales/index.js";
|
package/esm/internals/index.js
CHANGED
|
@@ -80,4 +80,5 @@ export * from "../models/axis.js";
|
|
|
80
80
|
export * from "./plugins/models/index.js";
|
|
81
81
|
export * from "./material/index.js";
|
|
82
82
|
export * from "./createSvgIcon.js";
|
|
83
|
-
export * from "./constants.js";
|
|
83
|
+
export * from "./constants.js";
|
|
84
|
+
export * from "./scales/index.js";
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
import { CartesianChartSeriesType } from "../models/seriesType/config.js";
|
|
2
|
-
export declare function isCartesianSeriesType(seriesType: string): seriesType is CartesianChartSeriesType;
|
|
1
|
+
import { CartesianChartSeriesType, ChartSeriesDefaultized, ChartSeriesType } from "../models/seriesType/config.js";
|
|
2
|
+
export declare function isCartesianSeriesType(seriesType: string): seriesType is CartesianChartSeriesType;
|
|
3
|
+
export declare function isCartesianSeries(series: ChartSeriesDefaultized<ChartSeriesType>): series is ChartSeriesDefaultized<CartesianChartSeriesType>;
|
|
@@ -8,5 +8,5 @@ import { UseChartClosestPointSignature } from "./featurePlugins/useChartClosestP
|
|
|
8
8
|
import { UseChartZAxisSignature } from "./featurePlugins/useChartZAxis/index.js";
|
|
9
9
|
import { UseChartBrushSignature } from "./featurePlugins/useChartBrush/index.js";
|
|
10
10
|
export type AllPluginSignatures<TSeries extends ChartSeriesType = ChartSeriesType> = [UseChartZAxisSignature, UseChartBrushSignature, UseChartCartesianAxisSignature<TSeries>, UseChartPolarAxisSignature, UseChartInteractionSignature, UseChartHighlightSignature, UseChartClosestPointSignature, UseChartKeyboardNavigationSignature];
|
|
11
|
-
export type DefaultPluginSignatures<TSeries extends ChartSeriesType = ChartSeriesType> = [UseChartZAxisSignature, UseChartBrushSignature, UseChartCartesianAxisSignature<TSeries>,
|
|
12
|
-
export declare const DEFAULT_PLUGINS: readonly [import("./models/index.js").ChartPlugin<UseChartZAxisSignature>, import("./models/index.js").ChartPlugin<UseChartBrushSignature>, import("./models/index.js").ChartPlugin<
|
|
11
|
+
export type DefaultPluginSignatures<TSeries extends ChartSeriesType = ChartSeriesType> = [UseChartZAxisSignature, UseChartBrushSignature, UseChartInteractionSignature, UseChartCartesianAxisSignature<TSeries>, UseChartHighlightSignature, UseChartClosestPointSignature, UseChartKeyboardNavigationSignature];
|
|
12
|
+
export declare const DEFAULT_PLUGINS: readonly [import("./models/index.js").ChartPlugin<UseChartZAxisSignature>, import("./models/index.js").ChartPlugin<UseChartBrushSignature>, import("./models/index.js").ChartPlugin<UseChartInteractionSignature>, import("./models/index.js").ChartPlugin<UseChartCartesianAxisSignature<any>>, import("./models/index.js").ChartPlugin<UseChartHighlightSignature>, import("./models/index.js").ChartPlugin<UseChartClosestPointSignature>, import("./models/index.js").ChartPlugin<UseChartKeyboardNavigationSignature>];
|
|
@@ -7,4 +7,4 @@ import { useChartKeyboardNavigation } from "./featurePlugins/useChartKeyboardNav
|
|
|
7
7
|
import { useChartClosestPoint } from "./featurePlugins/useChartClosestPoint/index.js";
|
|
8
8
|
import { useChartZAxis } from "./featurePlugins/useChartZAxis/index.js";
|
|
9
9
|
import { useChartBrush } from "./featurePlugins/useChartBrush/index.js";
|
|
10
|
-
export const DEFAULT_PLUGINS = [useChartZAxis, useChartBrush,
|
|
10
|
+
export const DEFAULT_PLUGINS = [useChartZAxis, useChartBrush, useChartInteraction, useChartCartesianAxis, useChartHighlight, useChartClosestPoint, useChartKeyboardNavigation];
|
package/esm/internals/plugins/corePlugins/useChartInteractionListener/useChartInteractionListener.js
CHANGED
|
@@ -53,6 +53,9 @@ export const useChartInteractionListener = ({
|
|
|
53
53
|
name: 'zoomPressAndDrag',
|
|
54
54
|
dragThreshold: 10,
|
|
55
55
|
preventIf: ['zoomPinch']
|
|
56
|
+
}), new TapGesture({
|
|
57
|
+
name: 'zoomDoubleTapReset',
|
|
58
|
+
taps: 2
|
|
56
59
|
})]
|
|
57
60
|
});
|
|
58
61
|
}
|
|
@@ -62,7 +65,7 @@ export const useChartInteractionListener = ({
|
|
|
62
65
|
if (!svg || !gestureManager) {
|
|
63
66
|
return undefined;
|
|
64
67
|
}
|
|
65
|
-
gestureManager.registerElement(['pan', 'move', 'zoomPinch', 'zoomPan', 'zoomTurnWheel', 'tap', 'quickPress', 'zoomTapAndDrag', 'zoomPressAndDrag', 'brush'], svg);
|
|
68
|
+
gestureManager.registerElement(['pan', 'move', 'zoomPinch', 'zoomPan', 'zoomTurnWheel', 'tap', 'quickPress', 'zoomTapAndDrag', 'zoomPressAndDrag', 'zoomDoubleTapReset', 'brush'], svg);
|
|
66
69
|
return () => {
|
|
67
70
|
// Cleanup gesture manager
|
|
68
71
|
gestureManager.unregisterAllGestures(svg);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { MoveEvent, PanEvent, PanGestureOptions, PinchEvent, PinchGestureOptions, PressEvent, TapEvent, TurnWheelEvent, type PressAndDragEvent, type PressAndDragGestureOptions, type TapAndDragEvent, type TapAndDragGestureOptions, type TurnWheelGestureOptions } from '@mui/x-internal-gestures/core';
|
|
1
|
+
import { MoveEvent, PanEvent, PanGestureOptions, PinchEvent, PinchGestureOptions, PressEvent, TapEvent, TurnWheelEvent, type PressAndDragEvent, type PressAndDragGestureOptions, type TapAndDragEvent, type TapAndDragGestureOptions, type TapGestureOptions, type TurnWheelGestureOptions } from '@mui/x-internal-gestures/core';
|
|
2
2
|
import { ChartPluginSignature } from "../../models/index.js";
|
|
3
|
-
export type ChartInteraction = 'pan' | 'panStart' | 'panEnd' | 'zoomPan' | 'zoomPanStart' | 'zoomPanEnd' | 'zoomPinch' | 'zoomPinchStart' | 'zoomPinchEnd' | 'zoomTurnWheel' | 'zoomTapAndDrag' | 'zoomTapAndDragStart' | 'zoomTapAndDragEnd' | 'zoomPressAndDrag' | 'zoomPressAndDragStart' | 'zoomPressAndDragEnd' | 'move' | 'moveStart' | 'moveEnd' | 'tap' | 'quickPress' | 'quickPressEnd' | 'brush' | 'brushStart' | 'brushCancel' | 'brushEnd';
|
|
3
|
+
export type ChartInteraction = 'pan' | 'panStart' | 'panEnd' | 'zoomPan' | 'zoomPanStart' | 'zoomPanEnd' | 'zoomPinch' | 'zoomPinchStart' | 'zoomPinchEnd' | 'zoomTurnWheel' | 'zoomTapAndDrag' | 'zoomTapAndDragStart' | 'zoomTapAndDragEnd' | 'zoomPressAndDrag' | 'zoomPressAndDragStart' | 'zoomPressAndDragEnd' | 'move' | 'moveStart' | 'moveEnd' | 'tap' | 'quickPress' | 'quickPressEnd' | 'zoomDoubleTapReset' | 'brush' | 'brushStart' | 'brushCancel' | 'brushEnd';
|
|
4
4
|
export type InteractionListenerResult = {
|
|
5
5
|
cleanup: () => void;
|
|
6
6
|
};
|
|
@@ -9,7 +9,7 @@ export type AddInteractionListener = {
|
|
|
9
9
|
<CustomData extends Record<string, unknown> = Record<string, unknown>>(interaction: 'zoomPinch' | 'zoomPinchStart' | 'zoomPinchEnd', callback: (event: PinchEvent<CustomData>) => void, options?: boolean | AddEventListenerOptions): InteractionListenerResult;
|
|
10
10
|
<CustomData extends Record<string, unknown> = Record<string, unknown>>(interaction: 'zoomTurnWheel', callback: (event: TurnWheelEvent<CustomData>) => void, options?: boolean | AddEventListenerOptions): InteractionListenerResult;
|
|
11
11
|
<CustomData extends Record<string, unknown> = Record<string, unknown>>(interaction: 'move' | 'moveStart' | 'moveEnd', callback: (event: MoveEvent<CustomData>) => void, options?: boolean | AddEventListenerOptions): InteractionListenerResult;
|
|
12
|
-
<CustomData extends Record<string, unknown> = Record<string, unknown>>(interaction: 'tap', callback: (event: TapEvent<CustomData>) => void, options?: boolean | AddEventListenerOptions): InteractionListenerResult;
|
|
12
|
+
<CustomData extends Record<string, unknown> = Record<string, unknown>>(interaction: 'tap' | 'zoomDoubleTapReset', callback: (event: TapEvent<CustomData>) => void, options?: boolean | AddEventListenerOptions): InteractionListenerResult;
|
|
13
13
|
<CustomData extends Record<string, unknown> = Record<string, unknown>>(interaction: 'quickPress' | 'quickPressEnd', callback: (event: PressEvent<CustomData>) => void, options?: boolean | AddEventListenerOptions): InteractionListenerResult;
|
|
14
14
|
<CustomData extends Record<string, unknown> = Record<string, unknown>>(interaction: 'zoomTapAndDrag' | 'zoomTapAndDragStart' | 'zoomTapAndDragEnd', callback: (event: TapAndDragEvent<CustomData>) => void, options?: boolean | AddEventListenerOptions): InteractionListenerResult;
|
|
15
15
|
<CustomData extends Record<string, unknown> = Record<string, unknown>>(interaction: 'zoomPressAndDrag' | 'zoomPressAndDragStart' | 'zoomPressAndDragEnd', callback: (event: PressAndDragEvent<CustomData>) => void, options?: boolean | AddEventListenerOptions): InteractionListenerResult;
|
|
@@ -20,6 +20,8 @@ export type UpdateZoomInteractionListeners = {
|
|
|
20
20
|
(interaction: 'zoomTurnWheel', options?: Omit<TurnWheelGestureOptions<'zoomTurnWheel'>, 'name'>): void;
|
|
21
21
|
(interaction: 'zoomTapAndDrag', options?: Omit<TapAndDragGestureOptions<'zoomTapAndDrag'>, 'name'>): void;
|
|
22
22
|
(interaction: 'zoomPressAndDrag', options?: Omit<PressAndDragGestureOptions<'zoomPressAndDrag'>, 'name'>): void;
|
|
23
|
+
(interaction: 'zoomDoubleTapReset', options?: Omit<TapGestureOptions<'zoomDoubleTapReset'>, 'name'>): void;
|
|
24
|
+
(interaction: 'brush', options?: Omit<PanGestureOptions<'brush'>, 'name'>): void;
|
|
23
25
|
};
|
|
24
26
|
export interface UseChartInteractionListenerParameters {}
|
|
25
27
|
export interface UseChartInteractionListenerState {}
|
|
@@ -5,12 +5,15 @@ import useEventCallback from '@mui/utils/useEventCallback';
|
|
|
5
5
|
import * as React from 'react';
|
|
6
6
|
import useEnhancedEffect from '@mui/utils/useEnhancedEffect';
|
|
7
7
|
import { getSVGPoint } from "../../../getSVGPoint.js";
|
|
8
|
+
import { useSelector } from "../../../store/useSelector.js";
|
|
9
|
+
import { selectorIsBrushEnabled } from "./useChartBrush.selectors.js";
|
|
8
10
|
export const useChartBrush = ({
|
|
9
11
|
store,
|
|
10
12
|
svgRef,
|
|
11
13
|
instance,
|
|
12
14
|
params
|
|
13
15
|
}) => {
|
|
16
|
+
const isEnabled = useSelector(store, selectorIsBrushEnabled);
|
|
14
17
|
useEnhancedEffect(() => {
|
|
15
18
|
store.update(prev => {
|
|
16
19
|
return _extends({}, prev, {
|
|
@@ -42,9 +45,21 @@ export const useChartBrush = ({
|
|
|
42
45
|
});
|
|
43
46
|
});
|
|
44
47
|
});
|
|
48
|
+
const setZoomBrushEnabled = useEventCallback(function setZoomBrushEnabled(enabled) {
|
|
49
|
+
store.update(prev => {
|
|
50
|
+
if (prev.brush.isZoomBrushEnabled === enabled) {
|
|
51
|
+
return prev;
|
|
52
|
+
}
|
|
53
|
+
return _extends({}, prev, {
|
|
54
|
+
brush: _extends({}, prev.brush, {
|
|
55
|
+
isZoomBrushEnabled: enabled
|
|
56
|
+
})
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
});
|
|
45
60
|
React.useEffect(() => {
|
|
46
61
|
const element = svgRef.current;
|
|
47
|
-
if (element === null || !
|
|
62
|
+
if (element === null || !isEnabled) {
|
|
48
63
|
return () => {};
|
|
49
64
|
}
|
|
50
65
|
const handleBrushStart = event => {
|
|
@@ -74,11 +89,12 @@ export const useChartBrush = ({
|
|
|
74
89
|
brushEndHandler.cleanup();
|
|
75
90
|
brushCancelHandler.cleanup();
|
|
76
91
|
};
|
|
77
|
-
}, [svgRef, instance, store, clearBrush, setBrushCoordinates]);
|
|
92
|
+
}, [svgRef, instance, store, clearBrush, setBrushCoordinates, isEnabled]);
|
|
78
93
|
return {
|
|
79
94
|
instance: {
|
|
80
95
|
setBrushCoordinates,
|
|
81
|
-
clearBrush
|
|
96
|
+
clearBrush,
|
|
97
|
+
setZoomBrushEnabled
|
|
82
98
|
}
|
|
83
99
|
};
|
|
84
100
|
};
|
|
@@ -100,6 +116,7 @@ useChartBrush.getInitialState = params => {
|
|
|
100
116
|
return {
|
|
101
117
|
brush: {
|
|
102
118
|
enabled: params.brushConfig.enabled,
|
|
119
|
+
isZoomBrushEnabled: false,
|
|
103
120
|
preventTooltip: params.brushConfig.preventTooltip,
|
|
104
121
|
preventHighlight: params.brushConfig.preventHighlight,
|
|
105
122
|
start: null,
|
|
@@ -67,9 +67,9 @@ export const selectorBrushConfigZoom = createSelector([selectorChartZoomOptionsL
|
|
|
67
67
|
return null;
|
|
68
68
|
});
|
|
69
69
|
export const selectorBrushConfig = createSelector([selectorBrushConfigNoZoom, selectorBrushConfigZoom], (configNoZoom, configZoom) => configZoom ?? configNoZoom);
|
|
70
|
-
export const selectorIsBrushEnabled = createSelector([selectorBrush], brush => brush?.enabled);
|
|
71
|
-
export const selectorIsBrushSelectionActive = createSelector([selectorBrush], brush => {
|
|
72
|
-
return
|
|
70
|
+
export const selectorIsBrushEnabled = createSelector([selectorBrush], brush => brush?.enabled || brush?.isZoomBrushEnabled);
|
|
71
|
+
export const selectorIsBrushSelectionActive = createSelector([selectorIsBrushEnabled, selectorBrush], (isBrushEnabled, brush) => {
|
|
72
|
+
return isBrushEnabled && brush?.start !== null && brush?.current !== null;
|
|
73
73
|
});
|
|
74
74
|
export const selectorBrushShouldPreventAxisHighlight = createSelector([selectorBrush, selectorIsBrushSelectionActive], (brush, isBrushSelectionActive) => isBrushSelectionActive && brush?.preventHighlight);
|
|
75
75
|
export const selectorBrushShouldPreventTooltip = createSelector([selectorBrush, selectorIsBrushSelectionActive], (brush, isBrushSelectionActive) => isBrushSelectionActive && brush?.preventTooltip);
|
|
@@ -9,6 +9,10 @@ export interface UseChartBrushState {
|
|
|
9
9
|
* Whether the brush interaction is enabled.
|
|
10
10
|
*/
|
|
11
11
|
enabled: boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Whether the zoom brush interaction is enabled.
|
|
14
|
+
*/
|
|
15
|
+
isZoomBrushEnabled: boolean;
|
|
12
16
|
/**
|
|
13
17
|
* Whether to prevent tooltip from showing during brush interaction.
|
|
14
18
|
*/
|
|
@@ -37,6 +41,11 @@ export interface UseChartBrushInstance {
|
|
|
37
41
|
* Clear the brush coordinates.
|
|
38
42
|
*/
|
|
39
43
|
clearBrush: () => void;
|
|
44
|
+
/**
|
|
45
|
+
* Enable or disable the zoom brush interaction.
|
|
46
|
+
* @param {boolean} enabled Whether to enable the zoom brush interaction.
|
|
47
|
+
*/
|
|
48
|
+
setZoomBrushEnabled: (enabled: boolean) => void;
|
|
40
49
|
}
|
|
41
50
|
export interface BrushConfig {
|
|
42
51
|
/**
|
|
@@ -46,12 +55,12 @@ export interface BrushConfig {
|
|
|
46
55
|
enabled?: boolean;
|
|
47
56
|
/**
|
|
48
57
|
* Whether to prevent tooltip from showing during brush interaction.
|
|
49
|
-
* @default
|
|
58
|
+
* @default true
|
|
50
59
|
*/
|
|
51
60
|
preventTooltip?: boolean;
|
|
52
61
|
/**
|
|
53
62
|
* Whether to prevent highlighting during brush interaction.
|
|
54
|
-
* @default
|
|
63
|
+
* @default true
|
|
55
64
|
*/
|
|
56
65
|
preventHighlight?: boolean;
|
|
57
66
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { scaleBand, scalePoint } from '@mui/x-charts-vendor/d3-scale';
|
|
2
1
|
import { isBandScaleConfig, isPointScaleConfig, isSymlogScaleConfig } from "../../../../models/axis.js";
|
|
3
2
|
import { getScale } from "../../../getScale.js";
|
|
3
|
+
import { scaleBand, scalePoint } from "../../../scales/index.js";
|
|
4
4
|
const DEFAULT_CATEGORY_GAP_RATIO = 0.2;
|
|
5
5
|
export function getRange(drawingArea, axisDirection, axis) {
|
|
6
6
|
const range = axisDirection === 'x' ? [drawingArea.left, drawingArea.left + drawingArea.width] : [drawingArea.top + drawingArea.height, drawingArea.top];
|