<!-- * @Description: 历年各类项目数量 * @Author: 王晓颖 * @Date: 2020-11-30 17:00:18 --> <template> <!--<single-layout title="财政收入/支出趋势" @click="getData">--> <div style="width: 100%;height:100%;padding:0.05rem"> <gradient-line-chart :id="options.id" :unit="options.unit" :height="options.height" :legend="options.legend" :xAxisData="options.xAxisData" :seriesData="options.seriesData" /> </div> <!--</single-layout>--> </template> <script> import GradientLineChart from '@/components/lineChart/gradientLineChart' import {fetchProjectCountByYear} from '@/api/projectManage' import SingleLayout from '@/components/layout/singleLayout' export default { name: 'EcologyLine', components: {SingleLayout, GradientLineChart}, data () { return { colors: ['255,45,85', '0,144,255', '255,204,0', '0,254,74'], options: { id: 'ecology_line', height: '100%', width: '100%', unit: '万人', xAxisData: [ '2016', '2017', '2018', '2019', '2020' ], legend: ['客流量'], seriesData: [ {name: '客流量', data: [ 0, 0, 0, 0, 0 ], color: '255,45,85'} ] } } }, created () { this.getData() }, methods: { // getData () { // const currentYear = new Date().getFullYear() // const threeYear = currentYear - 2 // const yearRange = [threeYear.toString(), (currentYear).toString()] // fetchProjectCountByYear(yearRange).then(response => { // if (response.code === 200) { // // debugger // const data = response.data // const datalength = data.length // this.options.legend = data.map(item => { return item.year.toString() }) // this.options.xAxisData = data[0].data.map(item => { return item.type }) // const dataFilter = [] // for (let i = 0; i < datalength; i++) { // const value = data[i].data.map(item => item.value) // dataFilter.push({ // name: data[i].year.toString(), data: value, color: this.colors[i] // }) // } // this.options.seriesData = dataFilter // } // }) // } } } </script> <style rel="stylesheet/scss" lang="scss" scoped> </style>