props "connectNulls" of <Line />
HTML
<script src="https://cdnjs.cloudflare.com/ajax/libs/babel-core/5.8.24/browser.js"></script>
<script src="https://npmcdn.com/[email protected]/dist/react-with-addons.min.js"></script>
<script src="https://npmcdn.com/[email protected]/dist/react-dom.min.js"></script>
<script src="https://npmcdn.com/prop-types/prop-types.min.js"></script>
<script src="https://npmcdn.com/recharts/umd/Recharts.min.js"></script>
<div id="container">
<!-- This element's contents will be replaced with your component. -->
</div>
CSS
body {
margin: 0;
}
#container {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
padding: 10px;
width: 800px;
height: 800px;
background-color: #fff;
}
Babel + JSX
const {LineChart, Line, XAxis, YAxis, CartesianGrid, Tooltip} = Recharts;
const data = [
{name: 1, uv: 2},
{name: 2, uv: 5},
{name: 3, uv: 10},
];
const points = [
{x: 1, y: 4, value: 3},
{x: 2, y: 5, value: 6},
{x: 3, y: 6, value: 9},
]
const SimpleAreaChart = React.createClass({
render () {
return (
<div>
<LineChart width={600} height={200} data={data}
margin={{top: 10, right: 30, left: 0, bottom: 0}}>
<CartesianGrid strokeDasharray="3 3"/>
<XAxis dataKey="name"/>
<YAxis/>
<Tooltip/>
<Line points={points} type='monotone' dataKey='uv' fill='#8884d8' />
</LineChart>
</div>
);
}
})
ReactDOM.render(
<SimpleAreaChart />,
document.getElementById('container')
);