I am using JS Charts to draw ‘bar’ chart and I don’t know how to build the XML file data with data collected from the DataBase?
This is how I prepare XML data but It doesn’t work, could you please help me?
<SCRIPT>var strXML = <JSChart><dataset type='bar'><data unit='Delivered' value='29/><data unit='Pending' value='9/><data unit='Rejected' value='6/><data unit='Unknown' value='/></dataset><colorset>
<color value='#7979DB'/>
<color value='#7952E9'/>
<color value='#792BC8'/>
<color value='#792BA1'/>
</colorset><optionset>
<option set='setAxisValuesColo' value= '#008'/>
<option set='setAxisColor' value='#ABABAB'/>
<option set='setAxisWidth' value='1'/>
<option set='setAxisValuesColor' value='#858585'/>
<option set='setAxisNameColor' value='#858585'/>
<option set='setBarBorderColor' value='#bbb'/>
<option set='setBarOpacity' value='0.8'/>
<option set='setBarSpacingRatio' value='50'/>
<option set='setBarValues' value='false'/>
<option set='setTitleColor' value='#928888'/>
<option set='setGridColor' value='#ABABAB'/>
</optionset></JSChart>;</SCRIPT>
<script type="text/javascript" src="/image/mobiletool/calander/js/jscharts.js"></script>
<div id="graph">Loading graph...</div>
<script type="text/javascript">
var myChart = new JSChart('graph', 'bar');
myChart.setDataXML(strXML);
myChart.draw();
</script>
It looks to me like you are creating the XML in PHP but not passing it over to JS. You effectively need to echo out your $strXML for JS to be able to use it. Something along the lines of this:
If you echo out this before your JS then you just need to change:
to
Give it a try.