Created
March 8, 2015 08:37
-
-
Save SPY/b40b127d855175d12182 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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