Class TreemapSeries


public class TreemapSeries extends HierarchySeries

A squarified treemap: every node is a rectangle whose area is proportional to its value, nested inside its parent. Branches large enough get a header with their name; leaves show their name and value when the text fits, and the tooltip always does.

Chart chart = new Chart();
TreeNode root = new TreeNode("All");
root.add(new TreeNode("Photos", 40));
TreeNode apps = root.add(new TreeNode("Apps"));
apps.add(new TreeNode("Games", 15));
apps.add(new TreeNode("Tools", 10));
root.add(new TreeNode("Music", 20));
chart.addSeries(new TreemapSeries("Portfolio", root));

A treemap

  • Constructor Details

    • TreemapSeries

      public TreemapSeries(String name, TreeNode root)

      Creates a treemap.

      Parameters
      • name: the series name

      • root: the tree's root

  • Method Details

    • 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
    • collapsed

      protected float[] collapsed(float[] r)
      Description copied from class: HierarchySeries

      The geometry a node added by a data change grows from: by default the geometry itself, so the node appears in place.

      Parameters
      • geometry: the node's geometry after the change
      Returns

      a new array of the same length

      Overrides:
      collapsed in class HierarchySeries
    • contains

      protected boolean contains(float[] r, float x, float y)
      Description copied from class: HierarchySeries

      True if the absolute point lies in a recorded geometry.

      Parameters
      • geometry: a recorded geometry

      • x: absolute x

      • y: absolute y

      Returns

      true on a hit

      Specified by:
      contains in class HierarchySeries
    • anchor

      protected float[] anchor(float[] r)
      Description copied from class: HierarchySeries

      The anchor point of a recorded geometry, {x, y} absolute.

      Parameters
      • geometry: a recorded geometry
      Returns

      the point a tooltip points at

      Specified by:
      anchor in class HierarchySeries