1
0
mirror of https://github.com/ohwgiles/laminar.git synced 2024-10-27 20:34:20 +00:00

fix time scales in graphs

these were not correct at all
This commit is contained in:
Oliver Giles 2020-09-04 13:12:52 +12:00
parent 4e9c4bfb04
commit a793a97424

View File

@ -19,7 +19,7 @@ const timeScale = function(max){
return max > 3600 return max > 3600
? { scale:function(v){return Math.round(v/360)/10}, label:'Hours' } ? { scale:function(v){return Math.round(v/360)/10}, label:'Hours' }
: max > 60 : max > 60
? { scale:function(v){return Math.round(v/60)/10}, label:'Minutes' } ? { scale:function(v){return Math.round(v/6)/10}, label:'Minutes' }
: { scale:function(v){return v;}, label:'Seconds' }; : { scale:function(v){return v;}, label:'Seconds' };
} }
const ServerEventHandler = function() { const ServerEventHandler = function() {
@ -284,7 +284,7 @@ const Home = function() {
}}}]} }}}]}
} }
}); });
var tpjScale = timeScale(Math.max(Object.values(msg.timePerJob))); var tpjScale = timeScale(Math.max(...Object.values(msg.timePerJob)));
chtTimePerJob = new Chart(document.getElementById("chartTpj"), { chtTimePerJob = new Chart(document.getElementById("chartTpj"), {
type: 'horizontalBar', type: 'horizontalBar',
data: { data: {
@ -309,7 +309,7 @@ const Home = function() {
}}} }}}
} }
}); });
var btcScale = timeScale(Math.max(msg.buildTimeChanges.map((e)=>{return Math.max(e.durations)}))); const btcScale = timeScale(Math.max(...msg.buildTimeChanges.map(e=>Math.max(...e.durations))));
var chtBuildTimeChanges = new Chart(document.getElementById("chartBuildTimeChanges"), { var chtBuildTimeChanges = new Chart(document.getElementById("chartBuildTimeChanges"), {
type: 'line', type: 'line',
data: { data: {
@ -520,7 +520,7 @@ var Job = function() {
// old chart and recreate it to prevent flickering of old data // old chart and recreate it to prevent flickering of old data
if(chtBt) if(chtBt)
chtBt.destroy(); chtBt.destroy();
var btScale = timeScale(Math.max(msg.recent.map(v=>{v.completed-v.started}))); const btScale = timeScale(Math.max(...msg.recent.map(v=>v.completed-v.started)));
chtBt = new Chart(document.getElementById("chartBt"), { chtBt = new Chart(document.getElementById("chartBt"), {
type: 'bar', type: 'bar',
data: { data: {