Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to set the colors in the justgage based on different conditions? #314

Closed
Tirumala7 opened this issue Mar 22, 2018 · 1 comment
Closed

Comments

@Tirumala7
Copy link

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.These are not constants.

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?
I tried g1.update function also,but i got the error like g1.update is not a function.
This g1.update function given in the custom-sectors.html .This html is also showing update is not a function.
Please help!

@robertsLando
Copy link
Collaborator

ATM the only way to do this is by destroy and recreate a new gauge when customSector changes, in next release we will implement #241 that will allow you to do this kind of things

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants