@mui/x-charts 8.14.1 → 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.js +8 -0
- package/BarChart/BarChart.plugins.d.ts +2 -1
- package/BarChart/BarChart.plugins.js +2 -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/useBarChartProps.js +4 -2
- package/BarChart/useBarPlotData.d.ts +17 -2
- package/BarChart/useBarPlotData.js +59 -34
- package/CHANGELOG.md +207 -0
- package/ChartContainer/ChartContainer.js +8 -0
- package/ChartContainer/useChartContainerProps.js +4 -2
- package/ChartsAxisHighlight/ChartsXAxisHighlight.js +2 -1
- package/ChartsAxisHighlight/ChartsYAxisHighlight.js +2 -1
- package/ChartsBrushOverlay/ChartsBrushOverlay.classes.d.ts +12 -0
- package/ChartsBrushOverlay/ChartsBrushOverlay.classes.js +9 -0
- package/ChartsBrushOverlay/ChartsBrushOverlay.d.ts +6 -0
- package/ChartsBrushOverlay/ChartsBrushOverlay.js +102 -0
- package/ChartsBrushOverlay/index.d.ts +4 -0
- package/ChartsBrushOverlay/index.js +19 -0
- package/ChartsReferenceLine/ChartsReferenceLine.js +1 -1
- package/ChartsReferenceLine/ChartsXReferenceLine.js +13 -8
- package/ChartsReferenceLine/ChartsYReferenceLine.js +13 -8
- package/ChartsReferenceLine/common.d.ts +3 -1
- package/ChartsReferenceLine/common.js +3 -1
- package/ChartsTooltip/ChartsTooltip.js +9 -0
- package/ChartsTooltip/ChartsTooltipContainer.d.ts +9 -0
- package/ChartsTooltip/ChartsTooltipContainer.js +67 -23
- package/ChartsTooltip/useItemTooltip.js +7 -14
- package/ChartsWrapper/ChartsWrapper.js +2 -1
- package/ChartsXAxis/getVisibleLabels.js +45 -25
- package/ChartsXAxis/useAxisTicksProps.d.ts +81 -81
- package/ChartsYAxis/useAxisTicksProps.d.ts +81 -81
- package/LineChart/LineChart.js +8 -0
- package/LineChart/LineChart.plugins.d.ts +2 -1
- package/LineChart/LineChart.plugins.js +2 -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/LineChart/useLineChartProps.js +4 -2
- 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.js +8 -0
- package/ScatterChart/ScatterChart.plugins.d.ts +2 -1
- package/ScatterChart/ScatterChart.plugins.js +2 -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/ScatterChart/useScatterChartProps.js +5 -3
- package/SparkLineChart/SparkLineChart.js +8 -0
- package/context/ChartProvider/ChartProvider.js +1 -1
- package/esm/BarChart/BarChart.js +8 -0
- package/esm/BarChart/BarChart.plugins.d.ts +2 -1
- package/esm/BarChart/BarChart.plugins.js +2 -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/useBarChartProps.js +4 -2
- package/esm/BarChart/useBarPlotData.d.ts +17 -2
- package/esm/BarChart/useBarPlotData.js +58 -34
- package/esm/ChartContainer/ChartContainer.js +8 -0
- package/esm/ChartContainer/useChartContainerProps.js +4 -2
- package/esm/ChartsAxisHighlight/ChartsXAxisHighlight.js +1 -2
- package/esm/ChartsAxisHighlight/ChartsYAxisHighlight.js +1 -2
- package/esm/ChartsBrushOverlay/ChartsBrushOverlay.classes.d.ts +12 -0
- package/esm/ChartsBrushOverlay/ChartsBrushOverlay.classes.js +2 -0
- package/esm/ChartsBrushOverlay/ChartsBrushOverlay.d.ts +6 -0
- package/esm/ChartsBrushOverlay/ChartsBrushOverlay.js +95 -0
- package/esm/ChartsBrushOverlay/index.d.ts +4 -0
- package/esm/ChartsBrushOverlay/index.js +2 -0
- package/esm/ChartsReferenceLine/ChartsReferenceLine.js +1 -1
- package/esm/ChartsReferenceLine/ChartsXReferenceLine.js +14 -9
- package/esm/ChartsReferenceLine/ChartsYReferenceLine.js +14 -9
- package/esm/ChartsReferenceLine/common.d.ts +3 -1
- package/esm/ChartsReferenceLine/common.js +2 -0
- package/esm/ChartsTooltip/ChartsTooltip.js +9 -0
- package/esm/ChartsTooltip/ChartsTooltipContainer.d.ts +9 -0
- package/esm/ChartsTooltip/ChartsTooltipContainer.js +68 -24
- package/esm/ChartsTooltip/useItemTooltip.js +9 -16
- package/esm/ChartsWrapper/ChartsWrapper.js +2 -1
- package/esm/ChartsXAxis/getVisibleLabels.js +45 -25
- package/esm/ChartsXAxis/useAxisTicksProps.d.ts +81 -81
- package/esm/ChartsYAxis/useAxisTicksProps.d.ts +81 -81
- package/esm/LineChart/LineChart.js +8 -0
- package/esm/LineChart/LineChart.plugins.d.ts +2 -1
- package/esm/LineChart/LineChart.plugins.js +2 -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/LineChart/useLineChartProps.js +4 -2
- 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.js +8 -0
- package/esm/ScatterChart/ScatterChart.plugins.d.ts +2 -1
- package/esm/ScatterChart/ScatterChart.plugins.js +2 -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/ScatterChart/useScatterChartProps.js +5 -3
- package/esm/SparkLineChart/SparkLineChart.js +8 -0
- package/esm/context/ChartProvider/ChartProvider.js +1 -1
- package/esm/hooks/index.d.ts +2 -1
- package/esm/hooks/index.js +2 -1
- package/esm/hooks/useBrush.d.ts +18 -0
- package/esm/hooks/useBrush.js +16 -0
- package/esm/hooks/useFocusedItem.d.ts +1 -1
- package/esm/hooks/useInteractionItemProps.js +6 -2
- package/esm/index.d.ts +2 -1
- package/esm/index.js +2 -1
- package/esm/internals/configInit.d.ts +1 -1
- package/esm/internals/domUtils.d.ts +9 -4
- package/esm/internals/domUtils.js +115 -52
- package/esm/internals/getScale.js +1 -1
- package/esm/internals/index.d.ts +3 -1
- package/esm/internals/index.js +3 -1
- package/esm/internals/isCartesian.d.ts +3 -2
- package/esm/internals/isCartesian.js +3 -0
- package/esm/internals/plugins/allPlugins.d.ts +4 -3
- package/esm/internals/plugins/allPlugins.js +2 -1
- package/esm/internals/plugins/corePlugins/useChartInteractionListener/useChartInteractionListener.js +19 -10
- package/esm/internals/plugins/corePlugins/useChartInteractionListener/useChartInteractionListener.types.d.ts +6 -4
- package/esm/internals/plugins/featurePlugins/useChartBrush/index.d.ts +3 -0
- package/esm/internals/plugins/featurePlugins/useChartBrush/index.js +3 -0
- package/esm/internals/plugins/featurePlugins/useChartBrush/useChartBrush.d.ts +3 -0
- package/esm/internals/plugins/featurePlugins/useChartBrush/useChartBrush.js +126 -0
- package/esm/internals/plugins/featurePlugins/useChartBrush/useChartBrush.selectors.d.ts +82 -0
- package/esm/internals/plugins/featurePlugins/useChartBrush/useChartBrush.selectors.js +75 -0
- package/esm/internals/plugins/featurePlugins/useChartBrush/useChartBrush.types.d.ts +81 -0
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/createZoomLookup.js +3 -2
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/defaultizeAxis.js +2 -2
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/defaultizeZoom.d.ts +2 -1
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/defaultizeZoom.js +8 -3
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisScale.js +1 -1
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxis.types.d.ts +3 -1
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianHighlight.selectors.d.ts +4 -4
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianHighlight.selectors.js +13 -6
- 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/utils/selectors.d.ts +1 -1
- 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/locales/elGR.js +97 -99
- package/esm/models/seriesType/common.d.ts +3 -2
- package/esm/tests/constants.js +1 -0
- package/hooks/index.d.ts +2 -1
- package/hooks/index.js +12 -0
- package/hooks/useBrush.d.ts +18 -0
- package/hooks/useBrush.js +21 -0
- package/hooks/useFocusedItem.d.ts +1 -1
- package/hooks/useInteractionItemProps.js +6 -2
- package/index.d.ts +2 -1
- package/index.js +13 -1
- package/internals/configInit.d.ts +1 -1
- package/internals/domUtils.d.ts +9 -4
- package/internals/domUtils.js +119 -54
- package/internals/getScale.js +2 -2
- package/internals/index.d.ts +3 -1
- package/internals/index.js +24 -0
- package/internals/isCartesian.d.ts +3 -2
- package/internals/isCartesian.js +4 -0
- package/internals/plugins/allPlugins.d.ts +4 -3
- package/internals/plugins/allPlugins.js +2 -1
- package/internals/plugins/corePlugins/useChartInteractionListener/useChartInteractionListener.js +19 -10
- package/internals/plugins/corePlugins/useChartInteractionListener/useChartInteractionListener.types.d.ts +6 -4
- package/internals/plugins/featurePlugins/useChartBrush/index.d.ts +3 -0
- package/internals/plugins/featurePlugins/useChartBrush/index.js +38 -0
- package/internals/plugins/featurePlugins/useChartBrush/useChartBrush.d.ts +3 -0
- package/internals/plugins/featurePlugins/useChartBrush/useChartBrush.js +134 -0
- package/internals/plugins/featurePlugins/useChartBrush/useChartBrush.selectors.d.ts +82 -0
- package/internals/plugins/featurePlugins/useChartBrush/useChartBrush.selectors.js +82 -0
- package/internals/plugins/featurePlugins/useChartBrush/useChartBrush.types.d.ts +81 -0
- package/internals/plugins/featurePlugins/useChartBrush/useChartBrush.types.js +5 -0
- package/internals/plugins/featurePlugins/useChartCartesianAxis/createZoomLookup.js +3 -2
- package/internals/plugins/featurePlugins/useChartCartesianAxis/defaultizeAxis.js +2 -2
- package/internals/plugins/featurePlugins/useChartCartesianAxis/defaultizeZoom.d.ts +2 -1
- package/internals/plugins/featurePlugins/useChartCartesianAxis/defaultizeZoom.js +8 -3
- package/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisScale.js +3 -3
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxis.types.d.ts +3 -1
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianHighlight.selectors.d.ts +4 -4
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianHighlight.selectors.js +13 -6
- 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/plugins/utils/selectors.d.ts +1 -1
- 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/locales/elGR.js +97 -99
- package/models/seriesType/common.d.ts +3 -2
- package/package.json +4 -4
- package/tests/constants.js +7 -0
- package/esm/internals/Flatbush.bench.js +0 -42
- package/esm/internals/symlogScale.d.ts +0 -2
- package/internals/Flatbush.bench.js +0 -44
- package/internals/symlogScale.d.ts +0 -2
- /package/esm/internals/{Flatbush.bench.d.ts → plugins/featurePlugins/useChartBrush/useChartBrush.types.js} +0 -0
- /package/{internals/Flatbush.bench.d.ts → esm/internals/plugins/models/seriesConfig/tooltipItemPositionGetter.types.js} +0 -0
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
'use client';
|
|
3
|
+
|
|
4
|
+
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
5
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
6
|
+
Object.defineProperty(exports, "__esModule", {
|
|
7
|
+
value: true
|
|
8
|
+
});
|
|
9
|
+
exports.ChartsBrushOverlay = ChartsBrushOverlay;
|
|
10
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
11
|
+
var React = _interopRequireWildcard(require("react"));
|
|
12
|
+
var _clsx = _interopRequireDefault(require("clsx"));
|
|
13
|
+
var _styles = require("@mui/material/styles");
|
|
14
|
+
var _ChartsBrushOverlay = require("./ChartsBrushOverlay.classes");
|
|
15
|
+
var _useChartDimensions = require("../internals/plugins/corePlugins/useChartDimensions");
|
|
16
|
+
var _useChartBrush = require("../internals/plugins/featurePlugins/useChartBrush");
|
|
17
|
+
var _useSelector = require("../internals/store/useSelector");
|
|
18
|
+
var _useStore = require("../internals/store/useStore");
|
|
19
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
20
|
+
function BrushRect(props) {
|
|
21
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)("rect", (0, _extends2.default)({
|
|
22
|
+
className: _ChartsBrushOverlay.brushOverlayClasses.rect,
|
|
23
|
+
strokeWidth: 1,
|
|
24
|
+
fillOpacity: 0.2,
|
|
25
|
+
pointerEvents: 'none'
|
|
26
|
+
}, props));
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Component that renders visual feedback during brush interaction
|
|
30
|
+
*/
|
|
31
|
+
function ChartsBrushOverlay(props) {
|
|
32
|
+
const store = (0, _useStore.useStore)();
|
|
33
|
+
const drawingArea = (0, _useSelector.useSelector)(store, _useChartDimensions.selectorChartDrawingArea);
|
|
34
|
+
const theme = (0, _styles.useTheme)();
|
|
35
|
+
const brushStartX = (0, _useSelector.useSelector)(store, _useChartBrush.selectorBrushStartX);
|
|
36
|
+
const brushStartY = (0, _useSelector.useSelector)(store, _useChartBrush.selectorBrushStartY);
|
|
37
|
+
const brushCurrentX = (0, _useSelector.useSelector)(store, _useChartBrush.selectorBrushCurrentX);
|
|
38
|
+
const brushCurrentY = (0, _useSelector.useSelector)(store, _useChartBrush.selectorBrushCurrentY);
|
|
39
|
+
const brushConfig = (0, _useSelector.useSelector)(store, _useChartBrush.selectorBrushConfig);
|
|
40
|
+
if (brushStartX === null || brushStartY === null || brushCurrentX === null || brushCurrentY === null) {
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
const {
|
|
44
|
+
left,
|
|
45
|
+
top,
|
|
46
|
+
width,
|
|
47
|
+
height
|
|
48
|
+
} = drawingArea;
|
|
49
|
+
|
|
50
|
+
// Clamp coordinates to drawing area
|
|
51
|
+
const clampX = x => Math.max(left, Math.min(left + width, x));
|
|
52
|
+
const clampY = y => Math.max(top, Math.min(top + height, y));
|
|
53
|
+
const startX = clampX(brushStartX);
|
|
54
|
+
const startY = clampY(brushStartY);
|
|
55
|
+
const currentX = clampX(brushCurrentX);
|
|
56
|
+
const currentY = clampY(brushCurrentY);
|
|
57
|
+
const rectColor = theme.palette.mode === 'light' ? theme.palette.common.black : theme.palette.common.white;
|
|
58
|
+
|
|
59
|
+
// For scatter charts, show only the rectangle without guide lines
|
|
60
|
+
if (brushConfig === 'xy') {
|
|
61
|
+
const rectWidth = currentX - startX;
|
|
62
|
+
const rectHeight = currentY - startY;
|
|
63
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)("g", {
|
|
64
|
+
className: (0, _clsx.default)(_ChartsBrushOverlay.brushOverlayClasses.root, _ChartsBrushOverlay.brushOverlayClasses.x, _ChartsBrushOverlay.brushOverlayClasses.y),
|
|
65
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(BrushRect, (0, _extends2.default)({
|
|
66
|
+
fill: rectColor,
|
|
67
|
+
x: rectWidth >= 0 ? startX : currentX,
|
|
68
|
+
y: rectHeight >= 0 ? startY : currentY,
|
|
69
|
+
width: Math.abs(rectWidth),
|
|
70
|
+
height: Math.abs(rectHeight)
|
|
71
|
+
}, props))
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
if (brushConfig === 'y') {
|
|
75
|
+
const minY = Math.min(startY, currentY);
|
|
76
|
+
const maxY = Math.max(startY, currentY);
|
|
77
|
+
const rectHeight = maxY - minY;
|
|
78
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)("g", {
|
|
79
|
+
className: (0, _clsx.default)(_ChartsBrushOverlay.brushOverlayClasses.root, _ChartsBrushOverlay.brushOverlayClasses.y),
|
|
80
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(BrushRect, (0, _extends2.default)({
|
|
81
|
+
fill: rectColor,
|
|
82
|
+
x: left,
|
|
83
|
+
y: minY,
|
|
84
|
+
width: width,
|
|
85
|
+
height: rectHeight
|
|
86
|
+
}, props))
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
const minX = Math.min(startX, currentX);
|
|
90
|
+
const maxX = Math.max(startX, currentX);
|
|
91
|
+
const rectWidth = maxX - minX;
|
|
92
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)("g", {
|
|
93
|
+
className: (0, _clsx.default)(_ChartsBrushOverlay.brushOverlayClasses.root, _ChartsBrushOverlay.brushOverlayClasses.x),
|
|
94
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(BrushRect, (0, _extends2.default)({
|
|
95
|
+
fill: rectColor,
|
|
96
|
+
x: minX,
|
|
97
|
+
y: top,
|
|
98
|
+
width: rectWidth,
|
|
99
|
+
height: height
|
|
100
|
+
}, props))
|
|
101
|
+
});
|
|
102
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { ChartsBrushOverlay } from "./ChartsBrushOverlay.js";
|
|
2
|
+
export type { ChartsBrushOverlayProps } from "./ChartsBrushOverlay.js";
|
|
3
|
+
export { brushOverlayClasses } from "./ChartsBrushOverlay.classes.js";
|
|
4
|
+
export type { BrushOverlayClasses, BrushOverlayClassKey } from "./ChartsBrushOverlay.classes.js";
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "ChartsBrushOverlay", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _ChartsBrushOverlay.ChartsBrushOverlay;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(exports, "brushOverlayClasses", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () {
|
|
15
|
+
return _ChartsBrushOverlay2.brushOverlayClasses;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
var _ChartsBrushOverlay = require("./ChartsBrushOverlay");
|
|
19
|
+
var _ChartsBrushOverlay2 = require("./ChartsBrushOverlay.classes");
|
|
@@ -63,7 +63,7 @@ process.env.NODE_ENV !== "production" ? ChartsReferenceLine.propTypes = {
|
|
|
63
63
|
/**
|
|
64
64
|
* Additional space around the label in px.
|
|
65
65
|
* Can be a number or an object `{ x, y }` to distinguish space with the reference line and space with axes.
|
|
66
|
-
* @default 5
|
|
66
|
+
* @default { x: 0, y: 5 } on a horizontal line and { x: 5, y: 0 } on a vertical line.
|
|
67
67
|
*/
|
|
68
68
|
spacing: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.shape({
|
|
69
69
|
x: _propTypes.default.number,
|
|
@@ -21,12 +21,17 @@ var _jsxRuntime = require("react/jsx-runtime");
|
|
|
21
21
|
const getTextParams = ({
|
|
22
22
|
top,
|
|
23
23
|
height,
|
|
24
|
-
|
|
24
|
+
spacing,
|
|
25
|
+
position,
|
|
25
26
|
labelAlign = 'middle'
|
|
26
27
|
}) => {
|
|
28
|
+
const defaultSpacingOtherAxis = labelAlign === 'middle' ? _common.DEFAULT_SPACING_MIDDLE_OTHER_AXIS : _common.DEFAULT_SPACING;
|
|
29
|
+
const spacingX = (typeof spacing === 'object' ? spacing.x : spacing) ?? _common.DEFAULT_SPACING;
|
|
30
|
+
const spacingY = (typeof spacing === 'object' ? spacing.y : defaultSpacingOtherAxis) ?? defaultSpacingOtherAxis;
|
|
27
31
|
switch (labelAlign) {
|
|
28
32
|
case 'start':
|
|
29
33
|
return {
|
|
34
|
+
x: position + spacingX,
|
|
30
35
|
y: top + spacingY,
|
|
31
36
|
style: {
|
|
32
37
|
dominantBaseline: 'hanging',
|
|
@@ -35,6 +40,7 @@ const getTextParams = ({
|
|
|
35
40
|
};
|
|
36
41
|
case 'end':
|
|
37
42
|
return {
|
|
43
|
+
x: position + spacingX,
|
|
38
44
|
y: top + height - spacingY,
|
|
39
45
|
style: {
|
|
40
46
|
dominantBaseline: 'auto',
|
|
@@ -43,7 +49,8 @@ const getTextParams = ({
|
|
|
43
49
|
};
|
|
44
50
|
default:
|
|
45
51
|
return {
|
|
46
|
-
|
|
52
|
+
x: position + spacingX,
|
|
53
|
+
y: top + height / 2 + spacingY,
|
|
47
54
|
style: {
|
|
48
55
|
dominantBaseline: 'central',
|
|
49
56
|
textAnchor: 'start'
|
|
@@ -62,9 +69,9 @@ function ChartsXReferenceLine(props) {
|
|
|
62
69
|
const {
|
|
63
70
|
x,
|
|
64
71
|
label = '',
|
|
65
|
-
spacing
|
|
72
|
+
spacing,
|
|
66
73
|
classes: inClasses,
|
|
67
|
-
labelAlign,
|
|
74
|
+
labelAlign = 'middle',
|
|
68
75
|
lineStyle,
|
|
69
76
|
labelStyle,
|
|
70
77
|
axisId
|
|
@@ -83,16 +90,14 @@ function ChartsXReferenceLine(props) {
|
|
|
83
90
|
}
|
|
84
91
|
const d = `M ${xPosition} ${top} l 0 ${height}`;
|
|
85
92
|
const classes = getXReferenceLineClasses(inClasses);
|
|
86
|
-
const spacingX = typeof spacing === 'object' ? spacing.x ?? 0 : spacing;
|
|
87
|
-
const spacingY = typeof spacing === 'object' ? spacing.y ?? 0 : spacing;
|
|
88
93
|
const textParams = (0, _extends2.default)({
|
|
89
|
-
x: xPosition + spacingX,
|
|
90
94
|
text: label,
|
|
91
95
|
fontSize: 12
|
|
92
96
|
}, getTextParams({
|
|
93
97
|
top,
|
|
94
98
|
height,
|
|
95
|
-
|
|
99
|
+
spacing,
|
|
100
|
+
position: xPosition,
|
|
96
101
|
labelAlign
|
|
97
102
|
}), {
|
|
98
103
|
className: classes.label
|
|
@@ -21,12 +21,17 @@ var _jsxRuntime = require("react/jsx-runtime");
|
|
|
21
21
|
const getTextParams = ({
|
|
22
22
|
left,
|
|
23
23
|
width,
|
|
24
|
-
|
|
24
|
+
spacing,
|
|
25
|
+
position,
|
|
25
26
|
labelAlign = 'middle'
|
|
26
27
|
}) => {
|
|
28
|
+
const defaultSpacingOtherAxis = labelAlign === 'middle' ? _common.DEFAULT_SPACING_MIDDLE_OTHER_AXIS : _common.DEFAULT_SPACING;
|
|
29
|
+
const spacingX = (typeof spacing === 'object' ? spacing.x : defaultSpacingOtherAxis) ?? defaultSpacingOtherAxis;
|
|
30
|
+
const spacingY = (typeof spacing === 'object' ? spacing.y : spacing) ?? _common.DEFAULT_SPACING;
|
|
27
31
|
switch (labelAlign) {
|
|
28
32
|
case 'start':
|
|
29
33
|
return {
|
|
34
|
+
y: position - spacingY,
|
|
30
35
|
x: left + spacingX,
|
|
31
36
|
style: {
|
|
32
37
|
dominantBaseline: 'auto',
|
|
@@ -35,6 +40,7 @@ const getTextParams = ({
|
|
|
35
40
|
};
|
|
36
41
|
case 'end':
|
|
37
42
|
return {
|
|
43
|
+
y: position - spacingY,
|
|
38
44
|
x: left + width - spacingX,
|
|
39
45
|
style: {
|
|
40
46
|
dominantBaseline: 'auto',
|
|
@@ -43,7 +49,8 @@ const getTextParams = ({
|
|
|
43
49
|
};
|
|
44
50
|
default:
|
|
45
51
|
return {
|
|
46
|
-
|
|
52
|
+
y: position - spacingY,
|
|
53
|
+
x: left + width / 2 + spacingX,
|
|
47
54
|
style: {
|
|
48
55
|
dominantBaseline: 'auto',
|
|
49
56
|
textAnchor: 'middle'
|
|
@@ -62,9 +69,9 @@ function ChartsYReferenceLine(props) {
|
|
|
62
69
|
const {
|
|
63
70
|
y,
|
|
64
71
|
label = '',
|
|
65
|
-
spacing
|
|
72
|
+
spacing,
|
|
66
73
|
classes: inClasses,
|
|
67
|
-
labelAlign,
|
|
74
|
+
labelAlign = 'middle',
|
|
68
75
|
lineStyle,
|
|
69
76
|
labelStyle,
|
|
70
77
|
axisId
|
|
@@ -83,16 +90,14 @@ function ChartsYReferenceLine(props) {
|
|
|
83
90
|
}
|
|
84
91
|
const d = `M ${left} ${yPosition} l ${width} 0`;
|
|
85
92
|
const classes = getYReferenceLineClasses(inClasses);
|
|
86
|
-
const spacingX = typeof spacing === 'object' ? spacing.x ?? 0 : spacing;
|
|
87
|
-
const spacingY = typeof spacing === 'object' ? spacing.y ?? 0 : spacing;
|
|
88
93
|
const textParams = (0, _extends2.default)({
|
|
89
|
-
y: yPosition - spacingY,
|
|
90
94
|
text: label,
|
|
91
95
|
fontSize: 12
|
|
92
96
|
}, getTextParams({
|
|
93
97
|
left,
|
|
94
98
|
width,
|
|
95
|
-
|
|
99
|
+
spacing,
|
|
100
|
+
position: yPosition,
|
|
96
101
|
labelAlign
|
|
97
102
|
}), {
|
|
98
103
|
className: classes.label
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { ChartsReferenceLineClasses } from "./chartsReferenceLineClasses.js";
|
|
2
2
|
import { ChartsTextStyle } from "../ChartsText/index.js";
|
|
3
3
|
import { AxisId } from "../models/axis.js";
|
|
4
|
+
export declare const DEFAULT_SPACING = 5;
|
|
5
|
+
export declare const DEFAULT_SPACING_MIDDLE_OTHER_AXIS = 0;
|
|
4
6
|
export type CommonChartsReferenceLineProps = {
|
|
5
7
|
/**
|
|
6
8
|
* The alignment if the label is in the chart drawing area.
|
|
@@ -14,7 +16,7 @@ export type CommonChartsReferenceLineProps = {
|
|
|
14
16
|
/**
|
|
15
17
|
* Additional space around the label in px.
|
|
16
18
|
* Can be a number or an object `{ x, y }` to distinguish space with the reference line and space with axes.
|
|
17
|
-
* @default 5
|
|
19
|
+
* @default { x: 0, y: 5 } on a horizontal line and { x: 5, y: 0 } on a vertical line.
|
|
18
20
|
*/
|
|
19
21
|
spacing?: number | {
|
|
20
22
|
x?: number;
|
|
@@ -4,10 +4,12 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.ReferenceLineRoot = void 0;
|
|
7
|
+
exports.ReferenceLineRoot = exports.DEFAULT_SPACING_MIDDLE_OTHER_AXIS = exports.DEFAULT_SPACING = void 0;
|
|
8
8
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
9
|
var _styles = require("@mui/material/styles");
|
|
10
10
|
var _chartsReferenceLineClasses = require("./chartsReferenceLineClasses");
|
|
11
|
+
const DEFAULT_SPACING = exports.DEFAULT_SPACING = 5;
|
|
12
|
+
const DEFAULT_SPACING_MIDDLE_OTHER_AXIS = exports.DEFAULT_SPACING_MIDDLE_OTHER_AXIS = 0;
|
|
11
13
|
const ReferenceLineRoot = exports.ReferenceLineRoot = (0, _styles.styled)('g')(({
|
|
12
14
|
theme
|
|
13
15
|
}) => ({
|
|
@@ -45,6 +45,11 @@ process.env.NODE_ENV !== "production" ? ChartsTooltip.propTypes = {
|
|
|
45
45
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
46
46
|
// | To update them edit the TypeScript types and run "pnpm proptypes" |
|
|
47
47
|
// ----------------------------------------------------------------------
|
|
48
|
+
/**
|
|
49
|
+
* Determine if the tooltip should be placed on the pointer location or on the node.
|
|
50
|
+
* @default 'pointer'
|
|
51
|
+
*/
|
|
52
|
+
anchor: _propTypes.default.oneOf(['node', 'pointer']),
|
|
48
53
|
/**
|
|
49
54
|
* An HTML element, [virtualElement](https://popper.js.org/docs/v2/virtual-elements/),
|
|
50
55
|
* or a function that returns either.
|
|
@@ -174,6 +179,10 @@ process.env.NODE_ENV !== "production" ? ChartsTooltip.propTypes = {
|
|
|
174
179
|
update: _propTypes.default.func.isRequired
|
|
175
180
|
})
|
|
176
181
|
})]),
|
|
182
|
+
/**
|
|
183
|
+
* Determines the tooltip position relatively to the anchor.
|
|
184
|
+
*/
|
|
185
|
+
position: _propTypes.default.oneOf(['bottom', 'left', 'right', 'top']),
|
|
177
186
|
/**
|
|
178
187
|
* The props used for each slot inside the Popper.
|
|
179
188
|
* @default {}
|
|
@@ -15,6 +15,15 @@ export interface ChartsTooltipContainerProps<T extends TriggerOptions = TriggerO
|
|
|
15
15
|
* Override or extend the styles applied to the component.
|
|
16
16
|
*/
|
|
17
17
|
classes?: Partial<ChartsTooltipClasses>;
|
|
18
|
+
/**
|
|
19
|
+
* Determine if the tooltip should be placed on the pointer location or on the node.
|
|
20
|
+
* @default 'pointer'
|
|
21
|
+
*/
|
|
22
|
+
anchor?: 'pointer' | 'node';
|
|
23
|
+
/**
|
|
24
|
+
* Determines the tooltip position relatively to the anchor.
|
|
25
|
+
*/
|
|
26
|
+
position?: 'top' | 'bottom' | 'left' | 'right';
|
|
18
27
|
children?: React.ReactNode;
|
|
19
28
|
}
|
|
20
29
|
/**
|
|
@@ -26,9 +26,11 @@ var _useChartCartesianAxis = require("../internals/plugins/featurePlugins/useCha
|
|
|
26
26
|
var _useChartPolarInteraction = require("../internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarInteraction.selectors");
|
|
27
27
|
var _useAxisSystem = require("../hooks/useAxisSystem");
|
|
28
28
|
var _hooks = require("../hooks");
|
|
29
|
+
var _useChartBrush = require("../internals/plugins/featurePlugins/useChartBrush");
|
|
30
|
+
var _selectors = require("../internals/plugins/utils/selectors");
|
|
29
31
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
30
|
-
const _excluded = ["trigger", "classes", "children"];
|
|
31
|
-
const
|
|
32
|
+
const _excluded = ["trigger", "position", "anchor", "classes", "children"];
|
|
33
|
+
const selectorReturnFalse = () => false;
|
|
32
34
|
const ChartsTooltipRoot = (0, _styles.styled)(_Popper.default, {
|
|
33
35
|
name: 'MuiChartsTooltip',
|
|
34
36
|
slot: 'Root'
|
|
@@ -38,6 +40,21 @@ const ChartsTooltipRoot = (0, _styles.styled)(_Popper.default, {
|
|
|
38
40
|
pointerEvents: 'none',
|
|
39
41
|
zIndex: theme.zIndex.modal
|
|
40
42
|
}));
|
|
43
|
+
const selectorSelectIsOpenSelector = (0, _selectors.createSelector)([_useChartBrush.selectorBrushShouldPreventTooltip, (_, trigger) => trigger, (_, __, axisSystem) => axisSystem], (shouldPreventBecauseOfBrush, trigger, axisSystem) => {
|
|
44
|
+
if (shouldPreventBecauseOfBrush) {
|
|
45
|
+
return selectorReturnFalse;
|
|
46
|
+
}
|
|
47
|
+
if (trigger === 'item') {
|
|
48
|
+
return _useChartInteraction.selectorChartsTooltipItemIsDefined;
|
|
49
|
+
}
|
|
50
|
+
if (axisSystem === 'polar') {
|
|
51
|
+
return _useChartPolarInteraction.selectorChartsInteractionPolarAxisTooltip;
|
|
52
|
+
}
|
|
53
|
+
if (axisSystem === 'cartesian') {
|
|
54
|
+
return _useChartCartesianAxis.selectorChartsInteractionAxisTooltip;
|
|
55
|
+
}
|
|
56
|
+
return selectorReturnFalse;
|
|
57
|
+
});
|
|
41
58
|
|
|
42
59
|
/**
|
|
43
60
|
* Demos:
|
|
@@ -55,6 +72,8 @@ function ChartsTooltipContainer(inProps) {
|
|
|
55
72
|
});
|
|
56
73
|
const {
|
|
57
74
|
trigger = 'axis',
|
|
75
|
+
position,
|
|
76
|
+
anchor = 'pointer',
|
|
58
77
|
classes: propClasses,
|
|
59
78
|
children
|
|
60
79
|
} = props,
|
|
@@ -70,31 +89,48 @@ function ChartsTooltipContainer(inProps) {
|
|
|
70
89
|
}));
|
|
71
90
|
const axisSystem = (0, _useAxisSystem.useAxisSystem)();
|
|
72
91
|
const store = (0, _useStore.useStore)();
|
|
73
|
-
const
|
|
92
|
+
const isOpenSelector = (0, _useSelector.useSelector)(store, selectorSelectIsOpenSelector, [trigger, axisSystem]);
|
|
93
|
+
const isOpen = (0, _useSelector.useSelector)(store, isOpenSelector);
|
|
94
|
+
const lastInteraction = (0, _useSelector.useSelector)(store, _useChartInteraction.selectorChartsLastInteraction);
|
|
95
|
+
const computedAnchor = lastInteraction === 'keyboard' ? 'node' : anchor;
|
|
96
|
+
const itemPosition = (0, _useSelector.useSelector)(store, trigger === 'item' && computedAnchor === 'node' ? _useChartInteraction.selectorChartsTooltipItemPosition : () => null, [position]);
|
|
74
97
|
React.useEffect(() => {
|
|
75
|
-
const
|
|
76
|
-
if (
|
|
98
|
+
const svgElement = svgRef.current;
|
|
99
|
+
if (svgElement === null) {
|
|
77
100
|
return () => {};
|
|
78
101
|
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
102
|
+
if (itemPosition !== null) {
|
|
103
|
+
const positionUpdate = (0, _rafThrottle.rafThrottle)(() => {
|
|
104
|
+
// eslint-disable-next-line react-compiler/react-compiler
|
|
105
|
+
positionRef.current = {
|
|
106
|
+
x: svgElement.getBoundingClientRect().left + (itemPosition?.x ?? 0),
|
|
107
|
+
y: svgElement.getBoundingClientRect().top + (itemPosition?.y ?? 0)
|
|
108
|
+
};
|
|
109
|
+
popperRef.current?.update();
|
|
110
|
+
});
|
|
111
|
+
positionUpdate();
|
|
112
|
+
return () => positionUpdate.clear();
|
|
113
|
+
}
|
|
114
|
+
const pointerUpdate = (0, _rafThrottle.rafThrottle)((x, y) => {
|
|
82
115
|
positionRef.current = {
|
|
83
|
-
x
|
|
84
|
-
y
|
|
116
|
+
x,
|
|
117
|
+
y
|
|
85
118
|
};
|
|
86
|
-
update();
|
|
119
|
+
popperRef.current?.update();
|
|
120
|
+
});
|
|
121
|
+
const handlePointerEvent = event => {
|
|
122
|
+
pointerUpdate(event.clientX, event.clientY);
|
|
87
123
|
};
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
124
|
+
svgElement.addEventListener('pointerdown', handlePointerEvent);
|
|
125
|
+
svgElement.addEventListener('pointermove', handlePointerEvent);
|
|
126
|
+
svgElement.addEventListener('pointerenter', handlePointerEvent);
|
|
91
127
|
return () => {
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
128
|
+
svgElement.removeEventListener('pointerdown', handlePointerEvent);
|
|
129
|
+
svgElement.removeEventListener('pointermove', handlePointerEvent);
|
|
130
|
+
svgElement.removeEventListener('pointerenter', handlePointerEvent);
|
|
131
|
+
pointerUpdate.clear();
|
|
96
132
|
};
|
|
97
|
-
}, [svgRef, positionRef]);
|
|
133
|
+
}, [svgRef, positionRef, itemPosition]);
|
|
98
134
|
const anchorEl = React.useMemo(() => ({
|
|
99
135
|
getBoundingClientRect: () => ({
|
|
100
136
|
x: positionRef.current.x,
|
|
@@ -138,14 +174,13 @@ function ChartsTooltipContainer(inProps) {
|
|
|
138
174
|
return null;
|
|
139
175
|
}
|
|
140
176
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_NoSsr.default, {
|
|
141
|
-
children: isOpen && /*#__PURE__*/(0, _jsxRuntime.jsx)(ChartsTooltipRoot, (0, _extends2.default)({
|
|
177
|
+
children: isOpen && /*#__PURE__*/(0, _jsxRuntime.jsx)(ChartsTooltipRoot, (0, _extends2.default)({}, other, {
|
|
142
178
|
className: classes?.root,
|
|
143
179
|
open: isOpen,
|
|
144
|
-
placement: isMouse ? 'right-start' : 'top',
|
|
180
|
+
placement: other.placement ?? position ?? (isMouse ? 'right-start' : 'top'),
|
|
145
181
|
popperRef: popperRef,
|
|
146
182
|
anchorEl: anchorEl,
|
|
147
|
-
modifiers: modifiers
|
|
148
|
-
}, other, {
|
|
183
|
+
modifiers: modifiers,
|
|
149
184
|
children: children
|
|
150
185
|
}))
|
|
151
186
|
});
|
|
@@ -155,6 +190,11 @@ process.env.NODE_ENV !== "production" ? ChartsTooltipContainer.propTypes = {
|
|
|
155
190
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
156
191
|
// | To update them edit the TypeScript types and run "pnpm proptypes" |
|
|
157
192
|
// ----------------------------------------------------------------------
|
|
193
|
+
/**
|
|
194
|
+
* Determine if the tooltip should be placed on the pointer location or on the node.
|
|
195
|
+
* @default 'pointer'
|
|
196
|
+
*/
|
|
197
|
+
anchor: _propTypes.default.oneOf(['node', 'pointer']),
|
|
158
198
|
/**
|
|
159
199
|
* An HTML element, [virtualElement](https://popper.js.org/docs/v2/virtual-elements/),
|
|
160
200
|
* or a function that returns either.
|
|
@@ -288,6 +328,10 @@ process.env.NODE_ENV !== "production" ? ChartsTooltipContainer.propTypes = {
|
|
|
288
328
|
update: _propTypes.default.func.isRequired
|
|
289
329
|
})
|
|
290
330
|
})]),
|
|
331
|
+
/**
|
|
332
|
+
* Determines the tooltip position relatively to the anchor.
|
|
333
|
+
*/
|
|
334
|
+
position: _propTypes.default.oneOf(['bottom', 'left', 'right', 'top']),
|
|
291
335
|
/**
|
|
292
336
|
* The props used for each slot inside the Popper.
|
|
293
337
|
* @default {}
|
|
@@ -13,9 +13,10 @@ var _useStore = require("../internals/store/useStore");
|
|
|
13
13
|
var _useAxis = require("../hooks/useAxis");
|
|
14
14
|
var _useZAxis = require("../hooks/useZAxis");
|
|
15
15
|
var _useChartSeries = require("../internals/plugins/corePlugins/useChartSeries/useChartSeries.selectors");
|
|
16
|
+
var _isCartesian = require("../internals/isCartesian");
|
|
16
17
|
function useInternalItemTooltip() {
|
|
17
18
|
const store = (0, _useStore.useStore)();
|
|
18
|
-
const identifier = (0, _useSelector.useSelector)(store, _useChartInteraction.
|
|
19
|
+
const identifier = (0, _useSelector.useSelector)(store, _useChartInteraction.selectorChartsTooltipItem);
|
|
19
20
|
const seriesConfig = (0, _useSelector.useSelector)(store, _useChartSeries.selectorChartSeriesConfig);
|
|
20
21
|
const series = (0, _useSeries.useSeries)();
|
|
21
22
|
const {
|
|
@@ -34,15 +35,6 @@ function useInternalItemTooltip() {
|
|
|
34
35
|
rotationAxis,
|
|
35
36
|
rotationAxisIds
|
|
36
37
|
} = (0, _useAxis.useRotationAxes)();
|
|
37
|
-
const {
|
|
38
|
-
radiusAxis,
|
|
39
|
-
radiusAxisIds
|
|
40
|
-
} = (0, _useAxis.useRadiusAxes)();
|
|
41
|
-
const xAxisId = series.xAxisId ?? xAxisIds[0];
|
|
42
|
-
const yAxisId = series.yAxisId ?? yAxisIds[0];
|
|
43
|
-
const zAxisId = series.zAxisId ?? zAxisIds[0];
|
|
44
|
-
const rotationAxisId = series.rotationAxisId ?? rotationAxisIds[0];
|
|
45
|
-
const radiusAxisId = series.radiusAxisId ?? radiusAxisIds[0];
|
|
46
38
|
if (!identifier) {
|
|
47
39
|
return null;
|
|
48
40
|
}
|
|
@@ -50,7 +42,11 @@ function useInternalItemTooltip() {
|
|
|
50
42
|
if (!itemSeries) {
|
|
51
43
|
return null;
|
|
52
44
|
}
|
|
53
|
-
const
|
|
45
|
+
const xAxisId = (0, _isCartesian.isCartesianSeries)(itemSeries) ? itemSeries.xAxisId ?? xAxisIds[0] : undefined;
|
|
46
|
+
const yAxisId = (0, _isCartesian.isCartesianSeries)(itemSeries) ? itemSeries.yAxisId ?? yAxisIds[0] : undefined;
|
|
47
|
+
const zAxisId = 'zAxisId' in itemSeries ? itemSeries.zAxisId ?? zAxisIds[0] : zAxisIds[0];
|
|
48
|
+
const rotationAxisId = rotationAxisIds[0];
|
|
49
|
+
const getColor = seriesConfig[itemSeries.type].colorProcessor?.(itemSeries, xAxisId !== undefined ? xAxis[xAxisId] : undefined, yAxisId !== undefined ? yAxis[yAxisId] : undefined, zAxisId !== undefined ? zAxis[zAxisId] : undefined) ?? (() => '');
|
|
54
50
|
const axesConfig = {};
|
|
55
51
|
if (xAxisId !== undefined) {
|
|
56
52
|
axesConfig.x = xAxis[xAxisId];
|
|
@@ -61,9 +57,6 @@ function useInternalItemTooltip() {
|
|
|
61
57
|
if (rotationAxisId !== undefined) {
|
|
62
58
|
axesConfig.rotation = rotationAxis[rotationAxisId];
|
|
63
59
|
}
|
|
64
|
-
if (radiusAxisId !== undefined) {
|
|
65
|
-
axesConfig.radius = radiusAxis[radiusAxisId];
|
|
66
|
-
}
|
|
67
60
|
return seriesConfig[itemSeries.type].tooltipGetter({
|
|
68
61
|
series: itemSeries,
|
|
69
62
|
axesConfig,
|
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.getVisibleLabels = getVisibleLabels;
|
|
8
8
|
var _geometry = require("../internals/geometry");
|
|
9
|
-
var
|
|
9
|
+
var _domUtils = require("../internals/domUtils");
|
|
10
10
|
/* Returns a set of indices of the tick labels that should be visible. */
|
|
11
11
|
function getVisibleLabels(xTicks, {
|
|
12
12
|
tickLabelStyle: style,
|
|
@@ -16,23 +16,6 @@ function getVisibleLabels(xTicks, {
|
|
|
16
16
|
isMounted,
|
|
17
17
|
isXInside
|
|
18
18
|
}) {
|
|
19
|
-
const getTickLabelSize = tick => {
|
|
20
|
-
if (!isMounted || tick.formattedValue === undefined) {
|
|
21
|
-
return {
|
|
22
|
-
width: 0,
|
|
23
|
-
height: 0
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
const tickSizes = (0, _getWordsByLines.getWordsByLines)({
|
|
27
|
-
style,
|
|
28
|
-
needsComputation: true,
|
|
29
|
-
text: tick.formattedValue
|
|
30
|
-
});
|
|
31
|
-
return {
|
|
32
|
-
width: Math.max(...tickSizes.map(size => size.width)),
|
|
33
|
-
height: Math.max(tickSizes.length * tickSizes[0].height)
|
|
34
|
-
};
|
|
35
|
-
};
|
|
36
19
|
if (typeof tickLabelInterval === 'function') {
|
|
37
20
|
return new Set(xTicks.filter((item, index) => tickLabelInterval(item.value, index)));
|
|
38
21
|
}
|
|
@@ -40,7 +23,7 @@ function getVisibleLabels(xTicks, {
|
|
|
40
23
|
// Filter label to avoid overlap
|
|
41
24
|
let previousTextLimit = 0;
|
|
42
25
|
const direction = reverse ? -1 : 1;
|
|
43
|
-
|
|
26
|
+
const candidateTickLabels = xTicks.filter(item => {
|
|
44
27
|
const {
|
|
45
28
|
offset,
|
|
46
29
|
labelOffset,
|
|
@@ -50,18 +33,25 @@ function getVisibleLabels(xTicks, {
|
|
|
50
33
|
return false;
|
|
51
34
|
}
|
|
52
35
|
const textPosition = offset + labelOffset;
|
|
36
|
+
return isXInside(textPosition);
|
|
37
|
+
});
|
|
38
|
+
const sizeMap = measureTickLabels(candidateTickLabels, style);
|
|
39
|
+
return new Set(candidateTickLabels.filter((item, labelIndex) => {
|
|
40
|
+
const {
|
|
41
|
+
offset,
|
|
42
|
+
labelOffset
|
|
43
|
+
} = item;
|
|
44
|
+
const textPosition = offset + labelOffset;
|
|
53
45
|
if (labelIndex > 0 && direction * textPosition < direction * (previousTextLimit + tickLabelMinGap)) {
|
|
54
46
|
return false;
|
|
55
47
|
}
|
|
56
|
-
if (!isXInside(textPosition)) {
|
|
57
|
-
return false;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
/* Measuring text width is expensive, so we need to delay it as much as possible to improve performance. */
|
|
61
48
|
const {
|
|
62
49
|
width,
|
|
63
50
|
height
|
|
64
|
-
} = getTickLabelSize(item)
|
|
51
|
+
} = isMounted ? getTickLabelSize(sizeMap, item) : {
|
|
52
|
+
width: 0,
|
|
53
|
+
height: 0
|
|
54
|
+
};
|
|
65
55
|
const distance = (0, _geometry.getMinXTranslation)(width, height, style?.angle);
|
|
66
56
|
const currentTextLimit = textPosition - direction * distance / 2;
|
|
67
57
|
if (labelIndex > 0 && direction * currentTextLimit < direction * (previousTextLimit + tickLabelMinGap)) {
|
|
@@ -72,4 +62,34 @@ function getVisibleLabels(xTicks, {
|
|
|
72
62
|
previousTextLimit = textPosition + direction * distance / 2;
|
|
73
63
|
return true;
|
|
74
64
|
}));
|
|
65
|
+
}
|
|
66
|
+
function getTickLabelSize(sizeMap, tick) {
|
|
67
|
+
if (tick.formattedValue === undefined) {
|
|
68
|
+
return {
|
|
69
|
+
width: 0,
|
|
70
|
+
height: 0
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
let width = 0;
|
|
74
|
+
let height = 0;
|
|
75
|
+
for (const line of tick.formattedValue.split('\n')) {
|
|
76
|
+
const lineSize = sizeMap.get(line);
|
|
77
|
+
if (lineSize) {
|
|
78
|
+
width = Math.max(width, lineSize.width);
|
|
79
|
+
height += lineSize.height;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
return {
|
|
83
|
+
width,
|
|
84
|
+
height
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
function measureTickLabels(ticks, style) {
|
|
88
|
+
const strings = new Set();
|
|
89
|
+
for (const tick of ticks) {
|
|
90
|
+
if (tick.formattedValue) {
|
|
91
|
+
tick.formattedValue.split('\n').forEach(line => strings.add(line));
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
return (0, _domUtils.batchMeasureStrings)(strings, style);
|
|
75
95
|
}
|