echart 使用小結

1、legend

一、隱藏特定類目

有時候但願默認選中特定類目,取消選中特定類目,那麼能夠這樣作:
legend: {
    data: ['2011年', '2012年'],
    selected: {
        '2011年':false
    }
}

只須要將不想顯示的項設置爲false便可。html

二、設置圖標形狀

legend: {
    icon: 'roundRect' // circle, 
}

詳情:https://www.echartsjs.com/opt...網絡

2、series

一、曲線平滑:

series: [
    { smooth: true;}
]

二、去掉折線中的小圓點:

series: [
    {symbol: 'none';}
]

彙總

option = {
    title: {
        text: '世界人口總量',
        subtext: '數據來自網絡'
    },
    tooltip: {
        trigger: 'axis',
        axisPointer: {
            type: 'shadow'
        }
    },
    legend: {
        data: ['2011年', '2012年'],
        selected: {
            '2011年':false
        }
    },
    grid: {
        left: '3%',
        right: '4%',
        bottom: '3%',
        containLabel: true
    },
    xAxis: {
        type: 'value',
        boundaryGap: [0, 0.01]
    },
    yAxis: {
        type: 'category',
        data: ['巴西','印尼','美國','印度','中國','世界人口(萬)']
    },
    series: [
        {
            name: '2011年',
            type: 'bar',
            smooth: true;
            symbol: 'none';
            data: [18203, 23489, 29034, 104970, 131744, 630230]
        },
        {
            name: '2012年',
            type: 'bar',
            symbol: 'none';
            smooth: true;
            data: [19325, 23438, 31000, 121594, 134141, 681807]
        }
    ]
};

詳見demo(需自行添加設置):https://echarts.baidu.com/exa...

持續更新中echarts

相關文章
相關標籤/搜索