<template>
  <vab-chart
    style="width: 100%; height: 280px"
    :autoresize="true"
    :options="options"
    theme="vab-echarts-theme"
  />
</template>
<script>
  import VabChart from "@/extra/vabCharts";
  import VabCount from "@/extra/vabCount";

  export default {
    components: {
      VabChart,
      // VabCount,
    },
    props: {
      timeData: {
        type: Array,
        default: () => {
          return [];
        },
      },
      goodsNum: {
        type: Array,
        default: () => {
          return [];
        },
      },
      orderNum: {
        type: Array,
        default: () => {
          return [];
        },
      },
      orderMoney: {
        type: Array,
        default: () => {
          return [];
        },
      },
    },
    data() {
      return {
        timer: 0,
        countConfig: {
          startVal: 0,
          endVal: this.$baseLodash.random(20000, 60000),
          decimals: 0,
          prefix: "",
          suffix: "",
          separator: ",",
          duration: 8000,
        },
        //访问量
        options: {
          grid: {
            left: "3%",
            right: "4%",
            bottom: "3%",
            containLabel: true,
          },
          tooltip: {
            trigger: "axis",
            axisPointer: {
              type: "cross",
              label: {
                backgroundColor: "#6a7985",
              },
            },
          },
          color: ["#0668F0", "#F7B500"],
          legend: {
            data: ["采购价", "销售价"],
            borderColor: "#000",
          },
          xAxis: [
            {
              type: "category",
              boundaryGap: false,
              data: this.timeData,
              // data: ["周一", "周二", "周三", "周四", "周五", "周六", "周日"],
              axisTick: {
                alignWithLabel: true,
              },
              splitLine: {
                show: false,
              },
            },
          ],
          yAxis: [
            {
              type: "value",
              splitLine: {
                show: false,
              },
            },
          ],
          series: [
            {
              name: "采购价",
              type: "line",
              // data: this.orderMoney,
              data: [120, 132, 101, 134, 90, 230, 210],
              smooth: true,
              areaStyle: {
                // normal: {
                //   color: "#0668F0",
                // },
                normal: {
                  color: {
                    type: "linear",
                    x: 0,
                    y: 0,
                    x2: 0,
                    y2: 1,
                    colorStops: [
                      {
                        offset: 0,
                        color: "rgb(198,199,248)", // 0% 处的颜色
                      },
                      {
                        offset: 1,
                        color: "#fff", // 100% 处的颜色
                      },
                    ],
                    globalCoord: false, // 缺省为 false
                  },
                },
              },
              symbol: "none",
              itemStyle: {
                normal: {
                  lineStyle: {
                    color: "#0668F0",
                    // opacity: 0.5,
                    // width: 2,
                  },
                },
              },
            },
            {
              name: "销售价",
              type: "line",
              // data: this.goodsNum,
              data: [220, 182, 191, 234, 290, 330, 310],
              smooth: true,
              areaStyle: {
                // normal: {
                //   color: "#F7B500",
                // },
                color: {
                  type: "linear",
                  x: 0,
                  y: 0,
                  x2: 0,
                  y2: 1,
                  colorStops: [
                    {
                      offset: 0,
                      color: "rgb(255,242,209)", // 0% 处的颜色
                    },
                    {
                      offset: 1,
                      color: "#fff", // 100% 处的颜色
                    },
                  ],
                  globalCoord: false, // 缺省为 false
                },
              },
              symbol: "none",
              itemStyle: {
                normal: {
                  lineStyle: {
                    color: "#F7B500",
                  },
                },
              },
            },
          ],
        },
      };
    },
    beforeDestroy() {
      clearInterval(this.timer);
    },
  };
</script>
