Table Of Contents
The Fetch section shows how to fetch content from a URL. The Info section shows how to view the key value dictionary description of a graph. This Tutorial amalgamates those sections and describes how to fetch XML content which defines the task state.
Line Graph
The following is the XML needed to make a line graph (curves). Line graphs are made with the Set Of 2D Points task so first select that task from the Tasks tool, click the Fetch tool, make sure the component pop up button is set to "All" and enter the URL to the XML content shown below. Then click the "Fetch Data" button.
Available at this URL: linegraph.plist
|
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>title</key>
<string>Set Of 2D Points XML Test</string>
<key>x_title</key>
<string>XML-X-Title</string>
<key>y_title</key>
<string>XML-Y-Title</string>
<key>data_3</key>
<string>1 15 2 16 3 17 4 18 5 5</string>
<key>data_2</key>
<string>1 2 2 26 3 2 4 28 5 2</string>
<key>data_1</key>
<string>1 31 2 36 3 32 4 33 5 41</string>
</dict>
</plist>
|
Once the fetch is confirmed to work then you may wish to turn on "Each Animation Step" and "At First Appearance", click "Done", click the Data tool and turn on Animate then click "Done". The XML will be fetched and its results will be displayed every second. As such, when you change the content of the XML then the graph and table will change to reflect the changes to the XML. If the URL points to a SOA service then the XML it serves will be polled and displayed every second.
Now you have some XML and know how to fetch it, but perhaps you don't know what XML exactly is so lets hit some bullets on that issue:
- The type of XML shown above is called a "Property List". It is a pretty well documented format on the Apple system so I won't describe it too much. Note that if you install the developer toolset then there is a Property List Editor application that can help you view and edit property list type XML. But, this XML is so simple that it is probably best to use a text editor. It is pretty obvious to tell that the content has a header, footer and key value pairs that are delimited by HTML type tags where a key is delimited by the <key></key> pair and a value is delimited by one of <string></string>, <integer></integer>, <float></float> pair.
- The keys and values in the XML are gathered in the Info tool and explained in the Vvidget Code Reference Manual. For the most part, you can simply see a graph you want and then view the Info tool table to determine the keys and values to use in the XML.
- Titles values are <string> type, data arrays are also <string> type as the numeric values are not atomic, which saves a lot on using repetitive tags. Lengths are generally of type <integer> and numbers are of type <float>. However, since XML is simply a delimited string you can also use <string> type instead of <integer> and <float> type.
- Of course, this is not a tutorial on HTML or XML so I didn't explain the DOCTYPE, enclosing plist and dict types and other common knowledge items. Suffice it to say that if you don't know of such things then simply do what the pros do: Copy the XML above and only change the keys and values you need.
Column Chart
The following is the XML needed to make a column chart. Column charts are made with the Set Of Scalars task so first select that task from the Tasks tool, click the Fetch tool, make sure the component pop up button is set to "All" and enter the URL to the XML content shown below. Then click the "Fetch Data" button.
Remember to use the Preferences tool to select the Column representation. You can also make stacked and offset bar and column charts and pie charts by using different representations and key value pairs.
Available at this URL: columnchart.plist
|
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>title</key>
<string>Set Of Scalars XML Test</string>
<key>x_title</key>
<string>XML-X-Title</string>
<key>y_title</key>
<string>XML-Y-Title</string>
<key>data_3</key>
<string>1 2 3 4</string>
<key>data_2</key>
<string>1 2 3 4</string>
<key>data_1</key>
<string>2 2 3 6</string>
<key>label_1</key>
<string>a kitty cat</string>
<key>label_2</key>
<string>dog eat dog</string>
<key>label_3</key>
<string>buddy</string>
<key>label_4</key>
<string>more</string>
<key>label_5</key>
<string>the sky</string>
</dict>
</plist>
|
Surface Graph
The following is the XML needed to make a surface graph. Surface graphs are made with the Z Values task so first select that task from the Tasks tool, click the Fetch tool, enter the URL to the XML content shown below. Then click the "Fetch Data" button.
Available at this URL: surfacegraph.plist
|
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>title</key>
<string>Z2 Values XML Test</string>
<key>x_title</key>
<string>XML-X-Title</string>
<key>data_values</key>
<string>1 1 1 2 3 2 0 1 0 5 5 3</string>
<key>grid_x_length</key>
<integer>4</integer>
<key>grid_y_length</key>
<integer>3</integer>
</dict>
</plist>
|
3D Density Graph
The following is the XML needed to make a 3D density graph. 3D density graphs are made with the Density task so first select that task from the Tasks tool, click the Fetch tool, enter the URL to the XML content shown below. Then click the "Fetch Data" button.
Available at this URL: densitygraph.plist
|
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>title</key>
<string>Density XML Test</string>
<key>x_title</key>
<string>XML-X-Title</string>
<key>data_values</key>
<string>0.2 0.2 0.1 0.2 0.2 0.2 0.2 0.2 0.2 0.3 0.3 0.3 0.3 0.3 0.3 0.3 0.3 0.3 0.6 0.6 0.6 0.6 0.6 0.6 0.6 0.6 0.6</string>
<key>grid_x_length</key>
<integer>3</integer>
<key>grid_y_length</key>
<integer>3</integer>
<key>grid_z_length</key>
<integer>3</integer>
</dict>
</plist>
|
Least Squares
The following is the XML needed for least squares. Least Squares graphs are made with the Least Squares task so first select that task from the Tasks tool, click the Fetch tool, enter the URL to the XML content shown below. Then click the "Fetch Data" button.
Available at this URL: leastsquares.plist
|
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>title</key>
<string></string>
<key>x_title</key>
<string>XML-X-Title</string>
<key>y_title</key>
<string>XML-Y-Title</string>
<key>data_values</key>
<string>1 31 2 36 3 32 4 33 5 25</string>
</dict>
</plist>
|
Least Squares is unusual because the Info tool shows <key>data_1</key> and <key>data_2</key> as data keys, but the XML uses the <key>data_values</key> key. That is an intricate implementation detail of this task that I won't explain, but mention so that you know not to totally rely upon the Info tool for the Least Squares task.
Conclusion
There are many graph types that can be updated with XML and those graphs can be accessed using the various tasks and their representations. With a little experimentation XML fetching may solve a lot of problems.