UNPKG

@mui/x-charts

Version:

The community edition of MUI X Charts components.

95 lines (93 loc) 3.08 kB
'use client'; import _extends from "@babel/runtime/helpers/esm/extends"; import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose"; const _excluded = ["x", "y", "id", "classes", "color", "dataIndex", "onClick", "skipAnimation", "isFaded", "isHighlighted"]; import * as React from 'react'; import PropTypes from 'prop-types'; import { styled, useTheme } from '@mui/material/styles'; import { ANIMATION_DURATION_MS, ANIMATION_TIMING_FUNCTION } from "../internals/animation/animation.js"; import { useInteractionItemProps } from "../hooks/useInteractionItemProps.js"; import { markElementClasses, useUtilityClasses } from "./markElementClasses.js"; import { jsx as _jsx } from "react/jsx-runtime"; const Circle = styled('circle')({ [`&.${markElementClasses.animate}`]: { transitionDuration: `${ANIMATION_DURATION_MS}ms`, transitionProperty: 'cx, cy', transitionTimingFunction: ANIMATION_TIMING_FUNCTION } }); /** * The line mark element that only render circle for performance improvement. * * Demos: * * - [Lines](https://mui.com/x/react-charts/lines/) * - [Line demonstration](https://mui.com/x/react-charts/line-demo/) * * API: * * - [CircleMarkElement API](https://mui.com/x/api/charts/circle-mark-element/) */ function CircleMarkElement(props) { const { x, y, id, classes: innerClasses, color, dataIndex, onClick, skipAnimation, isFaded = false, isHighlighted = false } = props, other = _objectWithoutPropertiesLoose(props, _excluded); const theme = useTheme(); const interactionProps = useInteractionItemProps({ type: 'line', seriesId: id, dataIndex }); const ownerState = { id, classes: innerClasses, isHighlighted, isFaded, color, skipAnimation }; const classes = useUtilityClasses(ownerState); return /*#__PURE__*/_jsx(Circle, _extends({}, other, { cx: x, cy: y, r: 5, fill: (theme.vars || theme).palette.background.paper, stroke: color, strokeWidth: 2, className: classes.root, onClick: onClick, cursor: onClick ? 'pointer' : 'unset' }, interactionProps)); } process.env.NODE_ENV !== "production" ? CircleMarkElement.propTypes = { // ----------------------------- Warning -------------------------------- // | These PropTypes are generated from the TypeScript type definitions | // | To update them edit the TypeScript types and run "pnpm proptypes" | // ---------------------------------------------------------------------- classes: PropTypes.object, /** * The index to the element in the series' data array. */ dataIndex: PropTypes.number.isRequired, id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired, /** * The shape of the marker. */ shape: PropTypes.oneOf(['circle', 'cross', 'diamond', 'square', 'star', 'triangle', 'wye']).isRequired, /** * If `true`, animations are skipped. * @default false */ skipAnimation: PropTypes.bool } : void 0; export { CircleMarkElement };