@patternfly/react-charts
Version:
This library provides a set of React chart components for use with the PatternFly reference implementation.
27 lines • 1.95 kB
JavaScript
import { __rest } from "tslib";
import * as React from 'react';
import hoistNonReactStatics from 'hoist-non-react-statics';
import { VictoryAxis } from 'victory-axis';
import { ChartContainer } from '../ChartContainer';
import { getAxisTheme, getTheme } from '../ChartUtils';
import { ChartLabel } from '../ChartLabel';
export const ChartAxis = (_a) => {
var { axisLabelComponent = React.createElement(ChartLabel, null), containerComponent = React.createElement(ChartContainer, null), name, showGrid = false, themeColor,
// eslint-disable-next-line @typescript-eslint/no-unused-vars
themeVariant, tickLabelComponent = React.createElement(ChartLabel, null),
// destructure last
theme = getTheme(themeColor) } = _a, rest = __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(VictoryAxis, Object.assign({ axisLabelComponent: getAxisLabelComponent(), containerComponent: container, name: name, theme: showGrid ? getAxisTheme(themeColor) : theme, tickLabelComponent: getTickLabelComponent() }, rest)));
};
ChartAxis.displayName = 'ChartAxis';
hoistNonReactStatics(ChartAxis, VictoryAxis);
//# sourceMappingURL=ChartAxis.js.map