-
Notifications
You must be signed in to change notification settings - Fork 3
SunburstJ Documentation
SunburstJ is a JavaFX Control to visualize hierarchical data in a pie-like chart, called sun burst view.
If you need a complete, running example, refer to to provided Showcase Test.
// Create the SunburstJ Control
SunburstView sunburstView = new SunburstView();
// Load your data
WeightedTreeItem<String> rootData = loadData();
// Set the data as root item
sunburstView.setRootItem(rootData);
// Now you only have to add the sunburstView to a panel & stage
// and show the world your nice app!
The SunBurstView allows user navigation by default - if a item is clicked, it becomes the new center item. However, we can not simply set the selected node as new root-node, since we would loose all previous color information derived from the node hierarchy. Instead, we have a second property which defines which node is show in the center - and subsequently defines the whole view.
// Basic SunburstView
SunburstView sunburstView = new SunburstView();
WeightedTreeItem<String> rootData = loadData();
sunburstView.setRootItem(rootData);
// Set a special node as selected center node:
WeightedTreeItem<String> someChild = rootData.getChildren().get(2);
sunburstView.setSelectedItem(someChild);
Note that the SelectedItem must be inside the rootData-Node tree, otherwise an exception is thrown.
Since we deal with hierarchical data, we use recursion to traverse the root/selected node tree in order to generate the chart. For performance and usability reasons, it is a good idea to limit the recursion deepness. I.e. this will limit the levels (onion skins) visualized.
SunburstView sunburstView = ...
sunburstView.setMaxDeepness(7); // Limit the node levels to 7
The SunburstJ Control itself does not include a Legend, but the API is aimed at supporting an external Legend. Off course, we provide such an external Legend, which can easily be added to a sunburst view. You usually will use a BorderPane and place the SunburstView in the center. The Legend can then be placed on Left, Right, Top or Bottom of it:
// Create the SunburstView and the Legend
SunburstView sunburstView = new SunburstView();
SunburstLegend myLegend = new SunburstLegend(sunburstView);
// Create the pane holding them together
BorderPane pane = new BorderPane();
pane.setCenter(sunburstView);
BorderPane.setAlignment(sunburstView, Pos.CENTER);
// Place the legend on the right side
pane.setRight(myLegend);
// Just add the pane to your scene and enjoy