UNPKG

@mui/x-charts

Version:

The community edition of MUI X Charts components.

85 lines 2.83 kB
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 PropTypes from 'prop-types'; import clsx from 'clsx'; import { useRadarSeriesData } from "./useRadarSeriesData.js"; import { getAreaPath } from "./getAreaPath.js"; import { useUtilityClasses } from "./radarSeriesPlotClasses.js"; import { useItemHighlightedGetter } from "../../hooks/useItemHighlightedGetter.js"; import { useInteractionAllItemProps } from "../../hooks/useInteractionItemProps.js"; import { jsx as _jsx } from "react/jsx-runtime"; export function getPathProps(params) { const { isHighlighted, isFaded, seriesId, classes, points, fillArea, color } = params; const isItemHighlighted = isHighlighted({ seriesId }); const isItemFaded = !isItemHighlighted && isFaded({ seriesId }); return { d: getAreaPath(points), fill: fillArea ? color : 'transparent', stroke: color, className: clsx(classes.area, isItemHighlighted && classes.highlighted || isItemFaded && classes.faded), strokeOpacity: isItemFaded ? 0.5 : 1, fillOpacity: isItemHighlighted && 0.4 || isItemFaded && 0.1 || 0.2, strokeWidth: !fillArea && isItemHighlighted ? 2 : 1 }; } function RadarSeriesArea(props) { const { seriesId } = props, other = _objectWithoutPropertiesLoose(props, _excluded); const seriesCoordinates = useRadarSeriesData(seriesId); const interactionProps = useInteractionAllItemProps(seriesCoordinates); const { isFaded, isHighlighted } = useItemHighlightedGetter(); const classes = useUtilityClasses(props.classes); return /*#__PURE__*/_jsx(React.Fragment, { children: seriesCoordinates?.map(({ seriesId: id, points, color, fillArea }, seriesIndex) => { return /*#__PURE__*/_jsx("path", _extends({}, getPathProps({ seriesId: id, points, color, fillArea, isFaded, isHighlighted, classes }), interactionProps[seriesIndex], other), id); }) }); } process.env.NODE_ENV !== "production" ? RadarSeriesArea.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 { RadarSeriesArea };