
Chart Data
To create a chart, start by organizing the data in a table like this:
| 2006 | 2007 | 2008 | 2009 |
Region A | 5 | 10 | 30 | 63 |
Region B | 100 | 20 | 65 | 55 |
Region C | 56 | 21 | 5 | 90 |
Then, translate the table into XML elements like this:
<chart>
<chart_data>
<row>
<null/>
<string>2006</string>
<string>2007</string>
<string>2008</string>
<string>2009</string>
</row>
<row>
<string>Region A</string>
<number>5</number>
<number>10</number>
<number>30</number>
<number>63</number>
</row>
<row>
<string>Region B</string>
<number>100</number>
<number>20</number>
<number>65</number>
<number>55</number>
</row>
<row>
<string>Region C</string>
<number>56</number>
<number>21</number>
<number>5</number>
<number>90</number>
</row>
</chart_data>
</chart>
|
Notice that:
- The XML elements mimic the table exactly
- Even though the top left cell is empty, it is included in the XML code as a null for consistency
- All the row and column titles are strings. All the table values are numbers
Copy the above code, paste it into the sample.xml source file, and preview the sample.html web page in a browser:
|