<template>
  <div class="special-monitoring">
    <div class="chart" ref="chart" />
    <Select class="custom-select" v-model="disease">
      <Option v-for="item in options" :key="item" :value="item">{{item}}</Option>
    </Select>
  </div>
</template>

<script>
export default {
  name: 'SpecialMonitoring',
  data() {
    return {
      disease: '出血性腐烂病',
      options: ['出血性腐烂病'],
      chart: null,
      option: {
        tooltip: {
          trigger: 'axis',
        },
        legend: {
          width: '100%',
          textStyle: {
            color: '#ccc',
            fontSize: this.fontSize,
          },
          data: ['阳性监测点数量', '阳性样品数量'],
        },
        grid: {
          top: '15%',
          left: '5%',
          right: '5%',
          bottom: '10%',
          width: 'auto',
          height: '70%',
          containLabel: true,
        },
        xAxis: {
          type: 'category',
          axisLine: {
            lineStyle: {
              color: 'rgba(91,213,255,0.1)'
            }
          },
          axisLabel: {
            textStyle: {
              color: '#ccc',
            },
            fontSize: this.fontSize,
          },
          data: ['2012', '2013', '2014', '2015', '2016', '2017', '2018', '2019', '2020'],
        },
        yAxis: [
          {
            type: 'value',
            // name: '单位：个',
            max: 400,
            min: 0,
            interval: 100,
            axisLine: {
              show: false,
            },
            axisLabel: {
              textStyle: {
                color: 'gold',
              },
              fontSize: this.fontSize,
            },
            nameTextStyle: {
              color: '#ccc',
              fontSize: this.fontSize,
            },
            splitLine: {
              lineStyle: {
                color: 'rgba(91,213,255,0.1)'
              }
            },
          },
          {
            type: 'value',
            // name: '单位：个',
            max: 600,
            min: 0,
            interval: 150,
            axisLine: {
              show: false,
            },
            axisLabel: {
              textStyle: {
                color: 'red',
              },
              fontSize: this.fontSize,
            },
            nameTextStyle: {
              color: '#ccc',
              fontSize: this.fontSize,
            },
            splitLine: {
              lineStyle: {
                color: 'rgba(91,213,255,0.1)'
              }
            },
          }
        ],
        series: [
          {name: '阳性监测点数量', itemStyle: {color: 'gold'}, type: 'line', data: [150, 140, 100, 180, 150, 200, 210, 130]},
          {name: '阳性样品数量', itemStyle: {color: 'red'}, yAxisIndex: 1, type: 'line', data: [280, 310, 270, 280, 310, 350, 350, 380, 350]},
        ],
        dataZoom: [{
          start: 10,
          end: 80,
          backgroundColor: '#105179',
          fillerColor: '#46b9ef',
          borderColor: 'transparent',
          bottom: '2%',
          height: 10,
          borderRadius: 10,
          handleSize: '200%',
          handleStyle: {
            color: '#fff',
          },
          textStyle: {
            color: '#fff',
          },
        }],
      }
    }
  },
  mounted() {
    // this.$nextTick(this.init)
    setTimeout(this.init, 0)
  },
  computed: {
    fontSize() {
      return Math.floor(screen.height * 1.48 / 100)
    },
  },
  methods: {
    init() {
      this.chart = this.$echarts.init(this.$refs.chart)
      this.chart.setOption(this.option)
    }
  }
}
</script>

<style lang="stylus" scoped>
.special-monitoring
  width 100%
  height 100%
  >.chart
    width 100%
    height 95%
</style>
