鍍金池/ 問答/HTML/ echarts X Y軸互換后顯示問題

echarts X Y軸互換后顯示問題

想要實(shí)現(xiàn)

clipboard.png

現(xiàn)在成了

clipboard.png

該如何設(shè)置?
代碼是:

{

                    label:{
                        normal:{
                            show: true,
                            textStyle:{color:'#000',fontSize:"18"},
                            position: 'top'
                        },
                    },
                    tooltip: {
                        trigger: 'axis',
                        axisPointer: {
                            type: 'shadow'
                        }
                    },
                    grid: {
                        //  x:0,
                        //  y:40,
                        //  x2:10,
                        //  y2: 30,
                        //  containLabel: true
                    },
                    xAxis: {
                        type: 'value',
                        axisLabel: {
                            textStyle: {
                                color: '#000',
                                fontSize:'12'
                            },
                             formatter:function(val){
                                var newval =val/10000;
                                return newval+ "萬";
                             },
                        }
                    },
                    yAxis: {
                        type: 'category',
                        nameLocation:"left",
                        boundaryGap : false,
                        data:  ["Apple|iPhone 6","Apple|iPhone 6s","Apple|iPhone 7 Plus","Apple|iPhone 7",
                            "Apple|iPhone 6 Plus","Apple|iPhone 6s Plus","Apple|iPhone 5S","OPPO R9s","HUAWEI MHA-AL00","Vivo X7"
                        ].reverse(),
                        splitLine: {show: false},
                        axisLabel: {
                            textStyle: {
                                color: '#666',
                                fontSize:'12',
                                align:'left',
                                baseline:'middle'
                            }
                        }
                    },
                    series: [
                        {
                            name: '數(shù)量',
                            type: 'bar',
                            data:  [698963,
                                567124,
                                503456,
                                441705,
                                426022,
                                401662,
                                174016,
                                152560,
                                143810,
                                101218
                            ].reverse(),
                            barWidth: 6,
                            // barGap: 10,
                            // smooth: true,
                            label: {
                                normal: {
                                    show: true,
                                    position: 'right',
                                    offset: [5, -2],
                                    textStyle: {
                                        color: '#000',
                                        fontSize: 13
                                    }
                                }
                            },
                            itemStyle: {
                                normal: {
                                    color: new echarts.graphic.LinearGradient(
                                        0, 0, 1, 0,
                                        [
                                            {offset: 0, color: '#fff'},
                                            {offset: 0.5, color: '#5E9DD6'},
                                            {offset: 1, color: '#5E9DD6'}

                                        ]
                                    )
                                }
                            }
                        }]
                }
                
                
回答
編輯回答
玄鳥

文字水平對齊方式錯(cuò)了,應(yīng)該是右對齊,默認(rèn)是右對齊,把yAxis的boundaryGap : false,和 align:'left'去掉,你不要y軸刻度應(yīng)該設(shè)置yAxis axisTick:false, 要用左對齊的話在axisLabel加個(gè)margin

      yAxis: {
                        type: 'category',
                        nameLocation:"left",
                        axisTick:false,
                        //boundaryGap : false,
                        data:  ["Apple|iPhone 6","Apple|iPhone 6s","Apple|iPhone 7 Plus","Apple|iPhone 7",
                            "Apple|iPhone 6 Plus","Apple|iPhone 6s Plus","Apple|iPhone 5S","OPPO R9s","HUAWEI MHA-AL00","Vivo X7"
                        ].reverse(),
                        splitLine: {show: false},
                        axisLabel: {
                             margin:150,              
                            textStyle: {
                                color: '#666',
                                fontSize:'12',
                                baseline:'middle',
                                align:'left',               
                            }
                        }
                 
                    },
                    ser
2017年1月21日 02:20