progress bar

HI All, 

I have manged to get a countdown progress bar working in my glance view. However, I am now trying to get it to show a countdown or progress too depending on values

the code to draw the countdown bar is 

  function drawProgress(dc, value, maxvalue, codeColor) {
      var h = dc.getHeight();
      var w = dc.getWidth();

      dc.setColor(Graphics.COLOR_DK_GRAY, Graphics.COLOR_TRANSPARENT);
      dc.fillRectangle(value * w / maxvalue + (h / 20), h / 2 - 1, w, h / 20);
      dc.setColor(Colour, Graphics.COLOR_TRANSPARENT);
      dc.fillRectangle(0, h / 2 - (h / 20), value * w / maxvalue, h / 10 + 1);
  }

its is called by 

 drawProgress(dc, value, maxvalue, Colour);

I expect this to be simple but again am unable to fathom, how I make the function show progress towards the maxvalue instead of effectively counting down from max to 0

  • I'm not sure your problem there are 2 cases

    min|------    |max

    min|     -----|max

    are you talking about second case?

  • Currently it does

    min|<<<<——|max (bar reduces)

    i would also like

    min|>>>>——|max (bar to increase)

    Hope that clarifies 

    thanks

  • unfortunately not :)

    you have always min|----   |max progress and want to draw current level?

    min|-----   |max

    min|--       |max

    min|-----   |max

  • might be over simplifying this but do you just need to change the (Maxvalue-Value) *w does your value increase or decrease i.e starts at 0 ends at 100 or starts at 100 and then goes to 0?

      function drawProgress(dc, value, maxvalue, codeColor) {
          var h = dc.getHeight();
          var w = dc.getWidth();
    
          dc.setColor(Graphics.COLOR_DK_GRAY, Graphics.COLOR_TRANSPARENT);
          dc.fillRectangle(value * w / maxvalue + (h / 20), h / 2 - 1, w, h / 20);
          dc.setColor(Colour, Graphics.COLOR_TRANSPARENT);
          dc.fillRectangle(0, h / 2 - (h / 20),(maxvalue-value) * w / maxvalue, h / 10 + 1);
      }

  • Thanks Robin, knew it would be simple.