Newer
Older
CloudBrainNew / src / views / industrialEconomy / components / expense / components / expenseLine.vue
<!--
 * @Description: 历年各类项目数量
 * @Author: 王晓颖
 * @Date: 2020-11-30 17:00:18
 -->
<template>
  <single-layout title="人均可支配收入趋势图" @click="getData">
    <div style="width: 100%;height:100%;padding:0rem">
      <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'
import mockData from '../../../../../../static/industrialEconomy.json'
export default {
  name: 'ExpenseLine',
  components: {SingleLayout, GradientLineChart},
  data () {
    return {
      colors: ['255,45,85', '0,144,255', '255,204,0', '0,254,74'],
      options: {
        id: 'expense_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'},
          {name: '农村', data: [0, 0, 0, 0, 0], color: '0,144,255'}
        ]
      }
    }
  },
  created () {
    // this.getData()
    this.options.xAxisData = mockData.right.expense.line.xAxisData
    this.options.seriesData = mockData.right.expense.line.seriesData
    this.options.unit = mockData.right.expense.line.unit
  },
  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>