Class Annotation

java.lang.Object
com.codename1.ui.chart.Annotation

public final class Annotation extends Object

A reference line, shaded band or label laid over a cartesian chart: a target, a threshold, a weekend, a release date.

Chart chart = new Chart();
double start = 2, end = 4;
chart.addAnnotation(Annotation.valueLine(100, "Target"));
chart.addAnnotation(Annotation.xBand(start, end, "Outage").setColor(0xEF5350));

A value line, a value band and an x band

  • Method Details

    • valueLine

      public static Annotation valueLine(double value, String label)
      A line across the plot at a value.
    • valueBand

      public static Annotation valueBand(double from, double to, String label)
      A shaded band between two values.
    • xLine

      public static Annotation xLine(double x, String label)
      A line across the plot at an x position (a date, a category index).
    • xBand

      public static Annotation xBand(double from, double to, String label)
      A shaded band between two x positions.
    • setColor

      public Annotation setColor(int rgb)
      Sets the colour; the theme's axis colour by default.
    • setDashed

      public Annotation setDashed(boolean dashed)
      Draws a line solid instead of dashed.
    • setBehindSeries

      public Annotation setBehindSeries(boolean behind)
      Draws behind the series instead of over them; bands default to behind.
    • setIncludeInRange

      public Annotation setIncludeInRange(boolean include)
      Whether a value line or band widens the value axis so it is always visible.
    • setSecondaryAxis

      public Annotation setSecondaryAxis(boolean secondary)
      Measures a value line or band against the chart's secondary y axis, for a threshold that belongs to a series drawn on that axis.