<!--
 * @Author: SunTao 328867980@qq.com
 * @Date: 2024-10-18 15:21:24
 * @LastEditors: SunTao 328867980@qq.com
 * @LastEditTime: 2024-10-18 17:06:39
 * @FilePath: \znxjxt-ui\src\views\big-screen\road-components\anomaly-facilities.vue
 * @Description: 附属设施异常统计
-->

<template>
  <div class="content">
    <div class="anomaly-select">下拉框</div>
    <div ref="anomalyChart" class="anomaly-echart"></div>
  </div>
</template>
  
  <script>
import * as echarts from "echarts";
export default {
  name: "AnomalyFacilities",
  data() {
    return {};
  },
  created() {
    this.getChartData();
  },
  methods: {
    /* 获取柱状图数据 */
    getChartData() {
      this.$nextTick(() => {
        this.drawChart();
      });
    },
    /* 绘制echart */
    drawChart() {
      const chart = echarts.init(this.$refs.anomalyChart);
      chart.setOption({
        // backgroundColor: "#041139",
        tooltip: {
          trigger: "item",
          backgroundColor: "rgba(9, 24, 48, 0.5)",
          borderColor: "rgba(75, 253, 238, 0.4)",
          textStyle: {
            fontSize: 12,
            color: "#808C9F",
          },
        },
        legend: {
          show: false,
        },
        grid: {
          top: "20%",
          left: "10%",
          right: 0,
          bottom: "20%",
        },
        xAxis: [
          {
            data: ["fdfs", "frffs", "wdwe", "10-1", "asdasd", "asd", "fdfs"],
            axisLabel: {
              textStyle: {
                color: "#808C9F",
                fontSize: 12,
              },
              interval: 0,
            },
            axisLine: {
              show: false, //不显示x轴
              lineStyle: {
                color: "rgba(53,65,95,1)",
              },
            },
            axisTick: {
              show: false, //不显示刻度
            },
            boundaryGap: true,
            splitLine: {
              show: false,
            },
          },
        ],
        yAxis: [
          {
            name: "数量",
            nameTextStyle: {
              color: "#C7DAF2",
            },
            splitLine: {
              show: false,
            },
            axisTick: {
              show: false,
            },
            axisLine: {
              show: false, //不显示x轴
              lineStyle: {
                color: "rgba(53,65,95,1)",
              },
            },
            axisLabel: {
              show: true,
              textStyle: {
                color: "#808C9F",
                fontSize: 12,
              },
            },
          },
        ],
        series: [
          // 柱体
          {
            name: "人数",
            type: "bar",
            barWidth: 10,
            itemStyle: {
              borderColor: "#08B4A6",
              borderWidth: 1,
            },
            showBackground: true,
            backgroundStyle: {
              color: "rgba(105,160,231,0.1)",
            },
            // itemStyle: {

            // },
            label: {
              show: false, //每条柱状图是否显示数字
              formatter: "{c}",
              position: "top",
              color: "#fff",
              fontSize: 14,
            },
            data: [
              {
                value: 15,
                itemStyle: {
                  color: {
                    x: 0,
                    y: 0,
                    x2: 0,
                    y2: 1,
                    type: "linear",
                    global: false,
                    colorStops: [
                      {
                        //第一节下面
                        offset: 0,
                        color: "#034299",
                      },
                      {
                        offset: 1,
                        color: "#35F0FF",
                      },
                    ],
                  },
                },
              },
              {
                value: 25,
                itemStyle: {
                  color: {
                    x: 0,
                    y: 0,
                    x2: 0,
                    y2: 1,
                    type: "linear",
                    global: false,
                    colorStops: [
                      {
                        //第一节下面
                        offset: 0,
                        color: "#033E43",
                      },
                      {
                        offset: 1,
                        color: "#00FFEA",
                      },
                    ],
                  },
                },
              },
              {
                value: 35,
                itemStyle: {
                  color: {
                    x: 0,
                    y: 0,
                    x2: 0,
                    y2: 1,
                    type: "linear",
                    global: false,
                    colorStops: [
                      {
                        //第一节下面
                        offset: 0,
                        color: "#034299",
                      },
                      {
                        offset: 1,
                        color: "#35F0FF",
                      },
                    ],
                  },
                },
              },
              {
                value: 45,
                itemStyle: {
                  color: {
                    x: 0,
                    y: 0,
                    x2: 0,
                    y2: 1,
                    type: "linear",
                    global: false,
                    colorStops: [
                      {
                        //第一节下面
                        offset: 0,
                        color: "#033E43",
                      },
                      {
                        offset: 1,
                        color: "#00FFEA",
                      },
                    ],
                  },
                },
              },
              {
                value: 55,
                itemStyle: {
                  color: {
                    x: 0,
                    y: 0,
                    x2: 0,
                    y2: 1,
                    type: "linear",
                    global: false,
                    colorStops: [
                      {
                        //第一节下面
                        offset: 0,
                        color: "#034299",
                      },
                      {
                        offset: 1,
                        color: "#35F0FF",
                      },
                    ],
                  },
                },
              },
              {
                value: 65,
                itemStyle: {
                  color: {
                    x: 0,
                    y: 0,
                    x2: 0,
                    y2: 1,
                    type: "linear",
                    global: false,
                    colorStops: [
                      {
                        //第一节下面
                        offset: 0,
                        color: "#033E43",
                      },
                      {
                        offset: 1,
                        color: "#00FFEA",
                      },
                    ],
                  },
                },
              },
              {
                value: 75,
                itemStyle: {
                  color: {
                    x: 0,
                    y: 0,
                    x2: 0,
                    y2: 1,
                    type: "linear",
                    global: false,
                    colorStops: [
                      {
                        //第一节下面
                        offset: 0,
                        color: "#034299",
                      },
                      {
                        offset: 1,
                        color: "#35F0FF",
                      },
                    ],
                  },
                },
              },
            ],
          },
        ],
      });
      window.addEventListener("resize", () => {
        chart.resize();
      });
    },
  },
};
</script>
  
  <style lang="scss" scoped>
.content {
  width: 100%;
  height: 100%;

  .anomaly-select {
    position: absolute;
  }

  .anomaly-echart {
    width: 100%;
    height: 100%;
  }
}
</style>
  