<template>
  <div>
    <charts
      style="margin-top: -40px"
      id="bizchart3"
      height="220px"
      width="440px"
      :option="option"
    />
  </div>
</template>

<script lang="js">
import charts from '../../../components/echarts/index.vue'
import * as echarts from 'echarts'
export default {
  components: { charts },
  data() {
    return {
      option : {
        tooltip: {
          trigger: 'axis',
          axisPointer: {
            type: 'shadow'
          }
        },
        legend: {},
        grid: {
          left: '3%',
          right: '4%',
          bottom: '3%',
          containLabel: true
        },
        xAxis: {
          type: 'value',
          boundaryGap: [0, 0.01],
          axisLabel: {
            show: false, // 不显示坐标轴上的文字
          },
          splitLine: {
            show: true,
            lineStyle: {
              color:'rgba(128,126,126,0.25)'
            },
          },
        },
        yAxis: {
          type: 'category',
          data: ['5.', '4.', '3.', '2.', '1.'],
          axisLine: {
            lineStyle: {
              color: "#a4a2a2",
            }
          },
          axisLabel: {
            textStyle: {
              fontSize: "20",
              color: function(params,index) {
                if (index > 1){
                  return '#FFA100'
                }else {
                  return '#FFFFFF'
                }
              },
              fontWeight:'bold'
            },
          },
        },
        label: {
          show: true,
          position: 'right',
        },
        textStyle: {
          color:'rgba(6,243,223,0.74)'
        },
        series: [
          {
            type: 'bar',
            data: [],
            itemStyle: {
              normal: {
                barBorderRadius: 20,
                color: new echarts.graphic.LinearGradient(1, 0, 0, 0, [{
                  offset: 1,
                  color: 'rgba(30,208,224,0.44)'
                }, {
                  offset: 0,
                  color: 'rgba(30,208,224,0.74)'
                }]),
              }
            }
          },
        ]
      }
    }
  },
  created() {
    this.getDebtList()
  },
  methods: {
    getDebtList() {
      this.$api.biz.getDebtList({ current: 1, size: 5}).then(res => {
        if (res.code === 200) {
          this.option.series[0].data = res.data.records.map((item) => {
            return item.viewNumber
          }).reverse()
        }
      })
    },
  }
}
</script>
