@mui/x-charts
Version:
The community edition of MUI X Charts components.
86 lines • 2.62 kB
JavaScript
import _extends from "@babel/runtime/helpers/esm/extends";
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
const _excluded = ["seriesId"];
import * as React from 'react';
import { clsx } from 'clsx';
import PropTypes from 'prop-types';
import { useRadarSeriesData } from "./useRadarSeriesData.js";
import { useItemHighlightedGetter } from "../../hooks/useItemHighlightedGetter.js";
import { useUtilityClasses } from "./radarSeriesPlotClasses.js";
import { jsx as _jsx } from "react/jsx-runtime";
export function getCircleProps(params) {
const {
isHighlighted,
isFaded,
seriesId,
classes,
point,
fillArea,
color
} = params;
const isItemHighlighted = isHighlighted({
seriesId
});
const isItemFaded = !isItemHighlighted && isFaded({
seriesId
});
return {
cx: point.x,
cy: point.y,
r: 3,
fill: color,
stroke: color,
opacity: fillArea && isItemFaded ? 0.5 : 1,
pointerEvents: 'none',
className: clsx(classes.mark, isItemHighlighted && classes.highlighted || isItemFaded && classes.faded)
};
}
function RadarSeriesMarks(props) {
const other = _objectWithoutPropertiesLoose(props, _excluded);
const seriesCoordinates = useRadarSeriesData(props.seriesId);
const classes = useUtilityClasses(props.classes);
const {
isFaded,
isHighlighted
} = useItemHighlightedGetter();
return /*#__PURE__*/_jsx(React.Fragment, {
children: seriesCoordinates?.map(({
seriesId: id,
points,
color,
hideMark,
fillArea
}) => {
if (hideMark) {
return null;
}
return /*#__PURE__*/_jsx("g", {
children: points.map((point, index) => /*#__PURE__*/_jsx("circle", _extends({}, getCircleProps({
seriesId: id,
point,
color,
fillArea,
isFaded,
isHighlighted,
classes
}), other), index))
}, id);
})
});
}
process.env.NODE_ENV !== "production" ? RadarSeriesMarks.propTypes = {
// ----------------------------- Warning --------------------------------
// | These PropTypes are generated from the TypeScript type definitions |
// | To update them edit the TypeScript types and run "pnpm proptypes" |
// ----------------------------------------------------------------------
/**
* Override or extend the styles applied to the component.
*/
classes: PropTypes.object,
/**
* The id of the series to display.
* If undefined all series are displayed.
*/
seriesId: PropTypes.string
} : void 0;
export { RadarSeriesMarks };