demand.vue 4.15 KB
Newer Older
乐宝呗666's avatar
乐宝呗666 committed
1
<template>
xulili's avatar
xulili committed
2 3 4 5 6 7
  <div class="demand">
    <triangle>
      <slot>
        <div class="common-title">
          <img
            class="icon-title"
xulili's avatar
xulili committed
8
            src="@/assets/images/screen/boardsDemand.png"
xulili's avatar
xulili committed
9 10 11
            alt=""
          />
          <span class="title">{{ title }}</span>
xulili's avatar
xulili committed
12
          <img class="bg" src="@/assets/images/screen/title02_bg.png" alt="" />
xulili's avatar
xulili committed
13 14 15 16 17
        </div>
        <div id="barDemand" @click="echartsClick"></div>
      </slot>
    </triangle>
  </div>
乐宝呗666's avatar
乐宝呗666 committed
18 19 20
</template>

<script>
xulili's avatar
xulili committed
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
import triangle from "../components/slot/triangle";
export default {
  name: "demand",
  data() {
    return {
      title: "互动频次",
    };
  },
  components: { triangle },
  props: {
    data: {
      type: Object,
      default: () => {
        return {};
      },
乐宝呗666's avatar
乐宝呗666 committed
36
    },
xulili's avatar
xulili committed
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92
  },
  mounted() {
  },
  methods: {
    init() {
      let option = {
        tooltip: {
          trigger: "axis",
        },
        grid: {
          top: 20,
          left: "0%",
          right: "2%",
          bottom: "15%",
          containLabel: true,
        },
        // dataZoom: [{
        //   type: "slider",
        //   show: true,
        //   bottom: '20',
        //   start: 0,
        //   end: 100,
        //   height: 18,
        //   handleStyle: {
        //     color: "#d3dee5",
        //   },
        //   textStyle: {
        //     color: "#fff",
        //     fontSize: "10px"
        //   },
        // }
        // ],
        xAxis: {
          type: "category",
          boundaryGap: true, //坐标轴两边留白
          data: this.data.xAxisData,
          axisLabel: {
            //坐标轴刻度标签的相关设置。
            interval: 0,
            textStyle: {
              color: "#FFFFFF",
              fontStyle: "normal",
              fontFamily: "微软雅黑",
              fontSize: 14,
            },
            formatter: function (value, index) {
              if (value.length > 4) {
                return value.slice(0, 4) + "...";
              } else {
                return value;
              }
            },
          },
          axisTick: {
            //坐标轴刻度相关设置。
            show: false,
乐宝呗666's avatar
乐宝呗666 committed
93
          },
xulili's avatar
xulili committed
94 95 96 97 98 99
          axisLine: {
            //坐标轴轴线相关设置
            lineStyle: {
              color: "rgba(98,186,255,0.6)",
              type: "solid",
            },
乐宝呗666's avatar
乐宝呗666 committed
100
          },
xulili's avatar
xulili committed
101 102 103 104 105 106 107 108 109 110 111 112
          splitLine: {
            //坐标轴在 grid 区域中的分隔线。
            show: false,
          },
        },
        yAxis: [
          {
            type: "value",
            name: "单位/次",
            splitNumber: 5,
            max: 100,
            axisLabel: {
乐宝呗666's avatar
乐宝呗666 committed
113
              textStyle: {
xulili's avatar
xulili committed
114 115 116 117
                color: "#FFFFFFFF",
                fontStyle: "normal",
                fontFamily: "微软雅黑",
                fontSize: 12,
乐宝呗666's avatar
乐宝呗666 committed
118
              },
xulili's avatar
xulili committed
119
              interval: "auto",
乐宝呗666's avatar
乐宝呗666 committed
120
            },
xulili's avatar
xulili committed
121
            axisLine: {
乐宝呗666's avatar
乐宝呗666 committed
122 123
              show: false,
            },
xulili's avatar
xulili committed
124
            axisTick: {
乐宝呗666's avatar
乐宝呗666 committed
125
              show: false,
xulili's avatar
xulili committed
126 127 128 129 130 131
            },
            splitLine: {
              show: true,
              lineStyle: {
                color: "rgba(98,186,255,0.6)",
                type: "dashed",
乐宝呗666's avatar
乐宝呗666 committed
132
              },
xulili's avatar
xulili committed
133 134 135 136 137 138 139 140 141 142
            },
          },
        ],
        series: [
          {
            type: "bar",
            barWidth: 16, // 柱子宽度
            itemStyle: {
              barBorderRadius: 120, // 圆角(左上、右上、右下、左下)
            },
乐宝呗666's avatar
乐宝呗666 committed
143

xulili's avatar
xulili committed
144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168
            color: new this.$echarts.graphic.LinearGradient(
              0,
              0,
              0,
              1,
              ["rgba(78,255,253,1)", "rgba(255,74,83,1)"].map(
                (color, offset) => ({
                  color,
                  offset,
                })
              )
            ), // 渐变
            data: this.data.yAxisData,
          },
        ],
      };
      let echartsDiv = this.$echarts.init(document.getElementById("barDemand"));
      echartsDiv.setOption(option);
    },
    // 点击事件
    echartsClick() {
      this.$emit("itemClick", { type: 1, title: this.title });
    },
  },
};
乐宝呗666's avatar
乐宝呗666 committed
169 170 171
</script>

<style lang=scss>
xulili's avatar
xulili committed
172 173 174 175 176
#barDemand {
  width: 100%;
  height: calc(100% - 0.6rem);
  margin-top: 0.6rem;
}
乐宝呗666's avatar
乐宝呗666 committed
177
</style>