组件调整

This commit is contained in:
zhaotiantian
2023-12-11 18:28:52 +08:00
parent d4f668548c
commit e449d5687b
7 changed files with 349 additions and 328 deletions
@@ -1,56 +1,56 @@
<template>
<div>
<public-title title="步数" />
<div class="inner" ref="healthChart"></div>
</div>
<div>
<public-title title="步数"/>
<div class="inner" ref="healthChart"></div>
</div>
</template>
<script setup lang="ts">
import { ref, unref, onMounted } from 'vue';
import * as echarts from 'echarts';
import PublicTitle from '/@/components/publicTitle.vue';
import { getHealthDataList } from '/@/components/body-d-right/right.api';
import { useSpin } from '/@/components/body-d-left/bodyLeftHooks.ts';
import { useHealth } from '/@/components/secondaryScreen/screen-right/screenRightHooks.ts';
import { screenPie } from '/@/components/item-d/pieCharts.ts';
import {ref, unref, onMounted} from 'vue';
import * as echarts from 'echarts';
import PublicTitle from '/@/components/publicTitle.vue';
import {getHealthDataList} from '/@/components/body-d-right/right.api';
import {useSpin} from '/@/components/body-d-left/bodyLeftHooks.ts';
import {useHealth} from '/@/components/secondaryScreen/screen-right/screenRightHooks.ts';
import {screenPie} from '/@/components/item-d/pieCharts.ts';
const { setSpin, spinning } = useSpin();
const healthChart = ref<HTMLElement>();
const {setSpin, spinning} = useSpin();
const healthChart = ref<HTMLElement>();
const color = ref(['#B750BE', '#6C63F0', '#3AACFF', '#ED589D', '#FB466C']);
onMounted(() => {
init();
});
const { healthData, getValue, setHealth } = useHealth();
const color = ref(['#B750BE', '#6C63F0', '#3AACFF', '#ED589D', '#FB466C']);
onMounted(() => {
init();
});
const {healthData, getValue, setHealth} = useHealth();
async function init() {
try {
const { code, result } = await getHealthDataList({});
setSpin(true);
if (code != 200) {
return;
}
setHealth(result);
const yData = unref(getValue);
let total = yData.reduce((accumulator, currentValue) => Number(accumulator) + Number(currentValue), 0);
initChart(unref(healthData), total);
} catch {
initChart(unref(healthData), 0);
}
async function init() {
try {
const {code, result} = await getHealthDataList({});
setSpin(true);
if (code != 200) {
return;
}
setHealth(result);
const yData = unref(getValue);
let total = yData.reduce((accumulator, currentValue) => Number(accumulator) + Number(currentValue), 0);
initChart(unref(healthData), '89');
} catch {
initChart(unref(healthData), 0);
}
}
function initChart(chartData, total) {
let myChart = echarts.init(healthChart.value);
let options = screenPie(chartData, total, color.value);
myChart.setOption(options);
window.addEventListener('resize', () => {
myChart.resize();
});
}
function initChart(chartData, total) {
let myChart = echarts.init(healthChart.value);
let options = screenPie(chartData, total, color.value, '{c}');
myChart.setOption(options);
window.addEventListener('resize', () => {
myChart.resize();
});
}
</script>
<style scoped lang="less">
.inner {
width: 100%;
margin: 0 auto;
height: calc(100% - 40px);
}
.inner {
width: 100%;
margin: 0 auto;
height: calc(100% - 40px);
}
</style>