BarLineOptions.js 2.38 KB
import * as echarts from 'echarts'
import utils from '../../../utils/util'
function getBarLineOptions(obj) {
  const { tooltipFormatter, seriesData } = obj
  var barLineOption = {
    // tooltip: {
    //   trigger: 'axis',
    //   borderWidth: 0,
    //   padding: 0,
    //   backgroundColor: '#051526',
    //   formatter: tooltipFormatter || ''
    // },
    xAxis: {
      data: []
    },
    barWidth: 14,
    yAxis: [
      {
        name: '单位:万次',
        splitLine: {
          show: false
        }
      },
      {
        name: '单位:家',
        type: 'value',
        min: 0,
        max: 100,
        interval: 20,
        // axisLabel: {
        //   formatter: '{value}%'
        // },
        splitLine: {
          lineStyle: {
            color: '#1d2a38'
          }
        }
      }
    ],
    grid: {
      left: '3%',
      right: '2%',
      top: '20%',
      bottom: '6%',
      containLabel: true
    },
    series: [
      {
        name: 'bar',
        type: 'bar',
        data: [],
        label: {
          show: true,
          position: 'top',
          color: '#fff',
          formatter: (params) => {
            return utils.numAddSymbol(params.value)
          }
        },
        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'
              }]
            )
          }
        }
      },
      {
        name: 'line',
        type: 'line',
        data: [],
        showSymbol: true, // 是否默认展示圆点
        symbol: 'circle', // 设定为实心点
        symbolSize: 6, // 设定实心点的大小
        itemStyle: {
          normal: {
            color: '#FFC200', // 改变折线点的颜色
            lineStyle: {
              color: '#FFC200' // 改变折线颜色
            }
          }
        }
      }
    ]
  }
  return barLineOption
}

export default getBarLineOptions