Skip to content

Commit bb7c08a

Browse files
committed
fix: resold chart
1 parent eb3ada4 commit bb7c08a

File tree

2 files changed

+109
-5
lines changed

2 files changed

+109
-5
lines changed

Diff for: src/views/house/components/BarChart.vue

+16-5
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,15 @@
66
<b>{{ chartData.title.text }}</b>
77
</div>
88
<div class="title">
9-
<el-text>七日:{{ chartData.sevenDayAverage }}</el-text>
10-
<el-text>半月:{{ chartData.fifteenDayAverage }}</el-text>
11-
<el-text>近月:{{ chartData.thirtyDayAverage }}</el-text>
9+
<el-text v-if="displayTitle"
10+
>七日:{{ chartData.sevenDayAverage }}</el-text
11+
>
12+
<el-text v-if="displayTitle"
13+
>半月:{{ chartData.fifteenDayAverage }}</el-text
14+
>
15+
<el-text v-if="displayTitle"
16+
>近月:{{ chartData.thirtyDayAverage }}</el-text
17+
>
1218
<el-text>单位:{{ chartData.title.unit }}</el-text>
1319
</div>
1420
</template>
@@ -45,6 +51,7 @@ const props = defineProps({
4551
},
4652
});
4753
const chartData: ChartHouseDataVO = props.data as ChartHouseDataVO;
54+
const displayTitle = ref(false);
4855
console.log(chartData);
4956
const options = {
5057
grid: {
@@ -78,15 +85,15 @@ const options = {
7885
{
7986
type: "inside",
8087
xAxisIndex: [0, 1],
81-
start: 70,
88+
start: chartData.series[0].chatData.length < 30 ? 0 : 70,
8289
end: 100,
8390
},
8491
{
8592
show: true,
8693
xAxisIndex: [0, 1],
8794
type: "slider",
8895
top: "82%",
89-
start: 90,
96+
start: chartData.series[0].chatData.length < 30 ? 0 : 70,
9097
end: 100,
9198
},
9299
],
@@ -182,6 +189,10 @@ const options = {
182189
const chart = ref<any>("");
183190
onMounted(() => {
184191
console.log("图表初始化");
192+
// 是否初始化标题统计
193+
if (chartData.sevenDayAverage > 0) {
194+
displayTitle.value = true;
195+
}
185196
// 图表初始化
186197
chart.value = markRaw(
187198
echarts.init(document.getElementById(props.id) as HTMLDivElement)

Diff for: src/views/house/resold-mon/index.vue

+93
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
<template>
2+
<div class="app-container">
3+
<!-- Echarts 图表 -->
4+
<el-row :gutter="10" class="mt-3">
5+
<el-col :xs="24" :sm="24" :lg="24" class="mb-2" :key="chartId">
6+
<component
7+
v-if="!loading"
8+
:is="chartComponent(chartType)"
9+
:id="chartId"
10+
:data="chartHousedataList"
11+
height="400px"
12+
width="100%"
13+
class="bg-[var(--el-bg-color-overlay)]"
14+
/>
15+
</el-col>
16+
</el-row>
17+
</div>
18+
</template>
19+
20+
<script setup lang="ts">
21+
import type { EpPropMergeType } from "element-plus/es/utils/vue/props/types";
22+
defineOptions({
23+
name: "Dashboard",
24+
inheritAttrs: false,
25+
});
26+
27+
import { useUserStore } from "@/store/modules/user";
28+
import { useTransition, TransitionPresets } from "@vueuse/core";
29+
30+
import HouseAPI from "@/api/house";
31+
import { ChartHouseDataVO } from "@/api/house/model";
32+
33+
const loading = ref(true); // 加载状态
34+
const chartHousedataList = ref<ChartHouseDataVO>();
35+
const userStore = useUserStore();
36+
// 图表数据
37+
const chartType = ref("BarChart");
38+
const chartId = ref("ResoldArea");
39+
const chartComponent = (item: string) => {
40+
return defineAsyncComponent(() => import(`../components/${item}.vue`));
41+
};
42+
43+
async function handleQuery(dataType: number) {
44+
loading.value = true;
45+
await HouseAPI.getHouseData(dataType)
46+
.then((data) => {
47+
chartHousedataList.value = data as ChartHouseDataVO;
48+
})
49+
.finally(() => {
50+
loading.value = false;
51+
});
52+
}
53+
54+
onMounted(() => {
55+
handleQuery(7);
56+
});
57+
</script>
58+
59+
<style lang="scss" scoped>
60+
.app-container {
61+
position: relative;
62+
padding: 24px;
63+
64+
.user-avatar {
65+
width: 40px;
66+
height: 40px;
67+
border-radius: 50%;
68+
}
69+
70+
.github-corner {
71+
position: absolute;
72+
top: 0;
73+
right: 0;
74+
z-index: 1;
75+
border: 0;
76+
}
77+
78+
.data-box {
79+
display: flex;
80+
justify-content: space-between;
81+
padding: 20px;
82+
font-weight: bold;
83+
color: var(--el-text-color-regular);
84+
background: var(--el-bg-color-overlay);
85+
border-color: var(--el-border-color);
86+
box-shadow: var(--el-box-shadow-dark);
87+
}
88+
89+
.svg-icon {
90+
fill: currentcolor !important;
91+
}
92+
}
93+
</style>

0 commit comments

Comments
 (0)