ECharts series data 數組里面的元素,可以是對象


修改自:https://echarts.apache.org/examples/zh/editor.html?c=line-stack

注意:

  1. 對象里面value的值,用來顯示在y軸上。
option = {
    title: {
        text: '折線圖堆疊'
    },
    tooltip: {
        trigger: 'axis',
        formatter: p => {
            let returnStr = ''
            let len = p.length
            for (let i = 0; i< len; i++) {
                returnStr += 'name:' + String(p[i].name) + 
                ', value:' + String(p[i].value) + ' <br/>'
            }
            return returnStr
        }
    },
    legend: {
        data: ['郵件營銷', '聯盟廣告', '視頻廣告', '直接訪問', '搜索引擎']
    },
    grid: {
        left: '3%',
        right: '4%',
        bottom: '3%',
        containLabel: true
    },
    toolbox: {
        feature: {
            saveAsImage: {}
        }
    },
    xAxis: {
        type: 'category',
        boundaryGap: false,
        data: ['周一', '周二', '周三', '周四', '周五', '周六', '周日']
    },
    yAxis: {
        type: 'value'
    },
    series: [
        {
            name: '郵件營銷',
            type: 'line',
            stack: '總量',
            data: [
                {'name':'jeff','age':18,'value':18}, 
                {'name':'jeff','age':18,'value':118}
            ]
        },
        {
            name: '聯盟廣告',
            type: 'line',
            stack: '總量',
            data: [
                {'name':'jeff','age':18,'value':19}, 
                {'name':'jeff','age':18,'value':219}
            ]
        },
        {
            name: '視頻廣告',
            type: 'line',
            stack: '總量',
            data: [
                {'name':'jeff','age':18,'value':20}, 
                {'name':'jeff','age':18,'value':320}
            ]
        },
        {
            name: '直接訪問',
            type: 'line',
            stack: '總量',
            data: [
                {'name':'jeff','age':18,'value':21},
                {'name':'jeff','age':18,'value':421}
            ]
        }
    ]
};


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM