BarChartOptions.js 1.66 KB
/*
 * @Description: 
 * @Author: huyue
 * @Date: 2023-07-07 14:04:52
 * @LastEditors: huyue
 * @LastEditTime: 2023-07-11 16:04:06
 */
import * as echarts from 'echarts'
function getBarOptions(obj) {
  const { tooltipFormatter } = obj
  var barLineOption = {
    // tooltip: {
    //   trigger: 'axis',
    //   borderWidth: 0,
    //   padding: 0,
    //   formatter: tooltipFormatter || '',
    //   confine: true
    // },
    barWidth: 14,
    xAxis: {
      data: []
    },
    yAxis: {
      name: '',
      type: 'value',
      interval: 250,
      splitLine: {
        lineStyle: {
          color: '#1d2a38'
        }
      }
    },
    grid: {
      left: '3%',
      right: '4%',
      top: '20%',
      bottom: '6%',
      containLabel: true
    },
    series: [
      {
        name: 'bar',
        type: 'bar',
        data: [],
        label: {
          show: true,
          position: 'top',
          color: '#fff'
        },
        itemStyle: {
          barBorderRadius: [2, 2, 0, 0], // 柱体圆角
          color: function(params) {
            return new echarts.graphic.LinearGradient(
              0, 0, 0, 1, [{ // 代表渐变色从正上方开始
                offset: 0, // offset范围是0~1,用于表示位置,0是指0%处的颜色
                color: '#00C8FF'
              }, // 柱图渐变色
            //   {
            //     offset: 0.5, // 指100%处的颜色
            //     color: '#223FA9'
            //   },
              {
                offset: 1, // 指100%处的颜色
                color: '#0069F2'
              }]
            )
          }
        }
      },
    ]
  }
  return barLineOption
}

export default getBarOptions