Class ResultGauge

Object
AbstractPortletDto
ResultGauge
All Implemented Interfaces:
Serializable, Portlet, ComplexCalculationResult

public class ResultGauge extends AbstractPortletDto implements ComplexCalculationResult
The Gauge widget class implements a graphical speedometer-style gauge for displaying a measurement by means of a needle on a dial. The dial is divided into sectors, each having its own color and value.

In some views, the gauge is drawn as a horizontal bar with a marker instead of the dial. The bar uses the same value, range and sectors.

Create an instance with api.newGauge() and return it from a logic element.

Example:


 def gauge = api.newGauge()
 gauge.setMin(0)
 gauge.setMax(100)
 gauge.setValue(37)
 gauge.addSector(20, "#FF0000")
 gauge.addSector(50, "#FFFF00")
 gauge.addSector(null, "#00FF00")

 return gauge
 
See Also:
  • Constructor Details

  • Method Details

    • getValue

      public BigDecimal getValue()
      The current value on the dial.
      Returns:
      The value set with setValue(BigDecimal), or 0 if it is not set.
    • setValue

      public void setValue(BigDecimal value)
      The current value on the dial.

      The gauge shows a value below the minimum dial value at the minimum, and a value above the maximum dial value at the maximum.

      Parameters:
      value - the new dial value. Default value is 0
    • getMin

      public BigDecimal getMin()
      The minimum dial value.
      Returns:
      The minimum dial value set with setMin(BigDecimal).
    • setMin

      public void setMin(BigDecimal minValue)
      The minimum dial value.
      Parameters:
      minValue - the new minimum dial value. If it is not set, the gauge uses 0.
    • getMax

      public BigDecimal getMax()
      The maximum dial value.
      Returns:
      The maximum dial value set with setMax(BigDecimal).
    • setMax

      public void setMax(BigDecimal maxValue)
      The maximum dial value.
      Parameters:
      maxValue - the new maximum dial value. If it is not set, the gauge uses 100.
    • addSector

      public void addSector(BigDecimal upperBound, String color)
      Adds a colored sector to the dial.

      Sectors are drawn in the order they are added. The first sector starts at the minimum dial value, and each next sector starts where the previous one ends. Use null as the upper bound of the last sector to extend it to the maximum dial value.

      Parameters:
      upperBound - The dial value where the sector ends, or null to end it at the maximum dial value.
      color - The CSS color of the sector, for example "#FF0000".
    • getSectors

      public List<Map<String,Object>> getSectors()
      Returns the sectors added with addSector(BigDecimal, String).
      Returns:
      The sectors in the order they were added. Each sector is a map with these keys:
      • upperBound: the dial value where the sector ends, or null
      • color: the CSS color of the sector
    • getSuffix

      public String getSuffix()
      Returns the tooltip suffix set with setSuffix(String).
      Returns:
      The tooltip suffix.
    • setSuffix

      public void setSuffix(String suffix)
      Sets the tooltip suffix, the text after the value in the tooltip of the dial.

      The tooltip does not show the suffix at the moment. It always shows the value without a suffix.

      Parameters:
      suffix - the new tooltip suffix.
    • getPrefix

      public String getPrefix()
      Returns the tooltip prefix set with setPrefix(String).
      Returns:
      The tooltip prefix.
    • setPrefix

      public void setPrefix(String prefix)
      Sets the tooltip prefix, the text before the value in the tooltip of the dial.

      The value label on the dial and the bar do not show the prefix.

      Parameters:
      prefix - the new tooltip prefix. If it is not set, the tooltip shows no prefix.
    • getResultType

      public String getResultType()
      Returns the result type of the gauge.
      Specified by:
      getResultType in interface ComplexCalculationResult
      Returns:
      Always "GAUGE".