<template>
  <div>
  <div class="label">客户满意度统计</div>
  <div id="contentmentstatistics" class="d1"></div>
</div>
</template>

<script>
  export default {
    name: "contentmentstatistics",
    data() {
      return {
        xc: '',
        timer:''
      }
    },
    beforeDestroy() {
      //清除定时器
      clearInterval(this.timer);
    },
    methods: {
      setBar() {
        this.xc = this.$echarts.init(document.getElementById('contentmentstatistics'))
        var scale=this.$parent.$parent.$parent.scale
        var xAxisData = ['01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12', '', ''];
        var legendData = ['话务满意度', '维修满意度'];
        var serieData = [];
        var metaDate = [
          [120, 140, 100, 120, 300, 230, 130, 170, 140, 120, 300, 230],
          [200, 120, 300, 200, 170, 300, 200, 180, 200, 190, 300, 200],
        ]
        for (var v = 0; v < legendData.length; v++) {
          var serie = {
            name: legendData[v],
            type: 'line',
            symbol: "circle",
            symbolSize: 5 ,
            itemStyle: {
              normal: {
                lineStyle: {
                  width: 1,
                  shadowBlur: 10 ,
                  shadowOffsetY: 15 ,
                }
              }
            },
            data: metaDate[v]
          }
          serieData.push(serie)
        }
        var colors = ["#f7cb32", "#6fd9d0"];

        this.xc.setOption({
          title: {
            text: '',
            textAlign: 'left',
            textStyle: {color: "#FFFFFF", fontSize: 20 * scale, fontWeight: "normal"}
          },
          legend: {
            itemGap: 20,
            width: '90%',
            show: true,
            bottom:'1%',
            right:'5%',
            data: legendData,
            y: 'top',
            // padding: [0, 25*scale, 0, 0],
            itemWidth: 14 ,
            itemHeight: 6 ,
            textStyle: {width: '20%', color: "#15dce2", fontSize: 12 },
          },
          color: colors,
          grid: {left: '5%', top: "18%", bottom: "5%", right: "5%", containLabel: true},
          tooltip: {
            alwaysShowContent:true,
            backgroundColor:'rgba(2, 59, 63, 0.45)',
            // borderColor :'rgba(13, 109, 180)',
            borderWidth:0,
            hideDelay:100,
              padding:10*scale,
              textStyle:{
                  fontSize:16*scale
              },
            formatter: function (params) {
              if (params[0].data == '') {
                return ''
              }
              var result = ''
              params.forEach(function (item) {
                result += item.marker + " " + item.seriesName + " &nbsp;&nbsp;&nbsp; <sapn style='color:#e1e52a;font-weight: bolder'>" + item.value + "</sapn></br>";
              });
              return "<div style='text-align: center;height: 1px;font-weight: normal'>"+params[0].axisValue + '月</div><br/>' + result
            },
            trigger: 'axis',
            axisPointer: {type: 'line', lineStyle: {width: 0}},
            extraCssText: 'width: auto;height: auto;'
          },
          xAxis: [
            {
              name: '      月份\n(2018-2019)',
              type: 'category',
              nameTextStyle: {
                fontSize: 12 * scale,
                color: '#15dce2',
                padding: [38, 0, 0, -75 * scale],
              },
              axisLine: {show: true, lineStyle: {color: '#04669e', width: 1}},
              axisLabel: {interval: 0, textStyle: {color: '#ffffff', fontSize: 14 * scale}},
              axisTick: {show: false},
              data: xAxisData,
            },
          ],
          yAxis: [
            {
              name: '数量',
              nameTextStyle: {
                fontSize: 12 * scale,
                padding: [0, 35 * scale, 0, 0],
              },
              axisTick: {show: false},
              splitLine: {show: true, lineStyle: {type: 'dashed', color: '#004371'}},
              axisLabel: {textStyle: {color: '#15dce2', fontSize: 14 * scale}},
              axisLine: {show: false, lineStyle: {color: '#15dce2', fontSize: 14 * scale}},
            },
          ],
          series: serieData
        })
        let idx = -1;
        var dataLen=metaDate[0].length
        var oroptionmapjsonr_charts1=this.xc
        this.timer= setInterval(()=>{
          idx = (idx+ 1) % dataLen;
          oroptionmapjsonr_charts1.dispatchAction({
            type: 'showTip',
            seriesIndex: 1,
            dataIndex: idx
          });

        }, 3000)
      },
    },
    ready() {
      this.setBar()
    }
  }
</script>

<style scoped>
  .label {
    margin-left: 6%;
    font-size: 0.85em;
    color: #fff;
    height: 8%;
  }

  #contentmentstatistics {
    height: 91%;
    width: 99%;
    padding: 1% 2% 3% 2%;
  }
</style>
