Tutorial: Add logic to my first Sankey diagram (intermediate)

Required license: Pro
The extended example: My calories
Understand the goal of this tutorial.

In this tutorial we start with the outcome of beginners tutorial (see picture below).

Our first goal is to create a form like the one shown in the picture on the right. The form shows JUST the CHANGEABLE values. And it serves as user interface for value changes.

This example requires at least a PRO license, which enables you to add logic to your diagram.

Our second goal is the automatical calculation of the "difference value". In other words: we want to change e.g. the "workout" value and we want to see the "difference" value adjusting automatically.
Preparation
Negative values and arrow heads

Can you imagine, how our diagram is looking, when we have a "workout" value of "0"? - In this case, there is a surplus of calories on the "meals" side. The sign of the difference value changes!

Now we want to prepare for this situation. First delete the branch to "Difference":
  1. Select the "difference" connection
  2. Click at the handle of the connection end next to "Difference" to delete the branch.
There is an inner point left in the connection. Delete it:
  1. Click at the handle of the inner point of "difference"
As a side effect, one of the indicators will disappear. (We can only have on indicator per connection segment.)
Connect "Difference" again (with changed direction):
  1. Hold the <shift>-key down and drag a branch out of the line handle of connection "difference"
  2. Move the mouse pointer over "Difference", so that it shows the connection focus
  3. While still pressing the <shift>-key (important!), release the mouse button
  4. In the value dialog enter the negative value "-2043"
  5. Add a second indicator to "difference"
  6. Select the item "Difference" and set the "Precision" to "4 digits".
Now, you should see nearly the same picture as the one we had in the beginning. Just the item "Difference" is showing a negative value. Please note, that negative values in connections and their branches change their graphical direction (arrow head). - We will return to this point at the end of the tutorial.
Basics: Item types
Understand the basic concepts.
Before we continue modifying our calories example, let's do some basic experiments:
  1. Find some free space in your diagram and create a picture similar to the one shown on the right: Two items "A" and "B" connected by a connection "connection1" with the value of 3000kJ.
Make sure that "connection1" has an indicator to follow what happens on value changes.
You can create this small example in our calories example and delete it afterwords (or create a new diagram).
Explore the "Data" properties:
  1. Click at the white diagram surface to select the diagram
  2. Open "Data" in the properties and details area
This is the place where you will find the form to change values at the end of this tutorial. Currently it's showing just a text message.
Tag the item "A" and it's output as changeable:
  1. Select item "A"
  2. Below "Data", set connections to "user input"
See, what has happened to the diagrams data form:
  1. Click at the white diagram surface
Now, the form shows an input field for "A".
Extend the example to a chain:
  1. Create an item "C" right to "B"
  2. Connect it to "B" with the value "3000kJ"
  3. Set the name of the connection to "connection2" and add an indicator showing the value.
Add logic to item "B":
  1. Select item "B"
  2. Below "Data" set connections to "Fix ratio"
"Fix ratio" means, that the inputs and output of "B" are no longer independent. If you followed our tutorial exactly, the input and output of "B" are now equal and will remain so. (You could also decide that the input of "A" should be e.g. half of it's output.)
Now, see what happens, if you change the output value of "A":
  1. Click at the white diagram surface to select it
  2. Below "Data" enter the value of "5000kJ"
Both indicatiors, the one of "connection1" and the one of "connection2" are now showing the value of "5000kJ". See the picture on the right for a comparison with "B"s connections having the initial value of "Auto adjust".
If you created this example in the calories diagram, please delete this example now.
Complete the calories example
Set item types.
Select the changeable values:
  1. Select the items "Breakfast", "Lunch", "Snack", "Dinner", "Sleep", "Sit or eat", "Walk" and "Workout" with the mouse (lasso, <shift>-lasso, <shift>-click)
  2. Below "Data" set connections to "user input"
Notice, what has happened to the diagrams data form.
Add logic to the item "Meals":
  1. Select the item "Meals"
  2. Below "Data" set connections to "Sum up (in-> out)"
Similar to "Fix ratio" this adds a relation to the input and output values. Now the output value of "Meals" is calculated (sum of the inputs of "Meals").
Add logic to the item "Activities":
  1. Select the item "Activities"
  2. Below "Data" set connections to "Sum up (out-> in)"
Congratulations, you did successfully finish this tutorial. You can now change e.g. the value of "Workout" to "0" in the diagrams data form. Your diagram will then look similar to the one above. Please note, that the connection "Difference" adjusts automatically and depending on your values, the DIRECTION of the branch to "Difference" changes too.

© 2017-24 THORTEC Software GmbH