A scatter chart that has two y-axes

by ucdl

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 {ScatterChart, Scatter, Cell, XAxis, YAxis, CartesianGrid, Tooltip, Legend, ReferenceArea} = Recharts;
const data01 = [
  {x: 100, y: 200, z: 200},
  {x: 120, y: 100, z: 260},
  {x: 170, y: 300, z: 400},
  {x: 140, y: 250, z: 280},
  {x: 150, y: 400, z: 500},
  {x: 110, y: 280, z: 200},
];
const data02 = [
  {x: 300, y: 300, z: 200},
  {x: 400, y: 500, z: 260},
  {x: 200, y: 700, z: 400},
  {x: 340, y: 350, z: 280},
  {x: 560, y: 500, z: 500},
  {x: 230, y: 780, z: 200},
  {x: 500, y: 400, z: 200},
  {x: 300, y: 500, z: 260},
  {x: 240, y: 300, z: 400},
  {x: 320, y: 550, z: 280},
  {x: 500, y: 400, z: 500},
  {x: 420, y: 280, z: 200},
];
const SimpleScatterChart = React.createClass({
	render () {
  	return (
    	<ScatterChart width={600} height={400} margin={{top: 20, right: 20, bottom: 20, left: 20}}>
      	<XAxis type="number" dataKey={'x'} name='stature' unit='cm'/>
      	<CartesianGrid />
      	<YAxis yAxisId="left" type="number" dataKey="y" name='weight' unit='kg' stroke="#8884d8" />
        <YAxis yAxisId="right" type="number" dataKey="y" name='weight' unit='kg' orientation="right" stroke="#82ca9d"/>
      	<Tooltip cursor={{strokeDasharray: '3 3'}}/>
        <Scatter yAxisId="left" name='A school' data={data01} fill='#8884d8'/>
        <Scatter yAxisId="right" name='A school' data={data02} fill='#82ca9d'/>
        <ReferenceArea x1={150} x2={180} y1={200} y2={300} stroke="red" strokeOpacity={0.3} />
      </ScatterChart>
    );
  }
})

ReactDOM.render(
  <SimpleScatterChart />,
  document.getElementById('container')
);