### Tutorial 7. Graph Animation

In this tutorial, we will learn about creating graph animation. It is recommended that you read the topics Animation through Time Travel and Animation through Sequence before continue.

Animation through Time Travel

Start the DataScene program and create a new project with two empty data tables Table1 and Table2. For Table1, apply the two column formulas "Row - 1" and "SIN(2 * PI * ( T - COL(1) ) / 50)" to Column 1 and Column 2 from row 1 to 101, respectively. For the second formula, check the Time Dependent checkbox in the Time Parameter group box of the Column Formula dialog box so that the math parser recognizes the T parameter as the time parameter. By doing this, we make Table1 time dependent. For Table2, apply the two column formulas "Row - 1" and "SIN(2 * PI * ( T + COL(1) ) / 50)" to Column 1 and Column 2 from row 1 to 101, respectively. Also enable the time parameter for the latter to make Table2 time dependent. Plot a 3D Line series using Table1 with its Column 1 and Column 2 associated with the Position and Value series components, respectively. Open the Series Editor and then click its Add button to open the Series Components dialog box with which add a second 3D Line series using Table2 with the same column - series component association as used for Table1.

Select Graph 1 as the active document. Press the Animation Meter tool on the Graph Tools tab of the ToolBox. DataScene inserts the animation meter onto Graph 1 and puts it in the edit mode (with four solid squares on the four corners of the animation meter). Press the Animation Meter tool  again to end its edit mode. Arrange the three documents (two data-table documents and one graph document) in a similar way as shown in Fig. 1 - one easy way to achieve this with Windows version of DataScene is first tiling documents by clicking the button on the Graph ToolBar, and then dragging the tab strip of Table2 and dropping it onto the right dock-site indicator of the Table1 document.

Fig. 1. Two time-dependent 3D Line series and their source data tables.

As discussed in the topic Animation through Time Travel, there are two methods of performing time travel: time travel a time-dependent data table and time travel a time-dependent graph. We will demonstrate both methods in the following examples.

Select Table1 as the active document. Click the Time Travel tool on the Data Tools tab of the ToolBox to open the Time Travel dialog box. Use the settings as shown in Fig. 2 in the dialog box. Click the Start button to start time travel of Table1. You will see DataScene keeps changing the current time and refreshing Table1 and its dependent series 3DLine1. As a result, an animation is created for 3DLine1. You may want to hide the Time Travel dialog box by clicking its Hide button so that you will have a cleaner view of the animation. Hiding the Time Travel dialog box will not stop the animation and it can be re-invoked by clicking the Time Travel tool on the ToolBox again.

Fig. 2. Time travel settings for Table1.

Stop the time travel of Table1 by clicking the Stop button on the Time Travel dialog box. Hide the dialog box and select Table2 as the active document. Perform time travel on Table2 by performing similar steps that we have used on Table1. This time, 3DLine2 is animated because it is the dependent series of Table2.

Stop the time travel of Table2 and select the Graph 1 graph document as the active document. Click the Time Travel tool on the Graph Tools tab of the ToolBox to open the Time Travel dialog box. Use the settings as shown in Fig. 2 in the dialog box. Click the Start button to start time travel of the active graph document. Datascene automatically finds out all time-dependent source data tables (in this case, Table1 and Table2) of Graph 1 and begins to time travel them simultaneously. As a result, you see both 3DLine1 and 3DLine2 are animated. If there was any other series that depends on Table1 or Table2, it would be animated, too.

Stop the animation and close the Time Travel dialog box. Select Table1 as the active document and right click inside it to open the context menu. Select the Export Data menu command to open the Export Data dialog box. In the dialog box, check the Data At All Times check box and leave others unchanged. Click the OK button of the dialog box. A Save As dialog box is popped up. In the Save As dialog box, create a folder on your desktop named Tmp/Table1 and select it. Type the name "forwardwave" in the Save As dialog box and click its OK button. DataScene saves the data at each time step to a file in the Tmp/Table1 folder with the name beginning with "forwardwave". Do the same for Table2 and save the data to files beginning with "backwardwave" in another folder called Tmp/Table2. We will use these data in the following section.

Animation through Sequence

