<!--
 * @Author: your name
 * @Date: 2021-10-26 10:35:56
 * @LastEditTime: 2021-12-02 15:25:07
 * @LastEditors: Please set LastEditors
 * @Description: 存栏变动
 * @FilePath: \hyyfScreen\src\views\Production\board\ChartAmountLine.vue
-->
<template>
  <div class="chart-inventory-lines">
    <div id="chartAmountLines"></div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      myChart: null,
    };
  },
  props: {
    data: {
      type: Object,
      required: true,
    },
  },
  methods: {
    init() {
      let options = {
        // title: {
        //   text: '存栏变动',
        //   x: 10,
        //   y: 0
        // },
        tooltip: {
          trigger: "axis",
        },
        // legend: {
        //   data: ['头']
        // },
        color: ["#3aa0ff", "#403DEA", "#226942", "#1AD06C", "#975fe4"],
        grid: {
          top: "22%",
          left: "10%",
          bottom: "10%",
          right: "15%",
        },
        xAxis: [
          {
            type: "category",
            name: "月份",
            nameTextStyle: {
              color: "#fff",
            },
            data: this.data.month,
            axisPointer: {
              type: "shadow",
            },
            axisLine: {
              show: true,
              lineStyle: {
                color: "#fff",
              },
            },
            axisTick: {
              show: true,
            },
          },
        ],
        //[
        yAxis: {
          type: "value",
          name: "头",
          // axisLabel: {
          //   formatter: '{value} °C'
          // },
          nameTextStyle: {
            color: "#fff",
          },
          axisLine: {
            show: true,
            lineStyle: {
              color: "#fff",
            },
          },
          axisTick: {
            show: false,
          },
          splitLine: {
            show: false,
          },
        },
        // {
        //   type: 'value',
        //   name: '湿度',
        //   axisLabel: {
        //     formatter: '{value} RH'
        //   },
        //   axisLine: {
        //     show: false,
        //     lineStyle: {
        //       color: '#6e7079',
        //     }
        //   },
        //   axisTick:{
        //     show:false
        //   },
        //   // splitLine:{
        //   //   show:false
        //   // }
        // }
        //],
        series: [
          {
            name: "母猪存栏",
            type: "line",
            smooth: false,
            data: this.data.sowStock,
            itemStyle: {
              normal: {
                color: "#3aa0ff",
                lineStyle: {
                  color: "#3aa0ff",
                },
              },
            },
          },
          {
            name: "公猪存栏",
            type: "line",
            smooth: false,
            data: this.data.boarStock,
            itemStyle: {
              normal: {
                color: "#403DEA",
                lineStyle: {
                  color: "#403DEA",
                },
              },
            },
          },
          {
            name: "哺乳猪存栏",
            type: "line",
            smooth: false,
            data: this.data.griceStock,
            itemStyle: {
              normal: {
                color: "#226942",
                lineStyle: {
                  color: "#226942",
                },
              },
            },
          },
          {
            name: "保育猪存栏",
            type: "line",
            smooth: false,
            data: this.data.pigletStock,
            itemStyle: {
              normal: {
                color: "#1AD06C",
                lineStyle: {
                  color: "#1AD06C",
                },
              },
            },
          },
          {
            name: "育肥猪存栏",
            type: "line",
            smooth: false,
            data: this.data.fatpigStock,
            itemStyle: {
              normal: {
                color: "#975fe4",
                lineStyle: {
                  color: "#975fe4",
                },
              },
            },
          },
          // {
          //   name: '湿度',
          //   type: 'line',
          //   smooth: false,
          //   yAxisIndex: 1,
          //   data: [20, 22, 33, 45, 63, 102, 23, 24, 23, 65, 50, 62]
          // }
        ],
      };
      this.myChart.setOption(options);
    },
  },
  mounted() {
    this.myChart = this.$echarts.init(
      document.getElementById("chartAmountLines")
    );
    this.init();
  },
  watch: {
    data: {
      handler(newValue) {
        console.log(newValue);
        this.init();
      },
      deep: true,
    },
  },
};
</script>

<style scoped>
.chart-inventory-lines {
  /* display: inline-block; */
  width: 100%;
  height: 100%;
}
#chartAmountLines {
  width: 100%;
  height: 100%;
}
</style>
