Newer
Older
CloudBrainNew / src / views / cityManage / components / wisdomTraffic / trafficCase / trafficCaseLine.vue
<!--
 * @Description: 事件数量日趋势
 * @Author: 王晓颖
 * @Date: 2020-10-13 14:31:45
 -->
<template>
  <single-layout title="事件数量统计">
    <div style="width: 100%;height:100%;padding:0rem 0.1rem">
      <gradient-line-chart
        :id="options.id"
        :unit="options.unit"
        :height="options.height"
        :legend="options.xAxisData"
        :xAxisData="options.xAxisData"
        :seriesData="options.seriesData"
      />
    </div>
  </single-layout>
</template>

<script>
import GradientLineChart from '@/components/lineChart/gradientLineChart'
import {fetchCaseByDay} from '@/api/smartTraffic'
import mockData from '../../../../../../static/city.json'
import SingleLayout from '@/components/layout/singleLayout'
export default {
  name: 'trafficCaseLine',
  components: {SingleLayout, GradientLineChart},
  data () {
    return {
      options: {
        id: 'traffic_case_count_line',
        height: '100%',
        width: '100%',
        unit: '个',
        xAxisData: ['', '', '', '', '', '', ''],
        seriesData: [
          // {name: '事故数量', data: [120, 252, 101, 134, 290, 230, 110], color: '255,45,85'}
        ]
      }
    }
  },
  created () {
    // this.getData()
    this.options.xAxisData = mockData.traffic.event.line.xData
    this.options.seriesData = mockData.traffic.event.line.yData
  },
  methods: {
    getData () {
      fetchCaseByDay().then(response => {
        if (response.code === 200) {
          const data = response.data
          this.options.xAxisData = data.map(item => { return item.name.slice(5, 10) })
          const value = data.map(item => { return item.value })
          this.options.seriesData = [
            {name: '事故数量', data: value, color: '255,45,85'}
          ]
        }
      })
    }
  }
}
</script>

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

</style>