<!--
 * @Author: your name
 * @Date: 2022-04-11 15:07:47
 * @LastEditTime: 2022-04-20 11:09:34
 * @LastEditors: Please set LastEditors
 * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 * @FilePath: /gassafety-progress/gassafetyprogress-web/src/views/operationMonitor/xunjianxuncha/topChars/left.vue
-->
<template>
  <div class="charsCom all-flex-h">
    <div class="title">风险变化走势</div>
    <div class="two all-flex">
      <div class="left">

        <div id="main"  class="chars-box" >

        </div>
      </div>

    </div>


  </div>
</template>

<script>
//import { hiddenBookqiyeStatistics,hiddenBookYearStatistics } from "@/api/standingBook/hidden";
import { byyearRanking } from "@/api/system/ranking";
export default {
  components: {
  },
  props:{
    annual: {
      type: String,
      default: 2025,
    },
    companyInfoId: {
      type: String,
      default: 23,
    },
  },
  data() {
    return {
      option:{
        ///color:['RoyalBlue',"lightblue"],
        title: {
          text: ''
        },
        legend: {
          data: ['已整改', '未整改']
        },
        xAxis: [
          {
            type: 'category',
            splitLine: { show: false },
            data: ['2020', '2021', '2022', '2023', '2024', '2025', '2026']
          }
        ],
        yAxis:{
          axisLine: {
            show: true,
            lineStyle: {
              color: "#bbb6b6",
            },
          },
          splitLine: {
            show: true,
            lineStyle: {
              type: "dashed",
              color: "#bbb6b6",
            },
          },
          type: "value",
        } ,
        series: [
          {
            name: '已整改',
            type: 'line',
            stack: 'Total',
            areaStyle: {},
            emphasis: {
              focus: 'series'
            },
            data: [120, 132, 101, 134, 90, 230, 210]
          },
          {
            name: '未整改',
            type: 'line',
            stack: 'Total',
            areaStyle: {},
            emphasis: {
              focus: 'series'
            },
            data: [220, 182, 191, 234, 290, 330, 310]
          }
        ]
      },

    };
  },
  created(){
    setTimeout(this.getzhanshi,1000)
  },

  methods: {
    getzhanshi(){
      var arr=[];
      byyearRanking({yearNum:2020}).then(res =>{
        if(res.data.length>0){
          var namestr = res.data[0].enterpriseName.split(',');
          this.option.legend.data = namestr;
          var listarr = res.data;

          for(var i =0;i<namestr.length;i++){
            var date = [];
            //取企业每年评分
            for(var item of listarr){
              date.push(parseFloat(item.fraction.split(',')[i]))
            }
            var model =  {
              name: namestr[i],
              type: 'line',
              areaStyle: {},
              smooth: true,
              emphasis: {
                focus: 'series'
              },
              data: date
            }
            arr.push(model)
          }
        }

        console.log("arr",arr);
          this.option.series = arr;
          this.option.xAxis.data = [2021,2022,2023,2024,2025,2026];
          console.log(this.option)
          var myChart =  this.$echarts.init(document.getElementById('main'));
            myChart.setOption(this.option);
      })
    },

  },
};
</script>

<style lang="scss" scoped>
.charsCom {
  width: 100%;
  height: 100%;
  color: #333333;
}
.title {
  text-align: center;
  font-size: 24px;
  margin-bottom: 7px;
}
.two {
  flex: 1;
  > .left {
    max-width: 90%;
    margin-right: 70px;
    .first {
      margin-bottom: 6px;
    }
    .chars-box {
      width: 90%;
      height: 100%;
      margin: 0 auto;
    }
    .second {
      width: 213px;
      height: 30px;
      line-height: 30px;
      box-sizing: border-box;
      box-shadow: 0px 0px 3px 1px #dddddd;
      margin-bottom: 19px;
      > div {
        // flex: 1;
        text-align: center;

        &.left {
          color: #1d8cf3;
        }
        &.right {
          color: #00c3f1;
        }
      }
    }
    .third {
      text-align: center;
      width: 213px;
      margin-bottom: 24px;
    }
  }
  > .right {
    width: 50%;
    .first {
      text-align: center !important;
    }
    .chars-box {
      width: 100%;
      height: 90%;
      margin: 0 auto;
    }
  }
  > div {
    font-size: 16px;
    flex: 1;
    // display: flex;
    // flex-direction: column;
  }
  .left,
  .right {
    // display: flex;
    // flex-direction: column;
    // justify-content: space-between;
    .first {
      text-align: left;
      .text {
        display: inline-block;
        margin-right: 8px;
      }
    }
  }
}
.three {
  font-size: 16px;
  flex: 1;
  // background: red;
  .chars-box {
    flex: 1;
  }
}
</style>
