<!-- * @Description: 基础设施 * @Author: 王晓颖 * @Date: 2020-11-30 17:00:18 --> <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.lengend" :xAxisData="options.xAxisData" :seriesData="options.seriesData" /> </div> </chart-layout> </template> <script> import GradientLineChart from '@/components/lineChart/gradientLineChart' import {fetchParkFlowByDay} from '@/api/cityManage' export default { name: 'InfrasturctureLine', components: {GradientLineChart}, data () { return { options: { id: 'infrastructure_line', height: '100%', width: '100%', unit: '次', xAxisData: ['道路设施', '轨道设施', '行政设施', '教育设施', '商业设施', '金融邮电设施', '轨道设施', '社会福利设施', '社区服务设施', '市政设施', '文化设施', '医疗设施' ], legend: ['总数量', '现状', '新增'], seriesData: [ {name: '总数量', data: [ 855, 1078, 856, 865, 990, 782, 1210, 867, 689, 777, 878, 1043, 478, 999 ], color: '255,45,85'}, {name: '现状', data: [545, 745, 546, 575, 777, 467, 710, 567, 590, 430, 610, 701], color: '0,144,255'}, {name: '新增', data: [300, 232, 233, 454, 190, 330, 210, 154, 390, 130, 310, 218], color: '255,204,0'} ] } } }, 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>