Babel + JSX
const {PropTypes} = React;
const { Label, LineChart, Line, CartesianGrid, XAxis, YAxis, Tooltip, ReferenceArea, BarChart, Legend, Bar, ResponsiveContainer,Scatter,ScatterChart } = Recharts;
const data = [
{ name: 1, cost: 4.11, impression: 100 },
{ name: 2, cost: 2.39, impression: 120 },
{ name: 3, cost: 1.37, impression: 150 },
{ name: 4, cost: 1.16, impression: 180 },
{ name: 5, cost: 2.29, impression: 200 },
{ name: 6, cost: 3, impression: 499 },
{ name: 7, cost: 0.53, impression: 50 },
{ name: 8, cost: 2.52, impression: 100 },
{ name: 9, cost: 1.79, impression: 200 },
{ name: 10, cost: 2.94, impression: 222},
{ name: 11, cost: 4.3, impression: 210 },
{ name: 12, cost: 4.41, impression: 300 },
{ name: 13, cost: 2.1, impression: 50 },
{ name: 14, cost: 8, impression: 190 },
{ name: 15, cost: 0, impression: 300 },
{ name: 16, cost: 9, impression: 400 },
{ name: 17, cost: 3, impression: 200 },
{ name: 18, cost: 2, impression: 50 },
{ name: 19, cost: 3, impression: 100 },
{ name: 20, cost: 7, impression: 100 }
];
const chartData = [
{ value: 14, time: 1503617297689 },
{ value: 15, time: 1503616962277 },
{ value: 15, time: 1503616882654 },
{ value: 20, time: 1503613184594 },
{ value: 15, time: 1503611308914 },
]
const CustomTooltip = React.createClass({
propTypes: {
type: PropTypes.string,
payload: PropTypes.array,
label: PropTypes.string,
},
render() {
const { active } = this.props;
if (active) {
const { payload, label } = this.props;
return (
<div className="custom-tooltip">
<p className="label">{this.props.label}</p>
<p className="label">Pv: {this.props.payload[0].value}</p>
</div>
);
}
return null;
}
});
const getAxisYDomain = (from, to, ref, offset) => {
const refData = data.slice(from-1, to);
let [ bottom, top ] = [ refData[0][ref], refData[0][ref] ];
...