Commit 3edaf511 authored by William Damgaard Lauritzen's avatar William Damgaard Lauritzen
Browse files

Fixer

parent d4f7dd61
const chartCtx = document.querySelector('#issues-chart')
function makeData (data) {
const labels = []
const issues = []
const avgTime = []
let totalStepTime = {}
let issueCounter = {}
for (let i = 0; i < data.length; i++) {
const step = data[i].step
let startTime = new Date(data[i].start_time)
let endTime = new Date(data[i].end_time)
// Increment count if it already has a count
if (issueCounter[step]) {
issueCounter[step] += 1
totalStepTime[step] += endTime - startTime
} else {
// If a step has no issue count
issueCounter[step] = 1
totalStepTime[step] = endTime - startTime
}
}
for (let step in issueCounter) {
issues.push(issueCounter[step])
avgTime.push((totalStepTime[step] / issueCounter[step]) / 60000)
labels.push(step)
}
return { labels, issues, avgTime }
}
function makeChart (data) {
const dataset = makeData(data)
let chart = new Chart(chartCtx, {
type: 'bar',
data: {
labels: dataset.labels,
datasets: [{
label: 'Antal problemer',
data: dataset.issues,
backgroundColor: 'gold'
}, {
label: 'Gennemsnitlig tid (Min)',
data: dataset.avgTime,
type: 'line',
backgroundColor: '#113657',
fill: false,
hidden: true
}]
},
options: {
barValueSpacing: 20,
title: {
display: true,
text: 'Help Indicator'
},
responsive: true,
scales: {
xAxes: [{
stacked: false
}],
yAxes: [{
stacked: false,
ticks: {
beginAtZero: true
}
}]
}
}
})
}
......@@ -11,63 +11,10 @@
</div>
<script src="/js/Chart.min.js"></script>
<script src="/js/chart.js"></script>
<script>
const chartCtx = document.querySelector('#issues-chart')
function makeData (data) {
const labels = []
const issues = []
let issueCounter = {}
let time = {}
for (let i = 0; i < data.length; i++) {
const step = data[i].step
// Increment count if it already has a count
if (issueCounter[step]) {
issueCounter[step] = issueCounter[step] += 1
} else {
// If a step has no issue count
issueCounter[step] = 1
}
}
for (let step in issueCounter) {
issues.push(issueCounter[step])
labels.push(step)
}
return { labels, issues }
}
function makeChart (data) {
const dataset = makeData(data)
let chart = new Chart(chartCtx, {
type: 'bar',
data: {
labels: dataset.labels,
datasets: [{
label: 'Problemer',
data: dataset.issues,
backgroundColor: 'gold'
}]
},
options: {
title: {
display: true,
text: 'Help Indicator'
},
responsive: true,
scales: {
xAxes: [{
stacked: true
}],
yAxes: [{
stacked: true
}]
}
}
})
}
const dataset = [{{#each issues}}{ id: '{{this.id}}', experiment_id: '{{this.experiment_id}}', hardware_id: '{{this.hardware_id}}', step: {{this.step}}, start_time: '{{this.start_time}}', end_time: '{{this.end_time}}' }{{#unless @last}}, {{/unless}}{{/each}}]
makeChart(dataset)
const data = [{{#each issues}}{ id: '{{this.id}}', experiment_id: '{{this.experiment_id}}', hardware_id: '{{this.hardware_id}}', step: {{this.step}}, start_time: '{{this.start_time}}', end_time: '{{this.end_time}}' }{{#unless @last}}, {{/unless}}{{/each}}]
makeChart(data)
</script>
{{else}}
<p>Det ser ud til at der ikke var nogen problemer under eksperimentets forløb.</p>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment