Skip to content

Commit 77e307f

Browse files
chore: improve graph responsiveness
Signed-off-by: Henry <mail@henrygressmann.de>
1 parent bf7c135 commit 77e307f

File tree

9 files changed

+275
-191
lines changed

9 files changed

+275
-191
lines changed

web/src/api/hooks.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,6 @@ export const useDimension = ({
108108
return { data: data?.data, biggest, order, isLoading, error };
109109
}, [data, isLoading, error]);
110110
};
111-
112111
export const useProjectGraph = ({
113112
projectId,
114113
metric,
@@ -127,16 +126,19 @@ export const useProjectGraph = ({
127126
staleTime = 0;
128127
}
129128
const dataPoints = range.getGraphDataPoints();
129+
const queryKey = ["project_graph", projectId, range.cacheKey(), metric, filters, dataPoints];
130130

131131
const {
132132
data: graph,
133133
isError,
134134
isLoading,
135+
isFetching,
136+
isPlaceholderData,
135137
} = useQuery({
136138
refetchInterval,
137139
staleTime,
138140
enabled: projectId !== undefined,
139-
queryKey: ["project_graph", projectId, range.cacheKey(), metric, filters, dataPoints],
141+
queryKey,
140142
queryFn: () =>
141143
api["/api/dashboard/project/{project_id}/graph"]
142144
.post({
@@ -154,10 +156,13 @@ export const useProjectGraph = ({
154156
placeholderData: (prev) => prev,
155157
});
156158

159+
const isUpdating = isFetching && isPlaceholderData;
160+
157161
return {
158162
graph,
159163
isLoading,
160164
isError,
165+
isUpdating,
161166
};
162167
};
163168

web/src/components/ThemeSwitcher.astro

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,6 @@ const { class: className, ...rest } = Astro.props;
7777
}
7878

7979
button.addEventListener("click", () => {
80-
console.log("click");
81-
8280
if (theme === "dark") {
8381
setTheme("light");
8482
sun.style.display = "block";

web/src/components/dimensions/dimensions.module.css

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
.card {
2-
padding-bottom: 0.6rem;
32
display: flex;
43
flex-direction: column;
54
margin-bottom: 0;

web/src/components/graph/graph.module.css

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,41 @@
77
}
88
}
99

10+
.graphContainer {
11+
flex: 1;
12+
width: 100%;
13+
height: 100%;
14+
position: relative;
15+
16+
.updatingOverlay {
17+
position: absolute;
18+
top: 0;
19+
left: 0;
20+
right: 0;
21+
bottom: 0;
22+
z-index: 1;
23+
opacity: 0;
24+
background-color: var(--pico-card-background-color);
25+
display: flex;
26+
justify-content: center;
27+
align-items: center;
28+
animation: fadeInOverlay 0.2s ease forwards 0.3s;
29+
30+
&[data-no-delay="true"] {
31+
animation-delay: 0s;
32+
}
33+
}
34+
}
35+
36+
@keyframes fadeInOverlay {
37+
from {
38+
opacity: 0;
39+
}
40+
to {
41+
opacity: 0.7;
42+
}
43+
}
44+
1045
.tooltip {
1146
background-color: var(--pico-secondary-background);
1247
padding: 0.4rem 0.5rem;

0 commit comments

Comments
 (0)