@mui/x-charts
Version:
The community edition of the charts components (MUI X).
111 lines (110 loc) • 4.94 kB
JavaScript
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.PieArc = PieArc;
exports.getPieArcUtilityClass = getPieArcUtilityClass;
exports.pieArcClasses = void 0;
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 _d3Shape = require("d3-shape");
var _web = require("@react-spring/web");
var _composeClasses = _interopRequireDefault(require("@mui/utils/composeClasses"));
var _generateUtilityClass = _interopRequireDefault(require("@mui/utils/generateUtilityClass"));
var _styles = require("@mui/material/styles");
var _generateUtilityClasses = _interopRequireDefault(require("@mui/utils/generateUtilityClasses"));
var _useInteractionItemProps = require("../hooks/useInteractionItemProps");
var _jsxRuntime = require("react/jsx-runtime");
const _excluded = ["id", "dataIndex", "classes", "color", "highlightScope", "onClick", "isFaded", "isHighlighted", "startAngle", "endAngle", "paddingAngle", "innerRadius", "outerRadius", "cornerRadius"];
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
function getPieArcUtilityClass(slot) {
return (0, _generateUtilityClass.default)('MuiPieArc', slot);
}
const pieArcClasses = exports.pieArcClasses = (0, _generateUtilityClasses.default)('MuiPieArc', ['root', 'highlighted', 'faded']);
const useUtilityClasses = ownerState => {
const {
classes,
id,
isFaded,
isHighlighted
} = ownerState;
const slots = {
root: ['root', `series-${id}`, isHighlighted && 'highlighted', isFaded && 'faded']
};
return (0, _composeClasses.default)(slots, getPieArcUtilityClass, classes);
};
const PieArcRoot = (0, _styles.styled)(_web.animated.path, {
name: 'MuiPieArc',
slot: 'Root',
overridesResolver: (_, styles) => styles.arc
})(({
theme
}) => ({
stroke: (theme.vars || theme).palette.background.paper,
strokeWidth: 1,
strokeLinejoin: 'round'
}));
function PieArc(props) {
const {
id,
dataIndex,
classes: innerClasses,
color,
highlightScope,
onClick,
isFaded,
isHighlighted,
startAngle,
endAngle,
paddingAngle,
innerRadius,
outerRadius,
cornerRadius
} = props,
other = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
const ownerState = {
id,
dataIndex,
classes: innerClasses,
color,
isFaded,
isHighlighted
};
const classes = useUtilityClasses(ownerState);
const getInteractionItemProps = (0, _useInteractionItemProps.useInteractionItemProps)(highlightScope);
return /*#__PURE__*/(0, _jsxRuntime.jsx)(PieArcRoot, (0, _extends2.default)({
d: (0, _web.to)([startAngle, endAngle, paddingAngle, innerRadius, outerRadius, cornerRadius], (sA, eA, pA, iR, oR, cR) => (0, _d3Shape.arc)().cornerRadius(cR)({
padAngle: pA,
startAngle: sA,
endAngle: eA,
innerRadius: iR,
outerRadius: oR
})),
onClick: onClick,
cursor: onClick ? 'pointer' : 'unset',
ownerState: ownerState,
className: classes.root
}, other, getInteractionItemProps({
type: 'pie',
seriesId: id,
dataIndex
})));
}
process.env.NODE_ENV !== "production" ? PieArc.propTypes = {
// ----------------------------- Warning --------------------------------
// | These PropTypes are generated from the TypeScript type definitions |
// | To update them edit the TypeScript types and run "yarn proptypes" |
// ----------------------------------------------------------------------
classes: _propTypes.default.object,
dataIndex: _propTypes.default.number.isRequired,
highlightScope: _propTypes.default.shape({
faded: _propTypes.default.oneOf(['global', 'none', 'series']),
highlighted: _propTypes.default.oneOf(['item', 'none', 'series'])
}),
isFaded: _propTypes.default.bool.isRequired,
isHighlighted: _propTypes.default.bool.isRequired
} : void 0;
;