Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PF4 Charts: Add ChartAxis for custom tic labels #1309

Merged
merged 1 commit into from
Feb 25, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import * as victory from 'victory';

export interface ChartAxisProps extends victory.VictoryAxisProps {}

declare const ChartAxis: React.ComponentClass<ChartAxisProps>;

export default ChartAxis;
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import React from 'react';
import PropTypes from 'prop-types';
import hoistNonReactStatics from 'hoist-non-react-statics';
import { VictoryAxis } from 'victory';
import { default as ChartTheme } from '../ChartTheme/ChartTheme';

export const propTypes = {
/**
* See TypeScript API docs: https://formidable.com/open-source/victory/docs/victory-chart/
*/
'': PropTypes.any
};

const ChartAxis = (props) => (
<VictoryAxis theme={ChartTheme.default} {...props}/>
);
hoistNonReactStatics(ChartAxis, VictoryAxis);
ChartAxis.propTypes = propTypes;

export default ChartAxis;
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import React from 'react';
import { shallow } from 'enzyme';
import Chart from '../Chart/Chart';
import ChartAxis from './ChartAxis';
import ChartGroup from '../ChartGroup/ChartGroup';
import ChartLine from '../ChartLine/ChartLine';

Object.values([true, false]).forEach(isRead => {
test(`ChartAxis`, () => {
const view = shallow(<ChartAxis/>);
expect(view).toMatchSnapshot();
});
});

test('renders component data', () => {
const view = shallow(
<Chart
domainPadding={{ x: [30, 25] }}
height={200}
width={300}
>
<ChartGroup>
<ChartLine data={[{ x: 1, y: 1 }, { x: 2, y: 2 }, { x: 3, y: 5 }, { x: 4, y: 3 }]} />
<ChartLine data={[{ x: 1, y: 2 }, { x: 2, y: 1 }, { x: 3, y: 7 }, { x: 4, y: 4 }]} />
<ChartLine data={[{ x: 1, y: 3 }, { x: 2, y: 4 }, { x: 3, y: 9 }, { x: 4, y: 5 }]} />
<ChartLine data={[{ x: 1, y: 3 }, { x: 2, y: 3 }, { x: 3, y: 8 }, { x: 4, y: 7 }]} />
</ChartGroup>
<ChartAxis tickValues={[2, 3, 4]} />
<ChartAxis dependentAxis tickValues={[2, 5, 8]} />
</Chart>
);
expect(view).toMatchSnapshot();
});

Loading