Close the time travel project and create a new empty project. Click the button on the Standard ToolBar to open the Text Data Source dialog box. In the File Source group box, check the Import file(s) as a data sequence check box and select all files in the Tmp/Table1 folder that we created in the previous section (in case that you are not familiar with multi-file selection in the Open dialog box: after selecting the first file, click the last file while keeping the SHIFT key pressed will select all files between the first and the last). This will import all files in the Tmp/Table1 folder into a data-sequence document. Do the same for files in the Tmp/Table2 folder to import them into another data-sequence document.

With the first data sequence selected, right click inside it to open the context menu. On the context menu, select the Sequence Editor menu command to open the Data Sequence Editor. Make sure that all data tables in the sequence are listed in the increasing order of their sequence number as appeared in their table names after the "_" character (i.e. forwardwave.txt, forwardwave_1.txt, forwardwave_2.txt, ..., forwardwave_200.txt). If you want to move a table to a specific position, you may do it by dragging and dropping it onto the desired position in the Data Sequence Editor. Do the same for the second data sequence.

Fig. 3. The first data sequence as shown in the Data Sequence Editor.

Plot two 3D Line series in the same graph within the same graph document (Graph 1) using the two data sequences. In both cases, Column 1 is associated with the Position series component and Column 2 is associated with the Value series component, respectively. The generated graph document is called a graph sequence since it changes as the current data table of one of the source data sequences changes.

Select Graph 1 as the active document. Press the Animation Meter tool on the Graph Tools tab of the ToolBox to inserts the animation meter onto Graph 1. Double click the animation meter to open the Animation Meter Editor. On the Display tab-page of the editor, change the formula to "CONCAT[" T = ", FORMAT(IDX * 0.5, "#,##0.0")]" and then close the editor. The new display formula convert the sequence index into time value so that the display of the animation meter matches that used in the previous section. Press the Animation Meter tool again to end its edit mode.  Arrange the three documents in a similar way as that shown in Fig. 1.

Fig. 4. Converting the sequence index to the time value in the Animation Meter Editor.

Select the first data sequence as the active document. Click the Data Sequence tool on the Data Tools tab of the ToolBox to open the Data Sequence dialog box. Use the settings as those shown in Fig. 5 in the dialog box. Click the Start button to "play back" the data tables in the data sequence. You will see DataScene keeps refreshing 3DLine1 with the data in the current data table and an animation of 3DLine1 is therefore created. As in the previous section, you may hide and re-invoke the Data Sequence dialog box without interrupting the animation.

Fig. 5. Settings used in the Data Sequence dialog box.

Stop the playback of the first data sequence by clicking the Stop button of the Data Sequence dialog box. Close the dialog box and select the second data sequence as the active document. Do the same steps to this data sequence to create an animation of 3DLine2.

Now that we have tried the Data Sequence tool, we will demonstrate the use of the Graph Sequence tool to create animation. Select the graph document as the active document and click the Graph Sequence tool on the Graph Tools tab of the ToolBox to open the Graph Sequence dialog box. In the dialog box, use similar settings as those shown in Fig. 5. Click the Start button to start playback of the graph sequence. In the playback of a graph sequence, Datascene finds out all its source data sequences and begins to playback them simultaneously. As a result, you see both 3DLine1 and 3DLine2 are both animated. If there were any other series that depends on either of the two data sequences, it would be animated, too.

Off-line Animation

DataScene allows the user to generate animation files for off-line playback. Two formats are currently supported: Animated Graphics Interchange Format (GIF), and Audio Video Interleave (AVI).

Stop the previous graph-sequence animation. Before generating an animation file, it is a good idea to change the graph to a fixed size that will be used in the exported animation file so that the off-line animation looks exactly like the on-line version. To do this, with the graph-sequence document selected as the active document, right click inside it to open the context menu. On the context menu, click the Size menu command to open the Graph Size dialog box. In the dialog box, change the graph size to be fixed to 450 ´ 250 and then close the dialog box.

Select the Animator tool on the Graph Tools tab of the ToolBox to open the Animation Generator dialog box. On the dialog box, select the AVI radio button in the Format group box and supply a path to the output file in the Output Path text box (the button next to this text box may be used to browse the file path). Click the Start button of the dialog box to start the generation of the AVI file. Close the dialog box after the file generation is finished.

Fig. 6. The Animation Generator dialog box.

Congratulations, you have created an animation file! You may now play back the generated animation file with a media player. You may also want to experiment with the animated GIF format. After you are done, close all opened projects without saving them.