123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899 |
- <script setup>
- import { ref, watch, onMounted, onUnmounted } from 'vue';
- import * as echarts from 'echarts';
- import { getBarOptions } from '../config/echartOption';
- let chart = null;
- const echartRef = ref(null);
- const props = defineProps({
- screenData: {
- type: Object,
- default: []
- }
- })
- watch(() => props.screenData, (currentVal) => {
- const { no3Hlj1Jqr, no3Hlj2Jqr, nh31Jqr, nh32Jqr, tpRccJqr } = currentVal;
- const options = [ no3Hlj1Jqr, no3Hlj2Jqr, nh31Jqr, nh32Jqr, tpRccJqr ].map(item => {
- return item ? Number(item.toFixed(2)) : 0;
- })
- chart.setOption( getBarOptions(options) )
- })
- const windowResize = () => {
- chart.resize();
- }
- onMounted(() => {
- chart = echarts.init(echartRef.value, 'light');
- window.addEventListener("resize", windowResize);
- })
- onUnmounted(() => {
- window.removeEventListener("resize", windowResize);
- })
- </script>
- <template>
- <div class="home-box echart-box">
- <div class="home-box-top">
- <div class="title">连续检测</div>
- </div>
- <div class="main">
- <ul class="legeng_inner space-x-[3rem]">
- <li class="item space-x-[0.6rem]">
- <span class="square-icon border-[#FF6737]"><i class="bg-[#FF6737]"></i></span>
- <span>当前值</span>
- </li>
- <li class="item space-x-[0.6rem]">
- <span class="square-icon border-[#00AB84]"><i class="bg-[#00AB84]"></i></span>
- <span>范围值</span>
- </li>
- </ul>
- <div class="echart_inner">
- <div class="echart w-full h-full" ref="echartRef"></div>
- </div>
- </div>
- </div>
- </template>
- <style lang="scss" scoped>
- .echart-box {
- min-height: 30rem;
- .echart_inner {
- height: calc(100% - 5.6rem);
- }
- }
- .main {
- height: 100%;
- padding: 1.8rem 1.8rem 1.6rem;
- .legeng_inner {
- display: flex;
- align-items: center;
- justify-content: flex-end;
- color: #415B73;
- .item {
- display: flex;
- align-items: center;
- justify-content: center;
- font-size: 1.2rem;
- .square-icon {
- display: inline-block;
- padding: 0.1rem;
- border-width: 0.2rem;
- border-style: solid;
- background: #fff;
- i {
- display: block;
- width: 0.8rem;
- height: 0.8rem;
- }
- }
- }
- }
- }
- </style>
|