Class GaugeSeries

java.lang.Object
com.codename1.ui.chart.Series
com.codename1.ui.chart.series.GaugeSeries

public class GaugeSeries extends Series

A gauge: one value on a curved scale, with optional coloured bands such as green / amber / red zones. The needle or the filled arc animates to each new value.

GaugeSeries cpu = new GaugeSeries("CPU", 0, 100).setValue(72);
cpu.addBand(0, 60, 0x009E73).addBand(60, 85, 0xE69F00).addBand(85, 100, 0xD55E00);

A gauge

  • Constructor Details

    • GaugeSeries

      public GaugeSeries(String name, double min, double max)

      Creates a gauge.

      Parameters
      • name: the label under the value

      • min: the start of the scale

      • max: the end of the scale

  • Method Details

    • isCartesian

      public boolean isCartesian()
      Description copied from class: Series
      True for series drawn against x and y axes; false for pies, treemaps and other series that fill the plot themselves.
      Specified by:
      isCartesian in class Series
    • setValue

      public GaugeSeries setValue(double v)

      Sets the value, animated from the current one.

      Parameters
      • v: the new value, clamped to the scale
      Returns

      this series

    • getValue

      public double getValue()
      The current value.
    • setRange

      public GaugeSeries setRange(double min, double max)

      Changes the scale. Ends given in the wrong order are swapped, so setRange(100, 0) is the scale from 0 to 100.

      Parameters
      • min: the start of the scale

      • max: the end of the scale

      Returns

      this series

    • getRangeMin

      public double getRangeMin()

      The start of the scale.

      Returns

      the smaller end

    • getRangeMax

      public double getRangeMax()

      The end of the scale.

      Returns

      the larger end

    • addBand

      public GaugeSeries addBand(double from, double to, int rgb)

      Adds a coloured zone to the scale.

      Parameters
      • from: where the zone starts

      • to: where the zone ends

      • rgb: its colour

      Returns

      this series

    • setSweep

      public GaugeSeries setSweep(double deg)

      The angle the scale spans; 180 is a semicircle, 240 the default, 360 a ring.

      Parameters
      • deg: the sweep in degrees
      Returns

      this series

    • setNeedle

      public GaugeSeries setNeedle(boolean n)

      Shows a needle over the bands instead of a filled arc.

      Parameters
      • n: true for a needle
      Returns

      this series

    • setUnit

      public GaugeSeries setUnit(String unit)

      Text appended to the value, such as "%" or " km/h".

      Parameters
      • unit: the suffix
      Returns

      this series

    • captureTransitionStart

      protected void captureTransitionStart()
      Description copied from class: Series
      Records the values currently on screen as the start of the next transition. Called by the chart before data changes; a subclass with animated data overrides it.
      Overrides:
      captureTransitionStart in class Series
    • captureEntryStart

      protected void captureEntryStart()
      Description copied from class: Series
      Records a zero baseline as the start of the entry animation.
      Overrides:
      captureEntryStart in class Series
    • paint

      public void paint(ChartContext ctx)
      Description copied from class: Series

      Paints the series.

      Parameters
      • ctx: the current frame: graphics, plot area, axes and animation progress
      Specified by:
      paint in class Series
    • hitTest

      public ChartPoint hitTest(ChartContext ctx, int x, int y, int radius)
      Description copied from class: Series

      Finds the data point nearest a screen position.

      Parameters
      • ctx: the frame the series was last painted in

      • x: chart relative x

      • y: chart relative y

      • radius: how far from the point a touch may land and still hit it

      Returns

      the point, or null

      Overrides:
      hitTest in class Series
    • getPointCount

      public int getPointCount()
      Description copied from class: Series
      The number of points along x, for a shared tooltip; -1 when not index aligned.
      Overrides:
      getPointCount in class Series
    • getPoint

      public ChartPoint getPoint(ChartContext ctx, int index)
      Description copied from class: Series
      The point at index for a shared tooltip, or null.
      Overrides:
      getPoint in class Series
    • collectTableRows

      public void collectTableRows(List<String[]> rows)
      Description copied from class: Series

      Adds this series' data to an accessible table, one {series, item, value} row per point. Used by Chart.toTable() and the chart's accessibility text.

      Parameters
      • rows: the list to append rows to
      Overrides:
      collectTableRows in class Series