Charting libraries that use XML files to define charts use a array based structure to enable users settings arbitrary parameters. The expected array structure is described here.
To allow the definition of any XML structure the array supports the following parameters:
To remove a tag defined by the charting library the user must pass a tag with the id to be removed and the #value parameter with the NULL value.
Here is a rather complete example. Remember that the only mandatory parameter is #id. Observe that the main array and each #children array is an array of arrays.
<?php
$canvas->settings = array(
array(
'#id' => 'value',
'#value' => $this->encode_for_xml($val),
'#attributes' => array(
'xid' => 13,
),
array('#id' => 'js_enabled', '#value' => 'false'),
array(
'#id' => 'axes',
'#children' => array(
array(
'#id' => 'y_left',
'#children' => array(array(
'#id' => 'logarithmic',
'#value' => 'true')),
),
array('#id' => 'show', '#cdata' => '{title}: {value}%'),
),
)),
);
The above code results in the following settings file:
<?xml version="1.0" encoding="utf-8"?>
<settings>
<value xid="13">STRING_REPRESENTATION_OF_ENCODED_VALUE_OF$val</value>
<js_enabled>false</js_enabled>
<axes>
<y_left>
<logarithmic>true</logarithmic>
</y_left>
<show><![CDATA[{title}: {value}%]]></show>
</axes>
</settings>
To guarantee complete flexibility no treatment is made in the contents of any paramters: #id, #value etc. Any enconding, case transformation or else must be done by the user before passing the data to each charting library.
#cdata content receive CDATA's prefix and suffix:
<![CDATA[and
]]>This can be seen as an exception for the above rule.