@mui/x-charts 8.0.0-beta.0 → 8.0.0-beta.2
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/seriesConfig/extremums.js +2 -2
- package/BarChart/useBarChartProps.d.ts +2 -1
- package/BarChart/useBarChartProps.js +20 -13
- package/CHANGELOG.md +171 -0
- package/ChartsAxisHighlight/ChartsXAxisHighlight.js +8 -8
- package/ChartsAxisHighlight/ChartsYAxisHighlight.js +8 -8
- package/ChartsOverlay/ChartsLoadingOverlay.js +1 -1
- package/ChartsOverlay/ChartsNoDataOverlay.js +1 -1
- package/ChartsTooltip/ChartsTooltipContainer.js +2 -1
- package/ChartsTooltip/useAxisTooltip.js +2 -2
- package/LineChart/CircleMarkElement.js +2 -2
- package/LineChart/LineHighlightPlot.js +2 -2
- package/LineChart/MarkElement.js +2 -2
- package/LineChart/useLineChartProps.d.ts +2 -1
- package/LineChart/useLineChartProps.js +7 -4
- package/RadarChart/RadarAxisHighlight/useRadarAxisHighlight.js +9 -5
- package/RadarChart/RadarGrid/RadarGrid.d.ts +1 -1
- package/RadarChart/RadarGrid/RadarGrid.js +5 -1
- package/RadarChart/RadarGrid/useRadarGridData.d.ts +1 -1
- package/RadarChart/RadarGrid/useRadarGridData.js +3 -0
- package/RadarChart/RadarSeriesPlot/useRadarSeriesData.js +2 -2
- package/ScatterChart/useScatterChartProps.d.ts +2 -1
- package/ScatterChart/useScatterChartProps.js +6 -3
- package/esm/BarChart/seriesConfig/extremums.js +2 -2
- package/esm/BarChart/useBarChartProps.d.ts +2 -1
- package/esm/BarChart/useBarChartProps.js +19 -13
- package/esm/ChartsAxisHighlight/ChartsXAxisHighlight.js +8 -8
- package/esm/ChartsAxisHighlight/ChartsYAxisHighlight.js +8 -8
- package/esm/ChartsOverlay/ChartsLoadingOverlay.js +1 -1
- package/esm/ChartsOverlay/ChartsNoDataOverlay.js +1 -1
- package/esm/ChartsTooltip/ChartsTooltipContainer.js +2 -1
- package/esm/ChartsTooltip/useAxisTooltip.js +1 -1
- package/esm/LineChart/CircleMarkElement.js +1 -1
- package/esm/LineChart/LineHighlightPlot.js +1 -1
- package/esm/LineChart/MarkElement.js +1 -1
- package/esm/LineChart/useLineChartProps.d.ts +2 -1
- package/esm/LineChart/useLineChartProps.js +6 -4
- package/esm/RadarChart/RadarAxisHighlight/useRadarAxisHighlight.js +9 -5
- package/esm/RadarChart/RadarGrid/RadarGrid.d.ts +1 -1
- package/esm/RadarChart/RadarGrid/RadarGrid.js +5 -1
- package/esm/RadarChart/RadarGrid/useRadarGridData.d.ts +1 -1
- package/esm/RadarChart/RadarGrid/useRadarGridData.js +3 -0
- package/esm/RadarChart/RadarSeriesPlot/useRadarSeriesData.js +2 -2
- package/esm/ScatterChart/useScatterChartProps.d.ts +2 -1
- package/esm/ScatterChart/useScatterChartProps.js +5 -3
- package/esm/hooks/useAxis.d.ts +5 -5
- package/esm/hooks/useInteractionItemProps.js +1 -1
- package/esm/hooks/useScale.d.ts +2 -2
- package/esm/hooks/useScale.js +2 -2
- package/esm/index.js +1 -1
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisValue.d.ts +8 -6
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisValue.js +28 -22
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/index.d.ts +1 -0
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/index.js +1 -0
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxis.js +10 -43
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianInteraction.selectors.d.ts +1 -0
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianInteraction.selectors.js +41 -0
- package/esm/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.js +7 -20
- package/esm/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.selectors.d.ts +36 -242
- package/esm/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.selectors.js +4 -10
- package/esm/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.types.d.ts +9 -15
- package/esm/internals/plugins/featurePlugins/useChartPolarAxis/coordinateTransformation.d.ts +12 -0
- package/esm/internals/plugins/featurePlugins/useChartPolarAxis/coordinateTransformation.js +8 -0
- package/esm/internals/plugins/featurePlugins/useChartPolarAxis/getAxisValue.d.ts +6 -4
- package/esm/internals/plugins/featurePlugins/useChartPolarAxis/getAxisValue.js +18 -13
- package/esm/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarAxis.js +17 -33
- package/esm/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarInteraction.selectors.d.ts +3669 -0
- package/esm/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarInteraction.selectors.js +22 -0
- package/hooks/useAxis.d.ts +5 -5
- package/hooks/useInteractionItemProps.js +1 -1
- package/hooks/useScale.d.ts +2 -2
- package/hooks/useScale.js +2 -2
- package/index.js +1 -1
- package/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisValue.d.ts +8 -6
- package/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisValue.js +29 -22
- package/internals/plugins/featurePlugins/useChartCartesianAxis/index.d.ts +1 -0
- package/internals/plugins/featurePlugins/useChartCartesianAxis/index.js +12 -0
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxis.js +8 -41
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianInteraction.selectors.d.ts +1 -0
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianInteraction.selectors.js +47 -0
- package/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.js +7 -20
- package/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.selectors.d.ts +36 -242
- package/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.selectors.js +5 -11
- package/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.types.d.ts +9 -15
- package/internals/plugins/featurePlugins/useChartPolarAxis/coordinateTransformation.d.ts +12 -0
- package/internals/plugins/featurePlugins/useChartPolarAxis/coordinateTransformation.js +17 -0
- package/internals/plugins/featurePlugins/useChartPolarAxis/getAxisValue.d.ts +6 -4
- package/internals/plugins/featurePlugins/useChartPolarAxis/getAxisValue.js +19 -13
- package/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarAxis.js +17 -33
- package/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarInteraction.selectors.d.ts +3669 -0
- package/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarInteraction.selectors.js +28 -0
- package/modern/BarChart/seriesConfig/extremums.js +2 -2
- package/modern/BarChart/useBarChartProps.d.ts +2 -1
- package/modern/BarChart/useBarChartProps.js +19 -13
- package/modern/ChartsAxisHighlight/ChartsXAxisHighlight.js +8 -8
- package/modern/ChartsAxisHighlight/ChartsYAxisHighlight.js +8 -8
- package/modern/ChartsOverlay/ChartsLoadingOverlay.js +1 -1
- package/modern/ChartsOverlay/ChartsNoDataOverlay.js +1 -1
- package/modern/ChartsTooltip/ChartsTooltipContainer.js +2 -1
- package/modern/ChartsTooltip/useAxisTooltip.js +1 -1
- package/modern/LineChart/CircleMarkElement.js +1 -1
- package/modern/LineChart/LineHighlightPlot.js +1 -1
- package/modern/LineChart/MarkElement.js +1 -1
- package/modern/LineChart/useLineChartProps.d.ts +2 -1
- package/modern/LineChart/useLineChartProps.js +6 -4
- package/modern/RadarChart/RadarAxisHighlight/useRadarAxisHighlight.js +9 -5
- package/modern/RadarChart/RadarGrid/RadarGrid.d.ts +1 -1
- package/modern/RadarChart/RadarGrid/RadarGrid.js +5 -1
- package/modern/RadarChart/RadarGrid/useRadarGridData.d.ts +1 -1
- package/modern/RadarChart/RadarGrid/useRadarGridData.js +3 -0
- package/modern/RadarChart/RadarSeriesPlot/useRadarSeriesData.js +2 -2
- package/modern/ScatterChart/useScatterChartProps.d.ts +2 -1
- package/modern/ScatterChart/useScatterChartProps.js +5 -3
- package/modern/hooks/useAxis.d.ts +5 -5
- package/modern/hooks/useInteractionItemProps.js +1 -1
- package/modern/hooks/useScale.d.ts +2 -2
- package/modern/hooks/useScale.js +2 -2
- package/modern/index.js +1 -1
- package/modern/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisValue.d.ts +8 -6
- package/modern/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisValue.js +28 -22
- package/modern/internals/plugins/featurePlugins/useChartCartesianAxis/index.d.ts +1 -0
- package/modern/internals/plugins/featurePlugins/useChartCartesianAxis/index.js +1 -0
- package/modern/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxis.js +10 -43
- package/modern/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianInteraction.selectors.d.ts +1 -0
- package/modern/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianInteraction.selectors.js +41 -0
- package/modern/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.js +7 -20
- package/modern/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.selectors.d.ts +36 -242
- package/modern/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.selectors.js +4 -10
- package/modern/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.types.d.ts +9 -15
- package/modern/internals/plugins/featurePlugins/useChartPolarAxis/coordinateTransformation.d.ts +12 -0
- package/modern/internals/plugins/featurePlugins/useChartPolarAxis/coordinateTransformation.js +8 -0
- package/modern/internals/plugins/featurePlugins/useChartPolarAxis/getAxisValue.d.ts +6 -4
- package/modern/internals/plugins/featurePlugins/useChartPolarAxis/getAxisValue.js +18 -13
- package/modern/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarAxis.js +17 -33
- package/modern/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarInteraction.selectors.d.ts +3669 -0
- package/modern/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarInteraction.selectors.js +22 -0
- package/package.json +3 -3
- package/tsconfig.build.tsbuildinfo +1 -1
package/esm/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarInteraction.selectors.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { createSelector } from "../../utils/selectors.js";
|
|
2
|
+
import { selectorChartsInteractionPointerX, selectorChartsInteractionPointerY } from "../useChartInteraction/useChartInteraction.selectors.js";
|
|
3
|
+
import { generateSvg2rotation } from "./coordinateTransformation.js";
|
|
4
|
+
import { getAxisIndex } from "./getAxisValue.js";
|
|
5
|
+
import { selectorChartPolarCenter, selectorChartRotationAxis } from "./useChartPolarAxis.selectors.js";
|
|
6
|
+
export const selectorChartsInteractionRotationAxisIndex = createSelector([selectorChartsInteractionPointerX, selectorChartsInteractionPointerY, selectorChartPolarCenter, selectorChartRotationAxis], (x, y, center, rotationAxis) => {
|
|
7
|
+
if (x === null || y === null || !rotationAxis.axis[rotationAxis.axisIds[0]]) {
|
|
8
|
+
return null;
|
|
9
|
+
}
|
|
10
|
+
const rotation = generateSvg2rotation(center)(x, y);
|
|
11
|
+
return getAxisIndex(rotationAxis.axis[rotationAxis.axisIds[0]], rotation);
|
|
12
|
+
});
|
|
13
|
+
export const selectorChartsInteractionRotationAxisValue = createSelector([selectorChartsInteractionPointerX, selectorChartsInteractionPointerY, selectorChartRotationAxis, selectorChartsInteractionRotationAxisIndex], (x, y, rotationAxis, rotationIndex) => {
|
|
14
|
+
if (x === null || y === null || rotationIndex === null || rotationIndex === -1) {
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
const data = rotationAxis.axis[rotationAxis.axisIds[0]]?.data;
|
|
18
|
+
if (!data) {
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
return data[rotationIndex];
|
|
22
|
+
});
|
package/hooks/useAxis.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AxisId } from "../models/axis.js";
|
|
1
|
+
import { AxisId, ChartsRadiusAxisProps, ChartsRotationAxisProps, PolarAxisDefaultized, ScaleName } from "../models/axis.js";
|
|
2
2
|
/**
|
|
3
3
|
* Get all the x-axes.
|
|
4
4
|
*
|
|
@@ -40,12 +40,12 @@ export declare function useXAxis(axisId?: AxisId): import("../internals").AxisDe
|
|
|
40
40
|
*/
|
|
41
41
|
export declare function useYAxis(axisId?: AxisId): import("../internals").AxisDefaultized<keyof import("../internals").AxisScaleConfig, any, import("..").ChartsYAxisProps>;
|
|
42
42
|
export declare function useRotationAxes(): {
|
|
43
|
-
rotationAxis: import("../internals/plugins/featurePlugins/useChartPolarAxis/computeAxisValue").DefaultizedAxisConfig<
|
|
43
|
+
rotationAxis: import("../internals/plugins/featurePlugins/useChartPolarAxis/computeAxisValue").DefaultizedAxisConfig<ChartsRotationAxisProps>;
|
|
44
44
|
rotationAxisIds: string[];
|
|
45
45
|
};
|
|
46
46
|
export declare function useRadiusAxes(): {
|
|
47
|
-
radiusAxis: import("../internals/plugins/featurePlugins/useChartPolarAxis/computeAxisValue").DefaultizedAxisConfig<
|
|
47
|
+
radiusAxis: import("../internals/plugins/featurePlugins/useChartPolarAxis/computeAxisValue").DefaultizedAxisConfig<ChartsRadiusAxisProps>;
|
|
48
48
|
radiusAxisIds: string[];
|
|
49
49
|
};
|
|
50
|
-
export declare function useRotationAxis(identifier?: number | string):
|
|
51
|
-
export declare function useRadiusAxis(identifier?: number | string):
|
|
50
|
+
export declare function useRotationAxis(identifier?: number | string): PolarAxisDefaultized<ScaleName, any, ChartsRotationAxisProps> | undefined;
|
|
51
|
+
export declare function useRadiusAxis(identifier?: number | string): PolarAxisDefaultized<ScaleName, any, ChartsRadiusAxisProps> | undefined;
|
|
@@ -9,7 +9,7 @@ exports.useInteractionItemProps = exports.useInteractionAllItemProps = void 0;
|
|
|
9
9
|
var React = _interopRequireWildcard(require("react"));
|
|
10
10
|
var _ChartProvider = require("../context/ChartProvider");
|
|
11
11
|
const onPointerDown = event => {
|
|
12
|
-
if (event.currentTarget.hasPointerCapture(event.pointerId)) {
|
|
12
|
+
if ('hasPointerCapture' in event.currentTarget && event.currentTarget.hasPointerCapture(event.pointerId)) {
|
|
13
13
|
event.currentTarget.releasePointerCapture(event.pointerId);
|
|
14
14
|
}
|
|
15
15
|
};
|
package/hooks/useScale.d.ts
CHANGED
|
@@ -20,5 +20,5 @@ export declare function useXScale<S extends ScaleName>(axisId?: AxisId): AxisSca
|
|
|
20
20
|
* @returns {AxisScaleConfig[S]['scale']} The scale for the specified Y axis.
|
|
21
21
|
*/
|
|
22
22
|
export declare function useYScale<S extends ScaleName>(axisId?: AxisId): AxisScaleConfig[S]['scale'];
|
|
23
|
-
export declare function useRotationScale<S extends ScaleName>(identifier?: number | string): AxisScaleConfig[S]['scale'];
|
|
24
|
-
export declare function useRadiusScale<S extends ScaleName>(identifier?: number | string): AxisScaleConfig[S]['scale'];
|
|
23
|
+
export declare function useRotationScale<S extends ScaleName>(identifier?: number | string): AxisScaleConfig[S]['scale'] | undefined;
|
|
24
|
+
export declare function useRadiusScale<S extends ScaleName>(identifier?: number | string): AxisScaleConfig[S]['scale'] | undefined;
|
package/hooks/useScale.js
CHANGED
|
@@ -47,9 +47,9 @@ function useYScale(axisId) {
|
|
|
47
47
|
}
|
|
48
48
|
function useRotationScale(identifier) {
|
|
49
49
|
const axis = (0, _useAxis.useRotationAxis)(identifier);
|
|
50
|
-
return axis
|
|
50
|
+
return axis?.scale;
|
|
51
51
|
}
|
|
52
52
|
function useRadiusScale(identifier) {
|
|
53
53
|
const axis = (0, _useAxis.useRadiusAxis)(identifier);
|
|
54
|
-
return axis
|
|
54
|
+
return axis?.scale;
|
|
55
55
|
}
|
package/index.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { AxisDefaultized } from "../../../../models/axis.js";
|
|
2
2
|
/**
|
|
3
|
-
* For a pointer coordinate, this function returns the
|
|
4
|
-
* Returns `
|
|
3
|
+
* For a pointer coordinate, this function returns the dataIndex associated.
|
|
4
|
+
* Returns `-1` if no dataIndex matches.
|
|
5
5
|
*/
|
|
6
|
-
export declare function
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
export declare function getAxisIndex(axisConfig: AxisDefaultized, pointerValue: number): number;
|
|
7
|
+
/**
|
|
8
|
+
* For a pointer coordinate, this function returns the value associated.
|
|
9
|
+
* Returns `null` if the coordinate has no value associated.
|
|
10
|
+
*/
|
|
11
|
+
export declare function getAxisValue(axisConfig: AxisDefaultized, pointerValue: number, dataIndex: number): number | Date | null;
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
+
exports.getAxisIndex = getAxisIndex;
|
|
6
7
|
exports.getAxisValue = getAxisValue;
|
|
7
8
|
var _isBandScale = require("../../../isBandScale");
|
|
8
9
|
function getAsANumber(value) {
|
|
@@ -10,10 +11,10 @@ function getAsANumber(value) {
|
|
|
10
11
|
}
|
|
11
12
|
|
|
12
13
|
/**
|
|
13
|
-
* For a pointer coordinate, this function returns the
|
|
14
|
-
* Returns `
|
|
14
|
+
* For a pointer coordinate, this function returns the dataIndex associated.
|
|
15
|
+
* Returns `-1` if no dataIndex matches.
|
|
15
16
|
*/
|
|
16
|
-
function
|
|
17
|
+
function getAxisIndex(axisConfig, pointerValue) {
|
|
17
18
|
const {
|
|
18
19
|
scale,
|
|
19
20
|
data: axisData,
|
|
@@ -22,10 +23,7 @@ function getAxisValue(axisConfig, pointerValue) {
|
|
|
22
23
|
if (!(0, _isBandScale.isBandScale)(scale)) {
|
|
23
24
|
const value = scale.invert(pointerValue);
|
|
24
25
|
if (axisData === undefined) {
|
|
25
|
-
return
|
|
26
|
-
value,
|
|
27
|
-
index: -1
|
|
28
|
-
};
|
|
26
|
+
return -1;
|
|
29
27
|
}
|
|
30
28
|
const valueAsNumber = getAsANumber(value);
|
|
31
29
|
const closestIndex = axisData?.findIndex((pointValue, index) => {
|
|
@@ -42,24 +40,33 @@ function getAxisValue(axisConfig, pointerValue) {
|
|
|
42
40
|
}
|
|
43
41
|
return false;
|
|
44
42
|
});
|
|
45
|
-
return
|
|
46
|
-
value: closestIndex !== undefined && closestIndex >= 0 ? axisData[closestIndex] : value,
|
|
47
|
-
index: closestIndex
|
|
48
|
-
};
|
|
43
|
+
return closestIndex;
|
|
49
44
|
}
|
|
50
45
|
const dataIndex = scale.bandwidth() === 0 ? Math.floor((pointerValue - Math.min(...scale.range()) + scale.step() / 2) / scale.step()) : Math.floor((pointerValue - Math.min(...scale.range())) / scale.step());
|
|
51
46
|
if (dataIndex < 0 || dataIndex >= axisData.length) {
|
|
52
|
-
return
|
|
47
|
+
return -1;
|
|
48
|
+
}
|
|
49
|
+
return reverse ? axisData.length - 1 - dataIndex : dataIndex;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* For a pointer coordinate, this function returns the value associated.
|
|
54
|
+
* Returns `null` if the coordinate has no value associated.
|
|
55
|
+
*/
|
|
56
|
+
function getAxisValue(axisConfig, pointerValue, dataIndex) {
|
|
57
|
+
const {
|
|
58
|
+
scale,
|
|
59
|
+
data: axisData
|
|
60
|
+
} = axisConfig;
|
|
61
|
+
if (!(0, _isBandScale.isBandScale)(scale)) {
|
|
62
|
+
const value = scale.invert(pointerValue);
|
|
63
|
+
if (dataIndex < 0) {
|
|
64
|
+
return value;
|
|
65
|
+
}
|
|
66
|
+
return axisData[dataIndex];
|
|
53
67
|
}
|
|
54
|
-
if (
|
|
55
|
-
|
|
56
|
-
return {
|
|
57
|
-
index: reverseIndex,
|
|
58
|
-
value: axisData[reverseIndex]
|
|
59
|
-
};
|
|
68
|
+
if (dataIndex < 0 || dataIndex >= axisData.length) {
|
|
69
|
+
return null;
|
|
60
70
|
}
|
|
61
|
-
return
|
|
62
|
-
index: dataIndex,
|
|
63
|
-
value: axisData[dataIndex]
|
|
64
|
-
};
|
|
71
|
+
return axisData[dataIndex];
|
|
65
72
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export { useChartCartesianAxis } from "./useChartCartesianAxis.js";
|
|
2
2
|
export type * from './useChartCartesianAxis.types';
|
|
3
3
|
export * from "./useChartCartesianAxisRendering.selectors.js";
|
|
4
|
+
export * from "./useChartCartesianInteraction.selectors.js";
|
|
4
5
|
export { defaultizeXAxis, defaultizeYAxis } from "./defaultizeAxis.js";
|
|
5
6
|
export * from "./computeAxisValue.js";
|
|
6
7
|
export * from "./createZoomLookup.js";
|
|
@@ -39,6 +39,18 @@ Object.keys(_useChartCartesianAxisRendering).forEach(function (key) {
|
|
|
39
39
|
}
|
|
40
40
|
});
|
|
41
41
|
});
|
|
42
|
+
var _useChartCartesianInteraction = require("./useChartCartesianInteraction.selectors");
|
|
43
|
+
Object.keys(_useChartCartesianInteraction).forEach(function (key) {
|
|
44
|
+
if (key === "default" || key === "__esModule") return;
|
|
45
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
46
|
+
if (key in exports && exports[key] === _useChartCartesianInteraction[key]) return;
|
|
47
|
+
Object.defineProperty(exports, key, {
|
|
48
|
+
enumerable: true,
|
|
49
|
+
get: function () {
|
|
50
|
+
return _useChartCartesianInteraction[key];
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
});
|
|
42
54
|
var _defaultizeAxis = require("./defaultizeAxis");
|
|
43
55
|
var _computeAxisValue = require("./computeAxisValue");
|
|
44
56
|
Object.keys(_computeAxisValue).forEach(function (key) {
|
|
@@ -40,7 +40,6 @@ const useChartCartesianAxis = ({
|
|
|
40
40
|
}
|
|
41
41
|
const drawingArea = (0, _useSelector.useSelector)(store, _useChartDimensions.selectorChartDrawingArea);
|
|
42
42
|
const processedSeries = (0, _useSelector.useSelector)(store, _useChartSeries.selectorChartSeriesProcessed);
|
|
43
|
-
const interactionAxis = (0, _useSelector.useSelector)(store, _useChartInteraction.selectorChartsInteractionAxis);
|
|
44
43
|
const isInteractionEnabled = (0, _useSelector.useSelector)(store, _useChartInteraction.selectorChartsInteractionIsInitialized);
|
|
45
44
|
const {
|
|
46
45
|
axis: xAxisWithScale,
|
|
@@ -82,58 +81,31 @@ const useChartCartesianAxis = ({
|
|
|
82
81
|
if (!instance.isPointInside(svgPoint, {
|
|
83
82
|
targetElement: event.target
|
|
84
83
|
})) {
|
|
85
|
-
|
|
86
|
-
interaction: {
|
|
87
|
-
item: null,
|
|
88
|
-
axis: {
|
|
89
|
-
x: null,
|
|
90
|
-
y: null
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
}));
|
|
84
|
+
instance.cleanInteraction?.();
|
|
94
85
|
return;
|
|
95
86
|
}
|
|
96
|
-
instance.
|
|
97
|
-
x: (0, _getAxisValue.getAxisValue)(xAxisWithScale[usedXAxis], svgPoint.x),
|
|
98
|
-
y: (0, _getAxisValue.getAxisValue)(yAxisWithScale[usedYAxis], svgPoint.y)
|
|
99
|
-
});
|
|
87
|
+
instance.setPointerCoordinate?.(svgPoint);
|
|
100
88
|
};
|
|
101
89
|
const handleDown = event => {
|
|
102
90
|
const target = event.currentTarget;
|
|
103
91
|
if (!target) {
|
|
104
92
|
return;
|
|
105
93
|
}
|
|
106
|
-
if (target.hasPointerCapture(event.pointerId)) {
|
|
94
|
+
if ('hasPointerCapture' in target && target.hasPointerCapture(event.pointerId)) {
|
|
107
95
|
target.releasePointerCapture(event.pointerId);
|
|
108
96
|
}
|
|
109
97
|
};
|
|
110
98
|
element.addEventListener('pointerdown', handleDown);
|
|
111
99
|
element.addEventListener('pointermove', handleMove);
|
|
112
|
-
element.addEventListener('pointerout', handleOut);
|
|
113
100
|
element.addEventListener('pointercancel', handleOut);
|
|
114
101
|
element.addEventListener('pointerleave', handleOut);
|
|
115
102
|
return () => {
|
|
116
103
|
element.removeEventListener('pointerdown', handleDown);
|
|
117
104
|
element.removeEventListener('pointermove', handleMove);
|
|
118
|
-
element.removeEventListener('pointerout', handleOut);
|
|
119
105
|
element.removeEventListener('pointercancel', handleOut);
|
|
120
106
|
element.removeEventListener('pointerleave', handleOut);
|
|
121
107
|
};
|
|
122
108
|
}, [svgRef, store, xAxisWithScale, usedXAxis, yAxisWithScale, usedYAxis, instance, params.disableAxisListener, isInteractionEnabled]);
|
|
123
|
-
const axisInteractionRef = React.useRef({
|
|
124
|
-
x: null,
|
|
125
|
-
y: null
|
|
126
|
-
});
|
|
127
|
-
|
|
128
|
-
// This avoids re-attaching the event listener on mouse move.
|
|
129
|
-
React.useEffect(() => {
|
|
130
|
-
const {
|
|
131
|
-
x,
|
|
132
|
-
y
|
|
133
|
-
} = interactionAxis;
|
|
134
|
-
axisInteractionRef.current.x = x;
|
|
135
|
-
axisInteractionRef.current.y = y;
|
|
136
|
-
}, [interactionAxis]);
|
|
137
109
|
React.useEffect(() => {
|
|
138
110
|
const element = svgRef.current;
|
|
139
111
|
const onAxisClick = params.onAxisClick;
|
|
@@ -144,15 +116,10 @@ const useChartCartesianAxis = ({
|
|
|
144
116
|
event.preventDefault();
|
|
145
117
|
let dataIndex = null;
|
|
146
118
|
let isXAxis = false;
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
dataIndex = isXAxis ? xIndex : (0, _getAxisValue.getAxisValue)(yAxisWithScale[usedYAxis], svgPoint.y)?.index ?? null;
|
|
152
|
-
} else {
|
|
153
|
-
isXAxis = axisInteractionRef.current.x !== null && axisInteractionRef.current.x.index !== -1;
|
|
154
|
-
dataIndex = isXAxis ? axisInteractionRef.current.x && axisInteractionRef.current.x.index : axisInteractionRef.current.y && axisInteractionRef.current.y.index;
|
|
155
|
-
}
|
|
119
|
+
const svgPoint = (0, _getSVGPoint.getSVGPoint)(element, event);
|
|
120
|
+
const xIndex = (0, _getAxisValue.getAxisIndex)(xAxisWithScale[usedXAxis], svgPoint.x);
|
|
121
|
+
isXAxis = xIndex !== -1;
|
|
122
|
+
dataIndex = isXAxis ? xIndex : (0, _getAxisValue.getAxisIndex)(yAxisWithScale[usedYAxis], svgPoint.y);
|
|
156
123
|
const USED_AXIS_ID = isXAxis ? xAxisIds[0] : yAxisIds[0];
|
|
157
124
|
if (dataIndex == null || dataIndex === -1) {
|
|
158
125
|
return;
|
|
@@ -182,7 +149,7 @@ const useChartCartesianAxis = ({
|
|
|
182
149
|
return () => {
|
|
183
150
|
element.removeEventListener('click', handleMouseClick);
|
|
184
151
|
};
|
|
185
|
-
}, [params.onAxisClick, processedSeries, svgRef, xAxisWithScale, xAxisIds, yAxisWithScale, yAxisIds,
|
|
152
|
+
}, [params.onAxisClick, processedSeries, svgRef, xAxisWithScale, xAxisIds, yAxisWithScale, yAxisIds, usedXAxis, usedYAxis]);
|
|
186
153
|
return {};
|
|
187
154
|
};
|
|
188
155
|
exports.useChartCartesianAxis = useChartCartesianAxis;
|