Newer
Older
CloudBrainNew / src / views / socialLive / components / community / components / troubleLine.vue
StephanieGitHub on 4 Feb 2021 1 KB first commit
<!--
 * @Description: 隐患发生趋势
 * @Author: 王晓颖
 * @Date: 2020-11-23 18:10:40
 -->
<template>
    <div style="width: 100%;height:100%;padding:0.1rem">
      <gradient-line-chart
        :id="options.id"
        :unit="options.unit"
        :height="options.height"
        :legend="options.xAxisData"
        :xAxisData="options.xAxisData"
        :seriesData="options.seriesData"
      />
    </div>
</template>

<script>
import GradientLineChart from '@/components/lineChart/gradientLineChart'
import {fetchParkFlowByDay} from '@/api/cityManage'
export default {
  name: 'troubleLine',
  components: {GradientLineChart},
  data () {
    return {
      options: {
        id: 'trouble_line',
        height: '100%',
        width: '100%',
        unit: '次',
        xAxisData: ['9-3', '9-4', '9-5', '9-6', '9-7', '9-8', '9-9'],
        seriesData: [
          {name: '基础设施隐患', data: [120, 252, 101, 134, 290, 230, 110], color: '0,144,255'},
          {name: '消防隐患', data: [150, 122, 151, 82, 278, 200, 91], color: '255,45,85'}
        ]
      }
    }
  },
  created () {
    // this.getData()
  },
  methods: {
    getData () {
      fetchParkFlowByDay().then(response => {
        if (response.code === 200) {
          const data = response.data
          this.options.xAxisData = data.map(item => { return item.name })
          const inNum = data.map(item => { return item.total })
          const outNum = data.map(item => { return item.complete })
          this.options.seriesData = [
            {name: '人流量', data: inNum, color: '0,144,255'},
            // {name: '出场流量', data: outNum, color: '0,144,255'}
          ]
        }
      })
    }
  }
}
</script>

<style rel="stylesheet/scss" lang="scss" scoped>

</style>