export const barOptions = {
  dataZoom: {
    show: true,
    realtime: true,
    height: 1,
    start: 0,
    end: 50,
    minValueSpan: 5,
    maxValueSpan: 5,
    bottom: 20,
    textStyle: {
      color: '#fff',
      fontSize: 14
    }
  },
  legend: {
    type: 'scroll'
  },
  tooltip: {
    trigger: 'axis',
    axisPointer: {
      type: 'shadow'
    },
    formatter(params) {
      let result = ''
      params.forEach((item) => {
        result += `${item.marker}` + item.axisValueLabel + ' : ' + '<span>' + item.value + '万元</span><br>'
      })
      return result
    }
  },
  grid: {
    left: '5%',
    right: '10%',
    bottom: '10%',
    containLabel: true
  },
  xAxis: {
    type: 'category',
    data: ['起落架', '轮胎', '灯', '油封'],
    axisLine: {
      lineStyle: {
        color: '#fff'
      }
    },
    axisLabel: {
      fontSize: 16,
      padding: [10, 0, 0, 0]
    }
  },
  yAxis: {
    type: 'value',
    axisLabel: { formatter: '{value} 万元', fontSize: 16 },
    axisLine: {
      lineStyle: {
        color: '#fff'
      }
    }
  },
  series: [
    {
      data: [400, 300, 200, 200],
      type: 'bar',
      color: 'rgb(230, 162, 60)',
      barMaxWidth: 30,
      showBackground: true,
      backgroundStyle: {
        color: 'rgba(180,180,180,0.2)'
      }
    }
  ]
}

export const lineOptions = {
  tooltip: {
    trigger: 'axis',
    axisPointer: {
      type: 'line',
      snap: true
    },
    legend: {},
    padding: [5, 10],
    formatter(params) {
      let result = ''
      params.forEach(function (item) {
        result += item.marker
        result += item.axisValue + '年' + ' : ' + '<span>' + item.data + '万元</span><br>'
      })
      return result
    }
  },
  grid: {
    left: '8%',
    right: '8%',
    top: '15%',
    bottom: '10%',
    containLabel: true
  },
  xAxis: {
    type: 'category',
    boundaryGap: false,
    data: ['2010', '2011', '2012', '2013', '2014'],
    axisLabel: { formatter: '{value} 年' },
    axisLine: {
      lineStyle: {
        color: '#fff'
      }
    },
    axisLabel: {
      fontSize: 16,
      padding: [10, 0, 0, 0]
    }
  },
  yAxis: {
    type: 'value',
    axisLabel: { formatter: '{value} 万元', fontSize: 16 },
    axisLine: {
      lineStyle: {
        color: '#fff'
      }
    }
  },
  series: [
    {
      data: [1000, 2200, 1050, 3600, 5600],
      type: 'line'
    }
  ]
}

export const setPieOptions = {
  title: {
    text: ''
  },
  // legend: {
  //   orient: 'vertical',
  //   left: 'right'
  // },
  tooltip: {
    trigger: 'item',
    formatter(params) {
      let result
      result = `${params.marker}${params.data.name}：     <span>${params.data.value}万元</span>`
      return result
    }
  },
  series: [
    {
      name: '单位名称',
      type: 'pie',
      radius: '60%',
      data: [
        {
          value: 120,
          name: '消耗品',
          label: {
            color: '#ccc',
            fontSize: 20
          }
        },
        {
          value: 360,
          name: '常用件',
          label: {
            color: '#ccc',
            fontSize: 20
          }
        },
        {
          value: 210,
          name: '其他',
          label: {
            color: '#ccc',
            fontSize: 20
          }
        },
        {
          value: 400,
          name: '维护品',
          label: {
            color: '#ccc',
            fontSize: 20
          }
        }
      ]
    }
  ]
}
