Class SankeySeries

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

public class SankeySeries extends Series

A sankey diagram: flows between stages drawn as bands whose thickness is the flow's value.

Nodes are created by name as links mention them.

SankeySeries s = new SankeySeries("Energy");
s.addLink("Solar", "Grid", 40).addLink("Gas", "Grid", 60).addLink("Grid", "Homes", 55).addLink("Grid", "Industry", 45);

A Sankey diagram

  • Constructor Details

    • SankeySeries

      public SankeySeries(String name)

      Creates an empty diagram.

      Parameters
      • name: the series name
  • 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
    • addLink

      public SankeySeries addLink(String source, String target, double value)

      Adds a flow, creating its nodes if needed.

      Parameters
      • source: the source node's name

      • target: the target node's name

      • value: the amount that flows

      Returns

      this series

    • clear

      public SankeySeries clear()

      Removes all nodes and links.

      Returns

      this series

    • setLinkAlpha

      public SankeySeries setLinkAlpha(float a)

      The opacity of the link bands.

      Parameters
      • a: 0 to 1
      Returns

      this series

    • getNodeCount

      public int getNodeCount()
      The number of nodes.
    • getLinkCount

      public int getLinkCount()
      The number of links.
    • 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
    • dataChanged

      protected void dataChanged()
      Description copied from class: Series
      Tells the chart this series' data changed, which animates the new values in.
      Overrides:
      dataChanged 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
    • 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)
      Points 0..nodeCount-1 are nodes, the rest are links.
      Overrides:
      getPoint 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
    • formatTooltip

      public String formatTooltip(ChartContext ctx, ChartPoint p)
      Description copied from class: Series

      The tooltip row for a point: the series or point name and its formatted value. Series with several values per point (open/high/low/close, ranges, box plots) override this.

      Parameters
      • ctx: the last paint context

      • p: the point

      Returns

      one line of text

      Overrides:
      formatTooltip 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