From bfde2e04210e9f8c8e470801ec6cdc668063db59 Mon Sep 17 00:00:00 2001 From: jbruce Date: Tue, 15 Nov 2022 10:46:00 -0500 Subject: [PATCH] fix ticks to be even hours/mins/secs on graph --- config.py | 2 +- public/assets/js/picoreflow.js | 70 +++++++++++++++++++++++++++------- 2 files changed, 57 insertions(+), 15 deletions(-) diff --git a/config.py b/config.py index 77d3736..3909e03 100644 --- a/config.py +++ b/config.py @@ -107,7 +107,7 @@ sim_R_ho_air = 0.05 # K/W " with internal air circulation temp_scale = "f" # c = Celsius | f = Fahrenheit - Unit to display time_scale_slope = "h" # s = Seconds | m = Minutes | h = Hours - Slope displayed in temp_scale per time_scale_slope -time_scale_profile = "m" # s = Seconds | m = Minutes | h = Hours - Enter and view target time in time_scale_profile +time_scale_profile = "h" # s = Seconds | m = Minutes | h = Hours - Enter and view target time in time_scale_profile # emergency shutoff the profile if this temp is reached or exceeded. # This just shuts off the profile. If your SSR is working, your kiln will diff --git a/public/assets/js/picoreflow.js b/public/assets/js/picoreflow.js index 95c6ede..3666579 100644 --- a/public/assets/js/picoreflow.js +++ b/public/assets/js/picoreflow.js @@ -188,23 +188,51 @@ function hazardTemp(){ } } -function timeTickFormatter(val) +function timeTickFormatter(val,axis) { - if (val < 1800) - { - return val; - } - else - { - var hours = Math.floor(val / (3600)); - var div_min = val % (3600); - var minutes = Math.floor(div_min / 60); +console.log(val) - if (hours < 10) {hours = "0"+hours;} - if (minutes < 10) {minutes = "0"+minutes;} +// hours +if(axis.max>3600) { + //var hours = Math.floor(val / (3600)); + //return hours; + return Math.floor(val/3600); + } - return hours+":"+minutes; - } +// minutes +if(axis.max<=3600) { + return Math.floor(val/60); + } + +// seconds +if(axis.max<=60) { + return val; + } + + +//var div_min = val % (3600); +//var minutes = Math.floor(div_min / 60); + + +//if(val < 60) { return "0:00:" + ("00"+val).slice(-3);} +//if(val > 60 and val < 3600) { return "0: + +// if (val < 1800) +// { +// return val; +// } +// else +// { +// var hours = Math.floor(val / (3600)); +// var div_min = val % (3600); +// var minutes = Math.floor(div_min / 60); + +// if (hours < 10) {hours = "0"+hours;} +// if (minutes < 10) {minutes = "0"+minutes;} + + //return hours+":"+minutes; +// return hours+":00"; +// } } function runTask() @@ -366,6 +394,19 @@ function saveProfile() leaveEditMode(); } +function get_tick_size() { +switch(time_scale_profile){ + case "s": + return 1; + case "m": + return 60; + case "h": + return 3600; + } +return 3600; +} + + function getOptions() { @@ -395,6 +436,7 @@ function getOptions() min: 0, tickColor: 'rgba(216, 211, 197, 0.2)', tickFormatter: timeTickFormatter, + tickSize: get_tick_size(), font: { size: 14,