Props "connectNulls" of <Area />
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 {AreaChart, Area, XAxis, YAxis, CartesianGrid, Tooltip} = Recharts;
const data = [
{name: 'Page A', uv: 4000},
{name: 'Page B', uv: 3000},
{name: 'Page C', uv: 2000},
{name: 'Page D'},
{name: 'Page E', uv: 1890},
{name: 'Page F', uv: 2390},
{name: 'Page G', uv: 3490},
];
const SimpleAreaChart = React.createClass({
render () {
return (
<div>
<AreaChart width={600} height={200} data={data}
margin={{top: 10, right: 30, left: 0, bottom: 0}}>
<CartesianGrid strokeDasharray="3 3"/>
<XAxis dataKey="name"/>
<YAxis/>
<Tooltip/>
<Area type='monotone' dataKey='uv' stroke='#8884d8' fill='#8884d8' />
</AreaChart>
<AreaChart width={600} height={200} data={data}
margin={{top: 10, right: 30, left: 0, bottom: 0}}>
<CartesianGrid strokeDasharray="3 3"/>
<XAxis dataKey="name"/>
<YAxis/>
<Tooltip/>
<Area connectNulls={false} type='monotone' dataKey='uv' stroke='#8884d8' fill='#8884d8' />
</AreaChart>
</div>
);
}
})
ReactDOM.render(
<SimpleAreaChart />,
document.getElementById('container')
);