XML technologies / SVG / Manipulating graphics with external scripts / Using external scripts for manipulation / Structure of the example

(Excerpt from “Das Einsteigerseminar SVG — Webgrafiken mit XML” by Helma Spona)

The following example consists of an HTML page into which the same SVG graphic is inserted twice. Both <EMBED> tags are named with the id attribute, and each chart has an XML file containing its formatting settings. When the HTML page loads, JavaScript opens these XML files, reads their values and assigns them to the charts. The browser must support ActiveX object creation, currently only available in Internet Explorer for Windows. Since access to SVG files in HTML has the same restrictions, this poses no additional problem. Processing XML files requires Internet Explorer 5.0 or later, which provides the XML DOM for XML files.

The inserted SVG graphic is a bar chart with at most four bars, axis labels, a title and a legend.

SVG graphic before formatting by script

Figure: SVG graphic before formatting by script.

The script formats the graphic according to the XML file, which also supplies the data series’ values and labels. After formatting, it could look as follows:

Script result

Figure: Script result.

   

 

 

 

back to top