<!-- * @Description: 停车场流量每日趋势统计 * @Author: 王晓颖 * @Date: 2020-10-13 14:32:03 --> <template> <chart-layout title="停车场流量统计" @click="getData"> <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> </chart-layout> </template> <script> import ChartLayout from '@/components/layout/chartLayout' import ColorfulBarChart from '@/components/barChart/colorfulBarChart' import GradientLineChart from '@/components/lineChart/gradientLineChart' import {fetchParkFlowByDay} from '@/api/cityManage' export default { name: 'parkFlowLine', components: {GradientLineChart, ColorfulBarChart, ChartLayout}, data () { return { options: { id: 'case_line', height: '100%', width: '100%', unit: '次', xAxisData: ['', '', '', '', '', '', ''], seriesData: [ // {name: '入场流量', data: [120, 252, 101, 134, 290, 230, 110], color: '255,45,85'}, // {name: '出场流量', data: [110, 222, 91, 82, 278, 200, 91], color: '0,144,255'} ] } } }, 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: '255,45,85'}, {name: '出场流量', data: outNum, color: '0,144,255'} ] } }) } } } </script> <style rel="stylesheet/scss" lang="scss" scoped> </style>