This article explains what a dependency graph is, how to view it, how to navigate using the dependency graph, and how to use it to identify bottlenecks in your code.
The dependency graph and how to view it
Outputs in Displayr can be either fixed - such as images and text. Or, they can be dependent on data, such as visualizations, calculations, and tables. When the output is dependent on data, you can right-click on the edge of the output and choose Dependency Graph from the context menu, Displayr shows you the dependency graph used to calculate the output and any downstream outputs.
The screenshot below shows a page in the Supermarket Department NPS dashboard. The NPS promoter score (NPS) breakdown clustered pie chart is selected, and the dependency graph is shown at the bottom.
The dependency graph above shows that:
- The selected chart is named chart.2.
- chart.2 is calculated from a table called table.Q12r3_3_2.Bakery.by.Bakery.
- table.Q12r3_3_2.Bakery.by.Bakery is calculated from two variables: Q12r2_3_2: Bakery and Bakery.
- The two variables are from the data file Shopping.sav.
Using the dependency graph to navigate
You can navigate by clicking on nodes in the dependency graph. For example, the screenshot below shows the dependency graph from above, after table.Q12r3_3_2.Bakery.by.Bakery has been clicked on.
The dependency graph shows you which objects in a document depend on which other objects. When you click on the objects, you can then inspect their properties in the object inspector to work out how the actual calculation is performed. For example, the example below shows that the word cloud depends on the variables Reasons for being a detractor: Bakery and Detractors: Bakery, and we can see in the object inspector that Detractors: Bakery is used to filter Reasons for being a detractor: Bakery.
Using the dependency graph to understand performance
Each of the nodes in the dependency graph contains the time taken for it to compute. In the clustered pie example above, we can see that the visualization took 0.37 seconds to compute, whereas the variables took no time to compute. The bar to the left of the time is proportional to the longest calculation in the dependency graph (which in this example, is for the chart).
Although the dependency graph is the easiest way to identify bottlenecks in performance. Keep in mind that it's not necessarily the case that the objects with the longest time next to them are bottlenecks, as Displayr caches (remembers) results. For example, table.Q12r3_3_2.Bakery.by.Bakery is updated by applying the filter Q12r2_3_2: Bakery, so any calculations to the left of the filter in the dependency graph are irrelevant when understanding how to optimize the performance of the calculation as they're cached.
To examine any code within a calculation, variable, or data set, see How To Check Custom Code in Calculations, Variables, and Data Sets
For more information on optimizing the performance of a document, see How to Optimize Speed of Displayr Documents.