@patternfly/react-charts
Version:
This library provides a set of React chart components for use with the PatternFly reference implementation.
31 lines • 2.29 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.ChartAxis = void 0;
const tslib_1 = require("tslib");
const React = tslib_1.__importStar(require("react"));
const hoist_non_react_statics_1 = tslib_1.__importDefault(require("hoist-non-react-statics"));
const victory_axis_1 = require("victory-axis");
const ChartContainer_1 = require("../ChartContainer");
const ChartUtils_1 = require("../ChartUtils");
const ChartLabel_1 = require("../ChartLabel");
const ChartAxis = (_a) => {
var { axisLabelComponent = React.createElement(ChartLabel_1.ChartLabel, null), containerComponent = React.createElement(ChartContainer_1.ChartContainer, null), name, showGrid = false, themeColor,
// eslint-disable-next-line @typescript-eslint/no-unused-vars
themeVariant, tickLabelComponent = React.createElement(ChartLabel_1.ChartLabel, null),
// destructure last
theme = (0, ChartUtils_1.getTheme)(themeColor) } = _a, rest = tslib_1.__rest(_a, ["axisLabelComponent", "containerComponent", "name", "showGrid", "themeColor", "themeVariant", "tickLabelComponent", "theme"]);
// Clone so users can override container props
const container = React.cloneElement(containerComponent, Object.assign({ theme }, containerComponent.props));
const getAxisLabelComponent = () => React.cloneElement(axisLabelComponent, Object.assign(Object.assign({}, (name && {
id: () => `${name}-${axisLabelComponent.type.displayName}`
})), axisLabelComponent.props));
const getTickLabelComponent = () => React.cloneElement(tickLabelComponent, Object.assign(Object.assign({}, (name && {
id: (props) => `${name}-${tickLabelComponent.type.displayName}-${props.index}`
})), tickLabelComponent.props));
// Note: containerComponent is required for theme
return (React.createElement(victory_axis_1.VictoryAxis, Object.assign({ axisLabelComponent: getAxisLabelComponent(), containerComponent: container, name: name, theme: showGrid ? (0, ChartUtils_1.getAxisTheme)(themeColor) : theme, tickLabelComponent: getTickLabelComponent() }, rest)));
};
exports.ChartAxis = ChartAxis;
exports.ChartAxis.displayName = 'ChartAxis';
(0, hoist_non_react_statics_1.default)(exports.ChartAxis, victory_axis_1.VictoryAxis);
//# sourceMappingURL=ChartAxis.js.map