options.js 6.91 KB
/*
 * @Author: 前端 qianduan01@didihu.com.cn
 * @Date: 2022-10-25 10:46:24
 * @LastEditors: 前端 qianduan01@didihu.com.cn
 * @LastEditTime: 2022-10-26 13:48:15
 * @FilePath: \dj-data-view\src\components\barOptions.js
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
function getBarOptions(obj) {
  var options = {
    xAxis: {
      type: 'category',
      axisLabel: {
        color: '#fff',
        fontSize: '0.8em',
        rotate: obj.rotate
      },
      splitLine: {
        show: false
      },
      axisTick: {
        show: false
      },
      axisLine: {
        show: false
      },
      data: ['广汽本田', '广汽丰田', '一汽奥迪', '宝马', '奔驰', '其他']
    },
    grid: {
      left: '8%',
      right: '6%',
      top: '3%',
      bottom: obj.rotate ? '4%' : '12%',
      containLabel: true
    },
    yAxis: {
      nameGap: 30,
      type: 'value',
      splitLine: {
        show: false
      },
      axisLabel: {
        show: false
      },
      splitLine: {
        lineStyle: {
          color: '#2F314F'
        }
      },
      splitNumber: 4
    },
    series: [
      {
        type: 'bar',
        symbol: 'circle',
        backgroundStyle: {
          color: '#6578FF'
        },
        barWidth: '35%',
        data: [120, 200, 150, 80, 70, 110, 130]
      }
    ]
  }
  return options
}
function getBarReverseOptions(obj) {
  var options = {
    tooltip: {
      trigger: 'axis',
      showContent: false,
      axisPointer: {
        type: 'shadow',
        shadowStyle: {
          color: 'rgba(210, 210, 210, 0.2)'
        }
      },
      borderWidth: 0,
      backgroundColor: 'rgba(68,68,68,0.80)',
      confine: true,
      textStyle: {
        color: '#ffffff',
        fontSize: 8
      }
    },
    yAxis: {
      type: 'category',
      axisLabel: {
        color: '#ccc',
        fontSize: '0.8em'
      },
      splitLine: {
        show: false
      },
      axisTick: {
        show: false
      },
      axisLine: {
        show: false
      },
      data: ['一般发展', '一般价值', '一般挽留', '重要挽留', '重要价值', '重要发展', '重要保持', '一般保持']
    },
    grid: {
      left: '15%',
      right: '0%',
      top: '0%',
      bottom: '0%',
      containLabel: true
    },
    xAxis: {
      nameGap: 30,
      type: 'value',
      splitLine: {
        show: false
      },
      axisLabel: {
        show: false
      },
      splitNumber: 4
    },
    series: [
      {
        type: 'bar',
        symbol: 'circle',
        backgroundStyle: {
          color: '#6578FF'
        },
        data: [30, 120, 200, 150, 80, 70, 110, 130]
      }
    ]
  }
  return options
}
function getLineOptions() {
  var options = {
    tooltip: {
      trigger: 'axis',
      axisPointer: {
        lineStyle: {
          type: 'solid'
        }
      },
      padding: 5,
      borderWidth: 0,
      backgroundColor: 'rgba(35, 45, 152, 1)',
      borderRadius: 4,
      textStyle: {
        color: 'rgba(255,255,255,1)',
        fontSize: 14
      },
      formatter: function (item) {
        return `用户数:${item[0].value}`
      }
    },
    xAxis: {
      type: 'category',
      axisLabel: {
        color: '#fff',
        fontSize: '0.8em'
      },
      splitLine: {
        show: false
      },
      axisTick: {
        show: false
      },
      axisLine: {
        show: false
      },
      data: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月']
    },
    grid: {
      left: '3%',
      right: '6%',
      top: '14%',
      bottom: '3%',
      containLabel: true
    },
    yAxis: {
      nameGap: 30,
      type: 'value',
      splitLine: {
        lineStyle: {
          color: '#2F314F'
        }
      },
      axisLabel: {
        color: '#fff',
        fontSize: '0.8em'
      },
      splitNumber: 4
    },
    series: [
      {
        type: 'line',
        symbol: 'circle',
        itemStyle: {
          color: '#F5AA01'
        },
        // 平滑曲线
        smooth: true,
        showSymbol: false,
        // 折线背景色
        areaStyle: {
          color: {
            type: 'linear',
            x: 0,
            y: 0,
            x2: 0,
            y2: 1,
            colorStops: [
              {
                offset: 0,
                color: 'rgba(254, 84, 0, 0.3)'
              },
              {
                offset: 1,
                color: 'rgba(254, 84, 0, 0.01)'
              }
            ]
          }
        },
        data: [666, 200, 150, 80, 70, 110, 130, 554, 3, 44, 33, 5, 666]
      }
    ]
  }
  return options
}
function lineAndBarOptions() {
  var options = {
    tooltip: {
      trigger: 'axis',
      axisPointer: {
        lineStyle: {
          type: 'solid'
        }
      },
      padding: 5,
      borderWidth: 0,
      backgroundColor: 'rgba(35, 45, 152, 1)',
      borderRadius: 4,
      textStyle: {
        color: 'rgba(255,255,255,1)',
        fontSize: 14
      },
      formatter: function (item) {
        return `门店数:${item[0].value}<br>新增数:${item[1].value}`
      }
    },
    xAxis: {
      type: 'category',
      axisLabel: {
        color: '#fff',
        fontSize: '0.8em'
      },
      splitLine: {
        show: false
      },
      axisTick: {
        show: false
      },
      axisLine: {
        show: false
      },
      data: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月']
    },
    grid: {
      left: '3%',
      right: '6%',
      top: '6%',
      bottom: '0%',
      containLabel: true
    },
    yAxis: {
      nameGap: 30,
      type: 'value',
      splitLine: {
        lineStyle: {
          color: '#2F314F'
        }
      },
      axisLabel: {
        color: '#fff',
        fontSize: '0.8em'
      },
      splitNumber: 4
    },
    series: [
      {
        type: 'bar',
        symbol: 'circle',
        backgroundStyle: {
          color: '#6578FF'
        },
        barWidth: '30%',
        data: [120, 200, 150, 80, 70, 110, 130, 5, 6, 98, 4, 3, 5, 555]
      },
      {
        type: 'line',
        symbol: 'circle',
        itemStyle: {
          color: '#F5AA01'
        },
        // 平滑曲线
        smooth: true,
        showSymbol: false,
        // 折线背景色
        areaStyle: {
          color: {
            type: 'linear',
            x: 0,
            y: 0,
            x2: 0,
            y2: 1,
            colorStops: [
              {
                offset: 0,
                color: 'rgba(254, 84, 0, 0.3)'
              },
              {
                offset: 1,
                color: 'rgba(254, 84, 0, 0.01)'
              }
            ]
          }
        },
        data: [666, 200, 150, 80, 70, 110, 130, 554, 3, 44, 33, 5, 666]
      }
    ]
  }
  return options
}
export { getBarReverseOptions, getBarOptions, lineAndBarOptions, getLineOptions }