UNPKG

@mui/x-charts

Version:

The community edition of MUI X Charts components.

112 lines (111 loc) 3.56 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", "shape", "dataIndex", "onClick", "skipAnimation", "isFaded", "isHighlighted"]; import * as React from 'react'; import PropTypes from 'prop-types'; import { styled } from '@mui/material/styles'; import { symbol as d3Symbol, symbolsFill as d3SymbolsFill } from '@mui/x-charts-vendor/d3-shape'; import { ANIMATION_DURATION_MS, ANIMATION_TIMING_FUNCTION } from "../internals/animation/animation.js"; import { getSymbol } from "../internals/getSymbol.js"; import { useInteractionItemProps } from "../hooks/useInteractionItemProps.js"; import { markElementClasses, useUtilityClasses } from "./markElementClasses.js"; import { jsx as _jsx } from "react/jsx-runtime"; const MarkElementPath = styled('path', { name: 'MuiMarkElement', slot: 'Root' })(({ ownerState, theme }) => ({ fill: (theme.vars || theme).palette.background.paper, stroke: ownerState.color, strokeWidth: 2, [`&.${markElementClasses.animate}`]: { transitionDuration: `${ANIMATION_DURATION_MS}ms`, transitionProperty: 'transform, transform-origin', transitionTimingFunction: ANIMATION_TIMING_FUNCTION } })); /** * Demos: * * - [Lines](https://mui.com/x/react-charts/lines/) * - [Line demonstration](https://mui.com/x/react-charts/line-demo/) * * API: * * - [MarkElement API](https://mui.com/x/api/charts/mark-element/) */ function MarkElement(props) { const { x, y, id, classes: innerClasses, color, shape, dataIndex, onClick, skipAnimation, isFaded = false, isHighlighted = false } = props, other = _objectWithoutPropertiesLoose(props, _excluded); const interactionProps = useInteractionItemProps({ type: 'line', seriesId: id, dataIndex }); const ownerState = { id, classes: innerClasses, isHighlighted, isFaded, color, skipAnimation }; const classes = useUtilityClasses(ownerState); return /*#__PURE__*/_jsx(MarkElementPath, _extends({}, other, { style: { transform: `translate(${x}px, ${y}px)`, transformOrigin: `${x}px ${y}px` }, ownerState: ownerState, className: classes.root, d: d3Symbol(d3SymbolsFill[getSymbol(shape)])(), onClick: onClick, cursor: onClick ? 'pointer' : 'unset' }, interactionProps)); } process.env.NODE_ENV !== "production" ? MarkElement.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, /** * If `true`, the marker is faded. * @default false */ isFaded: PropTypes.bool, /** * If `true`, the marker is highlighted. * @default false */ isHighlighted: PropTypes.bool, /** * The shape of the marker. */ shape: PropTypes.oneOf(['circle', 'cross', 'diamond', 'square', 'star', 'triangle', 'wye']).isRequired, /** * If `true`, animations are skipped. */ skipAnimation: PropTypes.bool } : void 0; export { MarkElement };