TODO: last

This commit is contained in:
eson 2020-11-30 19:00:35 +08:00
parent cbdc812fe4
commit 6ba27a2008

View File

@ -6,7 +6,12 @@ import echarts from 'echarts';
class Trend extends React.Component {
getOption(tsdata: any, data: any) :any {
state = {
tdata: null,
sdata: null
}
getOption(tdata: any, sdata: any) :any {
var option = {
tooltip: {
trigger: 'axis',
@ -31,7 +36,7 @@ class Trend extends React.Component {
type: 'time',
boundaryGap: false,
interval: 20,
data: tsdata
data: tdata
},
yAxis: {
type: 'value',
@ -73,7 +78,7 @@ class Trend extends React.Component {
color: 'rgb(255, 70, 131)'
}])
},
data: data
data: sdata
}
]
};
@ -83,25 +88,13 @@ class Trend extends React.Component {
render() {
var base = +new Date(1998, 9, 3);
var oneDay = 60 * 1000;
var date = [];
var data = [Math.random() * 1000];
for (var i = 1; i < 1000; i++) {
var now = new Date(base += oneDay);
date.push(now );
data.push(Math.round((Math.random() - 0.5) * 20 + data[i - 1]));
}
const { tdata, sdata } = this.state;
return (
<ReactEcharts
notMerge={true}
option={this.getOption(date, data)}
option={this.getOption(tdata, sdata)}
style={{ height: '600px', width: '100%' }}
className='react_for_echarts' />
)