Skip to content

Commit 024d9c0

Browse files
committed
Fixed the SpeedChart.jsx displaying the server time
1 parent 77562bb commit 024d9c0

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

client/src/pages/Statistics/charts/SpeedChart.jsx

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,22 @@ const chartOptions = {
1717
};
1818

1919
const SpeedChart = (props) => {
20+
const testTime = localStorage.getItem("testTime") || 1;
2021
const chartData = {
21-
labels: props.labels,
22+
labels: testTime < 3 ? props.labels.map((label) => new Date(label).toLocaleTimeString([],
23+
{hour: "2-digit", minute: "2-digit"})) : props.labels.slice(1).map((label) =>
24+
new Date(label).toLocaleDateString()),
2225
datasets: [
23-
{label: t("latest.down"), data: props.data.download, borderColor: '#45C65A'},
24-
{label: t("latest.up"), data: props.data.upload, borderColor: '#456AC6'},
26+
{
27+
label: t("latest.down"),
28+
data: testTime < 3 ? props.data.download : props.data.download.slice(1),
29+
borderColor: '#45C65A'
30+
},
31+
{
32+
label: t("latest.up"),
33+
data: testTime < 3 ? props.data.upload : props.data.upload.slice(1),
34+
borderColor: '#456AC6'
35+
},
2536
],
2637
};
2738

0 commit comments

Comments
 (0)