// 今日单模块预警情况
<template>
  <div class="main">
    <div class="mian-contain">
      <div class="top">
        <div class="top-tit">
          <img src="../../../assets/arrow.png" alt="" />
          <span>今日人员/车辆行为数据</span>
        </div>
        <div class="top-line">
          <img src="../../../assets/top-line.png" alt="" />
        </div>
      </div>
      <div class="container">
        <div ref="barEcharts" :style="{ width: '100%', height: '100%' }"></div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  props: {
    type: {
      type: String,
      default: "",
    },
    legend: {
      type: Array,
      default() {
        return [];
      },
    },
    // title: {
    //   type: String,
    //   default: ''
    // },
    xAxisData: {
      type: Array,
      default() {
        return [];
      },
    },
    yAxisData: {
      type: Array,
      default() {
        return [];
      },
    },
    colorList: {
      type: Array,
      default() {
        return ["#88aefe", "#4983fb"];
      },
    },
  },
  methods: {
    drawBar() {
      let barEcharts = this.$echarts.init(this.$refs.barEcharts);
      barEcharts.setOption({
        // legend: {
        //   itemStyle: {
        //     borderWidth: 1,
        //     borderColor: "#F1CF55",
        //   },
        // },
        grid: {
          top: 20,
          bottom: 50,
          left: 40,
          right: 20,
        },
        xAxis: [
          {
            type: "category",
            // data: this.xAxisData,
            data: ["无人机预警", "红绿灯预警", "冰冻雨雪预警"],
            axisLabel: {
              fontSize: 14,
              color: "#EBEFFFCC",
              lineHeight: 21,
            },
            // x轴最下面的线
            axisLine: {
              show: true, // X轴 网格线 颜色类型的修改
              lineStyle: {
                type: "dashed",
                color: "#596687",
              },
            },
          },
        ],
        yAxis: {
          type: "value",
          //y轴名字
          axisLabel: {
            show: true,
            textStyle: {
              color: "#EBEFFF80",
              fontSize: 13,
            },
          },
          splitLine: {
            show: true,
            lineStyle: {
              type: "dashed",
              color: "#596687B2",
            },
          },
        },
        color: {
          // type: 'radial',
          x: 0,
          y: 0,
          x2: 0,
          y2: 1,
          colorStops: [
            {
              offset: 0,
              color: "#06f0f0", // 0% 处的颜色
            },
            {
              offset: 0.8,
              color: "#1f2d9a", // 100% 处的颜色
            },
          ],
        },
        series: [
          {
            name: "hill",
            type: "pictorialBar",
            barCategoryGap: "40",
            // symbol: 'path://M0,10 L10,10 L5,0 L0,10 z',
            symbol:
              "path://M0,10 L10,10 C5.5,10 5.5,5 5,0 C4.5,5 4.5,10 0,10 z",
            itemStyle: {
              opacity: 0.7,
            },
            emphasis: {
              itemStyle: {
                opacity: 1,
              },
            },
            data: [11, 22, 9],
            z: 10,
          },
          {
            name: "glyph",
            type: "pictorialBar",
            barGap: "-100%",
            symbolPosition: "end",
            symbolSize: 50,
            symbolOffset: [0, "-120%"],
            data: [
              // {
              //   value: this.yAxisData[0],
              //   symbolSize: [0],
              // },
              {
                value: 11,
                symbolSize: [0],
              },
              {
                value: 22,
                symbolSize: [0],
              },
              {
                value: 9,
                symbolSize: [0],
              },
            ],
          },
        ],
      });
    },
  },
  watch: {
    yAxisData() {
      // console.log(this.findingsData);
      // console.log(this.yAxisData);
      this.drawBar();
    },
  },
  mounted() {
    this.drawBar();
  },
};
</script>

<style lang="scss" scoped>
.main {
  width: 455px;
  height: 308px;
  border-radius: 8px;
  // background: rgba(26, 52, 125, 0.95);
  padding: 10px;
}
.top {
  height: 45px;
  .top-tit {
    font-size: 18px;
    font-weight: 600;
    line-height: 23.4px;
    text-align: left;
    color: #ffffff;
    img {
      margin-right: 10px;
    }
  }
  .top-line {
    margin-top: -7px;
  }
}
.mian-contain {
  border-radius: 8px;
  padding: 10px;
  background: rgba(29, 65, 171);
  // overflow: hidden;
  height: 100%;
}
.container {
  width: 100%;
  height: 86%;
}
</style>
