Skip to content

Instantly share code, notes, and snippets.

@SPY
Created March 8, 2015 08:37
Show Gist options
  • Save SPY/b40b127d855175d12182 to your computer and use it in GitHub Desktop.
Save SPY/b40b127d855175d12182 to your computer and use it in GitHub Desktop.
var React = require('react');
var {Chart, Line, Axis, Layout} = require('react-chart');
var LineChart = React.createClass({
propTypes: {
data: React.propTypes.arrayOf(React.propTypes.shape({
x: React.propTypes.number.isRequired,
y: React.propTypes.number.isRequired
})).isRequired,
color: React.propTypes.string.isRequired
},
render() {
return (
<Chart width={400} height={300}>
<Layout.Flex direction="row">
<Layout.Flex.FlexItem grow={1}>
<Grid verticalLines={true}>
<Line points={this.props.data} color={this.props.color} />
</Grid>
</Layout.Flex.FlexItem>
<Layout.Flex.FlexItem grow={0} basis={30}>
<Axis
direction="vertical"
min={Axis.getMinWithGap(this.props.data, 'x', 0.05)}
max={Axis.getMaxWithGap(this.props.data, 'x', 0.05)}
steps={10}
/>
</Layout.Flex.FlexItem>
</Layout.Flex>
</Chart>
)
}
});
module.exports = LineChart;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment