IndexPage.vue 3.46 KB
Newer Older
hucy's avatar
hucy committed
1 2 3 4 5 6 7 8 9 10
<!--
 * 疫情防控
  -->
<script lang="ts">
export default {
  name: 'PAGE7',
};
</script>
<script setup lang="ts">
import { ref, onMounted } from 'vue';
hucy's avatar
hucy committed
11 12 13 14 15 16
import {
  X_DATA,
  LOCAL_INFECTED,
  PROVINCE_INNER_INFECTED,
  PROVINCE_OUT_INFECTED,
  OFFSHORE_INPUT_INFECTED,
hucy's avatar
hucy committed
17 18
  LABEL_DATA,
  COLOR_LIST,
hucy's avatar
hucy committed
19
} from './config';
hucy's avatar
hucy committed
20 21 22 23 24 25 26 27
import * as echarts from 'echarts';
type EChartsOption = echarts.EChartsOption;

var chartMain;
const chartMainRef = ref<any>(null);

onMounted(() => {
  initDom();
hucy's avatar
hucy committed
28 29 30
  let abc = false;
  let type = Object.prototype.toString.call(abc);
  console.log(type);
hucy's avatar
hucy committed
31 32 33 34 35 36 37 38
});

function initDom() {
  chartMain = echarts.init(chartMainRef.value);
  const option: EChartsOption = {
    tooltip: {
      trigger: 'axis',
    },
hucy's avatar
hucy committed
39
    color: COLOR_LIST,
hucy's avatar
hucy committed
40
    legend: {
hucy's avatar
hucy committed
41 42
      data: LABEL_DATA,
      show: true,
hucy's avatar
hucy committed
43 44
    },
    grid: {
hucy's avatar
hucy committed
45 46 47
      left: 80,
      right: 100,
      bottom: 80,
hucy's avatar
hucy committed
48 49 50 51 52 53
      top: 40,
      containLabel: true,
    },
    xAxis: {
      type: 'category',
      boundaryGap: false,
hucy's avatar
hucy committed
54
      data: X_DATA,
hucy's avatar
hucy committed
55 56 57 58 59 60
    },
    yAxis: {
      type: 'value',
    },
    series: [
      {
hucy's avatar
hucy committed
61
        name: LABEL_DATA[0],
hucy's avatar
hucy committed
62
        type: 'line',
hucy's avatar
hucy committed
63
        data: LOCAL_INFECTED,
hucy's avatar
hucy committed
64 65
      },
      {
hucy's avatar
hucy committed
66
        name: LABEL_DATA[1],
hucy's avatar
hucy committed
67
        type: 'line',
hucy's avatar
hucy committed
68
        data: PROVINCE_INNER_INFECTED,
hucy's avatar
hucy committed
69 70
      },
      {
hucy's avatar
hucy committed
71
        name: LABEL_DATA[2],
hucy's avatar
hucy committed
72
        type: 'line',
hucy's avatar
hucy committed
73
        data: PROVINCE_OUT_INFECTED,
hucy's avatar
hucy committed
74 75 76
      },

      {
hucy's avatar
hucy committed
77
        name: LABEL_DATA[3],
hucy's avatar
hucy committed
78
        type: 'line',
hucy's avatar
hucy committed
79
        data: OFFSHORE_INPUT_INFECTED,
hucy's avatar
hucy committed
80 81 82 83 84 85 86 87
      },
    ],
  };

  chartMain.setOption(option);
}
</script>
<template>
hucy's avatar
hucy committed
88
  <div class="box container-height">
hucy's avatar
hucy committed
89 90 91 92
    <div class="title">
      成都市新冠疫情 {{ X_DATA[X_DATA.length - 1] }} 新增情况
    </div>
    <div class="single-box">
hucy's avatar
hucy committed
93 94
      <div class="single" :style="{ color: COLOR_LIST[0] }">
        <div class="single-label">{{ LABEL_DATA[0] }}</div>
hucy's avatar
hucy committed
95 96 97 98
        <div class="single-value">
          + {{ LOCAL_INFECTED[LOCAL_INFECTED.length - 1] }}
        </div>
      </div>
hucy's avatar
hucy committed
99 100
      <div class="single" :style="{ color: COLOR_LIST[1] }">
        <div class="single-label">{{ LABEL_DATA[1] }}</div>
hucy's avatar
hucy committed
101 102 103 104
        <div class="single-value">
          + {{ PROVINCE_INNER_INFECTED[PROVINCE_INNER_INFECTED.length - 1] }}
        </div>
      </div>
hucy's avatar
hucy committed
105 106
      <div class="single" :style="{ color: COLOR_LIST[2] }">
        <div class="single-label">{{ LABEL_DATA[2] }}</div>
hucy's avatar
hucy committed
107 108 109 110
        <div class="single-value">
          + {{ PROVINCE_OUT_INFECTED[PROVINCE_OUT_INFECTED.length - 1] }}
        </div>
      </div>
hucy's avatar
hucy committed
111 112
      <div class="single" :style="{ color: COLOR_LIST[3] }">
        <div class="single-label">{{ LABEL_DATA[3] }}</div>
hucy's avatar
hucy committed
113 114 115 116 117
        <div class="single-value">
          + {{ OFFSHORE_INPUT_INFECTED[OFFSHORE_INPUT_INFECTED.length - 1] }}
        </div>
      </div>
    </div>
hucy's avatar
hucy committed
118
    <div class="content">
hucy's avatar
hucy committed
119
      <div class="chart-main" ref="chartMainRef"></div>
hucy's avatar
hucy committed
120 121 122 123 124
    </div>
  </div>
</template>

<style lang="scss" scoped>
hucy's avatar
hucy committed
125 126 127 128 129
.box {
  display: flex;
  flex-direction: column;
  flex-wrap: nowrap;
}
hucy's avatar
hucy committed
130 131 132 133 134 135
.title {
  text-align: center;
  margin: $padding-md auto;
  font-size: 26px;
  color: #414141;
}
hucy's avatar
hucy committed
136 137 138
.content {
  display: flex;
  justify-content: center;
hucy's avatar
hucy committed
139 140 141 142
  flex: 1;
  .chart-main {
    flex: 1;
  }
hucy's avatar
hucy committed
143
}
hucy's avatar
hucy committed
144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163
.single-box {
  display: flex;
  flex-direction: row;
  justify-content: center;
  align-items: center;
  margin: $padding-md;
  margin-bottom: 0;
}
.single {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  margin: 0 14px;
  .single-label {
    font-size: 12px;
  }
  .single-value {
    font-size: 20px;
  }
hucy's avatar
hucy committed
164 165
}
</style>