Skip to content

DataNode

Pieter Verschaffelt edited this page Apr 29, 2021 · 2 revisions

The DataNode class is used to recursively describe hierarchical data for the visualizations that work with hierarchical data (e.g. treeview, treemap and sunburst).

NOTE: Please take care when "reusing" data for multiple invocations of the visualizations. The visualizations update some of the properties of the objects passed in the constructor. This could cause conflicts if these objects are then shared over multiple visualizations at the same time. If required, you can create a deep copy of an object by performing JSON.parse(JSON.stringify(obj)).

API

DataNode

constructor

The constructor of a DataNode has the following signature:

  • id: number: ID that can be used to uniquely identify this DataNode. No other DataNode that belongs to the same hierarchy should have the same ID.
  • name: string: Name of the datapoint that is represented by this DataNode. This name will be used by some of the visualizations to render labels.
  • children: DataNode[]: A list of DataNode-objects that are the children of this node. Circular relationships are not allowed.
  • count: number: The sum of the count-values of all children of this node (including the value of this node itself).
  • selfCount: number: Quantitative value that should be associated with this node itself.
  • extra: any (optional, default = {}): Any other data that should be associated with this node and that can be read by one of the callback-functions that can, optionally, be passed to any of the visualizations.

DataNodeLike

An interface with only 2 required values. All other values for this interface are optional and will be filled in by the visualizations themselves (using placeholders) if they prove to be empty. This interface is accepted as the default data input format for most visualizations and is less restricted than the DataNode-variant (which is used internally by all visualizations). This interface states the following properties:

  • count: number: The sum of the count-values of all children of this node (including the value of this node itself).
  • selfCount: number: Quantitative value that should be associated with this node itself.
  • id: number (optional): Optional ID for this node. No other DataNodeLike that belongs to the same hierarchy should have the same ID.
  • name: string (optional): Optional name for this node. Will be used by the visualizations (if available) to render labels for some of the nodes.
  • children: DataNodeLike[] (optional): Optional list of child nodes.
  • extra: any (optional): Any other data that should be associated with this node and that can be read by one of the callback-functions that can, optionally, be passed to any of the visualizations.
Clone this wiki locally