zoukankan      html  css  js  c++  java
  • echarts 实现柱状图渐变色

    <!DOCTYPE html>
    <html>
    <head>
    <meta charset="UTF-8">
    <title>2019</title>
    </style>
    </head>
    <body>
    <div id="main" style=" 100%;height: 600px;"></div>
    
    <script>
    
    var myChart = echarts.init(document.getElementById('main'));
    // 指定图表的配置项和数据
    var option = {
          xAxis: {
                    type: 'value',
                    splitLine:{
                show:false
            },
            axisTick: {
              show: false,  
            },
            axisLine:{
                show: false,
                lineStyle:{
                color:'transparent',
                }
            },
                    boundaryGap: [0, 0.01],
          },
          yAxis: {
              type: 'category',
              splitLine:{
                show:false
            },
            axisTick: {
              show: false,  
            },
              axisLabel:{
                  margin:5,
                  fontWeight: 'bold',
                  fontSize: 15,
              interval: 0,// 横轴信息全部显示
              rotate: 0 // 0度角倾斜显示
                    },
                    axisLine:{
                        show: false,
                lineStyle:{
                  color:'#FFFFFF',
                }
           },
                     data:['隔壁泰山','夜空中最亮的星夜空中最亮的星','串烧','说学逗唱','猴子说','创意走秀','兔耳朵舞','咖喱咖喱+我爱你']
          },
          series: [{
              name: '评论量(QTY)',
              type: 'bar',
              data: [55,77,88,99,11,22,33,44],
              barWidth:30,
              itemStyle: {
                normal: {
                                    barBorderRadius: [0, 5, 5, 0],
                                color: function (params){
                      var colorList = [
                          ['#14c3a2','#14c3a2','#22e8c3','#22e8c3'],
                          ['#07b8d9','#62c4db','#86e9fc','#22e8c3'],
                          ['#0679e3','#3d97ed','#90c1fc','#22e8c3'],
                          ['#07b8d9','#62c4db','#86e9fc','#22e8c3'],
                          ['#0679e3','#3d97ed','#90c1fc','#22e8c3'],
                          ['#07b8d9','#62c4db','#86e9fc','#22e8c3'],
                          ['#0679e3','#3d97ed','#90c1fc','#22e8c3'],
                          ['#07b8d9','#62c4db','#86e9fc','#22e8c3']
                      ];
                      var index = params.dataIndex;
                      if(params.dataIndex >= colorList.length) {
                          index = params.dataIndex - colorList.length;
                      }
                      return new echarts.graphic.LinearGradient(0,0,0,1, [
                          {offset: 0, color: colorList[index][0]},
                          {offset: 0.3, color: colorList[index][1]},
                          {offset: 0.6, color: colorList[index][2]},
                          {offset: 1, color: colorList[index][3]}
                      ]);
                  },
                                label: {
                                    show: true,
                                    position: 'insideLeft',
                                    distance: 20,
                                    textStyle: {
                                        color: '#ffffff',
                                        fontSize: '16'
                                    }
                                }
                },
                            
              },
          }]
        };
    console.log(option.yAxis.data);
    // 使用刚指定的配置项和数据显示图表。
    if (option && typeof option === "object") {
        myChart.setOption(option, true);
    }
    
    </script>
    </body>
    </html>
  • 相关阅读:
    win10 Administrator
    笔记
    一步一步建MVC
    安装mysql数据库
    为什么工具监测不出内存泄漏
    实现客户端服务端编译分离
    session
    JavasScript基数排序
    asp.net C# 导出EXCEL数据
    (Excel导出失败)检索COM类工厂中CLSID为{00024500-0000-0000-C000-000000000046}的组件时失
  • 原文地址:https://www.cnblogs.com/quietxin/p/10557601.html
Copyright © 2011-2022 走看看