react echarts 折线图 每隔三秒钟切换数据

本文介绍如何在React项目中使用ECharts库,实现折线图数据每隔三秒钟自动切换的效果。尽管实际数据量可能较大,但通过示例可以清晰地看到动态切换的过程。
摘要由CSDN通过智能技术生成

实现效果:
由于我的数据过多看出来不是很明显 本文数据较少 效果会好
在这里插入图片描述

// “一带一路”交通大数据指数
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()
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值