
<template>
  <div col="col-sm-12">
    <div class="col-sm-6">
     <left-chart :param="param" id="leftchart" title="用气量情况"></left-chart>
    </div>
    <div class="col-sm-6">
      <left-chart :param="param1" id="leftchart2" title="用气比例"></left-chart>
    </div>
  </div>
</template>

<script>
import  {HttpResetClass} from "vue-client";
export default {
    props: ['condition'],
    data() {
      return {
        dataLength: 0,
        xData: ['1月','2月','3月','4月','5月','6月','7月','8月','9月','10月','11月','12月'],
        param:[],
        param1:[],
        name:[],
        yData: [],
        yData2:[],
      }
    },
    methods: {
     getParams (params) {
       this.name = []
       this.yData = []
       this.yData2 = []
       let http  = new HttpResetClass()
       http.load('post','api/af-revenue/sql/gasbai_body',{data: params}).then((res)=>{
         console.log(res.data)
         this.dataLength = res.data.length
         let sumgas1 = 0
         let sumgas2 = 0
         let sumgas3 = 0
         let sumgas4 = 0
         let sumgas5 = 0
         let sumgas6 = 0
         let sumgas7 = 0
         let sumgas8 = 0
         let sumgas9 = 0
         let sumgas10 = 0
         let sumgas11 = 0
         let sumgas12 = 0
         for (let i = 0; i < res.data.length; i++) {
           sumgas1 += res.data[i].f_gas1
           sumgas2 += res.data[i].f_gas2
           sumgas3 += res.data[i].f_gas3
           sumgas4 += res.data[i].f_gas4
           sumgas5 += res.data[i].f_gas5
           sumgas6 += res.data[i].f_gas6
           sumgas7 += res.data[i].f_gas7
           sumgas8 += res.data[i].f_gas8
           sumgas9 += res.data[i].f_gas9
           sumgas10 += res.data[i].f_gas10
           sumgas11 += res.data[i].f_gas11
           sumgas12 += res.data[i].f_gas12
         }
         for (let i = 0; i < res.data.length; i++) {
           this.name.push(res.data[i].f_gastype)
           let arr2 = []
           let arr1 = []
           arr1.push(res.data[i].f_gas1)
           arr1.push(res.data[i].f_gas2)
           arr1.push(res.data[i].f_gas3)
           arr1.push(res.data[i].f_gas4)
           arr1.push(res.data[i].f_gas5)
           arr1.push(res.data[i].f_gas6)
           arr1.push(res.data[i].f_gas7)
           arr1.push(res.data[i].f_gas8)
           arr1.push(res.data[i].f_gas9)
           arr1.push(res.data[i].f_gas10)
           arr1.push(res.data[i].f_gas11)
           arr1.push(res.data[i].f_gas12)
           if (sumgas1 > 0 ) {
             arr2.push((res.data[i].f_gas1*100/sumgas1).toFixed(2))
           } else {
             arr2.push(0)
           }
           if (sumgas2 > 0 ) {
             arr2.push((res.data[i].f_gas2*100/sumgas2).toFixed(2))
           } else {
             arr2.push(0)
           }
           if (sumgas3 > 0 ) {
             arr2.push((res.data[i].f_gas3*100/sumgas3).toFixed(2))
           } else {
             arr2.push(0)
           }
           if (sumgas4 > 0 ) {
             arr2.push((res.data[i].f_gas4*100/sumgas4).toFixed(2))
           } else {
             arr2.push(0)
           }
           if (sumgas5 > 0 ) {
             arr2.push((res.data[i].f_gas5*100/sumgas5).toFixed(2))
           } else {
             arr2.push(0)
           }
           if (sumgas6 > 0 ) {
             arr2.push((res.data[i].f_gas6*100/sumgas6).toFixed(2))
           } else {
             arr2.push(0)
           }
           if (sumgas7 > 0 ) {
             arr2.push((res.data[i].f_gas7*100/sumgas7).toFixed(2))
           } else {
             arr2.push(0)
           }
           if (sumgas8 > 0 ) {
             arr2.push((res.data[i].f_gas8*100/sumgas8).toFixed(2))
           } else {
             arr2.push(0)
           }
           if (sumgas9 > 0 ) {
             arr2.push((res.data[i].f_gas9*100/sumgas9).toFixed(2))
           } else {
             arr2.push(0)
           }
           if (sumgas10 > 0 ) {
             arr2.push((res.data[i].f_gas10*100/sumgas10).toFixed(2))
           } else {
             arr2.push(0)
           }
           if (sumgas11 > 0 ) {
             arr2.push((res.data[i].f_gas11*100/sumgas11).toFixed(2))
           } else {
             arr2.push(0)
           }
           if (sumgas12 > 0 ) {
             arr2.push((res.data[i].f_gas12*100/sumgas12).toFixed(2))
           } else {
             arr2.push(0)
           }
           this.yData.push(arr1)
           this.yData2.push(arr2)
         }
         this.param = {
           legendData:this.name,
           xData :this.xData,
           yData:this.yData,
         }
         this.param1 = {
           legendData:this.name,
           xData :this.xData,
           yData:this.yData2,
         }
       })
     }
    },
    watch: {
    }
  }
</script>

<style scoped>

</style>
