No announcement yet.
  • Filter
  • Time
Clear All
new posts

    Updating Gauge Values and Sectors

    I'm using SmartClient_v121p_2020-04-14_PowerEdition. I have an application where the user clicks on a row in a ListGrid and a window is created with a Gauge component that is built based on the values in ListGrid record that I am passing in. This works great. What I am having trouble with is that when a new row in the ListGrid is selected, I try to update the Gauge using the new values passed in. The code looks something like this:

    // Update gauge
    let gaugeSectors = [
       {value: record.value, fillColor: "green"},
       {value: record.maxValue, fillColor: "green"}
    When the gauge refreshes, the minValue is incorrect. If I click the same record in the grid (so that the gauge refreshes with the same values), it draws correctly. I've been able to reproduce this in the Feature Explorer. To reproduce, go to the Gauge example in the Feature Explorer.

    Replace the code in the click function of the "Add Sector" button with this:

    var sectors = [{value: 2790, fillColor: "green"}, {value: 3000, fillColor: "green"}];
    Try it. Click the "Add Sector" button to see the gauge update incorrectly. Min value is 99. Click the "Add Sector" a second time to see the gauge update correctly. Min value is now 2700, as expected.

    I know there has to be a minimum of 1 sector. It seems as though setSectors isn't fully replacing the sectors at first.

    Thanks for any insight you can provide.

    This is an order-of-operations issue - you can fix it by just setting the max before setting the min.

    We'll address it in the framework in the coming days.


      The behavior was not consistent depending on the new values being displayed, which had baffled me. This was just one use case that I could reproduce consistently. When I added in that workaround, it fixed several cases, but I still saw some issues. After further testing, this is what I discovered:
      1. If the previous minValue is LOWER than the current minValue, then you have to set maxValue first
      2. If the previous minValue is HIGHER than the current minValue, then you have to set minValue first.
      With you having said that there is an order of operations issue, then this makes sense. This workaround seems to cover the bases for me.

      Thanks so much for your assistance!


        This behavior, while a bit weird, is actually documented on both setMinValue() and setMaxValue() - your sure-fire workaround right now would be to set one of the values twice - set min, max, min - or max, min, max.

        We'll likely add an API that accepts both values in a single call, and we'll update here if we do.
        Last edited by Isomorphic; 2 Apr 2021, 08:36.


          Note that we've added Gauge.setValueRange(min, max) in 13.0 - for previous versions, just use the workaround in post #4