Previous Topic: Graphics and ChartsNext Topic: Preparing Chart Data


Charts

SVG only defines graphics primitives; to simplify the production of business charts, a template library (svg-chart.xsl) has been produced, providing basic pie, bar, column and line charts. To use the charting templates, the library can be incorporated into the custom format stylesheet by defining the namespace and using the xsl:import element to include the templates and the xsl function library as follows:

<xsl:stylesheet version="1.0" 
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
    xmlns:svg-chart="http://www.ca.com/svg-chart">

    <xsl:import href="../xsl-functions.xsl"/>
    <xsl:import href="../svg-chart.xsl"/>
…

Functions from the xsl function library can be accessed in the report by declaring the required namespaces. The most useful library is the string library (http://www.orchestria.com/string) which contains functions encodeName(name) and decodeName(name) which can be used to convert XML names that have been encoded with Unicode hex strings (e.g. an XML name cannot contain a space so 'My Name' is encoded as 'My_x0020_Name').

Producing a chart is a two-step process:

  1. Define the data to be charted.
  2. Draw the chart using the prepared data.