Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ITPDP2019
Gain.fam
web-server
Commits
85c7b118
Commit
85c7b118
authored
May 13, 2019
by
William Damgaard Lauritzen
Browse files
test
parent
fc6968c0
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/public/js/main.js
0 → 100644
View file @
85c7b118
'
use strict
'
/* global fetch Handlebars Chart */
let
myChartCtx
=
document
.
querySelector
(
'
#myChart
'
)
// Load page on startup.
updateChart
()
setInterval
(
function
()
{
updateChart
()
},
10000
)
function
updateChart
()
{
fetch
(
'
/api/experiments/bdce27fa-718a-11e9-9695-d07e350e43bd/issues
'
,
{
method
:
'
get
'
,
headers
:
{
'
Accept
'
:
'
application/json
'
}
}).
then
((
response
)
=>
{
response
.
json
().
then
((
data
)
=>
{
// Clear chart before reloading.
document
.
getElementById
(
'
chart-container
'
).
innerHTML
=
''
document
.
getElementById
(
'
chart-container
'
).
innerHTML
=
'
<canvas id="myChart"></canvas>
'
myChartCtx
=
document
.
getElementById
(
'
myChart
'
).
getContext
(
'
2d
'
)
makeMyChart
(
data
)
})
})
}
// Retrieve data.
function
makeMyData
(
data
)
{
const
labels
=
[]
const
issues
=
[]
let
counter
let
usedstep
for
(
let
i
of
data
)
{
// Iterate and group data
if
(
i
.
step
!==
usedstep
)
{
counter
=
0
usedstep
=
i
.
step
labels
.
push
(
i
.
step
)
for
(
let
j
of
data
)
{
if
(
usedstep
===
j
.
step
)
{
counter
++
}
}
issues
.
push
(
counter
)
}
}
return
{
labels
,
issues
}
}
function
makeMyChart
(
data
)
{
const
myData
=
makeMyData
(
data
)
const
myChart
=
new
Chart
(
myChartCtx
,
{
type
:
'
horizontalBar
'
,
data
:
{
labels
:
myData
.
labels
,
datasets
:
[{
label
:
'
Issues
'
,
data
:
myData
.
issues
,
backgroundColor
:
'
gold
'
}]
},
options
:
{
title
:
{
display
:
true
,
text
:
'
Help Indicator
'
},
responsive
:
true
,
scales
:
{
xAxes
:
[{
stacked
:
true
}],
yAxes
:
[{
stacked
:
true
}]
}
}
})
}
src/views/issues.hbs
View file @
85c7b118
<div
style=
"position: relative; height:40vh; width:80vw"
>
<canvas
id=
"myChart"
></canvas>
</div>
\ No newline at end of file
src/views/layouts/main.hbs
View file @
85c7b118
...
...
@@ -3,6 +3,8 @@
<head>
<meta
charset=
"UTF-8"
>
<link
rel=
"stylesheet"
href=
"/style/main.css"
>
<script
src=
"js/Chart.min.js"
></script>
<script
defer
src=
"js/main.js"
></script>
<title>
{{
meta
.
title
}}
</title>
</head>
<body>
...
...
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