Class ChartSeries

java.lang.Object
limn.components.chart.ChartSeries

public final class ChartSeries extends Object
One named run of values: a bar series, a line, or (in a DonutChart) the ring itself. The values are indexed against the chart's labels: value i belongs to category i, and a series shorter than the label list simply has no value for the categories past its end.

Double.NaN is a gap, not a zero: a line breaks across it and a bar is not drawn for it. That is the difference between "we measured nothing" and "we measured zero", and the two must not look the same.

Every setter here reaches back into the chart holding the series, so changing a series after the chart is on screen animates and repaints exactly like changing it through the chart. UI thread only, like every other widget mutation.


 ChartSeries revenue = ChartSeries.of("Revenue", 12, 19, 3, 5)
         .setStack("2026")        // bar: which stack this belongs to
         .setFilled(true);        // line: fill the area under it
 
  • Method Details

    • of

      public static ChartSeries of(String name, double... values)
      A series named name over values.
    • of

      public static ChartSeries of(I18nString name, double... values)
      A series whose name follows the UI language; see I18nString.
    • name

      public String name()
      The name as it currently reads, in the legend and in tooltip rows.
    • nameSource

      public I18nString nameSource()
      The localizable value behind name(), which a language change re-resolves.
    • setName

      public ChartSeries setName(String value)
      Renames the series.
    • setName

      public ChartSeries setName(I18nString value)
      Renames the series with a value that follows the UI language.
    • size

      public int size()
      How many values this series carries.
    • value

      public double value(int index)
      The value at index, or Double.NaN when the series is shorter than that, which reads as a gap, exactly like an explicit NaN.
    • values

      public double[] values()
      The values, copied.
    • setValues

      public ChartSeries setValues(double... newValues)
      Replaces the values. The chart animates from what is currently drawn to the new numbers, so a live series can be re-pushed as often as its data arrives.
    • color

      public Color color()
      The color the application pinned, or null while the palette decides.
    • setColor

      public ChartSeries setColor(Color value)
      Pins this series' color; null hands it back to the chart's palette.
    • stack

      public String stack()
      The stack this series belongs to in a stacked bar chart, or in a stacked line chart. Series sharing a key stack on top of each other; different keys stand side by side. Default "": one stack for everything.
    • setStack

      public ChartSeries setStack(String key)
      Sets the stack key.
    • isVisible

      public boolean isVisible()
      Whether this series is drawn; the legend toggles it.
    • setVisible

      public ChartSeries setVisible(boolean value)
      Shows or hides the series. The marks fade out and, in a stacked chart, the stack re-flows around them; the scale is recomputed from what is left.
    • isFilled

      public boolean isFilled()
      Whether a LineChart fills the area under this line.
    • setFilled

      public ChartSeries setFilled(boolean value)
      Fills the area between this line and the baseline with a fade of its own color.
    • isSmooth

      public boolean isSmooth()
      Whether a LineChart draws this series as a curve rather than as segments.
    • setSmooth

      public ChartSeries setSmooth(boolean value)
      Draws the line as a curve through its points. Off by default: a curve invents intermediate values the data never had, which is fine for a trend and wrong for a measurement the reader may try to read off the chart.
    • lineWidth

      public float lineWidth()
      Line thickness in logical points (default 2).
    • setLineWidth

      public ChartSeries setLineWidth(float value)
      Sets the line thickness in logical points.
    • pointRadius

      public float pointRadius()
      Marker radius in logical points; 0 draws no markers (default 3).
    • setPointRadius

      public ChartSeries setPointRadius(float value)
      Sets the marker radius in logical points (0 hides the markers).