UNPKG

victory-area

Version:
81 lines (77 loc) 2.9 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.VictoryArea = void 0; var _react = _interopRequireDefault(require("react")); var _helperMethods = require("./helper-methods"); var _area = require("./area"); var _victoryCore = require("victory-core"); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } const fallbackProps = { width: 450, height: 300, padding: 50, interpolation: "linear" }; const options = { components: [{ name: "parent", index: "parent" }, { name: "data", index: "all" }, { name: "labels" }] }; // eslint-disable-next-line @typescript-eslint/no-empty-object-type /** * Draw area charts with React. VictoryArea is a composable component, so it doesn't include axes. * Add VictoryArea as a child of VictoryChart for a complete chart. */ class VictoryAreaBase extends _react.default.Component { static animationWhitelist = ["data", "domain", "height", "padding", "style", "width"]; static defaultProps = { containerComponent: /*#__PURE__*/_react.default.createElement(_victoryCore.VictoryContainer, null), dataComponent: /*#__PURE__*/_react.default.createElement(_area.Area, null), groupComponent: /*#__PURE__*/_react.default.createElement(_victoryCore.VictoryClipContainer, null), labelComponent: /*#__PURE__*/_react.default.createElement(_victoryCore.VictoryLabel, { renderInPortal: true }), samples: 50, sortKey: "x", sortOrder: "ascending", standalone: true, theme: _victoryCore.VictoryTheme.grayscale }; static displayName = "VictoryArea"; static role = "area"; static continuous = true; static defaultTransitions = _victoryCore.DefaultTransitions.continuousTransitions(); static defaultPolarTransitions = _victoryCore.DefaultTransitions.continuousPolarTransitions(); static getDomain = _victoryCore.Domain.getDomainWithZero; static getData = _victoryCore.Data.getData; static getBaseProps(props) { return (0, _helperMethods.getBaseProps)(props, fallbackProps); } static expectedComponents = ["dataComponent", "labelComponent", "groupComponent", "containerComponent"]; // Overridden in native versions shouldAnimate() { return !!this.props.animate; } render() { const { animationWhitelist, role } = VictoryAreaBase; const props = _victoryCore.Helpers.modifyProps(this.props, fallbackProps, role); if (this.shouldAnimate()) { return this.animateComponent(props, animationWhitelist); } const children = this.renderContinuousData(props); const component = props.standalone ? this.renderContainer(props.containerComponent, children) : children; return _victoryCore.UserProps.withSafeUserProps(component, props); } } const VictoryArea = exports.VictoryArea = (0, _victoryCore.addEvents)(VictoryAreaBase, options);