@mui/x-charts 9.0.4 → 9.2.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.d.mts +1 -2
- package/BarChart/BarChart.d.ts +1 -2
- package/BarChart/BarChart.js +2 -913
- package/BarChart/BarChart.mjs +2 -913
- package/BarChart/seriesConfig/bar/seriesProcessor.js +2 -0
- package/BarChart/seriesConfig/bar/seriesProcessor.mjs +2 -0
- package/CHANGELOG.md +236 -0
- package/ChartsAxisHighlightValue/ChartsAxisHighlightValue.d.mts +55 -0
- package/ChartsAxisHighlightValue/ChartsAxisHighlightValue.d.ts +55 -0
- package/ChartsAxisHighlightValue/ChartsAxisHighlightValue.js +94 -0
- package/ChartsAxisHighlightValue/ChartsAxisHighlightValue.mjs +88 -0
- package/ChartsAxisHighlightValue/ChartsAxisHighlightValueItem.d.mts +13 -0
- package/ChartsAxisHighlightValue/ChartsAxisHighlightValueItem.d.ts +13 -0
- package/ChartsAxisHighlightValue/ChartsAxisHighlightValueItem.js +86 -0
- package/ChartsAxisHighlightValue/ChartsAxisHighlightValueItem.mjs +80 -0
- package/ChartsAxisHighlightValue/chartsAxisHighlightValueClasses.d.mts +18 -0
- package/ChartsAxisHighlightValue/chartsAxisHighlightValueClasses.d.ts +18 -0
- package/ChartsAxisHighlightValue/chartsAxisHighlightValueClasses.js +26 -0
- package/ChartsAxisHighlightValue/chartsAxisHighlightValueClasses.mjs +16 -0
- package/ChartsAxisHighlightValue/index.d.mts +1 -0
- package/ChartsAxisHighlightValue/index.d.ts +1 -0
- package/ChartsAxisHighlightValue/index.js +16 -0
- package/ChartsAxisHighlightValue/index.mjs +1 -0
- package/ChartsAxisHighlightValue/useAxisHighlightValue.d.mts +14 -0
- package/ChartsAxisHighlightValue/useAxisHighlightValue.d.ts +14 -0
- package/ChartsAxisHighlightValue/useAxisHighlightValue.js +130 -0
- package/ChartsAxisHighlightValue/useAxisHighlightValue.mjs +124 -0
- package/ChartsContainer/ChartsContainer.js +4 -1431
- package/ChartsContainer/ChartsContainer.mjs +4 -1431
- package/ChartsRadialAxisHighlight/ChartsRadialAxisHighlight.d.mts +15 -0
- package/ChartsRadialAxisHighlight/ChartsRadialAxisHighlight.d.ts +15 -0
- package/ChartsRadialAxisHighlight/ChartsRadialAxisHighlight.js +56 -0
- package/ChartsRadialAxisHighlight/ChartsRadialAxisHighlight.mjs +50 -0
- package/ChartsRadialAxisHighlight/ChartsRadialAxisHighlight.types.d.mts +6 -0
- package/ChartsRadialAxisHighlight/ChartsRadialAxisHighlight.types.d.ts +6 -0
- package/ChartsRadialAxisHighlight/ChartsRadialAxisHighlight.types.js +5 -0
- package/ChartsRadialAxisHighlight/ChartsRadialAxisHighlight.types.mjs +1 -0
- package/ChartsRadialAxisHighlight/ChartsRadialAxisHighlightPath.d.mts +11 -0
- package/ChartsRadialAxisHighlight/ChartsRadialAxisHighlightPath.d.ts +11 -0
- package/ChartsRadialAxisHighlight/ChartsRadialAxisHighlightPath.js +70 -0
- package/ChartsRadialAxisHighlight/ChartsRadialAxisHighlightPath.mjs +64 -0
- package/ChartsRadialAxisHighlight/ChartsRadiusAxisHighlight.d.mts +9 -0
- package/ChartsRadialAxisHighlight/ChartsRadiusAxisHighlight.d.ts +9 -0
- package/ChartsRadialAxisHighlight/ChartsRadiusAxisHighlight.js +104 -0
- package/ChartsRadialAxisHighlight/ChartsRadiusAxisHighlight.mjs +98 -0
- package/ChartsRadialAxisHighlight/ChartsRotationAxisHighlight.d.mts +9 -0
- package/ChartsRadialAxisHighlight/ChartsRotationAxisHighlight.d.ts +9 -0
- package/ChartsRadialAxisHighlight/ChartsRotationAxisHighlight.js +98 -0
- package/ChartsRadialAxisHighlight/ChartsRotationAxisHighlight.mjs +92 -0
- package/ChartsRadialAxisHighlight/chartsRadialAxisHighlightClasses.d.mts +7 -0
- package/ChartsRadialAxisHighlight/chartsRadialAxisHighlightClasses.d.ts +7 -0
- package/ChartsRadialAxisHighlight/chartsRadialAxisHighlightClasses.js +14 -0
- package/ChartsRadialAxisHighlight/chartsRadialAxisHighlightClasses.mjs +6 -0
- package/ChartsRadialAxisHighlight/index.d.mts +5 -0
- package/ChartsRadialAxisHighlight/index.d.ts +5 -0
- package/ChartsRadialAxisHighlight/index.js +47 -0
- package/ChartsRadialAxisHighlight/index.mjs +4 -0
- 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/ChartsRadiusAxis/index.d.mts +3 -2
- package/ChartsRadiusAxis/index.d.ts +3 -2
- package/ChartsRadiusAxis/index.mjs +3 -1
- 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/ChartsRotationAxis/index.d.mts +3 -2
- package/ChartsRotationAxis/index.d.ts +3 -2
- package/ChartsRotationAxis/index.mjs +3 -1
- 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/useAxisTicksProps.d.mts +162 -81
- package/ChartsXAxis/useAxisTicksProps.d.ts +162 -81
- package/ChartsYAxis/useAxisTicksProps.d.mts +162 -81
- package/ChartsYAxis/useAxisTicksProps.d.ts +162 -81
- package/LICENSE +2 -0
- package/LineChart/LineChart.js +2 -913
- package/LineChart/LineChart.mjs +2 -913
- package/LineChart/seriesConfig/curveEvaluation.d.mts +19 -1
- package/LineChart/seriesConfig/curveEvaluation.d.ts +19 -1
- package/LineChart/seriesConfig/curveEvaluation.js +132 -0
- package/LineChart/seriesConfig/curveEvaluation.mjs +131 -0
- package/LineChart/seriesConfig/getSeriesWithDefaultValues.js +2 -1
- package/LineChart/seriesConfig/getSeriesWithDefaultValues.mjs +2 -1
- package/LineChart/seriesConfig/seriesProcessor.js +4 -0
- package/LineChart/seriesConfig/seriesProcessor.mjs +4 -0
- package/LineChart/useAreaPlotData.js +4 -0
- package/LineChart/useAreaPlotData.mjs +4 -0
- package/LineChart/useLinePlotData.js +2 -0
- package/LineChart/useLinePlotData.mjs +2 -0
- package/LineChart/useMarkPlotData.js +2 -0
- package/LineChart/useMarkPlotData.mjs +2 -0
- package/RadarChart/RadarGrid/CircularRadarStripes.js +2 -3
- package/RadarChart/RadarGrid/CircularRadarStripes.mjs +2 -3
- package/RadarChart/RadarSeriesPlot/useRadarRotationIndex.js +1 -1
- package/RadarChart/RadarSeriesPlot/useRadarRotationIndex.mjs +2 -2
- package/ScatterChart/FocusedScatterMark.js +10 -24
- package/ScatterChart/FocusedScatterMark.mjs +10 -24
- package/ScatterChart/HighlightedScatterMark.d.mts +11 -0
- package/ScatterChart/HighlightedScatterMark.d.ts +11 -0
- package/ScatterChart/HighlightedScatterMark.js +68 -0
- package/ScatterChart/HighlightedScatterMark.mjs +62 -0
- package/ScatterChart/ScatterChart.d.mts +1 -2
- package/ScatterChart/ScatterChart.d.ts +1 -2
- package/ScatterChart/ScatterChart.js +2 -913
- package/ScatterChart/ScatterChart.mjs +2 -913
- package/ScatterChart/index.d.mts +1 -0
- package/ScatterChart/index.d.ts +1 -0
- package/ScatterChart/index.js +12 -0
- package/ScatterChart/index.mjs +1 -0
- package/ScatterChart/scatterClasses.d.mts +3 -1
- package/ScatterChart/scatterClasses.d.ts +3 -1
- package/ScatterChart/scatterClasses.js +3 -2
- package/ScatterChart/scatterClasses.mjs +3 -2
- package/ScatterChart/useScatterChartProps.js +3 -1
- package/ScatterChart/useScatterChartProps.mjs +3 -1
- package/ScatterChart/useScatterItemPosition.d.mts +16 -0
- package/ScatterChart/useScatterItemPosition.d.ts +16 -0
- package/ScatterChart/useScatterItemPosition.js +47 -0
- package/ScatterChart/useScatterItemPosition.mjs +41 -0
- package/SparkLineChart/SparkLineChart.js +2 -913
- package/SparkLineChart/SparkLineChart.mjs +2 -913
- package/hooks/useAxis.d.mts +3 -3
- package/hooks/useAxis.d.ts +3 -3
- package/hooks/useAxisSystem.d.mts +1 -1
- package/hooks/useAxisSystem.d.ts +1 -1
- package/hooks/useAxisSystem.js +1 -1
- package/hooks/useAxisSystem.mjs +1 -1
- package/index.d.mts +2 -0
- package/index.d.ts +2 -0
- package/index.js +25 -1
- package/index.mjs +3 -1
- 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 +8 -1
- package/internals/index.d.ts +8 -1
- package/internals/index.js +67 -0
- package/internals/index.mjs +7 -1
- package/internals/plugins/corePlugins/useChartInteractionListener/useChartInteractionListener.js +4 -2
- package/internals/plugins/corePlugins/useChartInteractionListener/useChartInteractionListener.mjs +4 -2
- package/internals/plugins/corePlugins/useChartSeriesConfig/types/polarExtremumGetter.types.d.mts +2 -2
- package/internals/plugins/corePlugins/useChartSeriesConfig/types/polarExtremumGetter.types.d.ts +2 -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 +77 -3
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.d.ts +77 -3
- 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/useChartPolarAxis/computeAxisValue.d.mts +4 -7
- package/internals/plugins/featurePlugins/useChartPolarAxis/computeAxisValue.d.ts +4 -7
- package/internals/plugins/featurePlugins/useChartPolarAxis/defaultizeAxis.d.mts +3 -2
- package/internals/plugins/featurePlugins/useChartPolarAxis/defaultizeAxis.d.ts +3 -2
- 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 +7 -2
- package/internals/plugins/featurePlugins/useChartPolarAxis/getAxisIndex.d.ts +7 -2
- package/internals/plugins/featurePlugins/useChartPolarAxis/getAxisIndex.js +56 -6
- package/internals/plugins/featurePlugins/useChartPolarAxis/getAxisIndex.mjs +54 -5
- package/internals/plugins/featurePlugins/useChartPolarAxis/index.d.mts +2 -1
- package/internals/plugins/featurePlugins/useChartPolarAxis/index.d.ts +2 -1
- package/internals/plugins/featurePlugins/useChartPolarAxis/index.js +12 -0
- package/internals/plugins/featurePlugins/useChartPolarAxis/index.mjs +2 -1
- package/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarAxis.js +1 -1
- package/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarAxis.mjs +2 -2
- package/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarAxis.selectors.d.mts +4 -4
- package/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarAxis.selectors.d.ts +4 -4
- package/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarAxis.types.d.mts +3 -3
- package/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarAxis.types.d.ts +3 -3
- package/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarInteraction.selectors.d.mts +23 -3
- package/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarInteraction.selectors.d.ts +23 -3
- package/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarInteraction.selectors.js +73 -12
- package/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarInteraction.selectors.mjs +74 -12
- package/models/axis.d.mts +79 -31
- package/models/axis.d.ts +79 -31
- package/models/axis.js +5 -1
- package/models/axis.mjs +5 -1
- package/models/seriesType/line.d.mts +6 -6
- package/models/seriesType/line.d.ts +6 -6
- package/package.json +32 -4
|
@@ -8,4 +8,22 @@ import type { CurveType } from "../../models/curve.mjs";
|
|
|
8
8
|
export declare function evaluateCurveY(points: Array<{
|
|
9
9
|
x: number;
|
|
10
10
|
y: number;
|
|
11
|
-
}>, targetX: number, curveType?: CurveType): number | null;
|
|
11
|
+
}>, targetX: number, curveType?: CurveType): number | null;
|
|
12
|
+
/**
|
|
13
|
+
* Build the curve segments for a set of pixel-coordinate points using d3's curve factory,
|
|
14
|
+
* then evaluate the point on the curve at the given angle.
|
|
15
|
+
*
|
|
16
|
+
* Returns null if no point on the curve matches the target angle.
|
|
17
|
+
*/
|
|
18
|
+
export declare function evaluateCurveAtAngle(
|
|
19
|
+
/**
|
|
20
|
+
* The points only uses the x/y coordinate system, because internally curve factory only works with x/y coordinates.
|
|
21
|
+
* So angles/radius are lost during the curve generation.
|
|
22
|
+
*/
|
|
23
|
+
points: Array<{
|
|
24
|
+
x: number;
|
|
25
|
+
y: number;
|
|
26
|
+
}>, targetAngle: number, curveType?: CurveType): {
|
|
27
|
+
x: number;
|
|
28
|
+
y: number;
|
|
29
|
+
} | null;
|
|
@@ -8,4 +8,22 @@ import type { CurveType } from "../../models/curve.js";
|
|
|
8
8
|
export declare function evaluateCurveY(points: Array<{
|
|
9
9
|
x: number;
|
|
10
10
|
y: number;
|
|
11
|
-
}>, targetX: number, curveType?: CurveType): number | null;
|
|
11
|
+
}>, targetX: number, curveType?: CurveType): number | null;
|
|
12
|
+
/**
|
|
13
|
+
* Build the curve segments for a set of pixel-coordinate points using d3's curve factory,
|
|
14
|
+
* then evaluate the point on the curve at the given angle.
|
|
15
|
+
*
|
|
16
|
+
* Returns null if no point on the curve matches the target angle.
|
|
17
|
+
*/
|
|
18
|
+
export declare function evaluateCurveAtAngle(
|
|
19
|
+
/**
|
|
20
|
+
* The points only uses the x/y coordinate system, because internally curve factory only works with x/y coordinates.
|
|
21
|
+
* So angles/radius are lost during the curve generation.
|
|
22
|
+
*/
|
|
23
|
+
points: Array<{
|
|
24
|
+
x: number;
|
|
25
|
+
y: number;
|
|
26
|
+
}>, targetAngle: number, curveType?: CurveType): {
|
|
27
|
+
x: number;
|
|
28
|
+
y: number;
|
|
29
|
+
} | null;
|
|
@@ -3,8 +3,11 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
+
exports.evaluateCurveAtAngle = evaluateCurveAtAngle;
|
|
6
7
|
exports.evaluateCurveY = evaluateCurveY;
|
|
8
|
+
var _epsilon = require("../../utils/epsilon");
|
|
7
9
|
var _getCurve = require("../../internals/getCurve");
|
|
10
|
+
var _clampAngle = require("../../internals/clampAngle");
|
|
8
11
|
var _cubiqSolver = require("../../internals/cubiqSolver");
|
|
9
12
|
/**
|
|
10
13
|
* A straight line segment.
|
|
@@ -90,6 +93,42 @@ function findTForX(segment, targetX) {
|
|
|
90
93
|
return -1;
|
|
91
94
|
}
|
|
92
95
|
|
|
96
|
+
/**
|
|
97
|
+
* Find parameter t such that the segment's x(t) ≈ targetX using cubic roots.
|
|
98
|
+
*/
|
|
99
|
+
function findTForAngle(segment, targetAngle) {
|
|
100
|
+
if (!isBezierSegment(segment)) {
|
|
101
|
+
// Linear segment.
|
|
102
|
+
const DeltaY = segment.y1 - segment.y0;
|
|
103
|
+
const DeltaX = segment.x1 - segment.x0;
|
|
104
|
+
const dx = Math.sin(targetAngle);
|
|
105
|
+
const dy = -Math.cos(targetAngle);
|
|
106
|
+
if (Math.abs(dx) < _epsilon.EPSILON) {
|
|
107
|
+
if (Math.abs(DeltaX) < _epsilon.EPSILON) {
|
|
108
|
+
return -1;
|
|
109
|
+
}
|
|
110
|
+
return -segment.x0 / DeltaX;
|
|
111
|
+
}
|
|
112
|
+
if (Math.abs(dy) < _epsilon.EPSILON) {
|
|
113
|
+
if (Math.abs(DeltaY) < _epsilon.EPSILON) {
|
|
114
|
+
return -1;
|
|
115
|
+
}
|
|
116
|
+
return -segment.y0 / DeltaY;
|
|
117
|
+
}
|
|
118
|
+
return (segment.y0 / dy - segment.x0 / dx) / (DeltaX / dx - DeltaY / dy);
|
|
119
|
+
}
|
|
120
|
+
const xBezierCoeffs = cubicBezierCoeffs(segment.x0, segment.cpx1, segment.cpx2, segment.x1);
|
|
121
|
+
const yBezierCoeffs = cubicBezierCoeffs(segment.y0, segment.cpy1, segment.cpy2, segment.y1);
|
|
122
|
+
const targetX = Math.sin(targetAngle);
|
|
123
|
+
const targetY = -Math.cos(targetAngle);
|
|
124
|
+
const polyToSolve = [targetY * xBezierCoeffs[0] - targetX * yBezierCoeffs[0], targetY * xBezierCoeffs[1] - targetX * yBezierCoeffs[1], targetY * xBezierCoeffs[2] - targetX * yBezierCoeffs[2], targetY * xBezierCoeffs[3] - targetX * yBezierCoeffs[3]];
|
|
125
|
+
const roots = (0, _cubiqSolver.cubicRoots)(polyToSolve);
|
|
126
|
+
if (roots.length > 0) {
|
|
127
|
+
return roots[0];
|
|
128
|
+
}
|
|
129
|
+
return -1;
|
|
130
|
+
}
|
|
131
|
+
|
|
93
132
|
/** Evaluate the segment's y at parameter t. */
|
|
94
133
|
function evaluateSegmentY(segment, t) {
|
|
95
134
|
if (!isBezierSegment(segment)) {
|
|
@@ -98,6 +137,14 @@ function evaluateSegmentY(segment, t) {
|
|
|
98
137
|
return cubicBezier(t, segment.y0, segment.cpy1, segment.cpy2, segment.y1);
|
|
99
138
|
}
|
|
100
139
|
|
|
140
|
+
/** Evaluate the segment's x at parameter t. */
|
|
141
|
+
function evaluateSegmentX(segment, t) {
|
|
142
|
+
if (!isBezierSegment(segment)) {
|
|
143
|
+
return segment.x0 + t * (segment.x1 - segment.x0);
|
|
144
|
+
}
|
|
145
|
+
return cubicBezier(t, segment.x0, segment.cpx1, segment.cpx2, segment.x1);
|
|
146
|
+
}
|
|
147
|
+
|
|
101
148
|
/**
|
|
102
149
|
* Build the curve segments for a set of pixel-coordinate points
|
|
103
150
|
* using d3's curve factory, then evaluate y at the given pixel x.
|
|
@@ -136,4 +183,89 @@ function evaluateCurveY(points, targetX, curveType) {
|
|
|
136
183
|
}
|
|
137
184
|
}
|
|
138
185
|
return null;
|
|
186
|
+
}
|
|
187
|
+
const vectorProduct = (a, b) => a.x * b.y - a.y * b.x;
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* Build the curve segments for a set of pixel-coordinate points using d3's curve factory,
|
|
191
|
+
* then evaluate the point on the curve at the given angle.
|
|
192
|
+
*
|
|
193
|
+
* Returns null if no point on the curve matches the target angle.
|
|
194
|
+
*/
|
|
195
|
+
function evaluateCurveAtAngle(
|
|
196
|
+
/**
|
|
197
|
+
* The points only uses the x/y coordinate system, because internally curve factory only works with x/y coordinates.
|
|
198
|
+
* So angles/radius are lost during the curve generation.
|
|
199
|
+
*/
|
|
200
|
+
points, targetAngle, curveType) {
|
|
201
|
+
if (points.length === 0) {
|
|
202
|
+
return null;
|
|
203
|
+
}
|
|
204
|
+
if (points.length === 1) {
|
|
205
|
+
return points[0];
|
|
206
|
+
}
|
|
207
|
+
const capture = new SegmentCapture();
|
|
208
|
+
const factory = (0, _getCurve.getCurveFactory)(curveType);
|
|
209
|
+
const curveInstance = factory(capture);
|
|
210
|
+
let pointsContainsOrigin = false;
|
|
211
|
+
curveInstance.lineStart();
|
|
212
|
+
for (const p of points) {
|
|
213
|
+
curveInstance.point(p.x, p.y);
|
|
214
|
+
if (p.x === 0 && p.y === 0) {
|
|
215
|
+
pointsContainsOrigin = true;
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
curveInstance.lineEnd();
|
|
219
|
+
const xTarget = Math.sin(targetAngle);
|
|
220
|
+
const yTarget = -Math.cos(targetAngle);
|
|
221
|
+
const pointTarget = {
|
|
222
|
+
x: xTarget,
|
|
223
|
+
y: yTarget
|
|
224
|
+
};
|
|
225
|
+
|
|
226
|
+
// Find the segment containing targetAngle.
|
|
227
|
+
for (const segment of capture.segments) {
|
|
228
|
+
const directionX0Target = vectorProduct({
|
|
229
|
+
x: segment.x0,
|
|
230
|
+
y: segment.y0
|
|
231
|
+
}, pointTarget);
|
|
232
|
+
const directionTargetX1 = vectorProduct(pointTarget, {
|
|
233
|
+
x: segment.x1,
|
|
234
|
+
y: segment.y1
|
|
235
|
+
});
|
|
236
|
+
|
|
237
|
+
// Test if target angle is between x0 and x1. To do so we check the sign of the vector product.
|
|
238
|
+
if (directionX0Target >= 0 && directionTargetX1 >= 0) {
|
|
239
|
+
const angle0 = Math.atan2(segment.x0, -segment.y0);
|
|
240
|
+
const angle1 = Math.atan2(segment.x1, -segment.y1);
|
|
241
|
+
const clampedAngleGap0 = (0, _clampAngle.clampAngleRad)(targetAngle - angle0);
|
|
242
|
+
if (clampedAngleGap0 < _epsilon.EPSILON || clampedAngleGap0 > Math.PI * 2 - _epsilon.EPSILON) {
|
|
243
|
+
return {
|
|
244
|
+
x: segment.x0,
|
|
245
|
+
y: segment.y0
|
|
246
|
+
};
|
|
247
|
+
}
|
|
248
|
+
const clampedAngleGap1 = (0, _clampAngle.clampAngleRad)(targetAngle - angle1);
|
|
249
|
+
if (clampedAngleGap1 < _epsilon.EPSILON || clampedAngleGap1 > Math.PI * 2 - _epsilon.EPSILON) {
|
|
250
|
+
return {
|
|
251
|
+
x: segment.x1,
|
|
252
|
+
y: segment.y1
|
|
253
|
+
};
|
|
254
|
+
}
|
|
255
|
+
const t = findTForAngle(segment, targetAngle);
|
|
256
|
+
return {
|
|
257
|
+
x: evaluateSegmentX(segment, t),
|
|
258
|
+
y: evaluateSegmentY(segment, t)
|
|
259
|
+
};
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
if (pointsContainsOrigin) {
|
|
263
|
+
// Frequent edge case when handling area with minRadius set to 0.
|
|
264
|
+
// The only point on the curve is at the origin, so we can return (0, 0) for any angle.
|
|
265
|
+
return {
|
|
266
|
+
x: 0,
|
|
267
|
+
y: 0
|
|
268
|
+
};
|
|
269
|
+
}
|
|
270
|
+
return null;
|
|
139
271
|
}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import { EPSILON } from "../../utils/epsilon.mjs";
|
|
1
2
|
import { getCurveFactory } from "../../internals/getCurve.mjs";
|
|
3
|
+
import { clampAngleRad } from "../../internals/clampAngle.mjs";
|
|
2
4
|
import { cubicRoots } from "../../internals/cubiqSolver.mjs";
|
|
3
5
|
|
|
4
6
|
/**
|
|
@@ -85,6 +87,42 @@ function findTForX(segment, targetX) {
|
|
|
85
87
|
return -1;
|
|
86
88
|
}
|
|
87
89
|
|
|
90
|
+
/**
|
|
91
|
+
* Find parameter t such that the segment's x(t) ≈ targetX using cubic roots.
|
|
92
|
+
*/
|
|
93
|
+
function findTForAngle(segment, targetAngle) {
|
|
94
|
+
if (!isBezierSegment(segment)) {
|
|
95
|
+
// Linear segment.
|
|
96
|
+
const DeltaY = segment.y1 - segment.y0;
|
|
97
|
+
const DeltaX = segment.x1 - segment.x0;
|
|
98
|
+
const dx = Math.sin(targetAngle);
|
|
99
|
+
const dy = -Math.cos(targetAngle);
|
|
100
|
+
if (Math.abs(dx) < EPSILON) {
|
|
101
|
+
if (Math.abs(DeltaX) < EPSILON) {
|
|
102
|
+
return -1;
|
|
103
|
+
}
|
|
104
|
+
return -segment.x0 / DeltaX;
|
|
105
|
+
}
|
|
106
|
+
if (Math.abs(dy) < EPSILON) {
|
|
107
|
+
if (Math.abs(DeltaY) < EPSILON) {
|
|
108
|
+
return -1;
|
|
109
|
+
}
|
|
110
|
+
return -segment.y0 / DeltaY;
|
|
111
|
+
}
|
|
112
|
+
return (segment.y0 / dy - segment.x0 / dx) / (DeltaX / dx - DeltaY / dy);
|
|
113
|
+
}
|
|
114
|
+
const xBezierCoeffs = cubicBezierCoeffs(segment.x0, segment.cpx1, segment.cpx2, segment.x1);
|
|
115
|
+
const yBezierCoeffs = cubicBezierCoeffs(segment.y0, segment.cpy1, segment.cpy2, segment.y1);
|
|
116
|
+
const targetX = Math.sin(targetAngle);
|
|
117
|
+
const targetY = -Math.cos(targetAngle);
|
|
118
|
+
const polyToSolve = [targetY * xBezierCoeffs[0] - targetX * yBezierCoeffs[0], targetY * xBezierCoeffs[1] - targetX * yBezierCoeffs[1], targetY * xBezierCoeffs[2] - targetX * yBezierCoeffs[2], targetY * xBezierCoeffs[3] - targetX * yBezierCoeffs[3]];
|
|
119
|
+
const roots = cubicRoots(polyToSolve);
|
|
120
|
+
if (roots.length > 0) {
|
|
121
|
+
return roots[0];
|
|
122
|
+
}
|
|
123
|
+
return -1;
|
|
124
|
+
}
|
|
125
|
+
|
|
88
126
|
/** Evaluate the segment's y at parameter t. */
|
|
89
127
|
function evaluateSegmentY(segment, t) {
|
|
90
128
|
if (!isBezierSegment(segment)) {
|
|
@@ -93,6 +131,14 @@ function evaluateSegmentY(segment, t) {
|
|
|
93
131
|
return cubicBezier(t, segment.y0, segment.cpy1, segment.cpy2, segment.y1);
|
|
94
132
|
}
|
|
95
133
|
|
|
134
|
+
/** Evaluate the segment's x at parameter t. */
|
|
135
|
+
function evaluateSegmentX(segment, t) {
|
|
136
|
+
if (!isBezierSegment(segment)) {
|
|
137
|
+
return segment.x0 + t * (segment.x1 - segment.x0);
|
|
138
|
+
}
|
|
139
|
+
return cubicBezier(t, segment.x0, segment.cpx1, segment.cpx2, segment.x1);
|
|
140
|
+
}
|
|
141
|
+
|
|
96
142
|
/**
|
|
97
143
|
* Build the curve segments for a set of pixel-coordinate points
|
|
98
144
|
* using d3's curve factory, then evaluate y at the given pixel x.
|
|
@@ -131,4 +177,89 @@ export function evaluateCurveY(points, targetX, curveType) {
|
|
|
131
177
|
}
|
|
132
178
|
}
|
|
133
179
|
return null;
|
|
180
|
+
}
|
|
181
|
+
const vectorProduct = (a, b) => a.x * b.y - a.y * b.x;
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* Build the curve segments for a set of pixel-coordinate points using d3's curve factory,
|
|
185
|
+
* then evaluate the point on the curve at the given angle.
|
|
186
|
+
*
|
|
187
|
+
* Returns null if no point on the curve matches the target angle.
|
|
188
|
+
*/
|
|
189
|
+
export function evaluateCurveAtAngle(
|
|
190
|
+
/**
|
|
191
|
+
* The points only uses the x/y coordinate system, because internally curve factory only works with x/y coordinates.
|
|
192
|
+
* So angles/radius are lost during the curve generation.
|
|
193
|
+
*/
|
|
194
|
+
points, targetAngle, curveType) {
|
|
195
|
+
if (points.length === 0) {
|
|
196
|
+
return null;
|
|
197
|
+
}
|
|
198
|
+
if (points.length === 1) {
|
|
199
|
+
return points[0];
|
|
200
|
+
}
|
|
201
|
+
const capture = new SegmentCapture();
|
|
202
|
+
const factory = getCurveFactory(curveType);
|
|
203
|
+
const curveInstance = factory(capture);
|
|
204
|
+
let pointsContainsOrigin = false;
|
|
205
|
+
curveInstance.lineStart();
|
|
206
|
+
for (const p of points) {
|
|
207
|
+
curveInstance.point(p.x, p.y);
|
|
208
|
+
if (p.x === 0 && p.y === 0) {
|
|
209
|
+
pointsContainsOrigin = true;
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
curveInstance.lineEnd();
|
|
213
|
+
const xTarget = Math.sin(targetAngle);
|
|
214
|
+
const yTarget = -Math.cos(targetAngle);
|
|
215
|
+
const pointTarget = {
|
|
216
|
+
x: xTarget,
|
|
217
|
+
y: yTarget
|
|
218
|
+
};
|
|
219
|
+
|
|
220
|
+
// Find the segment containing targetAngle.
|
|
221
|
+
for (const segment of capture.segments) {
|
|
222
|
+
const directionX0Target = vectorProduct({
|
|
223
|
+
x: segment.x0,
|
|
224
|
+
y: segment.y0
|
|
225
|
+
}, pointTarget);
|
|
226
|
+
const directionTargetX1 = vectorProduct(pointTarget, {
|
|
227
|
+
x: segment.x1,
|
|
228
|
+
y: segment.y1
|
|
229
|
+
});
|
|
230
|
+
|
|
231
|
+
// Test if target angle is between x0 and x1. To do so we check the sign of the vector product.
|
|
232
|
+
if (directionX0Target >= 0 && directionTargetX1 >= 0) {
|
|
233
|
+
const angle0 = Math.atan2(segment.x0, -segment.y0);
|
|
234
|
+
const angle1 = Math.atan2(segment.x1, -segment.y1);
|
|
235
|
+
const clampedAngleGap0 = clampAngleRad(targetAngle - angle0);
|
|
236
|
+
if (clampedAngleGap0 < EPSILON || clampedAngleGap0 > Math.PI * 2 - EPSILON) {
|
|
237
|
+
return {
|
|
238
|
+
x: segment.x0,
|
|
239
|
+
y: segment.y0
|
|
240
|
+
};
|
|
241
|
+
}
|
|
242
|
+
const clampedAngleGap1 = clampAngleRad(targetAngle - angle1);
|
|
243
|
+
if (clampedAngleGap1 < EPSILON || clampedAngleGap1 > Math.PI * 2 - EPSILON) {
|
|
244
|
+
return {
|
|
245
|
+
x: segment.x1,
|
|
246
|
+
y: segment.y1
|
|
247
|
+
};
|
|
248
|
+
}
|
|
249
|
+
const t = findTForAngle(segment, targetAngle);
|
|
250
|
+
return {
|
|
251
|
+
x: evaluateSegmentX(segment, t),
|
|
252
|
+
y: evaluateSegmentY(segment, t)
|
|
253
|
+
};
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
if (pointsContainsOrigin) {
|
|
257
|
+
// Frequent edge case when handling area with minRadius set to 0.
|
|
258
|
+
// The only point on the curve is at the origin, so we can return (0, 0) for any angle.
|
|
259
|
+
return {
|
|
260
|
+
x: 0,
|
|
261
|
+
y: 0
|
|
262
|
+
};
|
|
263
|
+
}
|
|
264
|
+
return null;
|
|
134
265
|
}
|
|
@@ -8,6 +8,7 @@ exports.default = void 0;
|
|
|
8
8
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
9
|
const getSeriesWithDefaultValues = (seriesData, seriesIndex, colors) => (0, _extends2.default)({}, seriesData, {
|
|
10
10
|
id: seriesData.id ?? `auto-generated-id-${seriesIndex}`,
|
|
11
|
-
color: seriesData.color ?? colors[seriesIndex % colors.length]
|
|
11
|
+
color: seriesData.color ?? colors[seriesIndex % colors.length],
|
|
12
|
+
curve: seriesData.curve ?? 'monotoneX'
|
|
12
13
|
});
|
|
13
14
|
var _default = exports.default = getSeriesWithDefaultValues;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
const getSeriesWithDefaultValues = (seriesData, seriesIndex, colors) => _extends({}, seriesData, {
|
|
3
3
|
id: seriesData.id ?? `auto-generated-id-${seriesIndex}`,
|
|
4
|
-
color: seriesData.color ?? colors[seriesIndex % colors.length]
|
|
4
|
+
color: seriesData.color ?? colors[seriesIndex % colors.length],
|
|
5
|
+
curve: seriesData.curve ?? 'monotoneX'
|
|
5
6
|
});
|
|
6
7
|
export default getSeriesWithDefaultValues;
|
|
@@ -51,12 +51,16 @@ function seriesProcessor(params, dataset, isItemVisible) {
|
|
|
51
51
|
}
|
|
52
52
|
});
|
|
53
53
|
} else if (dataset === undefined && process.env.NODE_ENV !== 'production') {
|
|
54
|
+
// TODO: fix mui/no-guarded-throw
|
|
55
|
+
// eslint-disable-next-line mui/no-guarded-throw
|
|
54
56
|
throw new Error(process.env.NODE_ENV !== "production" ? `MUI X Charts: Line series with id="${id}" has no data. ` + 'The chart cannot render this series without data. ' + 'Provide a data property to the series or use the dataset prop.' : (0, _formatErrorMessage2.default)(27, id));
|
|
55
57
|
}
|
|
56
58
|
if (process.env.NODE_ENV !== 'production') {
|
|
57
59
|
if (!data && dataset) {
|
|
58
60
|
const dataKey = series[id].dataKey;
|
|
59
61
|
if (!dataKey && !series[id].valueGetter) {
|
|
62
|
+
// TODO: fix mui/no-guarded-throw
|
|
63
|
+
// eslint-disable-next-line mui/no-guarded-throw
|
|
60
64
|
throw new Error(`MUI X Charts: Line series with id="${id}" has no data, no dataKey, and no valueGetter. ` + 'When using the dataset prop, each series must have a dataKey or valueGetter to identify which dataset values to use. ' + 'Add a dataKey or valueGetter property to the series configuration.');
|
|
61
65
|
}
|
|
62
66
|
if (dataKey) {
|
|
@@ -44,12 +44,16 @@ function seriesProcessor(params, dataset, isItemVisible) {
|
|
|
44
44
|
}
|
|
45
45
|
});
|
|
46
46
|
} else if (dataset === undefined && process.env.NODE_ENV !== 'production') {
|
|
47
|
+
// TODO: fix mui/no-guarded-throw
|
|
48
|
+
// eslint-disable-next-line mui/no-guarded-throw
|
|
47
49
|
throw new Error(process.env.NODE_ENV !== "production" ? `MUI X Charts: Line series with id="${id}" has no data. ` + 'The chart cannot render this series without data. ' + 'Provide a data property to the series or use the dataset prop.' : _formatErrorMessage(27, id));
|
|
48
50
|
}
|
|
49
51
|
if (process.env.NODE_ENV !== 'production') {
|
|
50
52
|
if (!data && dataset) {
|
|
51
53
|
const dataKey = series[id].dataKey;
|
|
52
54
|
if (!dataKey && !series[id].valueGetter) {
|
|
55
|
+
// TODO: fix mui/no-guarded-throw
|
|
56
|
+
// eslint-disable-next-line mui/no-guarded-throw
|
|
53
57
|
throw new Error(`MUI X Charts: Line series with id="${id}" has no data, no dataKey, and no valueGetter. ` + 'When using the dataset prop, each series must have a dataKey or valueGetter to identify which dataset values to use. ' + 'Add a dataKey or valueGetter property to the series configuration.');
|
|
54
58
|
}
|
|
55
59
|
if (dataKey) {
|
|
@@ -54,9 +54,13 @@ function useAreaPlotData(xAxes, yAxes) {
|
|
|
54
54
|
const gradientId = yAxes[yAxisId].colorScale && getGradientId(yAxisId) || xAxes[xAxisId].colorScale && getGradientId(xAxisId) || undefined;
|
|
55
55
|
if (process.env.NODE_ENV !== 'production') {
|
|
56
56
|
if (xData === undefined) {
|
|
57
|
+
// TODO: fix mui/no-guarded-throw
|
|
58
|
+
// eslint-disable-next-line mui/no-guarded-throw
|
|
57
59
|
throw new Error(`MUI X Charts: ${xAxisId === _constants.DEFAULT_X_AXIS_KEY ? 'The first `xAxis`' : `The x-axis with id "${xAxisId}"`} should have a data property to be able to display a line plot. ` + 'The x-axis data defines the positions for each point in the line. ' + 'Provide a data array to the x-axis configuration.');
|
|
58
60
|
}
|
|
59
61
|
if (xData.length < stackedData.length) {
|
|
62
|
+
// TODO: fix mui/no-guarded-throw
|
|
63
|
+
// eslint-disable-next-line mui/no-guarded-throw
|
|
60
64
|
throw new Error(`MUI X Charts: The data length of the x-axis (${xData.length} items) is less than the length of series data (${stackedData.length} items). ` + 'Some data points will not be displayed because they have no corresponding x-axis value. ' + 'Ensure the x-axis data has at least as many items as the series data.');
|
|
61
65
|
}
|
|
62
66
|
}
|
|
@@ -47,9 +47,13 @@ export function useAreaPlotData(xAxes, yAxes) {
|
|
|
47
47
|
const gradientId = yAxes[yAxisId].colorScale && getGradientId(yAxisId) || xAxes[xAxisId].colorScale && getGradientId(xAxisId) || undefined;
|
|
48
48
|
if (process.env.NODE_ENV !== 'production') {
|
|
49
49
|
if (xData === undefined) {
|
|
50
|
+
// TODO: fix mui/no-guarded-throw
|
|
51
|
+
// eslint-disable-next-line mui/no-guarded-throw
|
|
50
52
|
throw new Error(`MUI X Charts: ${xAxisId === DEFAULT_X_AXIS_KEY ? 'The first `xAxis`' : `The x-axis with id "${xAxisId}"`} should have a data property to be able to display a line plot. ` + 'The x-axis data defines the positions for each point in the line. ' + 'Provide a data array to the x-axis configuration.');
|
|
51
53
|
}
|
|
52
54
|
if (xData.length < stackedData.length) {
|
|
55
|
+
// TODO: fix mui/no-guarded-throw
|
|
56
|
+
// eslint-disable-next-line mui/no-guarded-throw
|
|
53
57
|
throw new Error(`MUI X Charts: The data length of the x-axis (${xData.length} items) is less than the length of series data (${stackedData.length} items). ` + 'Some data points will not be displayed because they have no corresponding x-axis value. ' + 'Ensure the x-axis data has at least as many items as the series data.');
|
|
54
58
|
}
|
|
55
59
|
}
|
|
@@ -52,6 +52,8 @@ function useLinePlotData(xAxes, yAxes) {
|
|
|
52
52
|
const gradientId = yAxes[yAxisId].colorScale && getGradientId(yAxisId) || xAxes[xAxisId].colorScale && getGradientId(xAxisId) || undefined;
|
|
53
53
|
if (process.env.NODE_ENV !== 'production') {
|
|
54
54
|
if (xData === undefined) {
|
|
55
|
+
// TODO: fix mui/no-guarded-throw
|
|
56
|
+
// eslint-disable-next-line mui/no-guarded-throw
|
|
55
57
|
throw new Error(`MUI X Charts: ${xAxisId === _constants.DEFAULT_X_AXIS_KEY ? 'The first `xAxis`' : `The x-axis with id "${xAxisId}"`} should have a data property to be able to display a line plot. ` + 'The x-axis data defines the positions for each point in the line. ' + 'Provide a data array to the x-axis configuration.');
|
|
56
58
|
}
|
|
57
59
|
if (xData.length < stackedData.length) {
|
|
@@ -45,6 +45,8 @@ export function useLinePlotData(xAxes, yAxes) {
|
|
|
45
45
|
const gradientId = yAxes[yAxisId].colorScale && getGradientId(yAxisId) || xAxes[xAxisId].colorScale && getGradientId(xAxisId) || undefined;
|
|
46
46
|
if (process.env.NODE_ENV !== 'production') {
|
|
47
47
|
if (xData === undefined) {
|
|
48
|
+
// TODO: fix mui/no-guarded-throw
|
|
49
|
+
// eslint-disable-next-line mui/no-guarded-throw
|
|
48
50
|
throw new Error(`MUI X Charts: ${xAxisId === DEFAULT_X_AXIS_KEY ? 'The first `xAxis`' : `The x-axis with id "${xAxisId}"`} should have a data property to be able to display a line plot. ` + 'The x-axis data defines the positions for each point in the line. ' + 'Provide a data array to the x-axis configuration.');
|
|
49
51
|
}
|
|
50
52
|
if (xData.length < stackedData.length) {
|
|
@@ -53,6 +53,8 @@ function useMarkPlotData(xAxes, yAxes) {
|
|
|
53
53
|
const xData = xAxes[xAxisId].data;
|
|
54
54
|
if (process.env.NODE_ENV !== 'production') {
|
|
55
55
|
if (xData === undefined) {
|
|
56
|
+
// TODO: fix mui/no-guarded-throw
|
|
57
|
+
// eslint-disable-next-line mui/no-guarded-throw
|
|
56
58
|
throw new Error(`MUI X Charts: ${xAxisId === _constants.DEFAULT_X_AXIS_KEY ? 'The first `xAxis`' : `The x-axis with id "${xAxisId}"`} should have a data property to be able to display a line plot. ` + 'The x-axis data defines the positions for each point in the line. ' + 'Provide a data array to the x-axis configuration.');
|
|
57
59
|
}
|
|
58
60
|
}
|
|
@@ -45,6 +45,8 @@ export function useMarkPlotData(xAxes, yAxes) {
|
|
|
45
45
|
const xData = xAxes[xAxisId].data;
|
|
46
46
|
if (process.env.NODE_ENV !== 'production') {
|
|
47
47
|
if (xData === undefined) {
|
|
48
|
+
// TODO: fix mui/no-guarded-throw
|
|
49
|
+
// eslint-disable-next-line mui/no-guarded-throw
|
|
48
50
|
throw new Error(`MUI X Charts: ${xAxisId === DEFAULT_X_AXIS_KEY ? 'The first `xAxis`' : `The x-axis with id "${xAxisId}"`} should have a data property to be able to display a line plot. ` + 'The x-axis data defines the positions for each point in the line. ' + 'Provide a data array to the x-axis configuration.');
|
|
49
51
|
}
|
|
50
52
|
}
|
|
@@ -6,9 +6,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.CircularRadarStripes = CircularRadarStripes;
|
|
8
8
|
var React = _interopRequireWildcard(require("react"));
|
|
9
|
+
var _getRingPath = require("../../internals/getRingPath");
|
|
9
10
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
10
|
-
const getPath = (center, outerRadius, innerRadius) => [`M ${center.x - outerRadius} ${center.y}`, `A ${outerRadius} ${outerRadius} 0 1 0 ${center.x + outerRadius} ${center.y}`, `A ${outerRadius} ${outerRadius} 0 1 0 ${center.x - outerRadius} ${center.y} Z`, `M ${center.x - innerRadius} ${center.y}`, `A ${innerRadius} ${innerRadius} 0 1 0 ${center.x + innerRadius} ${center.y}`, `A ${innerRadius} ${innerRadius} 0 1 0 ${center.x - innerRadius} ${center.y} Z`].join('');
|
|
11
|
-
|
|
12
11
|
/**
|
|
13
12
|
* @ignore - internal component.
|
|
14
13
|
*/
|
|
@@ -27,7 +26,7 @@ function CircularRadarStripes(props) {
|
|
|
27
26
|
children: divisionRadius.map((r, index) => {
|
|
28
27
|
const smallerRadius = divisionRadius[index - 1] ?? 0;
|
|
29
28
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)("path", {
|
|
30
|
-
d:
|
|
29
|
+
d: (0, _getRingPath.getRingPath)(center, r, smallerRadius),
|
|
31
30
|
fillRule: "evenodd",
|
|
32
31
|
fill: stripeColor?.(index) ?? 'none',
|
|
33
32
|
fillOpacity: 0.1,
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
+
import { getRingPath } from "../../internals/getRingPath.mjs";
|
|
2
3
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
-
const getPath = (center, outerRadius, innerRadius) => [`M ${center.x - outerRadius} ${center.y}`, `A ${outerRadius} ${outerRadius} 0 1 0 ${center.x + outerRadius} ${center.y}`, `A ${outerRadius} ${outerRadius} 0 1 0 ${center.x - outerRadius} ${center.y} Z`, `M ${center.x - innerRadius} ${center.y}`, `A ${innerRadius} ${innerRadius} 0 1 0 ${center.x + innerRadius} ${center.y}`, `A ${innerRadius} ${innerRadius} 0 1 0 ${center.x - innerRadius} ${center.y} Z`].join('');
|
|
4
|
-
|
|
5
4
|
/**
|
|
6
5
|
* @ignore - internal component.
|
|
7
6
|
*/
|
|
@@ -20,7 +19,7 @@ export function CircularRadarStripes(props) {
|
|
|
20
19
|
children: divisionRadius.map((r, index) => {
|
|
21
20
|
const smallerRadius = divisionRadius[index - 1] ?? 0;
|
|
22
21
|
return /*#__PURE__*/_jsx("path", {
|
|
23
|
-
d:
|
|
22
|
+
d: getRingPath(center, r, smallerRadius),
|
|
24
23
|
fillRule: "evenodd",
|
|
25
24
|
fill: stripeColor?.(index) ?? 'none',
|
|
26
25
|
fillOpacity: 0.1,
|
|
@@ -32,7 +32,7 @@ function useRadarRotationIndex() {
|
|
|
32
32
|
}
|
|
33
33
|
const svgPoint = (0, _getChartPoint.getChartPoint)(element, event);
|
|
34
34
|
const rotation = (0, _coordinateTransformation.generateSvg2rotation)(center)(svgPoint.x, svgPoint.y);
|
|
35
|
-
const rotationIndex = (0, _getAxisIndex.
|
|
35
|
+
const rotationIndex = (0, _getAxisIndex.getRotationAxisIndex)(rotationAxis, rotation);
|
|
36
36
|
return rotationIndex;
|
|
37
37
|
}, [center, rotationAxis, chartsLayerContainerRef]);
|
|
38
38
|
return rotationIndexGetter;
|
|
@@ -3,7 +3,7 @@ import * as React from 'react';
|
|
|
3
3
|
import { selectorChartPolarCenter } from "../../internals/plugins/featurePlugins/useChartPolarAxis/index.mjs";
|
|
4
4
|
import { getChartPoint } from "../../internals/getChartPoint.mjs";
|
|
5
5
|
import { generateSvg2rotation } from "../../internals/plugins/featurePlugins/useChartPolarAxis/coordinateTransformation.mjs";
|
|
6
|
-
import {
|
|
6
|
+
import { getRotationAxisIndex } from "../../internals/plugins/featurePlugins/useChartPolarAxis/getAxisIndex.mjs";
|
|
7
7
|
import { useStore } from "../../internals/store/useStore.mjs";
|
|
8
8
|
import { useChartsLayerContainerRef } from "../../hooks/useChartsLayerContainerRef.mjs";
|
|
9
9
|
import { useRotationAxis } from "../../hooks/useAxis.mjs";
|
|
@@ -25,7 +25,7 @@ export function useRadarRotationIndex() {
|
|
|
25
25
|
}
|
|
26
26
|
const svgPoint = getChartPoint(element, event);
|
|
27
27
|
const rotation = generateSvg2rotation(center)(svgPoint.x, svgPoint.y);
|
|
28
|
-
const rotationIndex =
|
|
28
|
+
const rotationIndex = getRotationAxisIndex(rotationAxis, rotation);
|
|
29
29
|
return rotationIndex;
|
|
30
30
|
}, [center, rotationAxis, chartsLayerContainerRef]);
|
|
31
31
|
return rotationIndexGetter;
|
|
@@ -13,8 +13,8 @@ var React = _interopRequireWildcard(require("react"));
|
|
|
13
13
|
var _clsx = _interopRequireDefault(require("clsx"));
|
|
14
14
|
var _styles = require("@mui/material/styles");
|
|
15
15
|
var _useFocusedItem = require("../hooks/useFocusedItem");
|
|
16
|
-
var _hooks = require("../hooks");
|
|
17
16
|
var _scatterClasses = require("./scatterClasses");
|
|
17
|
+
var _useScatterItemPosition = require("./useScatterItemPosition");
|
|
18
18
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
19
19
|
const _excluded = ["className"];
|
|
20
20
|
function FocusedScatterMark(_ref) {
|
|
@@ -24,38 +24,24 @@ function FocusedScatterMark(_ref) {
|
|
|
24
24
|
props = (0, _objectWithoutPropertiesLoose2.default)(_ref, _excluded);
|
|
25
25
|
const theme = (0, _styles.useTheme)();
|
|
26
26
|
const focusedItem = (0, _useFocusedItem.useFocusedItem)();
|
|
27
|
-
const scatterSeries = (0, _hooks.useScatterSeriesContext)();
|
|
28
|
-
const {
|
|
29
|
-
xAxis,
|
|
30
|
-
xAxisIds
|
|
31
|
-
} = (0, _hooks.useXAxes)();
|
|
32
|
-
const {
|
|
33
|
-
yAxis,
|
|
34
|
-
yAxisIds
|
|
35
|
-
} = (0, _hooks.useYAxes)();
|
|
36
27
|
const classes = (0, _scatterClasses.useUtilityClasses)();
|
|
37
|
-
|
|
28
|
+
const resolved = (0, _useScatterItemPosition.useScatterItemPosition)(focusedItem?.type === 'scatter' ? focusedItem : null);
|
|
29
|
+
if (!resolved) {
|
|
38
30
|
return null;
|
|
39
31
|
}
|
|
40
|
-
const
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
const yAxisId = series.yAxisId ?? yAxisIds[0];
|
|
46
|
-
const getXPosition = (0, _hooks.getValueToPositionMapper)(xAxis[xAxisId].scale);
|
|
47
|
-
const getYPosition = (0, _hooks.getValueToPositionMapper)(yAxis[yAxisId].scale);
|
|
48
|
-
const scatterPoint = series.data[focusedItem.dataIndex];
|
|
49
|
-
const x = getXPosition(scatterPoint.x);
|
|
50
|
-
const y = getYPosition(scatterPoint.y);
|
|
32
|
+
const {
|
|
33
|
+
cx,
|
|
34
|
+
cy,
|
|
35
|
+
series
|
|
36
|
+
} = resolved;
|
|
51
37
|
const size = series.markerSize + 3;
|
|
52
38
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)("rect", (0, _extends2.default)({
|
|
53
39
|
className: (0, _clsx.default)(classes.focusedMark, className),
|
|
54
40
|
fill: "none",
|
|
55
41
|
stroke: (theme.vars ?? theme).palette.text.primary,
|
|
56
42
|
strokeWidth: 2,
|
|
57
|
-
x:
|
|
58
|
-
y:
|
|
43
|
+
x: cx - size,
|
|
44
|
+
y: cy - size,
|
|
59
45
|
width: 2 * size,
|
|
60
46
|
height: 2 * size,
|
|
61
47
|
rx: 3,
|