Interactive Decision Tree Diagrams Interactively exploring a filtered decision tree helps to keep a clear view of the decision process
A decision tree guides a user from an initial question into one of the multiple possible end states. Each step along the decision process presents a choice that will branch down further until the user reaches a result. Often these trees consist only of a few steps and can be well provided as a static visualization. However, adding interaction improves the user experience and readability. For more complex diagrams, filtering the tree and interactively exploring it can be crucial to avoid infeasibly large, chaotic graphs.
Limitations of static decision trees
In static visualizations, all possible states and options have to be displayed. Options that can be reached using different decision routes either have to be duplicated or connected with cross or back-links, which both reduce the readability.
As the user should nevertheless easily grasp the current options and their consecutive steps, it is essential to use a suitable arrangement (i.e., layout) to facilitate this task. A well readable decision tree should emphasize the decision flow through the tree that is typically either from top to bottom or from left to right. However, node arrangements that follow this style usually keep succeeding steps close to their parents and produce visualizations with high width. Also, they introduce long cross and back-links that are hard to follow.
Another drawback of the static visualizations is that the user not only sees all possible branches beforehand but especially the consequences of each option before making a decision. Even though this may be irrelevant for some diagrams, it is entirely undesired for others.
Exploring a decision tree interactively
Hiding all branches not yet taken reduces the complexity of the diagram and conceals the consequences of a decision. This reduced diagram is easy to grasp and focuses only on the chosen decision route.
In the beginning, only the initial decision step is visible. When a user selects an option, the result of this choice and the next decision step appear in the visualization. The challenging task is to add these new elements (nodes/edges) in the tree without disturbing the user’s mental map. More precisely, the nodes and edges that were already in the graph should remain as close as possible to their previous positions.
Depending on the use case, the user may or may not be allowed to return to a previous decision route and take another branch.
Build interactive decision trees with yFiles
Implementing a decision diagram with advanced features like interactivity can be a daunting task. yFiles for HTML provides ready-to-use graph visualization components that handle the heavy lifting, including element placement, item styling, animations, and interaction.
Spend less time building diagram infrastructure and more time creating the decision logic and user experience your application needs.
Start exploring interactive decision trees with yFiles today!
Examples and source code
This demo provides a sample implementation of the features above. It allows a user to choose between several data sets and interactively make his way through the decision steps.
The source code of the Decision Tree Sample Application is available on the yWorks GitHub repository and part of the yFiles for HTML package.
Based on this example, yWorks built the Dungeons & Dragons Hero Class Decision Tree Application. This application guides users to the perfectly matching character class for the next Dungeons & Dragons session based on hand-picked criteria.
Implement your own decision tree application
Test the yFiles for HTML diagramming library with a fully functional trial package. To implement your own decision tree application, start with the Decision Tree Sample Application that is part of each yFiles package. It’s not only a showcase application but also provides best-practice source code that you can re-use in your project. yFiles makes it easy to customize all aspects of this application, for example, include your own styling or load the data from your personal data source.
- Download the trial version of yFiles for HTML for your target platform at the yWorks Customer Center.
- Navigate to the source directory of the Decision Tree Sample Application.
-
Explore the sample application’s features and
- adjust its source code to match your requirements or
- copy the source code of the features you like to your project.
About yFiles: The graph visualization SDK
yFiles is your go-to SDK for crafting advanced graph visualizations, whether you're working with Web, Java, or .NET technologies. Its unmatched flexibility and scalability enable you to convert complex data into clear, actionable visuals, fitting for both enterprise and startup needs.
With yFiles, you're equipped for the future—supporting any data source while maintaining strong data security. Getting started is seamless, thanks to over 300 source-code demos, thorough documentation, and direct access to core developer support. These resources are available even during your free trial.
Backed by 25 years of graph drawing expertise, yFiles is trusted by top companies worldwide for their most critical visualization tasks.
11 reasons why developers choose yFiles, the superior diagramming SDK
Recap
Interactive decision tree diagrams
Interactive decision trees reveal the next step only after a user makes a choice. This keeps the diagram focused on the current decision route and hides outcomes that are not yet relevant. In comparison, static visualizations show every possible branch at once, which can make larger trees difficult to read.
With yFiles for HTML, you can add decision steps as users explore while keeping existing nodes and edges close to their previous positions. The Decision Tree Sample Application demonstrates these interaction patterns, and the implementation guide explains how to build your own application.
Related content
Got questions about
interactive decision trees?
Dr. Nicolas Harbig-Brich
Senior Software Developer
Email: hello@yworks.com
Phone: +49 7071 9709050