Skip to content
This repository was archived by the owner on Jun 6, 2023. It is now read-only.

Commit 9a881e4

Browse files
author
gitgitWi
committed
Feat/Component: add Loading Component
1 parent 97de710 commit 9a881e4

File tree

3 files changed

+65
-10
lines changed

3 files changed

+65
-10
lines changed

src/components/highcharts/TreemapChart.vue

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
:current-category.sync="currentDataKey"
55
@click-button="tabButtonClickHandler"
66
/>
7+
<loading-component v-if="isLoading" />
78
<highcharts
9+
v-else
810
id="container"
911
:options="chartOptions"
1012
:deep-copy-on-update="true"
@@ -23,17 +25,19 @@ import {
2325
import { getChartOptions } from "@/components/highcharts/options";
2426
import { refineSectorData } from "@/components/highcharts/utils";
2527
28+
import { LoadingComponent } from "@/components/loading";
2629
import CategoryTab from "./CategoryTab.vue";
2730
2831
export default Vue.extend({
2932
name: "TreemapChart",
3033
31-
components: { CategoryTab },
34+
components: { CategoryTab, LoadingComponent },
3235
33-
data(): Record<string, unknown> {
36+
data() {
3437
return {
3538
chartOptions: {},
3639
currentDataKey: DataKeys.KosdaqBlue,
40+
isLoading: true,
3741
};
3842
},
3943
@@ -47,19 +51,19 @@ export default Vue.extend({
4751
const category =
4852
categoryKeys.find((key) => dataKey.toLowerCase().includes(key)) ?? `ko`;
4953
54+
const dataPromise =
55+
dummyDataMap?.[category] ??
56+
Promise.all([dummyDataMap.kospi, dummyDataMap.kosdaq]);
57+
5058
// @ts-ignore
51-
const data = refineSectorData(
52-
(await dummyDataMap?.[category]) ??
53-
(await Promise.all([dummyDataMap.kospi, dummyDataMap.kosdaq])).flat(
54-
1
55-
),
56-
{ dataKey }
57-
);
59+
const data = refineSectorData((await dataPromise).flat(), { dataKey });
60+
if (!data.length) return;
5861
5962
this.chartOptions = getChartOptions(data);
63+
this.isLoading = false;
6064
},
6165
62-
tabButtonClickHandler(dataKey: string) {
66+
tabButtonClickHandler(dataKey: DataKeys) {
6367
this.currentDataKey = dataKey;
6468
this.loadChartData();
6569
},

src/components/loading/Loading.vue

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<template>
2+
<section>데이터를 가져오는 중입니다...!!</section>
3+
</template>
4+
5+
<script lang="ts">
6+
import Vue from "vue";
7+
export default Vue.extend({
8+
name: "LoadingComponent",
9+
});
10+
</script>
11+
12+
<style lang="scss" scoped>
13+
section {
14+
box-sizing: border-box;
15+
width: 75vw;
16+
max-width: 1200px;
17+
height: 40vh;
18+
max-height: 1200px;
19+
margin: 15px;
20+
21+
display: grid;
22+
place-content: center;
23+
24+
color: rgba(255, 255, 255, 0.9);
25+
font-weight: 900;
26+
font-style: italic;
27+
background-image: linear-gradient(
28+
to right,
29+
rgba(0, 0, 0, 0.2),
30+
rgba(0, 0, 0, 0.8)
31+
);
32+
background-size: 500% 500%;
33+
border-radius: 15px;
34+
animation: gradient 4s ease-in-out infinite;
35+
36+
@keyframes gradient {
37+
0% {
38+
background-position: 0% 50%;
39+
}
40+
50% {
41+
background-position: 100% 50%;
42+
}
43+
100% {
44+
background-position: 0% 50%;
45+
}
46+
}
47+
}
48+
</style>

src/components/loading/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import { VueType } from "@/types";
2+
3+
export const LoadingComponent = (): Promise<VueType> => import("./Loading.vue");

0 commit comments

Comments
 (0)