Enforcing delay using Source-Data Component
I just read an article about the Source-Data component in Xcelsius – remembered that I used this component for ‘Enforcing delays’ for various reasons/applications…
The functionality of the component is pretty straight-forward – copy a value from the source cell to the target cell and this happens whenever the source changes. If you’ve not used this component before, you may wonder if this is same as the simple Excel formula “=A1” (Assuming A1 has the source value).
Yes, but the component do more than an Excel Assignment –
1) Cyclic Assignment – Excel will throw an error if you try this by Assignment (Will be using this concept for Enforcing delays)
2) Overwrite a formula dynamically
3) Avoid large sets of assignment formulas
By “Enforcing Delay”, I mean – an operation that need to wait conditionally or unconditionally for a certain amount of time by defining an integer counter… One could think of several applications of this concept – so far I’ve applied it in the following cases –
a) Animated Data Loading Screens
b) Change color of an “Icon” component to produce a blink effect
c) Worked around an issue where data connections are triggered when dashboard loads “After loading components” but even before some custom-built components write a value to the cell which should be an input parameter to these connections. All that is needed is a delay by a fraction of a second to trigger the connections
How to Enforce Delay?
Simple. Using a Source-Data Component, set a cyclic counter with two cells as shown below –
The Formula in Cell#A2 works this way: Count from 1 through 100 and cycle back to 1. Approximately, it takes 3 seconds for one iteration from 1 to 100. Map a spreadsheet table to these cells and on dashboard preview, you can see the counter running in loops. By trial and error, one can attain a sub-second delay.
For triggering an event after a delay, change the Formula on Cell#A2 to “=IF(B2=100,100, B2+1)
Also, note that you can impose a delay using a “Play Selector/Control” Component too but the efforts required to map and hide the component are higher…!