121 lines
4.1 KiB
JavaScript
121 lines
4.1 KiB
JavaScript
"use strict";
|
|
'use client';
|
|
|
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
exports.MarkElement = MarkElement;
|
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
|
|
var React = _interopRequireWildcard(require("react"));
|
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
var _styles = require("@mui/material/styles");
|
|
var _d3Shape = require("@mui/x-charts-vendor/d3-shape");
|
|
var _animation = require("../internals/animation/animation");
|
|
var _getSymbol = require("../internals/getSymbol");
|
|
var _useInteractionItemProps = require("../hooks/useInteractionItemProps");
|
|
var _markElementClasses = require("./markElementClasses");
|
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
const _excluded = ["x", "y", "id", "classes", "color", "shape", "dataIndex", "onClick", "skipAnimation", "isFaded", "isHighlighted"];
|
|
const MarkElementPath = (0, _styles.styled)('path', {
|
|
name: 'MuiMarkElement',
|
|
slot: 'Root'
|
|
})(({
|
|
ownerState,
|
|
theme
|
|
}) => ({
|
|
fill: (theme.vars || theme).palette.background.paper,
|
|
stroke: ownerState.color,
|
|
strokeWidth: 2,
|
|
[`&.${_markElementClasses.markElementClasses.animate}`]: {
|
|
transitionDuration: `${_animation.ANIMATION_DURATION_MS}ms`,
|
|
transitionProperty: 'transform, transform-origin',
|
|
transitionTimingFunction: _animation.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 = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
|
|
const interactionProps = (0, _useInteractionItemProps.useInteractionItemProps)({
|
|
type: 'line',
|
|
seriesId: id,
|
|
dataIndex
|
|
});
|
|
const ownerState = {
|
|
id,
|
|
classes: innerClasses,
|
|
isHighlighted,
|
|
isFaded,
|
|
color,
|
|
skipAnimation
|
|
};
|
|
const classes = (0, _markElementClasses.useUtilityClasses)(ownerState);
|
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(MarkElementPath, (0, _extends2.default)({}, other, {
|
|
style: {
|
|
transform: `translate(${x}px, ${y}px)`,
|
|
transformOrigin: `${x}px ${y}px`
|
|
},
|
|
ownerState: ownerState,
|
|
className: classes.root,
|
|
d: (0, _d3Shape.symbol)(_d3Shape.symbolsFill[(0, _getSymbol.getSymbol)(shape)])(),
|
|
onClick: onClick,
|
|
cursor: onClick ? 'pointer' : 'unset'
|
|
}, interactionProps, {
|
|
"data-highlighted": isHighlighted || undefined,
|
|
"data-faded": isFaded || undefined
|
|
}));
|
|
}
|
|
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.default.object,
|
|
/**
|
|
* The index to the element in the series' data array.
|
|
*/
|
|
dataIndex: _propTypes.default.number.isRequired,
|
|
id: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]).isRequired,
|
|
/**
|
|
* If `true`, the marker is faded.
|
|
* @default false
|
|
*/
|
|
isFaded: _propTypes.default.bool,
|
|
/**
|
|
* If `true`, the marker is highlighted.
|
|
* @default false
|
|
*/
|
|
isHighlighted: _propTypes.default.bool,
|
|
/**
|
|
* The shape of the marker.
|
|
*/
|
|
shape: _propTypes.default.oneOf(['circle', 'cross', 'diamond', 'square', 'star', 'triangle', 'wye']).isRequired,
|
|
/**
|
|
* If `true`, animations are skipped.
|
|
*/
|
|
skipAnimation: _propTypes.default.bool
|
|
} : void 0; |