### Tutorial 3. Creating Series and Graphs

In this tutorial, we will learn about creating series and  graphs using data imported from text files. We will also learn about some graph and series manipulation techniques. It is recommended that you read the topics Graph Document, Data Table, and Series before continue.

Importing Data from Text Files

Start the DataScene program. Create an empty project by selecting the New Project menu command on the File menu or by clicking the button on the Standard Toolbar.  Select the File: Import Data: From Text Files menu command or the button on the Standard Toolbar to open the Text Data Source dialog box.  In the File Source group-box of the dialog box, double click the cell with the text "Double click to add files(s)..." to open the File Open dialog box.

On the Open dialog box, browse ExamplesDataTutorial3Lines.txt under the DataScene installation folder (which can be opened by selecting the Help: Demo Projects menu command) and then click the Open button. On the Text Data Source dialog box, select "tab" in the Column delimiter combo-box in the File Structure group-box and then click the OK button. DataScene imports the data in the file into a data table and names it Lines.txt.

Fig. 1. Importing a data file with the Text Data Source dialog box.

Plotting Two Series in One Graph

Click the Common Graphs tab of the ToolBox and then select the 3D Line tool to open  the Series Components dialog box.

Fig. 2. Selecting the 3D Line tool on the ToolBox.

In the Series Components dialog box, click on the cell at row Value and column Table Columns of the data grid control. In the drop down list, check the check box Column 3 and then click the OK button of the dialog box. DataScene creates a graph document entitled Graph 1 and plots two 3D Line series, 3DLine1 and 3DLine2 (see Tutorial 4 for changing series name), in a graph entitled Lines.txt (see Tutorial 5 for changing graph title) within the graph document. This graph is called the master graph of the Graph 1 graph document for that it is the first graph in the graph document. The Position components (x values) of both 3DLine1 and 3DLine2 are associated with Column 1 of the Lines.txt data table. The Value components (y values) of 3DLine1 and 3DLine2 are associated with Column 2 and Column 3 of the Lines.txt data table, respectively.

Fig. 3. Settings in the Series Components dialog box.

Now, we would like to use the data in Column 1 and Column 4 of Lines.txt to plot a Line series in a second graph in the Graph 1 graph document - which will be called a sub-graph of Graph 1. To do this, Select the Graphs: Add Sub-Graph: Vertical Insert menu command on the Graph menu to add a vertically aligned sub-graph into Graph 1. DataScene entitles the sub-graph Sub-Graph 0 and makes it the active graph (it is selected in the Active Graph combo-box on the Graph ToolBar). With Sub-Graph 0 selected as the active graph, open the Series Editor by selecting the Graph: Series menu command and then click its Add button to open the Series Components dialog box

Fig. 4. Adding a new series with the Series Editor.

In the Series Components dialog box, select Line in the Graph Type combo-box and select Column 4 as the Value component. Click the OK button to close the dialog box. DataScene adds a new Line series entitled line1 to Sub-Graph 0. Close the Series Editor by clicking its OK button.

Fig. 5. The Graph 1 graph document contains two graphs: the master graph contains two 3D Line series and the sub-graph contains one Line series.

Basic Graph and Series Manipulations

Select Master Graph in the Active Graph combo-box on the Graph ToolBar. DataScene highlights the master graph by temporarily drawing a semi-transparent rectangle around it. Since the master graph contains two 3D Line series, DataScene shows the Active Series combo-box on the Graph ToolBar. Selecting a series in the Active Series combo-box makes it the active series. DataScene highlights the newly activated series by growing it in animation.

Please note that the two documents Graph 1 and Lines.txt are shown in the Workspace tab-page of the Navigator as two nodes under the project node Project 1. With the master graph selected as the active graph, click the Graph tab-page of the Navigator. The two 3D line series are shown in this tab-page. If you uncheck the check box in front of the inactive 3D Line series, it will be hidden from its parent graph. Be aware that it is not allowed to hide the active series of the graph.

Fig. 6. Two series of the active graph, 3DLine1 and 3DLine2, are shown on the Graph tab-page of the Navigator.

You may have noticed that 3DLine2 covers 3DLine1 - this is because it is drawn after 3DLine1. The drawing order of the series is the same as the order they are listed on the the Graph tab-page of the Navigator. To switch the drawing orders of two series, drag one series (e.g. 3DLine1) and drop it onto the other series (e.g. 3DLine2) inside the Graph tab-page of the Navigator. If you do switch the drawing orders of 3DLine1 and 3DLine2, you will see 3DLine1 covers 3DLine2 because the former is now drawn after the latter.

Now that we have two graphs in Graph 1, we would like to change the layout of these two graphs. With Graph 1 selected as the active document, select the Graphs: Align Graphs: Juxtapose Graphs menu command on the Graph menu. DataScene changes the two graphs to horizontal alignment. Now select the Graph Layout tool on the ToolBox, DataScene changes the active graph (which is the master graph if you have not changed the selection of the Active Graph combo-box) into the graph-layout mode and makes its bounding rectangle semi-transparent. Move the mouse pointer inside the bounding rectangle and start to drag it. Drop the bounding rectangle to a desired location to move the active graph to that position. Move the mouse pointer onto one of the borders of the bounding rectangle, resize the border to resize the active graph.

Fig. 7. Changing the layout of the active graph with the Graph Layout tool.

Exit the graph-layout mode by clicking the Graph Layout tool on the Navigator again. To precisely control the location and size of the bounding rectangle of a graph, open the Panel Editor by selecting the Panel menu command on the Graph menu. Switch to the Margins tab-page, change the values of the Left, Right, Top, and/or Bottom spin boxes to reposition and/or resize the graph selected in the Graph combo-box of the Margins tab.

Fig. 8. Changing graph layout with the Panel Editor.