<template>
  <div class="scoped-wrap">
    <div class="sw-name">
      近30天注册数据统计
      <dv-decoration-3 style="width:200px;height:20px;" />
    </div>
    <dv-charts :option="option" />
  </div>
</template>

<script>
export default {
  name: 'TopMiddleCmp',
  props: {
    curObj: Object,
  },
  data () {
    return {
      option: {}
    }
  },
  watch: {
    curObj () {
      let signupArr = this.curObj.day_30_signup || []
      signupArr = signupArr.reverse()
      let xAxisData = []
      let seriesData = []
      signupArr.forEach((item, index) => {
        xAxisData.push(item.format_time)
        seriesData.push(item.signup)
      })
      let option = {
        legend: {
          data: ['近30天注册'],
          textStyle: {
            fill: '#fff'
          }
        },
        grid: {
          // left: '3%',
          // right: '4%',
          // bottom: '3%',
          // containLabel: true
        },
        xAxis: {
          data: xAxisData,
          boundaryGap: false,
          axisLine: {
            style: {
              stroke: '#999'
            }
          },
          axisLabel: {
            style: {
              fill: '#999'
            }
          },
          axisTick: {
            show: false
          }
        },
        yAxis: {
          data: 'value',
          name: '人',
          splitLine: {
            show: false
          },
          axisLine: {
            style: {
              stroke: '#999'
            }
          },
          axisLabel: {
            style: {
              fill: '#999'
            },
          },
          axisTick: {
            show: false
          },
        },
        series: [
          {
            data: seriesData,
            type: 'line',
            name: '近30天注册',
            smooth: true,
            lineArea: {
              show: true,
              gradient: ['rgba(55, 162, 218, 0.6)', 'rgba(55, 162, 218, 0)']
            },
            linePoint: {
              radius: 4,
              style: {
                fill: '#00db95'
              }
            }
          }
        ]
      }
      this.option = {...option}
    }
  },
  created () {
    // console.log(this.curObj)
  }
}
</script>

<style lang="scss">
.scoped-wrap {
  position: relative;
  padding: 0 20px;
  box-sizing: border-box;
  height: 300px;
  .sw-name {
    position: absolute;
    font-size: 20px;
    top: 10px;
    right: 70px;
    color: #fff;
  }
}
</style>
