实现效果:
由于我的数据过多看出来不是很明显 本文数据较少 效果会好
// “一带一路”交通大数据指数
import React, {
Component } from 'react'
export default class Production extends Component {
constructor(props) {
super(props);
this.state = {
innerWidth: window.innerWidth,
innerHeight: window.innerHeight,
data: [
{
"name": "2017年7月", "maoyi": 112.11, "huoyun": 126.99, "sichou": 91.03 },
{
"name": "2017年8月", "maoyi": 108.63, "huoyun": 133.34, "sichou": 94.86 },
{
"name": "2017年9月", "maoyi": 113.1, "huoyun": 123.06, "sichou": 98.52 }],
tempData: [
{
"name": "2020年1月", "maoyi": 148.78, "huoyun": 142.63, "sichou": 108.53 },
{
"name": "2020年3月", "maoyi": 112.06, "huoyun": 125.78, "sichou": 97.02 },
{
"name": "2020年4月", "maoyi": 123.82, "huoyun": 136.96, "sichou": 102.62 }]}
this.onResize = this.onResize.bind(this);
this.initMap = this.initMap.bind(this);
this.chart;
this.timer = null;
}
componentDidMount() {
let that = this;
window.addEventListener("resize", this.onResize, false);
this.initMap()