<template>
  <chart :options="graph()" class="graph" />
</template>

<script>
import { graphic } from "echarts/lib/export";
export default {
  props: {
    data: {
      type: Object,
      default: () => {
        return {
          xaxis: [],
          data: [],
          legend: []
        };
      }
    }
  },
  data: () => ({}),
  mounted() {},
  methods: {
    graph() {
      let self = this;
      return {
        color: ["#274fee", "#ef9433"],
        legend: {
          bottom: 0,
          left: "center",
          icon: "roundRect",
          itemWidth: 10,
          itemHeight: 10,
          data: self.data.legend,
          orient: "horizontal",
          backgroundColor: "#f4f7fc"
        },
        grid: {
          left: 10,
          right: 10,
          bottom: 25,
          top: 25,
          containLabel: true
        },
        xAxis: [
          {
            type: "category",
            data: self.data.xaxis,
            axisLine: {
              lineStyle: {
                color: "#f2f2f2"
              }
            },
            axisLabel: {
              margin: 20,
              color: "#0d1847",
              textStyle: {
                fontSize: 12
              },
              interval: 0
            },
            boundaryGap: false
          }
        ],
        yAxis: [
          {
            type: "value",
            axisTick: {
              show: false
            },
            axisLine: {
              lineStyle: {
                color: "rgba(0, 0, 0, 0)"
              }
            },
            axisLabel: {
              color: "#a9aec0",
              textStyle: {
                fontSize: 12
              }
            },
            splitLine: {
              lineStyle: {
                color: "#f2f2f2",
                type: "solid"
              }
            }
          }
        ],
        series: [
          {
            name: self.data.legend[0],
            type: "line",
            data: self.data.data[0],
            symbolSize: 1,
            symbol: "circle",
            smooth: true,
            yAxisIndex: 0,
            showSymbol: false,
            lineStyle: {
              width: 2,
              color: "#274fee",
              shadowColor: "rgb(39, 79, 238, 0.4)",
              shadowBlur: 5,
              shadowOffsetY: 8
            }
          },
          {
            name: self.data.legend[1],
            type: "line",
            data: self.data.data[1],
            symbolSize: 1,
            symbol: "circle",
            smooth: true,
            yAxisIndex: 0,
            showSymbol: false,
            lineStyle: {
              width: 2,
              color: "#ef9433",
              shadowColor: "rgb(239, 148, 51, 0.4)",
              shadowBlur: 5,
              shadowOffsetY: 8
            }
          }
        ]
      };
    }
  }
};
</script>
<style scoped>
.graph {
  width: 100%;
  height: calc(100% - 20px);
}
</style>