Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
covid
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
2
Issues
2
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Michał Woźniak
covid
Commits
85a50d83
Commit
85a50d83
authored
Apr 25, 2020
by
Michał Woźniak
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bugfix
parent
2198ea05
Pipeline
#214
passed with stage
in 1 second
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
10 deletions
+22
-10
covid.js
covid.js
+22
-10
No files found.
covid.js
View file @
85a50d83
...
...
@@ -1285,6 +1285,9 @@ let chart = () => {
theChart
.
newLegend
=
legend
;
Chart
.
layoutService
.
addBox
(
theChart
,
legend
);
theChart
.
update
()
// prepare the new_datasets object
theChart
.
data
.
new_datasets
=
[]
// set the update timeout thingy
theChart
.
updateTimeout
=
false
...
...
@@ -1422,18 +1425,18 @@ let updateChartData = (siteSelect) => {
}
// assign the data to the chart
theChart
.
data
.
datasets
[
siteSelect
.
siteNo
+
3
]
=
to_chart
theChart
.
data
.
new_datasets
[
siteSelect
.
siteNo
]
=
to_chart
// if we have some undefined elements in the chart's data array
// that means that not all data is in yet -- bail!
if
(
theChart
.
data
.
datasets
.
includes
(
undefined
))
{
if
(
theChart
.
data
.
new_
datasets
.
includes
(
undefined
))
{
return
;
}
// update the chart settings
clearTimeout
(
theChart
.
updateTimeout
)
theChart
.
updateTimeout
=
setTimeout
(
updateChartSettings
,
100
)
}
// update the chart settings
clearTimeout
(
theChart
.
updateTimeout
)
theChart
.
updateTimeout
=
setTimeout
(
updateChartSettings
,
250
)
}
...
...
@@ -1442,6 +1445,10 @@ let updateChartData = (siteSelect) => {
* based on datasets we have
*/
let
updateChartSettings
=
()
=>
{
// make sure to cancel any other updates to the chart
clearTimeout
(
theChart
.
updateTimeout
)
theChart
.
updateTimeout
=
false
// if *any* of the sitesSelects are still fetching data, bail out
for
(
let
sselect
of
sitesSelects
)
{
...
...
@@ -1488,7 +1495,7 @@ let updateChartSettings = () => {
// find the maximums and minimums
var
max_data_points
=
20
;
theChart
.
data
.
datasets
.
slice
(
3
)
.
forEach
((
d
)
=>
{
theChart
.
data
.
new_datasets
.
forEach
((
d
)
=>
{
d_max
=
Math
.
max
(...
d
.
data
)
d_min
=
Math
.
min
(...
d
.
data
)
if
(
d_max
>
max_cases
)
{
...
...
@@ -1587,7 +1594,7 @@ let updateChartSettings = () => {
// set the x-axis length
if
(
chart_start_setting
===
"
date
"
)
{
theChart
.
data
.
labels
=
siteData
[
'
Global
'
].
data
.
slice
(
-
1
*
theChart
.
data
.
datasets
[
3
].
data
.
length
).
map
(
d
=>
d
.
date
)
theChart
.
data
.
labels
=
siteData
[
'
Global
'
].
data
.
slice
(
-
1
*
theChart
.
data
.
new_datasets
[
0
].
data
.
length
).
map
(
d
=>
d
.
date
)
}
else
{
theChart
.
data
.
labels
=
genArr
(
1
,
max_data_points
,
1
)
}
...
...
@@ -1605,6 +1612,11 @@ let updateChartSettings = () => {
// while data for (n-1)th is still undefined
// in which case theChart.update() will fail
try
{
// set the new datasets as datasets
theChart
.
data
.
new_datasets
.
forEach
((
el
,
idx
)
=>
{
theChart
.
data
.
datasets
[
idx
+
3
]
=
theChart
.
data
.
new_datasets
[
idx
]
})
// update the chart
theChart
.
update
();
}
catch
(
e
)
{}
}
...
...
@@ -2072,8 +2084,8 @@ document.addEventListener('DOMContentLoaded', (e)=>{
removeSite
.
addEventListener
(
'
click
'
,
(
ev
)
=>
{
ev
.
preventDefault
()
// update the chart
if
(
theChart
.
data
.
datasets
[
theChart
.
data
.
datasets
.
length
-
1
].
label
===
sitesSelects
[
sitesSelects
.
length
-
1
].
value
)
{
theChart
.
data
.
datasets
.
pop
()
if
(
(
theChart
.
data
.
new_datasets
.
length
>
0
)
&&
(
theChart
.
data
.
new_datasets
[
theChart
.
data
.
new_datasets
.
length
-
1
].
label
===
sitesSelects
[
sitesSelects
.
length
-
1
].
value
)
)
{
theChart
.
data
.
new_
datasets
.
pop
()
}
// if we have more than one site available
if
(
sitesSelects
.
length
>
1
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment