I have Power Level Sensor.I want to set different colors based on the different conditions.The conditions are:
if (var1>var2):
enable green color
elif(var1<var3):
enable red color
elif(var3<var1<var2):
enable orange color
I wrote the code for that:
var g1 = new JustGage({
id: "g1",
value:0,
min: 0,
max: 50000,
label: "SSTR",
title: "Ant-1 SSTR",
customSectors : [{"lo":var2,"hi":var1,"color":"#3aa914"},
{"lo":var1,"hi":var3,"color":"#FF0000"},
{"lo":var3,"hi":var2,"color":"#FFA500"}],
levelColorsGradient: false
});
and calling justgage function for every millisecond.The var1,var2 and var3 are the global variables.
setInterval((function () {
g1.refresh(var1);
}), 1000);
Is this is the right approach? Can we pass more than one argument(like color,id) to justgage refresh function?
How can I set the different colors in the gustgage based on different conditions?