FusionCharts uses XML or JSON data to render the charts. In both data format, the data file (or string) consists of data to be rendered, chart settings and cosmetics.
In this section, we'll explain XML data format of FusionCharts. XML is a simple and structured language,
that is easy to read and understand. Given below are the basics of XML:
- An XML document is a simple text file consisting of tags and data
associated with them.
- You can make up your own tags like <mytag></mytag>
to store data
- Every opening tag requires a matching closing tag like <name>
requires </name>. e.g.,
<name>John Doe</name>. If
an element has no content, the opening and closing tags may be combined
into a single "shortcut" tag such as <name/>.
- XML tags are case-sensitive. So <name>
should be closed with </name>
and not </Name> or
</NAME>
or any other variant of the same.
- You can define attributes for a tag to render more details. e.g.,
<name isPetName='1'>John Doe</name>.
Here isPetName is an attribute of the
name element. In FusionCharts v3, we've
four types of attributes:
- Boolean - Attributes which can take a 0 or 1
value. Like <chart showLabels='1' >
- Number - Attributes which take a numeric value.
Like <chart yAxisMaxValue='200' >
- String - Attributes which take a string value.
Like <chart caption='My Chart' >
- Hex Color Code - Attributes that take a hex color
code (without #). Like <chart bgColor='FFFFDD'
>
- Special characters like ' (quote), " (double quote), % (percentage)
etc are to be replaced by the XML converts. Like, the character "
(double quote) in a string constant must be denoted as "
There are a lot of properties that you can define for each chart
type. However, it is not necessary to define all the attributes for a given
chart. For example, if you do not want to change the default setting of
the canvas (color, alpha etc.), you don't need to define any attributes
for the canvas - the default values will be assumed. Thus, each chart
can be generated using minimal attributes without concern for finer
details.
FusionCharts has a specific XML structure for each chart. Broadly, we
define the XML structure into following types, depending on the chart
type:
- Single Series Charts
Single Series Charts are those which depict only one set of data on
the chart. Like, our previous example of Monthly sales summary was a
single series chart, as we had just one data set (i.e., data for 1 year).
In that chart, we were not comparing data between two datasets (e.g.,
monthly sales comparison between two or more years).
Single series charts include Column 2D, Column 3D, Bar 2D, Line, Area 2D, Pie 2D, Pie 3D, Doughnut 2D, Doughnut 3D, Pareto 3D and Pareto 3D.
XML for the single series chart is the simplest to understand, as you've
already seen in the previous examples.
- Multi-Series Charts
Multi-series charts are used to compare 2 or more datasets like
monthly comparison for 2 or more years. Under multi-series charts, we
can define the following subcategories:
- Standard Multi-series Charts
The standard multi-series charts, like multi-series column, line,
area etc., are used for straightforward comparison of various datasets
on the chart.
- Stacked Charts
Stacked charts, like stacked column, area etc., are used
to compare cumulative or grouped data. e.g., monthly summary of
sales on a chart. Say if we wanted to show which part of revenue
came from products and which part from services, we can use the
stacked column chart easily to depict the data. Each month would
represent a data column and the column would be divided into two
parts - one representing service and the other product.
- Combination Charts
Combination Charts are a combination of two or more charts or y-axis.
There are two sub-types of combination charts:
- Single Y-Axis Combination Chart - A single Y-axis (called primary axis) is drawn on the chart, against which all data is plotted.
- Dual Y-Axis Combination Chart - The chart assumes two y-axis (primary and secondary). Each axis can then plot multiple data-series against it.
- Scroll charts
Scroll charts are standard multi-series, combination, stacked charts with additional scrolling capabilities.
- XY Plot Charts (Multi-series data)
XY Plot Charts are charts where both the axes are numeric, like bubble
and scatter chart. In bubble chart, a third dimension of data (size of bubble) is also represented.
- Multi-series Stacked Charts
In charts like multi-series stacked column and multi-series stacked
column line combination charts, you've nested data-sets which allow
you to create multi-series stacked charts (i.e., cluster of stacked columns).
- Zoom Line chart
Zoom Line chart is an advanced chart that allows zooming, scrolling and pinning of data in the same chart. This chart can handle large sets of data including tens of thousands of points.
|