@mui/x-charts 9.1.0 → 9.3.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 +10 -10
- package/BarChart/BarChart.mjs +10 -10
- package/BarChart/seriesConfig/bar/getColor.js +7 -53
- package/BarChart/seriesConfig/bar/getColor.mjs +7 -53
- package/BarChart/seriesConfig/bar/seriesProcessor.js +3 -1
- package/BarChart/seriesConfig/bar/seriesProcessor.mjs +3 -1
- package/BarChart/seriesConfig/bar/tooltip.js +4 -27
- package/BarChart/seriesConfig/bar/tooltip.mjs +4 -27
- package/CHANGELOG.md +221 -0
- package/ChartsContainer/ChartsContainer.js +9 -9
- package/ChartsContainer/ChartsContainer.mjs +9 -9
- package/ChartsLabel/ChartsLabelMark.js +0 -2
- package/ChartsLabel/ChartsLabelMark.mjs +0 -2
- package/ChartsLabel/labelMarkClasses.d.mts +0 -1
- package/ChartsLabel/labelMarkClasses.d.ts +0 -1
- package/ChartsLabel/labelMarkClasses.js +1 -2
- package/ChartsLabel/labelMarkClasses.mjs +2 -2
- package/ChartsLayerContainer/ChartsLayerContainer.js +36 -30
- package/ChartsLayerContainer/ChartsLayerContainer.mjs +36 -30
- package/ChartsRadialAxisHighlight/ChartsRadialAxisHighlight.types.d.mts +1 -1
- package/ChartsRadialAxisHighlight/ChartsRadialAxisHighlight.types.d.ts +1 -1
- package/ChartsRadialAxisHighlight/ChartsRadiusAxisHighlight.js +31 -14
- package/ChartsRadialAxisHighlight/ChartsRadiusAxisHighlight.mjs +32 -15
- package/ChartsRadiusAxis/ChartsRadiusAxis.d.mts +1 -47
- package/ChartsRadiusAxis/ChartsRadiusAxis.d.ts +1 -47
- package/ChartsRadiusAxis/ChartsRadiusAxis.js +20 -16
- package/ChartsRadiusAxis/ChartsRadiusAxis.mjs +21 -15
- package/ChartsRotationAxis/ChartsRotationAxis.d.mts +1 -47
- package/ChartsRotationAxis/ChartsRotationAxis.d.ts +1 -47
- package/ChartsRotationAxis/ChartsRotationAxis.js +16 -19
- package/ChartsRotationAxis/ChartsRotationAxis.mjs +17 -18
- package/ChartsTooltip/useAxesTooltip.d.mts +1 -1
- package/ChartsTooltip/useAxesTooltip.d.ts +1 -1
- package/ChartsTooltip/useAxesTooltip.js +11 -2
- package/ChartsTooltip/useAxesTooltip.mjs +12 -3
- package/ChartsXAxis/ChartsXAxis.js +3 -1
- package/ChartsXAxis/ChartsXAxis.mjs +3 -1
- package/ChartsYAxis/ChartsYAxis.js +3 -1
- package/ChartsYAxis/ChartsYAxis.mjs +3 -1
- package/LineChart/LineChart.js +6 -6
- package/LineChart/LineChart.mjs +6 -6
- package/LineChart/seriesConfig/curveEvaluation.js +12 -1
- package/LineChart/seriesConfig/curveEvaluation.mjs +12 -1
- package/LineChart/seriesConfig/getColor.js +7 -54
- package/LineChart/seriesConfig/getColor.mjs +7 -54
- package/LineChart/seriesConfig/seriesProcessor.d.mts +2 -4
- package/LineChart/seriesConfig/seriesProcessor.d.ts +2 -4
- package/LineChart/seriesConfig/seriesProcessor.js +2 -139
- package/LineChart/seriesConfig/seriesProcessor.mjs +2 -138
- package/LineChart/seriesConfig/tooltip.js +4 -25
- package/LineChart/seriesConfig/tooltip.mjs +4 -25
- package/PieChart/PieChart.js +6 -6
- package/PieChart/PieChart.mjs +6 -6
- package/RadarChart/RadarAxis/useRadarAxis.js +1 -1
- package/RadarChart/RadarAxis/useRadarAxis.mjs +1 -1
- package/RadarChart/RadarChart.js +8 -8
- package/RadarChart/RadarChart.mjs +8 -8
- package/RadarChart/RadarGrid/CircularRadarStripes.js +2 -3
- package/RadarChart/RadarGrid/CircularRadarStripes.mjs +2 -3
- package/RadarChart/RadarSeriesPlot/RadarSeriesArea.js +3 -1
- package/RadarChart/RadarSeriesPlot/RadarSeriesArea.mjs +3 -1
- package/RadarChart/RadarSeriesPlot/RadarSeriesMarks.js +1 -0
- package/RadarChart/RadarSeriesPlot/RadarSeriesMarks.mjs +1 -0
- package/RadarChart/RadarSeriesPlot/RadarSeriesPlot.js +1 -0
- package/RadarChart/RadarSeriesPlot/RadarSeriesPlot.mjs +1 -0
- package/RadarChart/RadarSeriesPlot/useRadarRotationIndex.js +1 -1
- package/RadarChart/RadarSeriesPlot/useRadarRotationIndex.mjs +2 -2
- package/ScatterChart/ScatterChart.js +11 -11
- package/ScatterChart/ScatterChart.mjs +11 -11
- package/ScatterChart/seriesConfig/tooltip.js +2 -24
- package/ScatterChart/seriesConfig/tooltip.mjs +2 -24
- package/SparkLineChart/SparkLineChart.js +27 -27
- package/SparkLineChart/SparkLineChart.mjs +27 -27
- package/index.js +1 -1
- package/index.mjs +1 -1
- package/internals/components/ChartsAccessibilityProxy/ChartsAccessibilityProxy.js +1 -1
- package/internals/components/ChartsAccessibilityProxy/ChartsAccessibilityProxy.mjs +1 -1
- package/internals/getLineLikeTooltip.d.mts +9 -0
- package/internals/getLineLikeTooltip.d.ts +9 -0
- package/internals/getLineLikeTooltip.js +38 -0
- package/internals/getLineLikeTooltip.mjs +31 -0
- package/internals/getRingPath.d.mts +16 -0
- package/internals/getRingPath.d.ts +16 -0
- package/internals/getRingPath.js +39 -0
- package/internals/getRingPath.mjs +33 -0
- package/internals/index.d.mts +7 -2
- package/internals/index.d.ts +7 -2
- package/internals/index.js +46 -3
- package/internals/index.mjs +6 -2
- package/internals/plugins/corePlugins/useChartSeriesConfig/types/tooltipGetter.types.d.mts +4 -2
- package/internals/plugins/corePlugins/useChartSeriesConfig/types/tooltipGetter.types.d.ts +4 -2
- package/internals/plugins/featurePlugins/useChartCartesianAxis/createZoomLookup.d.mts +3 -3
- package/internals/plugins/featurePlugins/useChartCartesianAxis/createZoomLookup.d.ts +3 -3
- package/internals/plugins/featurePlugins/useChartCartesianAxis/index.d.mts +1 -0
- package/internals/plugins/featurePlugins/useChartCartesianAxis/index.d.ts +1 -0
- package/internals/plugins/featurePlugins/useChartCartesianAxis/index.js +8 -0
- package/internals/plugins/featurePlugins/useChartCartesianAxis/index.mjs +1 -0
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisPosition.selectors.d.mts +6 -1
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisPosition.selectors.d.ts +6 -1
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisPosition.selectors.js +48 -36
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisPosition.selectors.mjs +47 -36
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.d.mts +74 -1
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.d.ts +74 -1
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianHighlight.selectors.d.mts +152 -2
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianHighlight.selectors.d.ts +152 -2
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianInteraction.selectors.d.mts +2 -2
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianInteraction.selectors.d.ts +2 -2
- package/internals/plugins/featurePlugins/useChartHighlight/useChartHighlight.js +3 -0
- package/internals/plugins/featurePlugins/useChartHighlight/useChartHighlight.mjs +3 -0
- package/internals/plugins/featurePlugins/useChartPolarAxis/getAxisExtremum.d.mts +2 -2
- package/internals/plugins/featurePlugins/useChartPolarAxis/getAxisExtremum.d.ts +2 -2
- package/internals/plugins/featurePlugins/useChartPolarAxis/getAxisIndex.d.mts +6 -1
- package/internals/plugins/featurePlugins/useChartPolarAxis/getAxisIndex.d.ts +6 -1
- package/internals/plugins/featurePlugins/useChartPolarAxis/getAxisIndex.js +36 -2
- package/internals/plugins/featurePlugins/useChartPolarAxis/getAxisIndex.mjs +34 -1
- package/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarAxis.js +1 -1
- package/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarAxis.mjs +2 -2
- package/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarInteraction.selectors.d.mts +22 -2
- package/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarInteraction.selectors.d.ts +22 -2
- package/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarInteraction.selectors.js +73 -12
- package/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarInteraction.selectors.mjs +74 -12
- package/internals/processLineLikeSeries.d.mts +6 -0
- package/internals/processLineLikeSeries.d.ts +6 -0
- package/internals/processLineLikeSeries.js +145 -0
- package/internals/processLineLikeSeries.mjs +138 -0
- package/internals/resolveColorProcessor.d.mts +11 -0
- package/internals/resolveColorProcessor.d.ts +11 -0
- package/internals/resolveColorProcessor.js +62 -0
- package/internals/resolveColorProcessor.mjs +56 -0
- package/models/axis.d.mts +55 -7
- package/models/axis.d.ts +55 -7
- package/package.json +3 -3
|
@@ -10,8 +10,9 @@ import { selectorChartPolarCenter } from "../internals/plugins/featurePlugins/us
|
|
|
10
10
|
import { useUtilityClasses } from "./chartsRadiusAxisClasses.mjs";
|
|
11
11
|
import { createGetLabelTextAnchors } from "./createGetLabelTextAnchors.mjs";
|
|
12
12
|
import { getLabelTransform } from "./getLabelTransform.mjs";
|
|
13
|
-
|
|
13
|
+
|
|
14
14
|
/* Gap between a tick and its label. */
|
|
15
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
15
16
|
const TICK_LABEL_GAP = 3;
|
|
16
17
|
const getLabelTextAnchors = createGetLabelTextAnchors(getLabelTransform);
|
|
17
18
|
|
|
@@ -34,17 +35,22 @@ function getAxisAngleInRadians(position, rotationAxis) {
|
|
|
34
35
|
return 0;
|
|
35
36
|
}
|
|
36
37
|
export function ChartsRadiusAxis(props) {
|
|
38
|
+
const radiusAxis = useRadiusAxis(props.axisId);
|
|
39
|
+
const settings = _extends({}, radiusAxis, props);
|
|
37
40
|
const {
|
|
38
|
-
axisId,
|
|
39
41
|
position = 'start',
|
|
40
42
|
disableLine,
|
|
41
43
|
disableTicks,
|
|
42
|
-
tickLabelPosition = '
|
|
43
|
-
tickPosition = 'after',
|
|
44
|
+
tickLabelPosition: tickLabelPositionProp = 'auto',
|
|
45
|
+
tickPosition = position === 'start' ? 'before' : 'after',
|
|
44
46
|
tickSize = 6,
|
|
45
47
|
className,
|
|
46
48
|
classes: classesProp
|
|
47
|
-
} =
|
|
49
|
+
} = settings;
|
|
50
|
+
let tickLabelPosition = tickLabelPositionProp;
|
|
51
|
+
if (tickLabelPosition === 'auto') {
|
|
52
|
+
tickLabelPosition = position === 'start' ? 'before' : 'after';
|
|
53
|
+
}
|
|
48
54
|
const isCentered = tickLabelPosition === 'center';
|
|
49
55
|
const classes = useUtilityClasses({
|
|
50
56
|
classes: classesProp,
|
|
@@ -58,7 +64,6 @@ export function ChartsRadiusAxis(props) {
|
|
|
58
64
|
cx,
|
|
59
65
|
cy
|
|
60
66
|
} = store.use(selectorChartPolarCenter);
|
|
61
|
-
const radiusAxis = useRadiusAxis(axisId);
|
|
62
67
|
const rotationAxis = useRotationAxis();
|
|
63
68
|
const ticks = useTicks({
|
|
64
69
|
scale: radiusAxis.scale,
|
|
@@ -68,7 +73,7 @@ export function ChartsRadiusAxis(props) {
|
|
|
68
73
|
valueFormatter: radiusAxis?.valueFormatter,
|
|
69
74
|
direction: 'radius'
|
|
70
75
|
});
|
|
71
|
-
if (!radiusAxis) {
|
|
76
|
+
if (!radiusAxis || settings.position === 'none') {
|
|
72
77
|
return null;
|
|
73
78
|
}
|
|
74
79
|
const angle = getAxisAngleInRadians(position, rotationAxis);
|
|
@@ -96,17 +101,18 @@ export function ChartsRadiusAxis(props) {
|
|
|
96
101
|
className: classes.line
|
|
97
102
|
}), ticks.map(({
|
|
98
103
|
offset: radius,
|
|
104
|
+
labelOffset,
|
|
99
105
|
formattedValue
|
|
100
106
|
}, index) => {
|
|
101
107
|
if (!formattedValue) {
|
|
102
108
|
return null;
|
|
103
109
|
}
|
|
104
|
-
const
|
|
105
|
-
const
|
|
110
|
+
const tickX = cx + dx * radius;
|
|
111
|
+
const tickY = cy + dy * radius;
|
|
106
112
|
|
|
107
113
|
// Compute the label position.
|
|
108
|
-
let labelX =
|
|
109
|
-
let labelY =
|
|
114
|
+
let labelX = cx + dx * (radius + labelOffset);
|
|
115
|
+
let labelY = cy + dy * (radius + labelOffset);
|
|
110
116
|
if (tickLabelGap !== 0) {
|
|
111
117
|
labelX += tickLabelGapDx;
|
|
112
118
|
labelY += tickLabelGapDy;
|
|
@@ -119,10 +125,10 @@ export function ChartsRadiusAxis(props) {
|
|
|
119
125
|
return /*#__PURE__*/_jsxs("g", {
|
|
120
126
|
className: classes.tickContainer,
|
|
121
127
|
children: [!disableTicks && /*#__PURE__*/_jsx("line", {
|
|
122
|
-
x1:
|
|
123
|
-
y1:
|
|
124
|
-
x2:
|
|
125
|
-
y2:
|
|
128
|
+
x1: tickX,
|
|
129
|
+
y1: tickY,
|
|
130
|
+
x2: tickX + tickDx,
|
|
131
|
+
y2: tickY + tickDy,
|
|
126
132
|
stroke: stroke,
|
|
127
133
|
className: classes.tick
|
|
128
134
|
}), /*#__PURE__*/_jsx("text", _extends({
|
|
@@ -1,48 +1,2 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import { type ChartsRadialAxisClasses } from "./chartsRotationAxisClasses.mjs";
|
|
3
|
-
export interface ChartsRotationAxisProps {
|
|
4
|
-
/**
|
|
5
|
-
* Id of the rotation axis to render.
|
|
6
|
-
* If not provided, it will use the first defined rotation axis.
|
|
7
|
-
*/
|
|
8
|
-
axisId?: AxisId;
|
|
9
|
-
/**
|
|
10
|
-
* If `true`, the axis line is not rendered.
|
|
11
|
-
* @default false
|
|
12
|
-
*/
|
|
13
|
-
disableLine?: boolean;
|
|
14
|
-
/**
|
|
15
|
-
* If `true`, the ticks are not rendered.
|
|
16
|
-
* @default false
|
|
17
|
-
*/
|
|
18
|
-
disableTicks?: boolean;
|
|
19
|
-
/**
|
|
20
|
-
* The position of the rotation axis.
|
|
21
|
-
* It can be 'inside' or 'outside'.
|
|
22
|
-
* @default 'outside'
|
|
23
|
-
*/
|
|
24
|
-
position?: 'inside' | 'outside';
|
|
25
|
-
/**
|
|
26
|
-
* The size (in pixels) of the tick marks.
|
|
27
|
-
* @default 6
|
|
28
|
-
*/
|
|
29
|
-
tickSize?: number;
|
|
30
|
-
/**
|
|
31
|
-
* Set the position of the tick labels relative to the axis line.
|
|
32
|
-
* `'after'` places them outside the arc, `'before'` inside.
|
|
33
|
-
* @default position === 'outside' ? 'after' : 'before'
|
|
34
|
-
*/
|
|
35
|
-
tickLabelPosition?: 'after' | 'before';
|
|
36
|
-
/**
|
|
37
|
-
* Set the position of the tick relative to the axis line.
|
|
38
|
-
* `'after'` places them outside the arc, `'before'` inside.
|
|
39
|
-
* @default position === 'outside' ? 'after' : 'before'
|
|
40
|
-
*/
|
|
41
|
-
tickPosition?: 'after' | 'before';
|
|
42
|
-
/**
|
|
43
|
-
* A CSS class name applied to the root element.
|
|
44
|
-
*/
|
|
45
|
-
className?: string;
|
|
46
|
-
classes?: Partial<ChartsRadialAxisClasses>;
|
|
47
|
-
}
|
|
1
|
+
import type { ChartsRotationAxisProps } from "../models/axis.mjs";
|
|
48
2
|
export declare function ChartsRotationAxis(props: ChartsRotationAxisProps): import("react/jsx-runtime").JSX.Element | null;
|
|
@@ -1,48 +1,2 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import { type ChartsRadialAxisClasses } from "./chartsRotationAxisClasses.js";
|
|
3
|
-
export interface ChartsRotationAxisProps {
|
|
4
|
-
/**
|
|
5
|
-
* Id of the rotation axis to render.
|
|
6
|
-
* If not provided, it will use the first defined rotation axis.
|
|
7
|
-
*/
|
|
8
|
-
axisId?: AxisId;
|
|
9
|
-
/**
|
|
10
|
-
* If `true`, the axis line is not rendered.
|
|
11
|
-
* @default false
|
|
12
|
-
*/
|
|
13
|
-
disableLine?: boolean;
|
|
14
|
-
/**
|
|
15
|
-
* If `true`, the ticks are not rendered.
|
|
16
|
-
* @default false
|
|
17
|
-
*/
|
|
18
|
-
disableTicks?: boolean;
|
|
19
|
-
/**
|
|
20
|
-
* The position of the rotation axis.
|
|
21
|
-
* It can be 'inside' or 'outside'.
|
|
22
|
-
* @default 'outside'
|
|
23
|
-
*/
|
|
24
|
-
position?: 'inside' | 'outside';
|
|
25
|
-
/**
|
|
26
|
-
* The size (in pixels) of the tick marks.
|
|
27
|
-
* @default 6
|
|
28
|
-
*/
|
|
29
|
-
tickSize?: number;
|
|
30
|
-
/**
|
|
31
|
-
* Set the position of the tick labels relative to the axis line.
|
|
32
|
-
* `'after'` places them outside the arc, `'before'` inside.
|
|
33
|
-
* @default position === 'outside' ? 'after' : 'before'
|
|
34
|
-
*/
|
|
35
|
-
tickLabelPosition?: 'after' | 'before';
|
|
36
|
-
/**
|
|
37
|
-
* Set the position of the tick relative to the axis line.
|
|
38
|
-
* `'after'` places them outside the arc, `'before'` inside.
|
|
39
|
-
* @default position === 'outside' ? 'after' : 'before'
|
|
40
|
-
*/
|
|
41
|
-
tickPosition?: 'after' | 'before';
|
|
42
|
-
/**
|
|
43
|
-
* A CSS class name applied to the root element.
|
|
44
|
-
*/
|
|
45
|
-
className?: string;
|
|
46
|
-
classes?: Partial<ChartsRadialAxisClasses>;
|
|
47
|
-
}
|
|
1
|
+
import type { ChartsRotationAxisProps } from "../models/axis.js";
|
|
48
2
|
export declare function ChartsRotationAxis(props: ChartsRotationAxisProps): import("react/jsx-runtime").JSX.Element | null;
|
|
@@ -17,12 +17,12 @@ var _chartsRotationAxisClasses = require("./chartsRotationAxisClasses");
|
|
|
17
17
|
var _createGetLabelTextAnchors = require("../ChartsRadiusAxis/createGetLabelTextAnchors");
|
|
18
18
|
var _getLabelTransform = require("./getLabelTransform");
|
|
19
19
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
20
|
-
/* Gap between a tick and its label. */
|
|
21
|
-
const TICK_LABEL_GAP = 3;
|
|
20
|
+
/* Gap between a tick and its label. */const TICK_LABEL_GAP = 3;
|
|
22
21
|
const getLabelTextAnchors = (0, _createGetLabelTextAnchors.createGetLabelTextAnchors)(_getLabelTransform.getLabelTransform);
|
|
23
22
|
function ChartsRotationAxis(props) {
|
|
23
|
+
const rotationAxis = (0, _useAxis.useRotationAxis)(props.axisId);
|
|
24
|
+
const settings = (0, _extends2.default)({}, rotationAxis, props);
|
|
24
25
|
const {
|
|
25
|
-
axisId,
|
|
26
26
|
disableLine,
|
|
27
27
|
disableTicks,
|
|
28
28
|
position = 'outside',
|
|
@@ -31,7 +31,7 @@ function ChartsRotationAxis(props) {
|
|
|
31
31
|
tickSize = 6,
|
|
32
32
|
className,
|
|
33
33
|
classes: classesProp
|
|
34
|
-
} =
|
|
34
|
+
} = settings;
|
|
35
35
|
const classes = (0, _chartsRotationAxisClasses.useUtilityClasses)({
|
|
36
36
|
classes: classesProp
|
|
37
37
|
});
|
|
@@ -43,7 +43,6 @@ function ChartsRotationAxis(props) {
|
|
|
43
43
|
cx,
|
|
44
44
|
cy
|
|
45
45
|
} = store.use(_useChartPolarAxis.selectorChartPolarCenter);
|
|
46
|
-
const rotationAxis = (0, _useAxis.useRotationAxis)(axisId);
|
|
47
46
|
const radiusAxis = (0, _useAxis.useRadiusAxis)();
|
|
48
47
|
const ticks = (0, _useTicks.useTicks)({
|
|
49
48
|
scale: rotationAxis.scale,
|
|
@@ -53,7 +52,7 @@ function ChartsRotationAxis(props) {
|
|
|
53
52
|
valueFormatter: rotationAxis?.valueFormatter,
|
|
54
53
|
direction: 'rotation'
|
|
55
54
|
});
|
|
56
|
-
if (!rotationAxis || !radiusAxis) {
|
|
55
|
+
if (!rotationAxis || !radiusAxis || settings.position === 'none') {
|
|
57
56
|
return null;
|
|
58
57
|
}
|
|
59
58
|
const radius = radiusAxis.scale.range()[position === 'inside' ? 0 : 1];
|
|
@@ -65,7 +64,6 @@ function ChartsRotationAxis(props) {
|
|
|
65
64
|
x: cx + Math.sin(angle) * r,
|
|
66
65
|
y: cy - Math.cos(angle) * r
|
|
67
66
|
});
|
|
68
|
-
const isFullCircle = Math.abs(endAngle - startAngle) > 2 * Math.PI - 0.01;
|
|
69
67
|
const sweepFlag = endAngle - startAngle >= 0 ? 1 : 0;
|
|
70
68
|
const start = angleToPoint(startAngle, radius);
|
|
71
69
|
const end = angleToPoint(endAngle, radius);
|
|
@@ -73,7 +71,7 @@ function ChartsRotationAxis(props) {
|
|
|
73
71
|
const arcPath = `M ${start.x} ${start.y} ` + `A ${radius} ${radius} 0 ${largeArcFlag} ${sweepFlag} ${end.x} ${end.y}`;
|
|
74
72
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)("g", {
|
|
75
73
|
className: (0, _clsx.default)(classes.root, className),
|
|
76
|
-
children: [!disableLine && (isFullCircle ?
|
|
74
|
+
children: [!disableLine && (rotationAxis.isFullCircle ?
|
|
77
75
|
/*#__PURE__*/
|
|
78
76
|
// Use a circle to avoid degenerated arcs when start and end angles are the same or very close.
|
|
79
77
|
(0, _jsxRuntime.jsx)("circle", {
|
|
@@ -90,6 +88,7 @@ function ChartsRotationAxis(props) {
|
|
|
90
88
|
className: classes.line
|
|
91
89
|
})), ticks.map(({
|
|
92
90
|
offset: angle,
|
|
91
|
+
labelOffset,
|
|
93
92
|
formattedValue
|
|
94
93
|
}, index) => {
|
|
95
94
|
if (!formattedValue) {
|
|
@@ -99,23 +98,21 @@ function ChartsRotationAxis(props) {
|
|
|
99
98
|
// Convert "0 = up" convention to SVG math angle (0 = right, clockwise y-down).
|
|
100
99
|
const dx = Math.sin(angle);
|
|
101
100
|
const dy = -Math.cos(angle);
|
|
101
|
+
const labelDx = labelOffset === 0 ? dx : Math.sin(angle + labelOffset);
|
|
102
|
+
const labelDy = labelOffset === 0 ? dy : -Math.cos(angle + labelOffset);
|
|
102
103
|
const tx = cx + dx * radius;
|
|
103
104
|
const ty = cy + dy * radius;
|
|
104
105
|
const tickDx = (tickPosition === 'after' ? 1 : -1) * dx * tickSize;
|
|
105
106
|
const tickDy = (tickPosition === 'after' ? 1 : -1) * dy * tickSize;
|
|
106
|
-
|
|
107
|
-
const tickLabelGapDy = (tickLabelPosition === 'after' ? 1 : -1) * dy * TICK_LABEL_GAP;
|
|
108
|
-
|
|
109
|
-
// Compute the label position.
|
|
110
|
-
let labelX = tx;
|
|
111
|
-
let labelY = ty;
|
|
112
|
-
labelX += tickLabelGapDx;
|
|
113
|
-
labelY += tickLabelGapDy;
|
|
107
|
+
let tickLabelRadius = radius + (tickLabelPosition === 'after' ? 1 : -1) * TICK_LABEL_GAP;
|
|
114
108
|
if (tickLabelPosition === tickPosition && !disableTicks) {
|
|
115
109
|
// Add the size of the tick if they are in the same direction.
|
|
116
|
-
|
|
117
|
-
labelY += tickDy;
|
|
110
|
+
tickLabelRadius += tickSize;
|
|
118
111
|
}
|
|
112
|
+
|
|
113
|
+
// Compute the label position.
|
|
114
|
+
const labelX = cx + labelDx * tickLabelRadius;
|
|
115
|
+
const labelY = cy + labelDy * tickLabelRadius;
|
|
119
116
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)("g", {
|
|
120
117
|
className: classes.tickContainer,
|
|
121
118
|
children: [!disableTicks && /*#__PURE__*/(0, _jsxRuntime.jsx)("line", {
|
|
@@ -132,7 +129,7 @@ function ChartsRotationAxis(props) {
|
|
|
132
129
|
fontSize: 12,
|
|
133
130
|
className: classes.tickLabel,
|
|
134
131
|
pointerEvents: "none"
|
|
135
|
-
}, getLabelTextAnchors(
|
|
132
|
+
}, getLabelTextAnchors(labelDx, labelDy, tickLabelPosition), {
|
|
136
133
|
children: formattedValue
|
|
137
134
|
}))]
|
|
138
135
|
}, index);
|
|
@@ -10,13 +10,15 @@ import { selectorChartPolarCenter } from "../internals/plugins/featurePlugins/us
|
|
|
10
10
|
import { useUtilityClasses } from "./chartsRotationAxisClasses.mjs";
|
|
11
11
|
import { createGetLabelTextAnchors } from "../ChartsRadiusAxis/createGetLabelTextAnchors.mjs";
|
|
12
12
|
import { getLabelTransform } from "./getLabelTransform.mjs";
|
|
13
|
-
|
|
13
|
+
|
|
14
14
|
/* Gap between a tick and its label. */
|
|
15
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
15
16
|
const TICK_LABEL_GAP = 3;
|
|
16
17
|
const getLabelTextAnchors = createGetLabelTextAnchors(getLabelTransform);
|
|
17
18
|
export function ChartsRotationAxis(props) {
|
|
19
|
+
const rotationAxis = useRotationAxis(props.axisId);
|
|
20
|
+
const settings = _extends({}, rotationAxis, props);
|
|
18
21
|
const {
|
|
19
|
-
axisId,
|
|
20
22
|
disableLine,
|
|
21
23
|
disableTicks,
|
|
22
24
|
position = 'outside',
|
|
@@ -25,7 +27,7 @@ export function ChartsRotationAxis(props) {
|
|
|
25
27
|
tickSize = 6,
|
|
26
28
|
className,
|
|
27
29
|
classes: classesProp
|
|
28
|
-
} =
|
|
30
|
+
} = settings;
|
|
29
31
|
const classes = useUtilityClasses({
|
|
30
32
|
classes: classesProp
|
|
31
33
|
});
|
|
@@ -37,7 +39,6 @@ export function ChartsRotationAxis(props) {
|
|
|
37
39
|
cx,
|
|
38
40
|
cy
|
|
39
41
|
} = store.use(selectorChartPolarCenter);
|
|
40
|
-
const rotationAxis = useRotationAxis(axisId);
|
|
41
42
|
const radiusAxis = useRadiusAxis();
|
|
42
43
|
const ticks = useTicks({
|
|
43
44
|
scale: rotationAxis.scale,
|
|
@@ -47,7 +48,7 @@ export function ChartsRotationAxis(props) {
|
|
|
47
48
|
valueFormatter: rotationAxis?.valueFormatter,
|
|
48
49
|
direction: 'rotation'
|
|
49
50
|
});
|
|
50
|
-
if (!rotationAxis || !radiusAxis) {
|
|
51
|
+
if (!rotationAxis || !radiusAxis || settings.position === 'none') {
|
|
51
52
|
return null;
|
|
52
53
|
}
|
|
53
54
|
const radius = radiusAxis.scale.range()[position === 'inside' ? 0 : 1];
|
|
@@ -59,7 +60,6 @@ export function ChartsRotationAxis(props) {
|
|
|
59
60
|
x: cx + Math.sin(angle) * r,
|
|
60
61
|
y: cy - Math.cos(angle) * r
|
|
61
62
|
});
|
|
62
|
-
const isFullCircle = Math.abs(endAngle - startAngle) > 2 * Math.PI - 0.01;
|
|
63
63
|
const sweepFlag = endAngle - startAngle >= 0 ? 1 : 0;
|
|
64
64
|
const start = angleToPoint(startAngle, radius);
|
|
65
65
|
const end = angleToPoint(endAngle, radius);
|
|
@@ -67,7 +67,7 @@ export function ChartsRotationAxis(props) {
|
|
|
67
67
|
const arcPath = `M ${start.x} ${start.y} ` + `A ${radius} ${radius} 0 ${largeArcFlag} ${sweepFlag} ${end.x} ${end.y}`;
|
|
68
68
|
return /*#__PURE__*/_jsxs("g", {
|
|
69
69
|
className: clsx(classes.root, className),
|
|
70
|
-
children: [!disableLine && (isFullCircle ?
|
|
70
|
+
children: [!disableLine && (rotationAxis.isFullCircle ?
|
|
71
71
|
/*#__PURE__*/
|
|
72
72
|
// Use a circle to avoid degenerated arcs when start and end angles are the same or very close.
|
|
73
73
|
_jsx("circle", {
|
|
@@ -84,6 +84,7 @@ export function ChartsRotationAxis(props) {
|
|
|
84
84
|
className: classes.line
|
|
85
85
|
})), ticks.map(({
|
|
86
86
|
offset: angle,
|
|
87
|
+
labelOffset,
|
|
87
88
|
formattedValue
|
|
88
89
|
}, index) => {
|
|
89
90
|
if (!formattedValue) {
|
|
@@ -93,23 +94,21 @@ export function ChartsRotationAxis(props) {
|
|
|
93
94
|
// Convert "0 = up" convention to SVG math angle (0 = right, clockwise y-down).
|
|
94
95
|
const dx = Math.sin(angle);
|
|
95
96
|
const dy = -Math.cos(angle);
|
|
97
|
+
const labelDx = labelOffset === 0 ? dx : Math.sin(angle + labelOffset);
|
|
98
|
+
const labelDy = labelOffset === 0 ? dy : -Math.cos(angle + labelOffset);
|
|
96
99
|
const tx = cx + dx * radius;
|
|
97
100
|
const ty = cy + dy * radius;
|
|
98
101
|
const tickDx = (tickPosition === 'after' ? 1 : -1) * dx * tickSize;
|
|
99
102
|
const tickDy = (tickPosition === 'after' ? 1 : -1) * dy * tickSize;
|
|
100
|
-
|
|
101
|
-
const tickLabelGapDy = (tickLabelPosition === 'after' ? 1 : -1) * dy * TICK_LABEL_GAP;
|
|
102
|
-
|
|
103
|
-
// Compute the label position.
|
|
104
|
-
let labelX = tx;
|
|
105
|
-
let labelY = ty;
|
|
106
|
-
labelX += tickLabelGapDx;
|
|
107
|
-
labelY += tickLabelGapDy;
|
|
103
|
+
let tickLabelRadius = radius + (tickLabelPosition === 'after' ? 1 : -1) * TICK_LABEL_GAP;
|
|
108
104
|
if (tickLabelPosition === tickPosition && !disableTicks) {
|
|
109
105
|
// Add the size of the tick if they are in the same direction.
|
|
110
|
-
|
|
111
|
-
labelY += tickDy;
|
|
106
|
+
tickLabelRadius += tickSize;
|
|
112
107
|
}
|
|
108
|
+
|
|
109
|
+
// Compute the label position.
|
|
110
|
+
const labelX = cx + labelDx * tickLabelRadius;
|
|
111
|
+
const labelY = cy + labelDy * tickLabelRadius;
|
|
113
112
|
return /*#__PURE__*/_jsxs("g", {
|
|
114
113
|
className: classes.tickContainer,
|
|
115
114
|
children: [!disableTicks && /*#__PURE__*/_jsx("line", {
|
|
@@ -126,7 +125,7 @@ export function ChartsRotationAxis(props) {
|
|
|
126
125
|
fontSize: 12,
|
|
127
126
|
className: classes.tickLabel,
|
|
128
127
|
pointerEvents: "none"
|
|
129
|
-
}, getLabelTextAnchors(
|
|
128
|
+
}, getLabelTextAnchors(labelDx, labelDy, tickLabelPosition), {
|
|
130
129
|
children: formattedValue
|
|
131
130
|
}))]
|
|
132
131
|
}, index);
|
|
@@ -16,7 +16,7 @@ export interface UseAxesTooltipParams {
|
|
|
16
16
|
* The axis directions to consider.
|
|
17
17
|
* If not defined, all directions are considered
|
|
18
18
|
*/
|
|
19
|
-
directions?: ('x' | 'y' | 'rotation')[];
|
|
19
|
+
directions?: ('x' | 'y' | 'rotation' | 'radius')[];
|
|
20
20
|
}
|
|
21
21
|
export interface SeriesItem<T extends CartesianChartSeriesType | PolarChartSeriesType> {
|
|
22
22
|
seriesId: SeriesId;
|
|
@@ -16,7 +16,7 @@ export interface UseAxesTooltipParams {
|
|
|
16
16
|
* The axis directions to consider.
|
|
17
17
|
* If not defined, all directions are considered
|
|
18
18
|
*/
|
|
19
|
-
directions?: ('x' | 'y' | 'rotation')[];
|
|
19
|
+
directions?: ('x' | 'y' | 'rotation' | 'radius')[];
|
|
20
20
|
}
|
|
21
21
|
export interface SeriesItem<T extends CartesianChartSeriesType | PolarChartSeriesType> {
|
|
22
22
|
seriesId: SeriesId;
|
|
@@ -58,6 +58,7 @@ function useAxesTooltip(params) {
|
|
|
58
58
|
const tooltipXAxes = store.use(_useChartCartesianAxis.selectorChartsInteractionTooltipXAxes);
|
|
59
59
|
const tooltipYAxes = store.use(_useChartCartesianAxis.selectorChartsInteractionTooltipYAxes);
|
|
60
60
|
const tooltipRotationAxes = store.use(_useChartPolarInteraction.selectorChartsInteractionTooltipRotationAxes);
|
|
61
|
+
const tooltipRadiusAxes = store.use(_useChartPolarInteraction.selectorChartsInteractionTooltipRadiusAxes);
|
|
61
62
|
const series = (0, _useSeries.useSeries)();
|
|
62
63
|
const {
|
|
63
64
|
xAxis
|
|
@@ -77,7 +78,7 @@ function useAxesTooltip(params) {
|
|
|
77
78
|
} = (0, _useAxis.useRadiusAxes)();
|
|
78
79
|
const colorProcessors = (0, _useColorProcessor.useColorProcessor)();
|
|
79
80
|
const isItemVisible = store.use(_useChartVisibilityManager.selectorIsItemVisibleGetter);
|
|
80
|
-
if (tooltipXAxes.length === 0 && tooltipYAxes.length === 0 && tooltipRotationAxes.length === 0) {
|
|
81
|
+
if (tooltipXAxes.length === 0 && tooltipYAxes.length === 0 && tooltipRotationAxes.length === 0 && tooltipRadiusAxes.length === 0) {
|
|
81
82
|
return null;
|
|
82
83
|
}
|
|
83
84
|
const tooltipAxes = [];
|
|
@@ -105,6 +106,14 @@ function useAxesTooltip(params) {
|
|
|
105
106
|
tooltipAxes.push(defaultAxisTooltipConfig(rotationAxis[axisId], dataIndex, 'rotation'));
|
|
106
107
|
});
|
|
107
108
|
}
|
|
109
|
+
if (directions === undefined || directions.includes('radius')) {
|
|
110
|
+
tooltipRadiusAxes.forEach(({
|
|
111
|
+
axisId,
|
|
112
|
+
dataIndex
|
|
113
|
+
}) => {
|
|
114
|
+
tooltipAxes.push(defaultAxisTooltipConfig(radiusAxis[axisId], dataIndex, 'radius'));
|
|
115
|
+
});
|
|
116
|
+
}
|
|
108
117
|
Object.keys(series).filter(seriesType => _composition.composableCartesianSeriesTypes.has(seriesType)).forEach(seriesType => {
|
|
109
118
|
const seriesOfType = series[seriesType];
|
|
110
119
|
if (!seriesOfType) {
|
|
@@ -202,7 +211,7 @@ function useAxesTooltip(params) {
|
|
|
202
211
|
const tooltipItemIndex = tooltipAxes.findIndex(({
|
|
203
212
|
axisDirection,
|
|
204
213
|
axisId
|
|
205
|
-
}) => axisDirection === 'rotation' && axisId === providedRotationAxisId);
|
|
214
|
+
}) => axisDirection === 'rotation' && axisId === providedRotationAxisId || axisDirection === 'radius' && axisId === providedRadiusAxisId);
|
|
206
215
|
// Test if the series uses the default axis
|
|
207
216
|
if (tooltipItemIndex >= 0) {
|
|
208
217
|
const {
|
|
@@ -8,7 +8,7 @@ import { utcFormatter } from "./utils.mjs";
|
|
|
8
8
|
import { useRadiusAxes, useRadiusAxis, useRotationAxes, useRotationAxis, useXAxes, useXAxis, useYAxes, useYAxis } from "../hooks/useAxis.mjs";
|
|
9
9
|
import { useZAxes } from "../hooks/useZAxis.mjs";
|
|
10
10
|
import { selectorChartsInteractionTooltipXAxes, selectorChartsInteractionTooltipYAxes } from "../internals/plugins/featurePlugins/useChartCartesianAxis/index.mjs";
|
|
11
|
-
import { selectorChartsInteractionTooltipRotationAxes } from "../internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarInteraction.selectors.mjs";
|
|
11
|
+
import { selectorChartsInteractionTooltipRadiusAxes, selectorChartsInteractionTooltipRotationAxes } from "../internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarInteraction.selectors.mjs";
|
|
12
12
|
import { isPolarSeriesType } from "../internals/isPolar.mjs";
|
|
13
13
|
import { selectorIsItemVisibleGetter } from "../internals/plugins/featurePlugins/useChartVisibilityManager/useChartVisibilityManager.selectors.mjs";
|
|
14
14
|
import { composableCartesianSeriesTypes } from "../models/seriesType/composition.mjs";
|
|
@@ -53,6 +53,7 @@ export function useAxesTooltip(params) {
|
|
|
53
53
|
const tooltipXAxes = store.use(selectorChartsInteractionTooltipXAxes);
|
|
54
54
|
const tooltipYAxes = store.use(selectorChartsInteractionTooltipYAxes);
|
|
55
55
|
const tooltipRotationAxes = store.use(selectorChartsInteractionTooltipRotationAxes);
|
|
56
|
+
const tooltipRadiusAxes = store.use(selectorChartsInteractionTooltipRadiusAxes);
|
|
56
57
|
const series = useSeries();
|
|
57
58
|
const {
|
|
58
59
|
xAxis
|
|
@@ -72,7 +73,7 @@ export function useAxesTooltip(params) {
|
|
|
72
73
|
} = useRadiusAxes();
|
|
73
74
|
const colorProcessors = useColorProcessor();
|
|
74
75
|
const isItemVisible = store.use(selectorIsItemVisibleGetter);
|
|
75
|
-
if (tooltipXAxes.length === 0 && tooltipYAxes.length === 0 && tooltipRotationAxes.length === 0) {
|
|
76
|
+
if (tooltipXAxes.length === 0 && tooltipYAxes.length === 0 && tooltipRotationAxes.length === 0 && tooltipRadiusAxes.length === 0) {
|
|
76
77
|
return null;
|
|
77
78
|
}
|
|
78
79
|
const tooltipAxes = [];
|
|
@@ -100,6 +101,14 @@ export function useAxesTooltip(params) {
|
|
|
100
101
|
tooltipAxes.push(defaultAxisTooltipConfig(rotationAxis[axisId], dataIndex, 'rotation'));
|
|
101
102
|
});
|
|
102
103
|
}
|
|
104
|
+
if (directions === undefined || directions.includes('radius')) {
|
|
105
|
+
tooltipRadiusAxes.forEach(({
|
|
106
|
+
axisId,
|
|
107
|
+
dataIndex
|
|
108
|
+
}) => {
|
|
109
|
+
tooltipAxes.push(defaultAxisTooltipConfig(radiusAxis[axisId], dataIndex, 'radius'));
|
|
110
|
+
});
|
|
111
|
+
}
|
|
103
112
|
Object.keys(series).filter(seriesType => composableCartesianSeriesTypes.has(seriesType)).forEach(seriesType => {
|
|
104
113
|
const seriesOfType = series[seriesType];
|
|
105
114
|
if (!seriesOfType) {
|
|
@@ -197,7 +206,7 @@ export function useAxesTooltip(params) {
|
|
|
197
206
|
const tooltipItemIndex = tooltipAxes.findIndex(({
|
|
198
207
|
axisDirection,
|
|
199
208
|
axisId
|
|
200
|
-
}) => axisDirection === 'rotation' && axisId === providedRotationAxisId);
|
|
209
|
+
}) => axisDirection === 'rotation' && axisId === providedRotationAxisId || axisDirection === 'radius' && axisId === providedRadiusAxisId);
|
|
201
210
|
// Test if the series uses the default axis
|
|
202
211
|
if (tooltipItemIndex >= 0) {
|
|
203
212
|
const {
|
|
@@ -28,7 +28,9 @@ function ChartsXAxis(inProps) {
|
|
|
28
28
|
} = (0, _useAxis.useXAxes)();
|
|
29
29
|
const axis = xAxis[inProps.axisId ?? xAxisIds[0]];
|
|
30
30
|
if (!axis) {
|
|
31
|
-
|
|
31
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
32
|
+
(0, _warning.warnOnce)(`MUI X Charts: No axis found. The axisId "${inProps.axisId}" is probably invalid.`);
|
|
33
|
+
}
|
|
32
34
|
return null;
|
|
33
35
|
}
|
|
34
36
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsXAxisImpl.ChartsXAxisImpl, (0, _extends2.default)({}, inProps, {
|
|
@@ -22,7 +22,9 @@ function ChartsXAxis(inProps) {
|
|
|
22
22
|
} = useXAxes();
|
|
23
23
|
const axis = xAxis[inProps.axisId ?? xAxisIds[0]];
|
|
24
24
|
if (!axis) {
|
|
25
|
-
|
|
25
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
26
|
+
warnOnce(`MUI X Charts: No axis found. The axisId "${inProps.axisId}" is probably invalid.`);
|
|
27
|
+
}
|
|
26
28
|
return null;
|
|
27
29
|
}
|
|
28
30
|
return /*#__PURE__*/_jsx(ChartsXAxisImpl, _extends({}, inProps, {
|
|
@@ -28,7 +28,9 @@ function ChartsYAxis(inProps) {
|
|
|
28
28
|
} = (0, _hooks.useYAxes)();
|
|
29
29
|
const axis = yAxis[inProps.axisId ?? yAxisIds[0]];
|
|
30
30
|
if (!axis) {
|
|
31
|
-
|
|
31
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
32
|
+
(0, _warning.warnOnce)(`MUI X Charts: No axis found. The axisId "${inProps.axisId}" is probably invalid.`);
|
|
33
|
+
}
|
|
32
34
|
return null;
|
|
33
35
|
}
|
|
34
36
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsYAxisImpl.ChartsYAxisImpl, (0, _extends2.default)({}, inProps, {
|
|
@@ -22,7 +22,9 @@ function ChartsYAxis(inProps) {
|
|
|
22
22
|
} = useYAxes();
|
|
23
23
|
const axis = yAxis[inProps.axisId ?? yAxisIds[0]];
|
|
24
24
|
if (!axis) {
|
|
25
|
-
|
|
25
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
26
|
+
warnOnce(`MUI X Charts: No axis found. The axisId "${inProps.axisId}" is probably invalid.`);
|
|
27
|
+
}
|
|
26
28
|
return null;
|
|
27
29
|
}
|
|
28
30
|
return /*#__PURE__*/_jsx(ChartsYAxisImpl, _extends({}, inProps, {
|
package/LineChart/LineChart.js
CHANGED
|
@@ -205,11 +205,11 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
|
|
|
205
205
|
*/
|
|
206
206
|
highlightedItem: _propTypes.default.oneOfType([_propTypes.default.shape({
|
|
207
207
|
dataIndex: _propTypes.default.number,
|
|
208
|
-
seriesId: _propTypes.default.string.isRequired
|
|
209
|
-
type: _propTypes.default.oneOf(['line']).isRequired
|
|
208
|
+
seriesId: _propTypes.default.string.isRequired
|
|
210
209
|
}), _propTypes.default.shape({
|
|
211
210
|
dataIndex: _propTypes.default.number,
|
|
212
|
-
seriesId: _propTypes.default.string.isRequired
|
|
211
|
+
seriesId: _propTypes.default.string.isRequired,
|
|
212
|
+
type: _propTypes.default.oneOf(['line']).isRequired
|
|
213
213
|
})]),
|
|
214
214
|
/**
|
|
215
215
|
* This prop is used to help implement the accessibility logic.
|
|
@@ -365,11 +365,11 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
|
|
|
365
365
|
*/
|
|
366
366
|
tooltipItem: _propTypes.default.oneOfType([_propTypes.default.shape({
|
|
367
367
|
dataIndex: _propTypes.default.number,
|
|
368
|
-
seriesId: _propTypes.default.string.isRequired
|
|
369
|
-
type: _propTypes.default.oneOf(['line']).isRequired
|
|
368
|
+
seriesId: _propTypes.default.string.isRequired
|
|
370
369
|
}), _propTypes.default.shape({
|
|
371
370
|
dataIndex: _propTypes.default.number,
|
|
372
|
-
seriesId: _propTypes.default.string.isRequired
|
|
371
|
+
seriesId: _propTypes.default.string.isRequired,
|
|
372
|
+
type: _propTypes.default.oneOf(['line']).isRequired
|
|
373
373
|
})]),
|
|
374
374
|
/**
|
|
375
375
|
* The width of the chart in px. If not defined, it takes the width of the parent element.
|
package/LineChart/LineChart.mjs
CHANGED
|
@@ -198,11 +198,11 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
|
|
|
198
198
|
*/
|
|
199
199
|
highlightedItem: PropTypes.oneOfType([PropTypes.shape({
|
|
200
200
|
dataIndex: PropTypes.number,
|
|
201
|
-
seriesId: PropTypes.string.isRequired
|
|
202
|
-
type: PropTypes.oneOf(['line']).isRequired
|
|
201
|
+
seriesId: PropTypes.string.isRequired
|
|
203
202
|
}), PropTypes.shape({
|
|
204
203
|
dataIndex: PropTypes.number,
|
|
205
|
-
seriesId: PropTypes.string.isRequired
|
|
204
|
+
seriesId: PropTypes.string.isRequired,
|
|
205
|
+
type: PropTypes.oneOf(['line']).isRequired
|
|
206
206
|
})]),
|
|
207
207
|
/**
|
|
208
208
|
* This prop is used to help implement the accessibility logic.
|
|
@@ -358,11 +358,11 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
|
|
|
358
358
|
*/
|
|
359
359
|
tooltipItem: PropTypes.oneOfType([PropTypes.shape({
|
|
360
360
|
dataIndex: PropTypes.number,
|
|
361
|
-
seriesId: PropTypes.string.isRequired
|
|
362
|
-
type: PropTypes.oneOf(['line']).isRequired
|
|
361
|
+
seriesId: PropTypes.string.isRequired
|
|
363
362
|
}), PropTypes.shape({
|
|
364
363
|
dataIndex: PropTypes.number,
|
|
365
|
-
seriesId: PropTypes.string.isRequired
|
|
364
|
+
seriesId: PropTypes.string.isRequired,
|
|
365
|
+
type: PropTypes.oneOf(['line']).isRequired
|
|
366
366
|
})]),
|
|
367
367
|
/**
|
|
368
368
|
* The width of the chart in px. If not defined, it takes the width of the parent element.
|
|
@@ -161,14 +161,25 @@ function evaluateCurveY(points, targetX, curveType) {
|
|
|
161
161
|
const capture = new SegmentCapture();
|
|
162
162
|
const factory = (0, _getCurve.getCurveFactory)(curveType);
|
|
163
163
|
const curveInstance = factory(capture);
|
|
164
|
+
|
|
165
|
+
// Track which side of targetX the first point is on, so we detect the
|
|
166
|
+
// crossing regardless of whether x is increasing or decreasing.
|
|
167
|
+
const initialSide = points[0].x > targetX;
|
|
168
|
+
let searchStartIndex = 0;
|
|
169
|
+
let crossingDetected = false;
|
|
164
170
|
curveInstance.lineStart();
|
|
165
171
|
for (const p of points) {
|
|
172
|
+
if (!crossingDetected && p.x > targetX !== initialSide) {
|
|
173
|
+
searchStartIndex = Math.max(0, capture.segments.length - 1);
|
|
174
|
+
crossingDetected = true;
|
|
175
|
+
}
|
|
166
176
|
curveInstance.point(p.x, p.y);
|
|
167
177
|
}
|
|
168
178
|
curveInstance.lineEnd();
|
|
169
179
|
|
|
170
180
|
// Find the segment containing targetX.
|
|
171
|
-
for (
|
|
181
|
+
for (let i = searchStartIndex; i < capture.segments.length; i += 1) {
|
|
182
|
+
const segment = capture.segments[i];
|
|
172
183
|
if (targetX < segment.x0 + 0.5 && targetX > segment.x0 - 0.5) {
|
|
173
184
|
return segment.y0;
|
|
174
185
|
}
|