1. 程式人生 > >echarts中Y軸名稱與值的設定

echarts中Y軸名稱與值的設定

 

option = {
    title : {
        text: '二手車銷量前十的品牌',
        /* subtext: '純屬虛構',*/
        x:'center'
    },
    color: ['#3398DB'],
    tooltip : {
        trigger: 'axis',
        axisPointer : {            // 座標軸指示器,座標軸觸發有效
            type : 'shadow'        // 預設為直線,可選為:'line' | 'shadow'
        }
    },
    grid: { //控制圖表上下左右距離
        left: '3%',
        right: '4%',
        bottom: '3%',
        containLabel: true
    },
    xAxis : [
        {
            type : 'category',
//boundaryGap: false, //間隔
            data: ['寶馬','賓士','奧迪','勞斯萊斯','賓利','別克','蘭博基尼','本田','豐田'],
            axisTick: {
                alignWithLabel: true
            }
        }
    ],
    yAxis : [
        {
            type : 'value',
            name : '銷售臺數',
            // min: 0,
            // max: 200,
            // interval: 20,
            axisLabel: {
                 formatter: '{value} 臺'
            }
        }
    ],
    series : [
        {
            name:'銷售',
            type:'bar',
            barWidth: '60%',
            data:[500, 420, 390, 350, 320, 250, 170,120,80]
        }
    ]
};