FusionCharts and XML> Multi-Series XML Structure |
Multi-series charts are charts where you compare multiple series of data. Like, in our previous example we had seen how to plot a chart indicating monthly sales summary. This data belonged to one particular series, that is for the year 2004. Now, if we need to compare the data for 2 or more years, we would be using the multi-series charts. Using multi-series charts, you can compare data for 2 or more number of series. A simple 2D multi-series chart looks as under: |
As you can see above, here we are comparing data for the year 2004 and 2003. We've set different colors for both the years to easily recognize the data. Also, we've hid the values for 2003, as they would look too cluttered on the chart (and we're more interested in 2004 data - 2003 data is just to show the comparison). The XML data for this chart can be listed as under: |
<graph caption='Monthly Sales Summary Comparison'
xAxisName='Month' yAxisName='Sales' numberPrefix='$' showNames='1'> <categories> <category name='Jan' hoverText='January' /> <category name='Feb' hoverText='February' /> <category name='Mar' hoverText='March' /> <category name='Apr' hoverText='April' /> <category name='May' hoverText='May' /> <category name='Jun' hoverText='June' /> <category name='Jul' hoverText='July' /> <category name='Aug' hoverText='August' /> <category name='Sep' hoverText='September' /> <category name='Oct' hoverText='October' /> <category name='Nov' hoverText='November' /> <category name='Dec' hoverText='December' /> </categories> <dataset seriesName='2004' color='AFD8F8'> <set value='17400' /> <set value='19800' /> <set value='21800' /> <set value='23800' /> <set value='29600' /> <set value='27600' /> <set value='31800' /> <set value='39700' /> <set value='37800' /> <set value='21900' /> <set value='32900' /> <set value='39800' /> </dataset> <dataset seriesName='2003' color='F6BD0F' showValues='0'> <set value='13500'/> <set value='15300' /> <set value='17400' /> <set value='12700' /> <set value='24400' /> <set value='18700' /> <set value='22300' /> <set value='28600' /> <set value='29700' /> <set value='26400' /> <set value='22900' /> <set value='29800' /> </dataset> <trendlines> <line startValue='22000' color='00cc00' displayValue='Average'/> </trendlines> </graph> |
|
Brief Explanation |
If you've already gone through the single series XML structure, you'll find notable differences between the two XML structures. There is the new <category> and <dataset> elements and the <set> elements now just contain the value attribute. However, if you're still unaware about the FusionCharts XML structure,
let's get to the basics first. The <graph>
element is the main element of any FusionCharts XML document - it represents
the starting point and the ending point of data. The <graph>
element has a number of attributes which helps to manipulate the chart.
In the most general form, attributes have the following form: The attributes can occur in any order and quotes can be single or double like xAxisName='Month'. However, you need to make sure that a particular attribute occurs in the XML only once. Next to the <graph> element are <categories> element and its child <category> elements. Each <category> element represents a label on the x-axis. The <category> elements need to be defined for all the multi-series charts before you can define the data. For example, in our chart, the categories are the month names (Jan, Feb, Mar .... ) as we're plotting a chart to show monthly sales summary for two consecutive years. Now, in a multi-series chart, each series of data (i.e., each set of data) needs to be enclosed between a <dataset> element. Like in our example, we're plotting a chart showing the monthly sales trend for 2 different years - the first dataset element's childnodes would be the data for the year 2004 and the second one for 2003. Depending on the chart type, there are a number of properties which you can define for each <dataset> element, which we'll soon see. Moving on, each <set> element (which is a child element of the <graph> element) represents a set of data which is to be plotted on the graph and determines a set of data which would appear on the graph. A typical <set> element would look like: <set value="17400" /> You should note that the number of categories should be equal to the number of data rows in each data sets, i.e., if you mention twelve categories (twelve months), the data for both years (2003 & 2004) should also contain twelve <set> elements (twelve rows of data). Next we have the <trendlines> element. Using this function of the chart, you could draw custom lines on the chart to represent a trend. For example, in our above XML, we have defined a line at 22000 to represent the average sales for the period. Let's now delve into details of each attribute and also see the general
attributes. We'll try to group all the common attributes for the single
series charts and study them. Each item in the list below isn't however
specifically applicable to all the charts - for chart wise XML attributes,
please see the next section. |
<graph> Attributes |
Attributes of the <graph> element help you set the
visual looks of the chart and a few functional parameters. Here we'll group
those attributes by their parent chart element and then look at it.
|
Background Properties
Canvas Properties
Chart and Axis Titles
Chart Numerical Limits
Generic Properties
Font Properties
Number Formatting Options
Zero Plane
Divisional Lines (Horizontal) Divisional Lines are horizontal or vertical lines running through the canvas. Each divisional line signfies a smaller unit of the entire axis thus aiding the users in interpreting the chart.
Divisional Lines (Vertical)
Hover Caption Properties The hover caption is the tool tip which shows up when the user moves his mouse over a particular data item (column, line, pie, bar etc.).
Chart Margins Chart Margins refers to the empty space left on the top, bottom, left and right of the chart. That means, FusionCharts would leave that much amount of empty space on the chart, before it starts plotting.
Apart from the above attributes, the <graph> element can also take in a lot more attributes depending on the chart type. We've discussed them in the next section "Chart wise XML Attribute". |
<categories> element |
The <categories> element can have the following attributes:
|
<category> element |
Each <category> element represents a x-axis data label. You can specify the following attributes for <category> element: |
|
<dataset> element |
Depending on the chart type, the <dataset> element has a number of properties. Four properties are common to all charts (the other attributes have been explained in the Chart-wise XML attribute section):
|
<set> element |
We now move on to the <set> element which is a child element of the <graph> element and determines a set of data which would appear on the graph. A <set> element looks as under: Now let's study the the possible attributes of the <set> element: |
At the end of the <set> element, you would find a "/"
which signals that it has no more child element |
<trendLines> |
Using the <trendLines>
element (and child elements), you can define trend lines on the charts.
Trend lines are the horizontal lines spanning the chart canvas that aid
in interpretation of data with respect to some previous pre-determined
figure. For each trend line on the chart, you need to define a <line>
element as under: The <line> element can have the following attributes:
|
At the end of the data file, you would find a </graph> element, which signals the end of the data file for the graph. |