recharts 中的实时图表
RealTime chart in recharts
我有一个函数,其中数据以随机顺序出现,而不是一个块。这是我的数组:
this.props.data = [
{date: "07", visitors: 0},
{date: "08", visitors: 8},
{date: "09", visitors: 14},
{date: "10", visitors: 17},
{date: "11", visitors: 23},
{date: "12", visitors: 31},
{date: "13", visitors: 40}]
以及下面的图表代码
<LineChart data={this.props.data}>
<XAxis dataKey='date' label={{ value: "Horas", position: "insideBottom", dy: 10} } />
<YAxis label={{ value: 'Visitantes', angle: -90, position: 'insideLeft' }}/>
<Tooltip/>
<Line type="monotone" dataKey="visitors" stroke="#001529" activeDot={{r: 5}}/>
</LineChart>
问题是,图表上我的最高访问者价值低于第一个。 (提示:他比第一个大5倍)。
我的代码有问题吗?或者这是重新图表的问题?
适合我。 CodePen
const {LineChart, Line, XAxis, YAxis, Tooltip} = Recharts;
const mydata = [
{date: "07", visitors: 0},
{date: "08", visitors: 8},
{date: "09", visitors: 14},
{date: "10", visitors: 17},
{date: "11", visitors: 23},
{date: "12", visitors: 31},
{date: "13", visitors: 40}]
const SimpleLineChart = function() {
return (
<LineChart data={mydata} width={600} height={400} margin={{ top: 50, bottom: 50, left:50, right:50}}>
<XAxis dataKey='date'/>
<YAxis label='Visitantes'/>
<Line type="monotone" dataKey="visitors" stroke="#001529" activeDot={{r: 5}}/>
<Tooltip/>
</LineChart>
);
};
ReactDOM.render(
<SimpleLineChart />,
document.getElementById('container')
);
我有一个函数,其中数据以随机顺序出现,而不是一个块。这是我的数组:
this.props.data = [
{date: "07", visitors: 0},
{date: "08", visitors: 8},
{date: "09", visitors: 14},
{date: "10", visitors: 17},
{date: "11", visitors: 23},
{date: "12", visitors: 31},
{date: "13", visitors: 40}]
以及下面的图表代码
<LineChart data={this.props.data}>
<XAxis dataKey='date' label={{ value: "Horas", position: "insideBottom", dy: 10} } />
<YAxis label={{ value: 'Visitantes', angle: -90, position: 'insideLeft' }}/>
<Tooltip/>
<Line type="monotone" dataKey="visitors" stroke="#001529" activeDot={{r: 5}}/>
</LineChart>
问题是,图表上我的最高访问者价值低于第一个。 (提示:他比第一个大5倍)。
我的代码有问题吗?或者这是重新图表的问题?
适合我。 CodePen
const {LineChart, Line, XAxis, YAxis, Tooltip} = Recharts;
const mydata = [
{date: "07", visitors: 0},
{date: "08", visitors: 8},
{date: "09", visitors: 14},
{date: "10", visitors: 17},
{date: "11", visitors: 23},
{date: "12", visitors: 31},
{date: "13", visitors: 40}]
const SimpleLineChart = function() {
return (
<LineChart data={mydata} width={600} height={400} margin={{ top: 50, bottom: 50, left:50, right:50}}>
<XAxis dataKey='date'/>
<YAxis label='Visitantes'/>
<Line type="monotone" dataKey="visitors" stroke="#001529" activeDot={{r: 5}}/>
<Tooltip/>
</LineChart>
);
};
ReactDOM.render(
<SimpleLineChart />,
document.getElementById('container')
);