vue echarts 柱狀圖 變色 顯示


 
         
echartscustom2(id,title,xdata,ydata){
            var chartDom = document.getElementById(id);
            var myChart = echarts.init(chartDom);
            var option;
            option = {
                title:{
                    text:title,
                    left:"center"
                },
                tooltip: {
                    trigger: 'axis',
                    axisPointer: {
                        type: 'shadow'
                    },
                },
                xAxis: {
                    type: 'value',
                    axisLabel:{show:false}
                },
                yAxis: {
                    type: 'category',
                    data: ydata,
                    axisLabel:{show:false}
                },
                series: [{
                    data: xdata,
                    type: 'bar',
                    itemStyle: {
                        normal: {
                            color: function(params) {
                                var colorList = ['#5470c6', '#91cc75','#fac858','#ee6666','#73c0de','#3ba272','#fc8452','#9a60b4','#ea7ccc',];
                                var index=params.dataIndex%colorList.length;
                                return colorList[index]
                            }
                        }
                    },
                }],
            };
            option && myChart.setOption(option);

        },
 

xdata,ydata自造數組,color為滾動顯示顏色組的顏色


免責聲明!

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



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