<!-- * @Description: 总体就餐人次每日趋势统计 * @Description: 总体就餐人次每日趋势统计 * @Author: 王晓颖 * @Date: 2020-11-17 10:07:47 --> <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 { fetchCanteenDayNum } from '@/api/ecard' import { dateToString, getLastWeek } from '@/utils/formatDate' export default { name: 'canteenFlowLine', components: {GradientLineChart, ColorfulBarChart, ChartLayout}, data () { return { options: { id: 'canteen_flow_line', height: '100%', width: '100%', unit: '次', xAxisData: ['', '', '', '', '', '', ''], seriesData: [ {name: '人流量', data: [0, 0, 0, 0, 0, 0, 0], color: '0,144,255'} // {name: '出场流量', data: [110, 222, 91, 82, 278, 200, 91], color: '0,144,255'} ] } } }, created () { this.getData() }, methods: { getData () { const today = dateToString(new Date(), 'y-m-d') const sevenday = dateToString(getLastWeek(), 'y-m-d') const params = {params: [sevenday, today]} fetchCanteenDayNum(params).then(response => { if (response.code === 200) { const data = response.data if (data.length === 0) { this.options.xAxisData = [] } else { this.options.xAxisData = data.map(item => { return item.date.substring(5) }) } const value = data.map(item => { return item.value === '' ? 0 : item.value }) this.options.seriesData = [ {name: '人流量', data: value, color: '0,144,255'} ] } }) } } } </script> <style rel="stylesheet/scss" lang="scss" scoped> </style>