<template>
  <div class="mainBox">
    <div class="select-nav">
      <div>年份:</div>
      <el-select v-model="ruleForm.date" placeholder="请选择年份" size="mini">
        <el-option
          v-for="item in options"
          :key="item.value"
          :label="item.label"
          :value="item.value"
        >
        </el-option>
      </el-select>
    </div>
    <!-- 各区域执法计划 -->
    <div class="bodyBox boxAllStyle">
      <div id="execution"></div>
    </div>
    <div class="bottomBox">
      <div class="boxAllStyle">
        <completePlan></completePlan>
      </div>
      <div style="width: 15px;"></div>
      <div class="boxAllStyle">
        <finishRate></finishRate>
      </div>
    </div>
  </div>
</template>
<script>
import * as echarts from "echarts";
import completePlan from "./echarts/completePlan.vue";
import finishRate from "./echarts/finishRate.vue";
export default {
  data() {
    return {
      ruleForm: {
        date: "",
      },
      options: [
        {
          value: "选项1",
          label: "2019",
        },
        {
          value: "选项2",
          label: "2020",
        },
        {
          value: "选项3",
          label: "2021",
        },
        {
          value: "选项4",
          label: "2022",
        },
        {
          value: "选项5",
          label: "2023",
        },
      ],
    };
  },
  components:{
    completePlan,
    finishRate
  },
  mounted() {
    this.init();
  },
  methods: {
    init() {
      var chartDom = document.getElementById("execution");
      var myChart = echarts.init(chartDom);
      var option = {
        title: {
          show: true,
          text: "各区域执法计划",
          textStyle: {
            color: "#3D434D",
            fontSize: 16,
          },
          left: 34,
          top: 15,
        },
        tooltip: {
          trigger: "axis",
          axisPointer: {
            type: "shadow",
            shadowStyle: {
              color: "rgba(237,240,242,0.5)",
              //   opacity: 0.1,
              //   shadowColor: "rgba(237,240,242,0.5)",
              //   shadowBlur: 10,
            },
          },
          showContent: false,
        },
        grid: {
          left: "3%",
          right: "3%",
          bottom: "3%",
          containLabel: true,
        },
        xAxis: [
          {
            type: "category",
            data: [
              "苏州",
              "张家港市",
              "常熟市",
              "太仓市",
              "昆山市",
              "吴江区",
              "吴中区",
              "姑苏区",
              "相城区",
              "工业园区",
              "高新区",
            ],
            axisTick: {
              show: false,
            },
            axisLabel: {
              color: "#525966",
              //   fontFamily:'Alibaba-PuHuiTi-Medium.otf'
            },
            axisLine: {
              lineStyle: {
                color: "#B6C3D9",
              },
            },
            z: 1000,
          },
        ],
        yAxis: [
          {
            type: "value",
            // splitLine: {
            //   show: true,
            //   lineStyle: {
            //     type: "dashed",
            //     color: "#B6C3D9",
            //   },
            // },
            z: 1,
          },
        ],
        series: [
          {
            type: "bar",
            barWidth: 28,
            itemStyle: {
              color: new echarts.graphic.LinearGradient(0, 1, 0, 0, [
                {
                  //只要修改前四个参数就ok
                  offset: 0,
                  color: "#FF8B02",
                }, //柱图渐变色
                {
                  offset: 1,
                  color: "#FFA70F",
                },
              ]),
            },
            data: [700, 400, 600, 300, 580, 250, 490, 200, 390, 460, 90],

            //高亮的效果
            emphasis: {
              itemStyle: {
                // color: "rgba(0,0,0,0.3)",
              },
              //每根柱子上的字
              label: {
                show: true,
                position: "top",
                formatter: "{c}",
                color: "#FF8C03",
                //   fontFamily:'Alibaba-PuHuiTi-Regular.otf'
              },
            },
          },
        ],
      };
      option && myChart.setOption(option);
    },
  },
};
</script>
<style lang="scss" scoped>
.boxAllStyle {
  background: #ffffff;
  box-shadow: 0px 1px 24px 0px #e2e2e2;
  border-radius: 10px;
}
.mainBox {
  height: 100%;
  width: 100%;
  padding: 20px;
  .select-nav {
    height: 38px;
    display: flex;
    align-items: center;
    margin-bottom: 15px;
    & > div:nth-of-type(1) {
      font-family: "Alibaba-PuHuiTi-Regular.otf";
      margin-right: 5px;
    }
  }
  .bodyBox {
    width: 100%;
    height: 250px;

    margin-bottom: 15px;
    #execution {
      width: 100%;
      height: 100%;
    }
  }
  .bottomBox {
    height: calc(100% - 250px - 53px - 15px);
    display: flex;
    justify-content: space-between;
    & > .boxAllStyle {
      flex: 1;
    }
  }
}
</style>