柱状图

时间:2022-07-25
本文章向大家介绍柱状图,主要内容包括其使用实例、应用技巧、基本知识点总结和需要注意事项,具有一定的参考价值,需要的朋友可以参考一下。

柱状图

let option = {
      color: ['#3398DB'],
      tooltip: {
        trigger: 'axis',
        axisPointer: {            // 坐标轴指示器,坐标轴触发有效
          type: 'none'        // 默认为直线,可选为:'line' | 'shadow'
        },
        formatter(p) {
          return p[0].data.showText
        }
      },
      grid: {
        left: '3%',
        right: '3%',
        bottom: '3%',
        containLabel: true
      },
      xAxis: [
        {
          type: 'category',
          data: ['该车型', '同价位车型'],
          axisTick: {
            alignWithLabel: true,
            lineStyle: {
              color: ['#ffffff']
            }
          },
          axisLine:{
            lineStyle:{
              color: '#eeeeee'
            }
          },
          axisLabel: {
            show: true,
            textStyle: {
              color: '#666666'
            }
          }
        }
      ],
      yAxis: [
        {
          max,
          // 值展示的类型,value直接展示value,category可以展示自定义
          type: 'value',
          show: false,
          interval,
          // 轴线上凸出来的点线
          axisTick: {
            show: false
          },
          // 坐标轴轴线相关设置
          axisLine: {             
             // 是否显示坐标轴轴线
            show: false,        
          },
          // 轴线文本
          axisLabel: {
            show: true,
            textStyle: {
              color: '#666666'
            }
          },
          /// 影响网格线
          splitLine: {
            show: true,
            lineStyle:{
              color: ['#eeeeee'],
              width: 1,
              type: 'solid'
            }
          }
        }
      ],
      series: [
        {
          type: 'bar',
          ccc: '60%',
          // 内部或者顶部可以展示文本
          label: {
            show: true,
            position: 'insideRight'
          },
          data: [{
            showText: '经销商报价:20-15万n经销商数量:8家',
            name: 'hello',
            value: 20
          }, 15, 30, 1, 5, 8, 12],

                show: true,     //开启显示
                position: 'top',    //在上方显示
                textStyle: {        //数值样式
                  color: '#333',
                  fontSize: 14,
                  fontWeight: 500
                }
              },
          /// 轴风格配置
          itemStyle: {
            normal: {
              color: new echarts.graphic.LinearGradient(0.5, 0, 0.5, 1, [{
                offset: 0,
                color: '#00B8B0'
              }, {
                offset: 1,
                color: '#0C98E7'
              }]),
              barBorderRadius: [3, 3, 0, 0]
            }
          }
        }
      ],

    };