@mui/x-charts 9.0.1 → 9.0.3
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 +29 -10
- package/BarChart/BarChart.mjs +29 -10
- package/BarChart/BarElement.js +1 -5
- package/BarChart/BarElement.mjs +1 -5
- package/BarChart/BarPlot.js +2 -1
- package/BarChart/BarPlot.mjs +2 -1
- package/BarChart/seriesConfig/bar/getSeriesWithDefaultValues.d.mts +8 -7
- package/BarChart/seriesConfig/bar/getSeriesWithDefaultValues.d.ts +8 -7
- package/BarChart/seriesConfig/bar/seriesProcessor.js +37 -13
- package/BarChart/seriesConfig/bar/seriesProcessor.mjs +37 -13
- package/CHANGELOG.md +257 -0
- package/ChartsContainer/ChartsContainer.js +59 -30
- package/ChartsContainer/ChartsContainer.mjs +59 -30
- package/ChartsDataProvider/useChartsDataProviderProps.js +1 -6
- package/ChartsDataProvider/useChartsDataProviderProps.mjs +1 -6
- package/ChartsGrid/styledComponents.js +2 -2
- package/ChartsGrid/styledComponents.mjs +2 -2
- package/ChartsRadialDataProvider/ChartsRadialDataProvider.d.mts +38 -0
- package/ChartsRadialDataProvider/ChartsRadialDataProvider.d.ts +38 -0
- package/ChartsRadialDataProvider/ChartsRadialDataProvider.js +115 -0
- package/ChartsRadialDataProvider/ChartsRadialDataProvider.mjs +109 -0
- package/ChartsRadialDataProvider/ChartsRadialDataProvider.plugins.d.mts +9 -0
- package/ChartsRadialDataProvider/ChartsRadialDataProvider.plugins.d.ts +9 -0
- package/ChartsRadialDataProvider/ChartsRadialDataProvider.plugins.js +13 -0
- package/ChartsRadialDataProvider/ChartsRadialDataProvider.plugins.mjs +7 -0
- package/ChartsRadialDataProvider/index.d.mts +2 -0
- package/ChartsRadialDataProvider/index.d.ts +2 -0
- package/ChartsRadialDataProvider/index.js +27 -0
- package/ChartsRadialDataProvider/index.mjs +2 -0
- package/ChartsRadialDataProvider/useChartsRadialDataProviderProps.d.mts +13 -0
- package/ChartsRadialDataProvider/useChartsRadialDataProviderProps.d.ts +13 -0
- package/ChartsRadialDataProvider/useChartsRadialDataProviderProps.js +46 -0
- package/ChartsRadialDataProvider/useChartsRadialDataProviderProps.mjs +39 -0
- package/ChartsRadialGrid/ChartsRadialGrid.d.mts +33 -0
- package/ChartsRadialGrid/ChartsRadialGrid.d.ts +33 -0
- package/ChartsRadialGrid/ChartsRadialGrid.js +101 -0
- package/ChartsRadialGrid/ChartsRadialGrid.mjs +96 -0
- package/ChartsRadialGrid/ChartsRadiusGrid.d.mts +14 -0
- package/ChartsRadialGrid/ChartsRadiusGrid.d.ts +14 -0
- package/ChartsRadialGrid/ChartsRadiusGrid.js +72 -0
- package/ChartsRadialGrid/ChartsRadiusGrid.mjs +65 -0
- package/ChartsRadialGrid/ChartsRotationGrid.d.mts +13 -0
- package/ChartsRadialGrid/ChartsRotationGrid.d.ts +13 -0
- package/ChartsRadialGrid/ChartsRotationGrid.js +65 -0
- package/ChartsRadialGrid/ChartsRotationGrid.mjs +58 -0
- package/ChartsRadialGrid/chartsRadialGridClasses.d.mts +13 -0
- package/ChartsRadialGrid/chartsRadialGridClasses.d.ts +13 -0
- package/ChartsRadialGrid/chartsRadialGridClasses.js +14 -0
- package/ChartsRadialGrid/chartsRadialGridClasses.mjs +6 -0
- package/ChartsRadialGrid/index.d.mts +3 -0
- package/ChartsRadialGrid/index.d.ts +3 -0
- package/ChartsRadialGrid/index.js +19 -0
- package/ChartsRadialGrid/index.mjs +2 -0
- package/ChartsRadialGrid/styledComponents.d.mts +4 -0
- package/ChartsRadialGrid/styledComponents.d.ts +4 -0
- package/ChartsRadialGrid/styledComponents.js +50 -0
- package/ChartsRadialGrid/styledComponents.mjs +44 -0
- package/ChartsRadiusAxis/ChartsRadiusAxis.d.mts +48 -0
- package/ChartsRadiusAxis/ChartsRadiusAxis.d.ts +48 -0
- package/ChartsRadiusAxis/ChartsRadiusAxis.js +147 -0
- package/ChartsRadiusAxis/ChartsRadiusAxis.mjs +141 -0
- package/ChartsRadiusAxis/chartsRadiusAxisClasses.d.mts +6 -0
- package/ChartsRadiusAxis/chartsRadiusAxisClasses.d.ts +6 -0
- package/ChartsRadiusAxis/chartsRadiusAxisClasses.js +30 -0
- package/ChartsRadiusAxis/chartsRadiusAxisClasses.mjs +17 -0
- package/ChartsRadiusAxis/createGetLabelTextAnchors.d.mts +10 -0
- package/ChartsRadiusAxis/createGetLabelTextAnchors.d.ts +10 -0
- package/ChartsRadiusAxis/createGetLabelTextAnchors.js +46 -0
- package/ChartsRadiusAxis/createGetLabelTextAnchors.mjs +39 -0
- package/ChartsRadiusAxis/getLabelTransform.d.mts +11 -0
- package/ChartsRadiusAxis/getLabelTransform.d.ts +11 -0
- package/ChartsRadiusAxis/getLabelTransform.js +37 -0
- package/ChartsRadiusAxis/getLabelTransform.mjs +31 -0
- package/ChartsRadiusAxis/index.d.mts +3 -0
- package/ChartsRadiusAxis/index.d.ts +3 -0
- package/ChartsRadiusAxis/index.js +19 -0
- package/ChartsRadiusAxis/index.mjs +2 -0
- package/ChartsRadiusAxis/sharedRadialAxisClasses.d.mts +21 -0
- package/ChartsRadiusAxis/sharedRadialAxisClasses.d.ts +21 -0
- package/ChartsRadiusAxis/sharedRadialAxisClasses.js +14 -0
- package/ChartsRadiusAxis/sharedRadialAxisClasses.mjs +6 -0
- package/ChartsRotationAxis/ChartsRotationAxis.d.mts +48 -0
- package/ChartsRotationAxis/ChartsRotationAxis.d.ts +48 -0
- package/ChartsRotationAxis/ChartsRotationAxis.js +141 -0
- package/ChartsRotationAxis/ChartsRotationAxis.mjs +135 -0
- package/ChartsRotationAxis/chartsRotationAxisClasses.d.mts +5 -0
- package/ChartsRotationAxis/chartsRotationAxisClasses.d.ts +5 -0
- package/ChartsRotationAxis/chartsRotationAxisClasses.js +29 -0
- package/ChartsRotationAxis/chartsRotationAxisClasses.mjs +16 -0
- package/ChartsRotationAxis/getLabelTransform.d.mts +11 -0
- package/ChartsRotationAxis/getLabelTransform.d.ts +11 -0
- package/ChartsRotationAxis/getLabelTransform.js +37 -0
- package/ChartsRotationAxis/getLabelTransform.mjs +31 -0
- package/ChartsRotationAxis/index.d.mts +2 -0
- package/ChartsRotationAxis/index.d.ts +2 -0
- package/ChartsRotationAxis/index.js +19 -0
- package/ChartsRotationAxis/index.mjs +2 -0
- package/ChartsTooltip/useAxesTooltip.js +7 -4
- package/ChartsTooltip/useAxesTooltip.mjs +8 -5
- package/ChartsTooltip/useItemTooltip.d.mts +1 -1
- package/ChartsTooltip/useItemTooltip.d.ts +1 -1
- package/ChartsTooltip/useItemTooltip.js +17 -2
- package/ChartsTooltip/useItemTooltip.mjs +18 -3
- package/ChartsXAxis/useAxisTicksProps.d.mts +652 -490
- package/ChartsXAxis/useAxisTicksProps.d.ts +652 -490
- package/ChartsYAxis/useAxisTicksProps.d.mts +652 -490
- package/ChartsYAxis/useAxisTicksProps.d.ts +652 -490
- package/LineChart/LineChart.js +27 -9
- package/LineChart/LineChart.mjs +27 -9
- package/LineChart/seriesConfig/curveEvaluation.js +24 -19
- package/LineChart/seriesConfig/curveEvaluation.mjs +24 -19
- package/LineChart/seriesConfig/getItemAtPosition.js +14 -3
- package/LineChart/seriesConfig/getItemAtPosition.mjs +14 -3
- package/LineChart/seriesConfig/getSeriesWithDefaultValues.js +4 -6
- package/LineChart/seriesConfig/getSeriesWithDefaultValues.mjs +4 -6
- package/LineChart/seriesConfig/seriesProcessor.d.mts +4 -2
- package/LineChart/seriesConfig/seriesProcessor.d.ts +4 -2
- package/LineChart/seriesConfig/seriesProcessor.js +39 -15
- package/LineChart/seriesConfig/seriesProcessor.mjs +39 -15
- package/RadarChart/RadarSeriesPlot/useRadarSeriesData.d.mts +2 -2
- package/RadarChart/RadarSeriesPlot/useRadarSeriesData.d.ts +2 -2
- package/ScatterChart/Scatter.d.mts +11 -0
- package/ScatterChart/Scatter.d.ts +11 -0
- package/ScatterChart/Scatter.js +11 -0
- package/ScatterChart/Scatter.mjs +14 -0
- package/ScatterChart/ScatterChart.js +29 -10
- package/ScatterChart/ScatterChart.mjs +29 -10
- package/ScatterChart/seriesConfig/seriesProcessor.js +9 -4
- package/ScatterChart/seriesConfig/seriesProcessor.mjs +9 -4
- package/SparkLineChart/SparkLineChart.js +27 -9
- package/SparkLineChart/SparkLineChart.mjs +27 -9
- package/hooks/useAxis.d.mts +2 -2
- package/hooks/useAxis.d.ts +2 -2
- package/hooks/useTicks.d.mts +1 -1
- package/hooks/useTicks.d.ts +1 -1
- package/hooks/useTicks.js +21 -3
- package/hooks/useTicks.mjs +21 -3
- package/index.d.mts +4 -0
- package/index.d.ts +4 -0
- package/index.js +46 -2
- package/index.mjs +5 -1
- package/internals/cubiqSolver.d.mts +5 -0
- package/internals/cubiqSolver.d.ts +5 -0
- package/internals/cubiqSolver.js +62 -0
- package/internals/cubiqSolver.mjs +56 -0
- package/internals/index.d.mts +5 -1
- package/internals/index.d.ts +5 -1
- package/internals/index.js +47 -2
- package/internals/index.mjs +5 -1
- package/internals/isPolar.d.mts +3 -2
- package/internals/isPolar.d.ts +3 -2
- package/internals/isPolar.js +4 -0
- package/internals/isPolar.mjs +3 -0
- package/internals/material/index.js +6 -1
- package/internals/material/index.mjs +6 -1
- package/internals/plugins/corePlugins/useChartSeriesConfig/types/colorProcessor.types.d.mts +8 -9
- package/internals/plugins/corePlugins/useChartSeriesConfig/types/colorProcessor.types.d.ts +8 -9
- package/internals/plugins/featurePlugins/useChartCartesianAxis/defaultizeAxis.js +8 -12
- package/internals/plugins/featurePlugins/useChartCartesianAxis/defaultizeAxis.mjs +8 -12
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.d.mts +1 -0
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.d.ts +1 -0
- package/internals/plugins/featurePlugins/useChartPolarAxis/computeAxisValue.d.mts +3 -2
- package/internals/plugins/featurePlugins/useChartPolarAxis/computeAxisValue.d.ts +3 -2
- package/internals/plugins/featurePlugins/useChartPolarAxis/computeAxisValue.js +29 -16
- package/internals/plugins/featurePlugins/useChartPolarAxis/computeAxisValue.mjs +30 -17
- package/internals/plugins/featurePlugins/useChartPolarAxis/defaultizeAxis.js +3 -3
- package/internals/plugins/featurePlugins/useChartPolarAxis/defaultizeAxis.mjs +3 -3
- package/internals/plugins/featurePlugins/useChartTooltip/useChartTooltip.selectors.d.mts +2 -2
- package/internals/plugins/featurePlugins/useChartTooltip/useChartTooltip.selectors.d.ts +2 -2
- package/internals/plugins/featurePlugins/useChartZAxis/useChartZAxis.js +3 -3
- package/internals/plugins/featurePlugins/useChartZAxis/useChartZAxis.mjs +3 -3
- package/models/axis.d.mts +13 -2
- package/models/axis.d.ts +13 -2
- package/models/seriesType/bar.d.mts +21 -7
- package/models/seriesType/bar.d.ts +21 -7
- package/models/seriesType/common.d.mts +10 -0
- package/models/seriesType/common.d.ts +10 -0
- package/models/seriesType/composition.d.mts +3 -1
- package/models/seriesType/composition.d.ts +3 -1
- package/models/seriesType/composition.js +6 -2
- package/models/seriesType/composition.mjs +5 -1
- package/models/seriesType/index.d.mts +3 -3
- package/models/seriesType/index.d.ts +3 -3
- package/models/seriesType/index.js +0 -22
- package/models/seriesType/index.mjs +0 -2
- package/models/seriesType/line.d.mts +22 -8
- package/models/seriesType/line.d.ts +22 -8
- package/models/seriesType/scatter.d.mts +9 -0
- package/models/seriesType/scatter.d.ts +9 -0
- package/models/slots/chartsBaseSlotProps.d.mts +17 -0
- package/models/slots/chartsBaseSlotProps.d.ts +17 -0
- package/models/slots/chartsBaseSlots.d.mts +7 -1
- package/models/slots/chartsBaseSlots.d.ts +7 -1
- package/models/z-axis.d.mts +9 -0
- package/models/z-axis.d.ts +9 -0
- package/package.json +182 -126
- package/themeAugmentation/components.d.mts +4 -0
- package/themeAugmentation/components.d.ts +4 -0
- package/themeAugmentation/overrides.d.mts +2 -0
- package/themeAugmentation/overrides.d.ts +2 -0
- package/themeAugmentation/props.d.mts +2 -0
- package/themeAugmentation/props.d.ts +2 -0
- package/utils/epsilon.d.mts +1 -0
- package/utils/epsilon.d.ts +1 -0
- package/utils/epsilon.js +7 -0
- package/utils/epsilon.mjs +1 -0
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { AxisId } from "../models/axis.mjs";
|
|
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
|
+
}
|
|
48
|
+
export declare function ChartsRotationAxis(props: ChartsRotationAxisProps): import("react/jsx-runtime").JSX.Element | null;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { AxisId } from "../models/axis.js";
|
|
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
|
+
}
|
|
48
|
+
export declare function ChartsRotationAxis(props: ChartsRotationAxisProps): import("react/jsx-runtime").JSX.Element | null;
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
'use client';
|
|
3
|
+
|
|
4
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.ChartsRotationAxis = ChartsRotationAxis;
|
|
9
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
10
|
+
var _clsx = _interopRequireDefault(require("clsx"));
|
|
11
|
+
var _styles = require("@mui/material/styles");
|
|
12
|
+
var _useTicks = require("../hooks/useTicks");
|
|
13
|
+
var _useAxis = require("../hooks/useAxis");
|
|
14
|
+
var _ChartsProvider = require("../context/ChartsProvider");
|
|
15
|
+
var _useChartPolarAxis = require("../internals/plugins/featurePlugins/useChartPolarAxis");
|
|
16
|
+
var _chartsRotationAxisClasses = require("./chartsRotationAxisClasses");
|
|
17
|
+
var _createGetLabelTextAnchors = require("../ChartsRadiusAxis/createGetLabelTextAnchors");
|
|
18
|
+
var _getLabelTransform = require("./getLabelTransform");
|
|
19
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
20
|
+
/* Gap between a tick and its label. */
|
|
21
|
+
const TICK_LABEL_GAP = 3;
|
|
22
|
+
const getLabelTextAnchors = (0, _createGetLabelTextAnchors.createGetLabelTextAnchors)(_getLabelTransform.getLabelTransform);
|
|
23
|
+
function ChartsRotationAxis(props) {
|
|
24
|
+
const {
|
|
25
|
+
axisId,
|
|
26
|
+
disableLine,
|
|
27
|
+
disableTicks,
|
|
28
|
+
position = 'outside',
|
|
29
|
+
tickLabelPosition = position === 'outside' ? 'after' : 'before',
|
|
30
|
+
tickPosition = position === 'outside' ? 'after' : 'before',
|
|
31
|
+
tickSize = 6,
|
|
32
|
+
className,
|
|
33
|
+
classes: classesProp
|
|
34
|
+
} = props;
|
|
35
|
+
const classes = (0, _chartsRotationAxisClasses.useUtilityClasses)({
|
|
36
|
+
classes: classesProp
|
|
37
|
+
});
|
|
38
|
+
const theme = (0, _styles.useTheme)();
|
|
39
|
+
const {
|
|
40
|
+
store
|
|
41
|
+
} = (0, _ChartsProvider.useChartsContext)();
|
|
42
|
+
const {
|
|
43
|
+
cx,
|
|
44
|
+
cy
|
|
45
|
+
} = store.use(_useChartPolarAxis.selectorChartPolarCenter);
|
|
46
|
+
const rotationAxis = (0, _useAxis.useRotationAxis)(axisId);
|
|
47
|
+
const radiusAxis = (0, _useAxis.useRadiusAxis)();
|
|
48
|
+
const ticks = (0, _useTicks.useTicks)({
|
|
49
|
+
scale: rotationAxis.scale,
|
|
50
|
+
tickNumber: rotationAxis?.tickNumber ?? 5,
|
|
51
|
+
tickInterval: rotationAxis?.tickInterval,
|
|
52
|
+
tickSpacing: rotationAxis?.tickSpacing,
|
|
53
|
+
valueFormatter: rotationAxis?.valueFormatter,
|
|
54
|
+
direction: 'rotation'
|
|
55
|
+
});
|
|
56
|
+
if (!rotationAxis || !radiusAxis) {
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
const radius = radiusAxis.scale.range()[position === 'inside' ? 0 : 1];
|
|
60
|
+
const [startAngle, endAngle] = rotationAxis.scale.range();
|
|
61
|
+
const stroke = (theme.vars ?? theme).palette.text.primary;
|
|
62
|
+
|
|
63
|
+
// Convert "0 = up" convention to SVG coordinates (y-down).
|
|
64
|
+
const angleToPoint = (angle, r) => ({
|
|
65
|
+
x: cx + Math.sin(angle) * r,
|
|
66
|
+
y: cy - Math.cos(angle) * r
|
|
67
|
+
});
|
|
68
|
+
const isFullCircle = Math.abs(endAngle - startAngle) > 2 * Math.PI - 0.01;
|
|
69
|
+
const sweepFlag = endAngle - startAngle >= 0 ? 1 : 0;
|
|
70
|
+
const start = angleToPoint(startAngle, radius);
|
|
71
|
+
const end = angleToPoint(endAngle, radius);
|
|
72
|
+
const largeArcFlag = Math.abs(endAngle - startAngle) > Math.PI ? 1 : 0;
|
|
73
|
+
const arcPath = `M ${start.x} ${start.y} ` + `A ${radius} ${radius} 0 ${largeArcFlag} ${sweepFlag} ${end.x} ${end.y}`;
|
|
74
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)("g", {
|
|
75
|
+
className: (0, _clsx.default)(classes.root, className),
|
|
76
|
+
children: [!disableLine && (isFullCircle ?
|
|
77
|
+
/*#__PURE__*/
|
|
78
|
+
// Use a circle to avoid degenerated arcs when start and end angles are the same or very close.
|
|
79
|
+
(0, _jsxRuntime.jsx)("circle", {
|
|
80
|
+
cx: cx,
|
|
81
|
+
cy: cy,
|
|
82
|
+
r: radius,
|
|
83
|
+
stroke: stroke,
|
|
84
|
+
fill: "none",
|
|
85
|
+
className: classes.line
|
|
86
|
+
}) : /*#__PURE__*/(0, _jsxRuntime.jsx)("path", {
|
|
87
|
+
d: arcPath,
|
|
88
|
+
stroke: stroke,
|
|
89
|
+
fill: "none",
|
|
90
|
+
className: classes.line
|
|
91
|
+
})), ticks.map(({
|
|
92
|
+
offset: angle,
|
|
93
|
+
formattedValue
|
|
94
|
+
}, index) => {
|
|
95
|
+
if (!formattedValue) {
|
|
96
|
+
return null;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// Convert "0 = up" convention to SVG math angle (0 = right, clockwise y-down).
|
|
100
|
+
const dx = Math.sin(angle);
|
|
101
|
+
const dy = -Math.cos(angle);
|
|
102
|
+
const tx = cx + dx * radius;
|
|
103
|
+
const ty = cy + dy * radius;
|
|
104
|
+
const tickDx = (tickPosition === 'after' ? 1 : -1) * dx * tickSize;
|
|
105
|
+
const tickDy = (tickPosition === 'after' ? 1 : -1) * dy * tickSize;
|
|
106
|
+
const tickLabelGapDx = (tickLabelPosition === 'after' ? 1 : -1) * dx * TICK_LABEL_GAP;
|
|
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;
|
|
114
|
+
if (tickLabelPosition === tickPosition && !disableTicks) {
|
|
115
|
+
// Add the size of the tick if they are in the same direction.
|
|
116
|
+
labelX += tickDx;
|
|
117
|
+
labelY += tickDy;
|
|
118
|
+
}
|
|
119
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)("g", {
|
|
120
|
+
className: classes.tickContainer,
|
|
121
|
+
children: [!disableTicks && /*#__PURE__*/(0, _jsxRuntime.jsx)("line", {
|
|
122
|
+
x1: tx,
|
|
123
|
+
y1: ty,
|
|
124
|
+
x2: tx + tickDx,
|
|
125
|
+
y2: ty + tickDy,
|
|
126
|
+
stroke: stroke,
|
|
127
|
+
className: classes.tick
|
|
128
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("text", (0, _extends2.default)({
|
|
129
|
+
x: labelX,
|
|
130
|
+
y: labelY,
|
|
131
|
+
fill: stroke,
|
|
132
|
+
fontSize: 12,
|
|
133
|
+
className: classes.tickLabel,
|
|
134
|
+
pointerEvents: "none"
|
|
135
|
+
}, getLabelTextAnchors(dx, dy, tickLabelPosition), {
|
|
136
|
+
children: formattedValue
|
|
137
|
+
}))]
|
|
138
|
+
}, index);
|
|
139
|
+
})]
|
|
140
|
+
});
|
|
141
|
+
}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
4
|
+
import clsx from 'clsx';
|
|
5
|
+
import { useTheme } from '@mui/material/styles';
|
|
6
|
+
import { useTicks } from "../hooks/useTicks.mjs";
|
|
7
|
+
import { useRadiusAxis, useRotationAxis } from "../hooks/useAxis.mjs";
|
|
8
|
+
import { useChartsContext } from "../context/ChartsProvider/index.mjs";
|
|
9
|
+
import { selectorChartPolarCenter } from "../internals/plugins/featurePlugins/useChartPolarAxis/index.mjs";
|
|
10
|
+
import { useUtilityClasses } from "./chartsRotationAxisClasses.mjs";
|
|
11
|
+
import { createGetLabelTextAnchors } from "../ChartsRadiusAxis/createGetLabelTextAnchors.mjs";
|
|
12
|
+
import { getLabelTransform } from "./getLabelTransform.mjs";
|
|
13
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
14
|
+
/* Gap between a tick and its label. */
|
|
15
|
+
const TICK_LABEL_GAP = 3;
|
|
16
|
+
const getLabelTextAnchors = createGetLabelTextAnchors(getLabelTransform);
|
|
17
|
+
export function ChartsRotationAxis(props) {
|
|
18
|
+
const {
|
|
19
|
+
axisId,
|
|
20
|
+
disableLine,
|
|
21
|
+
disableTicks,
|
|
22
|
+
position = 'outside',
|
|
23
|
+
tickLabelPosition = position === 'outside' ? 'after' : 'before',
|
|
24
|
+
tickPosition = position === 'outside' ? 'after' : 'before',
|
|
25
|
+
tickSize = 6,
|
|
26
|
+
className,
|
|
27
|
+
classes: classesProp
|
|
28
|
+
} = props;
|
|
29
|
+
const classes = useUtilityClasses({
|
|
30
|
+
classes: classesProp
|
|
31
|
+
});
|
|
32
|
+
const theme = useTheme();
|
|
33
|
+
const {
|
|
34
|
+
store
|
|
35
|
+
} = useChartsContext();
|
|
36
|
+
const {
|
|
37
|
+
cx,
|
|
38
|
+
cy
|
|
39
|
+
} = store.use(selectorChartPolarCenter);
|
|
40
|
+
const rotationAxis = useRotationAxis(axisId);
|
|
41
|
+
const radiusAxis = useRadiusAxis();
|
|
42
|
+
const ticks = useTicks({
|
|
43
|
+
scale: rotationAxis.scale,
|
|
44
|
+
tickNumber: rotationAxis?.tickNumber ?? 5,
|
|
45
|
+
tickInterval: rotationAxis?.tickInterval,
|
|
46
|
+
tickSpacing: rotationAxis?.tickSpacing,
|
|
47
|
+
valueFormatter: rotationAxis?.valueFormatter,
|
|
48
|
+
direction: 'rotation'
|
|
49
|
+
});
|
|
50
|
+
if (!rotationAxis || !radiusAxis) {
|
|
51
|
+
return null;
|
|
52
|
+
}
|
|
53
|
+
const radius = radiusAxis.scale.range()[position === 'inside' ? 0 : 1];
|
|
54
|
+
const [startAngle, endAngle] = rotationAxis.scale.range();
|
|
55
|
+
const stroke = (theme.vars ?? theme).palette.text.primary;
|
|
56
|
+
|
|
57
|
+
// Convert "0 = up" convention to SVG coordinates (y-down).
|
|
58
|
+
const angleToPoint = (angle, r) => ({
|
|
59
|
+
x: cx + Math.sin(angle) * r,
|
|
60
|
+
y: cy - Math.cos(angle) * r
|
|
61
|
+
});
|
|
62
|
+
const isFullCircle = Math.abs(endAngle - startAngle) > 2 * Math.PI - 0.01;
|
|
63
|
+
const sweepFlag = endAngle - startAngle >= 0 ? 1 : 0;
|
|
64
|
+
const start = angleToPoint(startAngle, radius);
|
|
65
|
+
const end = angleToPoint(endAngle, radius);
|
|
66
|
+
const largeArcFlag = Math.abs(endAngle - startAngle) > Math.PI ? 1 : 0;
|
|
67
|
+
const arcPath = `M ${start.x} ${start.y} ` + `A ${radius} ${radius} 0 ${largeArcFlag} ${sweepFlag} ${end.x} ${end.y}`;
|
|
68
|
+
return /*#__PURE__*/_jsxs("g", {
|
|
69
|
+
className: clsx(classes.root, className),
|
|
70
|
+
children: [!disableLine && (isFullCircle ?
|
|
71
|
+
/*#__PURE__*/
|
|
72
|
+
// Use a circle to avoid degenerated arcs when start and end angles are the same or very close.
|
|
73
|
+
_jsx("circle", {
|
|
74
|
+
cx: cx,
|
|
75
|
+
cy: cy,
|
|
76
|
+
r: radius,
|
|
77
|
+
stroke: stroke,
|
|
78
|
+
fill: "none",
|
|
79
|
+
className: classes.line
|
|
80
|
+
}) : /*#__PURE__*/_jsx("path", {
|
|
81
|
+
d: arcPath,
|
|
82
|
+
stroke: stroke,
|
|
83
|
+
fill: "none",
|
|
84
|
+
className: classes.line
|
|
85
|
+
})), ticks.map(({
|
|
86
|
+
offset: angle,
|
|
87
|
+
formattedValue
|
|
88
|
+
}, index) => {
|
|
89
|
+
if (!formattedValue) {
|
|
90
|
+
return null;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// Convert "0 = up" convention to SVG math angle (0 = right, clockwise y-down).
|
|
94
|
+
const dx = Math.sin(angle);
|
|
95
|
+
const dy = -Math.cos(angle);
|
|
96
|
+
const tx = cx + dx * radius;
|
|
97
|
+
const ty = cy + dy * radius;
|
|
98
|
+
const tickDx = (tickPosition === 'after' ? 1 : -1) * dx * tickSize;
|
|
99
|
+
const tickDy = (tickPosition === 'after' ? 1 : -1) * dy * tickSize;
|
|
100
|
+
const tickLabelGapDx = (tickLabelPosition === 'after' ? 1 : -1) * dx * TICK_LABEL_GAP;
|
|
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;
|
|
108
|
+
if (tickLabelPosition === tickPosition && !disableTicks) {
|
|
109
|
+
// Add the size of the tick if they are in the same direction.
|
|
110
|
+
labelX += tickDx;
|
|
111
|
+
labelY += tickDy;
|
|
112
|
+
}
|
|
113
|
+
return /*#__PURE__*/_jsxs("g", {
|
|
114
|
+
className: classes.tickContainer,
|
|
115
|
+
children: [!disableTicks && /*#__PURE__*/_jsx("line", {
|
|
116
|
+
x1: tx,
|
|
117
|
+
y1: ty,
|
|
118
|
+
x2: tx + tickDx,
|
|
119
|
+
y2: ty + tickDy,
|
|
120
|
+
stroke: stroke,
|
|
121
|
+
className: classes.tick
|
|
122
|
+
}), /*#__PURE__*/_jsx("text", _extends({
|
|
123
|
+
x: labelX,
|
|
124
|
+
y: labelY,
|
|
125
|
+
fill: stroke,
|
|
126
|
+
fontSize: 12,
|
|
127
|
+
className: classes.tickLabel,
|
|
128
|
+
pointerEvents: "none"
|
|
129
|
+
}, getLabelTextAnchors(dx, dy, tickLabelPosition), {
|
|
130
|
+
children: formattedValue
|
|
131
|
+
}))]
|
|
132
|
+
}, index);
|
|
133
|
+
})]
|
|
134
|
+
});
|
|
135
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { type ChartsRadialAxisClasses } from "../ChartsRadiusAxis/sharedRadialAxisClasses.mjs";
|
|
2
|
+
export declare const useUtilityClasses: (props: {
|
|
3
|
+
classes?: Partial<ChartsRadialAxisClasses>;
|
|
4
|
+
}) => Record<"root" | "line" | "tickContainer" | "tick" | "tickLabel", string>;
|
|
5
|
+
export { type ChartsRadialAxisClasses, type ChartsRadialAxisClassKey, chartsRadialAxisClasses } from "../ChartsRadiusAxis/sharedRadialAxisClasses.mjs";
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { type ChartsRadialAxisClasses } from "../ChartsRadiusAxis/sharedRadialAxisClasses.js";
|
|
2
|
+
export declare const useUtilityClasses: (props: {
|
|
3
|
+
classes?: Partial<ChartsRadialAxisClasses>;
|
|
4
|
+
}) => Record<"root" | "line" | "tickContainer" | "tick" | "tickLabel", string>;
|
|
5
|
+
export { type ChartsRadialAxisClasses, type ChartsRadialAxisClassKey, chartsRadialAxisClasses } from "../ChartsRadiusAxis/sharedRadialAxisClasses.js";
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
Object.defineProperty(exports, "chartsRadialAxisClasses", {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: function () {
|
|
10
|
+
return _sharedRadialAxisClasses.chartsRadialAxisClasses;
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
exports.useUtilityClasses = void 0;
|
|
14
|
+
var _composeClasses = _interopRequireDefault(require("@mui/utils/composeClasses"));
|
|
15
|
+
var _sharedRadialAxisClasses = require("../ChartsRadiusAxis/sharedRadialAxisClasses");
|
|
16
|
+
const useUtilityClasses = props => {
|
|
17
|
+
const {
|
|
18
|
+
classes
|
|
19
|
+
} = props;
|
|
20
|
+
const slots = {
|
|
21
|
+
root: ['root', 'rotation'],
|
|
22
|
+
line: ['line'],
|
|
23
|
+
tickContainer: ['tickContainer'],
|
|
24
|
+
tick: ['tick'],
|
|
25
|
+
tickLabel: ['tickLabel']
|
|
26
|
+
};
|
|
27
|
+
return (0, _composeClasses.default)(slots, _sharedRadialAxisClasses.getRadialAxisUtilityClass, classes);
|
|
28
|
+
};
|
|
29
|
+
exports.useUtilityClasses = useUtilityClasses;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import composeClasses from '@mui/utils/composeClasses';
|
|
2
|
+
import { getRadialAxisUtilityClass } from "../ChartsRadiusAxis/sharedRadialAxisClasses.mjs";
|
|
3
|
+
export const useUtilityClasses = props => {
|
|
4
|
+
const {
|
|
5
|
+
classes
|
|
6
|
+
} = props;
|
|
7
|
+
const slots = {
|
|
8
|
+
root: ['root', 'rotation'],
|
|
9
|
+
line: ['line'],
|
|
10
|
+
tickContainer: ['tickContainer'],
|
|
11
|
+
tick: ['tick'],
|
|
12
|
+
tickLabel: ['tickLabel']
|
|
13
|
+
};
|
|
14
|
+
return composeClasses(slots, getRadialAxisUtilityClass, classes);
|
|
15
|
+
};
|
|
16
|
+
export { chartsRadialAxisClasses } from "../ChartsRadiusAxis/sharedRadialAxisClasses.mjs";
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Return the vertical/horizontal alignment for a tick label at a given position.
|
|
3
|
+
* @param px The normalized x position to the axis line (between -1 and 1).
|
|
4
|
+
* @param py The normalized y position to the axis line (between -1 and 1).
|
|
5
|
+
* @param tickLabelPosition The position of the tick label relative to the axis line.
|
|
6
|
+
* @returns The vertical and horizontal alignment for the tick label.
|
|
7
|
+
*/
|
|
8
|
+
export declare function getLabelTransform(px: number, py: number, tickLabelPosition: 'center' | 'after' | 'before'): {
|
|
9
|
+
verticalAlign: 'start' | 'middle' | 'end';
|
|
10
|
+
horizontalAlign: 'start' | 'middle' | 'end';
|
|
11
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Return the vertical/horizontal alignment for a tick label at a given position.
|
|
3
|
+
* @param px The normalized x position to the axis line (between -1 and 1).
|
|
4
|
+
* @param py The normalized y position to the axis line (between -1 and 1).
|
|
5
|
+
* @param tickLabelPosition The position of the tick label relative to the axis line.
|
|
6
|
+
* @returns The vertical and horizontal alignment for the tick label.
|
|
7
|
+
*/
|
|
8
|
+
export declare function getLabelTransform(px: number, py: number, tickLabelPosition: 'center' | 'after' | 'before'): {
|
|
9
|
+
verticalAlign: 'start' | 'middle' | 'end';
|
|
10
|
+
horizontalAlign: 'start' | 'middle' | 'end';
|
|
11
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getLabelTransform = getLabelTransform;
|
|
7
|
+
/**
|
|
8
|
+
* Return the vertical/horizontal alignment for a tick label at a given position.
|
|
9
|
+
* @param px The normalized x position to the axis line (between -1 and 1).
|
|
10
|
+
* @param py The normalized y position to the axis line (between -1 and 1).
|
|
11
|
+
* @param tickLabelPosition The position of the tick label relative to the axis line.
|
|
12
|
+
* @returns The vertical and horizontal alignment for the tick label.
|
|
13
|
+
*/
|
|
14
|
+
function getLabelTransform(px, py, tickLabelPosition) {
|
|
15
|
+
if (tickLabelPosition === 'center') {
|
|
16
|
+
return {
|
|
17
|
+
verticalAlign: 'middle',
|
|
18
|
+
horizontalAlign: 'middle'
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
let verticalAlign = 'middle';
|
|
22
|
+
let horizontalAlign = 'middle';
|
|
23
|
+
if (px > 0.3) {
|
|
24
|
+
horizontalAlign = tickLabelPosition === 'after' ? 'start' : 'end';
|
|
25
|
+
} else if (px < -0.3) {
|
|
26
|
+
horizontalAlign = tickLabelPosition === 'after' ? 'end' : 'start';
|
|
27
|
+
}
|
|
28
|
+
if (py > 0.3) {
|
|
29
|
+
verticalAlign = tickLabelPosition === 'after' ? 'start' : 'end';
|
|
30
|
+
} else if (py < -0.3) {
|
|
31
|
+
verticalAlign = tickLabelPosition === 'after' ? 'end' : 'start';
|
|
32
|
+
}
|
|
33
|
+
return {
|
|
34
|
+
verticalAlign,
|
|
35
|
+
horizontalAlign
|
|
36
|
+
};
|
|
37
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Return the vertical/horizontal alignment for a tick label at a given position.
|
|
3
|
+
* @param px The normalized x position to the axis line (between -1 and 1).
|
|
4
|
+
* @param py The normalized y position to the axis line (between -1 and 1).
|
|
5
|
+
* @param tickLabelPosition The position of the tick label relative to the axis line.
|
|
6
|
+
* @returns The vertical and horizontal alignment for the tick label.
|
|
7
|
+
*/
|
|
8
|
+
export function getLabelTransform(px, py, tickLabelPosition) {
|
|
9
|
+
if (tickLabelPosition === 'center') {
|
|
10
|
+
return {
|
|
11
|
+
verticalAlign: 'middle',
|
|
12
|
+
horizontalAlign: 'middle'
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
let verticalAlign = 'middle';
|
|
16
|
+
let horizontalAlign = 'middle';
|
|
17
|
+
if (px > 0.3) {
|
|
18
|
+
horizontalAlign = tickLabelPosition === 'after' ? 'start' : 'end';
|
|
19
|
+
} else if (px < -0.3) {
|
|
20
|
+
horizontalAlign = tickLabelPosition === 'after' ? 'end' : 'start';
|
|
21
|
+
}
|
|
22
|
+
if (py > 0.3) {
|
|
23
|
+
verticalAlign = tickLabelPosition === 'after' ? 'start' : 'end';
|
|
24
|
+
} else if (py < -0.3) {
|
|
25
|
+
verticalAlign = tickLabelPosition === 'after' ? 'end' : 'start';
|
|
26
|
+
}
|
|
27
|
+
return {
|
|
28
|
+
verticalAlign,
|
|
29
|
+
horizontalAlign
|
|
30
|
+
};
|
|
31
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "Unstable_ChartsRotationAxis", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _ChartsRotationAxis.ChartsRotationAxis;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(exports, "chartsRadialAxisClasses", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () {
|
|
15
|
+
return _chartsRotationAxisClasses.chartsRadialAxisClasses;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
var _ChartsRotationAxis = require("./ChartsRotationAxis");
|
|
19
|
+
var _chartsRotationAxisClasses = require("./chartsRotationAxisClasses");
|
|
@@ -45,6 +45,7 @@ function useAxesTooltip(params) {
|
|
|
45
45
|
const defaultXAxis = (0, _useAxis.useXAxis)();
|
|
46
46
|
const defaultYAxis = (0, _useAxis.useYAxis)();
|
|
47
47
|
const defaultRotationAxis = (0, _useAxis.useRotationAxis)();
|
|
48
|
+
const defaultRadiusAxis = (0, _useAxis.useRadiusAxis)();
|
|
48
49
|
const store = (0, _useStore.useStore)();
|
|
49
50
|
const tooltipXAxes = store.use(_useChartCartesianAxis.selectorChartsInteractionTooltipXAxes);
|
|
50
51
|
const tooltipYAxes = store.use(_useChartCartesianAxis.selectorChartsInteractionTooltipYAxes);
|
|
@@ -63,6 +64,9 @@ function useAxesTooltip(params) {
|
|
|
63
64
|
const {
|
|
64
65
|
rotationAxis
|
|
65
66
|
} = (0, _useAxis.useRotationAxes)();
|
|
67
|
+
const {
|
|
68
|
+
radiusAxis
|
|
69
|
+
} = (0, _useAxis.useRadiusAxes)();
|
|
66
70
|
const colorProcessors = (0, _useColorProcessor.useColorProcessor)();
|
|
67
71
|
const isItemVisible = store.use(_useChartVisibilityManager.selectorIsItemVisibleGetter);
|
|
68
72
|
if (tooltipXAxes.length === 0 && tooltipYAxes.length === 0 && tooltipRotationAxes.length === 0) {
|
|
@@ -185,9 +189,8 @@ function useAxesTooltip(params) {
|
|
|
185
189
|
})) {
|
|
186
190
|
return;
|
|
187
191
|
}
|
|
188
|
-
const providedRotationAxisId =
|
|
189
|
-
|
|
190
|
-
seriesToAdd.rotationAxisId ?? defaultRotationAxis?.id;
|
|
192
|
+
const providedRotationAxisId = ('rotationAxisId' in seriesToAdd ? seriesToAdd.rotationAxisId : undefined) ?? defaultRotationAxis?.id;
|
|
193
|
+
const providedRadiusAxisId = ('radiusAxisId' in seriesToAdd ? seriesToAdd.radiusAxisId : undefined) ?? defaultRadiusAxis?.id;
|
|
191
194
|
const tooltipItemIndex = tooltipAxes.findIndex(({
|
|
192
195
|
axisDirection,
|
|
193
196
|
axisId
|
|
@@ -197,7 +200,7 @@ function useAxesTooltip(params) {
|
|
|
197
200
|
const {
|
|
198
201
|
dataIndex
|
|
199
202
|
} = tooltipAxes[tooltipItemIndex];
|
|
200
|
-
const color = colorProcessors[seriesType]?.(seriesToAdd)(dataIndex) ?? '';
|
|
203
|
+
const color = colorProcessors[seriesType]?.(seriesToAdd, providedRotationAxisId !== undefined ? rotationAxis[providedRotationAxisId] : undefined, providedRadiusAxisId !== undefined ? radiusAxis[providedRadiusAxisId] : undefined)(dataIndex) ?? '';
|
|
201
204
|
const value = seriesToAdd.data[dataIndex] ?? null;
|
|
202
205
|
const formattedValue = seriesToAdd.valueFormatter(value, {
|
|
203
206
|
dataIndex
|
|
@@ -5,7 +5,7 @@ import { useColorProcessor } from "../internals/plugins/corePlugins/useChartSeri
|
|
|
5
5
|
import { useStore } from "../internals/store/useStore.mjs";
|
|
6
6
|
import { getLabel } from "../internals/getLabel.mjs";
|
|
7
7
|
import { utcFormatter } from "./utils.mjs";
|
|
8
|
-
import { useRotationAxes, useRotationAxis, useXAxes, useXAxis, useYAxes, useYAxis } from "../hooks/useAxis.mjs";
|
|
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
11
|
import { selectorChartsInteractionTooltipRotationAxes } from "../internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarInteraction.selectors.mjs";
|
|
@@ -40,6 +40,7 @@ export function useAxesTooltip(params) {
|
|
|
40
40
|
const defaultXAxis = useXAxis();
|
|
41
41
|
const defaultYAxis = useYAxis();
|
|
42
42
|
const defaultRotationAxis = useRotationAxis();
|
|
43
|
+
const defaultRadiusAxis = useRadiusAxis();
|
|
43
44
|
const store = useStore();
|
|
44
45
|
const tooltipXAxes = store.use(selectorChartsInteractionTooltipXAxes);
|
|
45
46
|
const tooltipYAxes = store.use(selectorChartsInteractionTooltipYAxes);
|
|
@@ -58,6 +59,9 @@ export function useAxesTooltip(params) {
|
|
|
58
59
|
const {
|
|
59
60
|
rotationAxis
|
|
60
61
|
} = useRotationAxes();
|
|
62
|
+
const {
|
|
63
|
+
radiusAxis
|
|
64
|
+
} = useRadiusAxes();
|
|
61
65
|
const colorProcessors = useColorProcessor();
|
|
62
66
|
const isItemVisible = store.use(selectorIsItemVisibleGetter);
|
|
63
67
|
if (tooltipXAxes.length === 0 && tooltipYAxes.length === 0 && tooltipRotationAxes.length === 0) {
|
|
@@ -180,9 +184,8 @@ export function useAxesTooltip(params) {
|
|
|
180
184
|
})) {
|
|
181
185
|
return;
|
|
182
186
|
}
|
|
183
|
-
const providedRotationAxisId =
|
|
184
|
-
|
|
185
|
-
seriesToAdd.rotationAxisId ?? defaultRotationAxis?.id;
|
|
187
|
+
const providedRotationAxisId = ('rotationAxisId' in seriesToAdd ? seriesToAdd.rotationAxisId : undefined) ?? defaultRotationAxis?.id;
|
|
188
|
+
const providedRadiusAxisId = ('radiusAxisId' in seriesToAdd ? seriesToAdd.radiusAxisId : undefined) ?? defaultRadiusAxis?.id;
|
|
186
189
|
const tooltipItemIndex = tooltipAxes.findIndex(({
|
|
187
190
|
axisDirection,
|
|
188
191
|
axisId
|
|
@@ -192,7 +195,7 @@ export function useAxesTooltip(params) {
|
|
|
192
195
|
const {
|
|
193
196
|
dataIndex
|
|
194
197
|
} = tooltipAxes[tooltipItemIndex];
|
|
195
|
-
const color = colorProcessors[seriesType]?.(seriesToAdd)(dataIndex) ?? '';
|
|
198
|
+
const color = colorProcessors[seriesType]?.(seriesToAdd, providedRotationAxisId !== undefined ? rotationAxis[providedRotationAxisId] : undefined, providedRadiusAxisId !== undefined ? radiusAxis[providedRadiusAxisId] : undefined)(dataIndex) ?? '';
|
|
196
199
|
const value = seriesToAdd.data[dataIndex] ?? null;
|
|
197
200
|
const formattedValue = seriesToAdd.valueFormatter(value, {
|
|
198
201
|
dataIndex
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { ChartSeriesType } from "../models/seriesType/config.mjs";
|
|
2
2
|
import { type ItemTooltip, type ItemTooltipWithMultipleValues } from "../internals/plugins/corePlugins/useChartSeriesConfig/index.mjs";
|
|
3
3
|
export type UseItemTooltipReturnValue<SeriesType extends ChartSeriesType> = ItemTooltip<SeriesType>;
|
|
4
4
|
export type UseRadarItemTooltipReturnValue = ItemTooltipWithMultipleValues<'radar'>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { ChartSeriesType } from "../models/seriesType/config.js";
|
|
2
2
|
import { type ItemTooltip, type ItemTooltipWithMultipleValues } from "../internals/plugins/corePlugins/useChartSeriesConfig/index.js";
|
|
3
3
|
export type UseItemTooltipReturnValue<SeriesType extends ChartSeriesType> = ItemTooltip<SeriesType>;
|
|
4
4
|
export type UseRadarItemTooltipReturnValue = ItemTooltipWithMultipleValues<'radar'>;
|