Skip to content

Commit

Permalink
error message
Browse files Browse the repository at this point in the history
  • Loading branch information
alikirec committed Dec 2, 2024
1 parent 0ec2c9a commit a9402aa
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 14 deletions.
36 changes: 22 additions & 14 deletions data.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,20 +60,28 @@ const options = {
};

(async function () {
const result = await loadClientConfig();
try {
const result = await loadClientConfig();

const ctx = document.getElementById("data");
const ctx = document.getElementById("data");

new Chart(ctx, {
type: "line",
options: options,
data: {
labels: result.map((item) => item.labels),
datasets: [
{
data: result.map((item) => item.data)
}
]
}
});
new Chart(ctx, {
type: "line",
options: options,
data: {
labels: result.map((item) => item.labels),
datasets: [
{
data: result.map((item) => item.data)
}
]
}
});
} catch {
const body = document.querySelector("body");
const message = document.createElement("p");
message.classList.add("error");
message.innerHTML = "Please run this page in a formsort flow.";
body.prepend(message);
}
})();
1 change: 1 addition & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" href="./styles.css" />
<title>Chart.js</title>
</head>
<body>
Expand Down
5 changes: 5 additions & 0 deletions styles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
p.error {
color: red;
font-size: 1.5em;
text-align: center;
}

0 comments on commit a9402aa

Please sign in to comment.