Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
V
visualizer-echarts
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Owen Graham
visualizer-echarts
Commits
3299bcd9
Verified
Commit
3299bcd9
authored
1 year ago
by
Owen Graham
Browse files
Options
Downloads
Patches
Plain Diff
Alert the user when data fails loading
parent
2b6c08a6
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
visualizer/static/visualizer.js
+12
-3
12 additions, 3 deletions
visualizer/static/visualizer.js
with
12 additions
and
3 deletions
visualizer/static/visualizer.js
+
12
−
3
View file @
3299bcd9
...
...
@@ -160,8 +160,14 @@ async function getData(name, year) {
const
key
=
JSON
.
stringify
([
name
,
year
]);
let
data
=
cachedData
[
key
];
if
(
data
===
undefined
)
{
data
=
await
fetchData
(
`
${
SCRIPT_ROOT
}
/data.cgi?station=
${
name
}
&year=
${
year
}
`
);
try
{
data
=
await
fetchData
(
`
${
SCRIPT_ROOT
}
/data.cgi?station=
${
name
}
&year=
${
year
}
`
);
}
catch
(
err
)
{
console
.
error
(
err
);
alert
(
`Error fetching data for
${
name
}
,
${
year
}
`
);
data
=
[];
}
cachedData
[
key
]
=
data
;
}
return
data
;
...
...
@@ -169,7 +175,10 @@ async function getData(name, year) {
async
function
fetchData
(
jsonURL
)
{
const
res
=
await
fetch
(
jsonURL
);
return
await
res
.
json
();
if
(
res
.
ok
)
{
return
await
res
.
json
();
}
throw
new
Error
(
'
response not OK
'
);
}
async
function
switchToSelected
()
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment