zoukankan      html  css  js  c++  java
  • 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为滚动显示颜色组的颜色

  • 相关阅读:
    从零打造树莓派智能助手(一)——让树莓派说话
    以np.concatenate为主题,谈谈numpy数组按维度合并的问题
    树莓派apt报错:E: 'Release' 这个值对 APT::Default-Release 是无效的,因为在源里找不到这样的发行
    我遇到的一些Git问题汇编
    在Mac平台用Sublime编辑器使用Git并连接github
    LeetCode108——Convert Sorted Array to Binary Search Tree
    LeetCode122——Best Time to Buy and Sell Stock II
    LeetCode686——Repeated String Match
    Python爬虫 — 百度翻译
    HTTP 协议
  • 原文地址:https://www.cnblogs.com/huanyun/p/14486840.html
Copyright © 2011-2022 走看看