nodejs+echarts循环添加数据

本文介绍如何在Node.js环境中使用ECharts实现数据的动态加载。通过定义series数组,并利用循环将获取到的数据(data)推送到series中,再在option中调用series进行图表的展示。具体包括设置title、xAxis、yAxis、grid、legend等配置项。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

nodejs+echarts循环添加数据

定义series,将获取到的数据(data,假设为数组)通过循环push进入series中

	var series = [];
    for (let i=0;i<data[i].length;i++){
        series.push({
            name: 
            type: 'bar',
            data: data[i]
        });

option中直接调用series

option = {
        title: {
            text: '30天系统与各项目使用量统计'
        },
        xAxis: {
            type: 'category',
            data: date
        },
        yAxis: {
            type: 'value'
        },
        grid: {
            left: '3%',
            right: '4%',
            bottom: '3%',
            containLabel: true
        },
        legend: {
            data: legend
        },
        series: series
    }; 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值