UNPKG

@mui/x-charts

Version:

The community edition of MUI X Charts components.

66 lines 1.94 kB
import * as React from 'react'; import { useTicks } from "../hooks/useTicks.mjs"; import { GridCircle, GridPath } from "./styledComponents.mjs"; import { useChartsContext } from "../context/ChartsProvider/index.mjs"; import { selectorChartPolarCenter } from "../internals/plugins/featurePlugins/useChartPolarAxis/index.mjs"; import { EPSILON } from "../utils/epsilon.mjs"; import { jsx as _jsx } from "react/jsx-runtime"; /** * @ignore - internal component. */ export function ChartsRadiusGrid(props) { const { store } = useChartsContext(); const { axis, startAngle, endAngle, classes } = props; const { cx, cy } = store.use(selectorChartPolarCenter); const { scale, tickNumber, tickInterval, tickSpacing } = axis; const ticks = useTicks({ scale, tickNumber, tickInterval, tickSpacing, direction: 'radius' }); const isFullCircle = Math.abs(endAngle - startAngle) >= 2 * Math.PI - EPSILON; if (isFullCircle) { return /*#__PURE__*/_jsx(React.Fragment, { children: ticks.map(({ offset: radius }) => /*#__PURE__*/_jsx(GridCircle, { cx: cx, cy: cy, r: radius, className: classes.radiusLine }, `radius-${radius}`)) }); } const startDx = Math.cos(startAngle - Math.PI / 2); const startDy = Math.sin(startAngle - Math.PI / 2); const endDx = Math.cos(endAngle - Math.PI / 2); const endDy = Math.sin(endAngle - Math.PI / 2); const isLargeArc = Math.abs(endAngle - startAngle) >= Math.PI; return /*#__PURE__*/_jsx(React.Fragment, { children: ticks.map(({ offset: radius }) => { return /*#__PURE__*/_jsx(GridPath, { d: `M${cx + startDx * radius},${cy + startDy * radius} A ${radius} ${radius} 0 ${isLargeArc ? 1 : 0} 1 ${cx + endDx * radius},${cy + endDy * radius}`, className: classes.radiusLine }, `radius-${radius}`); }) }); }