razr99 Report post Posted February 28, 2012 I have to render a number of charts in the same page and the data comes from a MySQL db. The issue that I have is the page is rendering the same chart twice, instead of 2 different charts. Here's the XML file that's generated through php: <chart caption="% Asthma Patients w/ Flu Vaccine" sformatNumberScale='1' syncAxisLimits='1' rotateValues='0' rotateLabels='1' slantLabels='0' showSum='1' numVDivLines='10' vDivLineIsDashed='1' vDivLineDashLen='2' vDivLineDashGap='2' xAxisName='Month' > <set label="May/2010" value="58"/> <set label="Jun/2010" value="16"/> <set label="Jul/2010" value="3"/> <set label="Aug/2010" value="6"/> <set label="Sep/2010" value="6"/> <set label="Oct/2010" value="3"/> <set label="Dec/2010" value="5"/> <set label="Jan/2011" value="5"/> <trendLines> <line startValue='180' color='009933' isTrendZone='1' displayvalue='' /> </trendLines> <styles> <definition> <style name='myShadow' type='Shadow' distance='5' angle='45' /> </definition> <application> <apply toObject='Canvas' styles='myShadow' /> </application> </styles> </chart> <chart caption="% Asthma Patients w/ 3 Care Components" sformatNumberScale='1' syncAxisLimits='1' rotateValues='0' rotateLabels='1' slantLabels='0' showSum='0' numVDivLines='10' vDivLineIsDashed='1' vDivLineDashLen='2' vDivLineDashGap='2' xAxisName='Month'> <set label="May/2010" value="55"/> <set label="Jun/2010" value="17"/> <set label="Jul/2010" value="4"/> <set label="Aug/2010" value="4"/> <set label="Sep/2010" value="4"/> <set label="Oct/2010" value="6"/> <set label="Dec/2010" value="7"/> <set label="Jan/2011" value="5"/> <trendLines> <line startValue='180' color='009933' isTrendZone='1' displayvalue='' /> </trendLines> <styles> <definition> <style name='myShadow2' type='Shadow' distance='5' angle='45' /> </definition> <application> <apply toObject='Canvas' styles='myShadow2' /> </application> </styles> </chart> The above code when seeing in a browser gives me the following error: XML Parsing Error: junk after document element Location: http://staging.ncahec.net/roles/ipip/dataChartXML.php Line Number 21, Column 21: </styles></chart><chart caption="% Asthma Patients w/ 3 Care Components" sformatNumberScale='1' and points to the second opening <chart> tag. Here's how I'm calling these: var myChart = new FusionCharts( "../../includes/Charts/Line.swf", "myChartId", "700", "400", "0", "1" ); myChart.setXMLUrl("dataChartXML.php"); myChart.configure("RenderingChartText", "Rendering chart. Please wait"); myChart.render("asthmaChart1"); var myChart2 = new FusionCharts( "../../includes/Charts/Line.swf", "myChartId2", "700", "400", "0", "1" ); myChart2.setXMLUrl("dataChartXML.php"); myChart2.configure("RenderingChartText", "Rendering chart. Please wait"); myChart2.render("asthmaChart2"); And I have the two divs that render the charts <div id="asthmaChart1"></div> <div id="asthmaChart2"></div> I was successful implementing this using two separate XML files. I'm wondering what's the way to do this using only one single XML files, otherwise I'll have to generate tons of XML files (one for each chart). Thanks. Share this post Link to post Share on other sites
Guest Sumedh Report post Posted February 29, 2012 Hi, You would need to add a conditional block into your code to render two charts in the same page. Create one variable to store the value which is passed from the setXMLUrl method, ( which will not overwrite the XML code of chart2 with the XML code of chart1) $var1=$_POST['chart']; if($var1=="ch1") { echo "strXML1"; ------ (QueryString 1 from database to generate chart1 XML) } else if($var1=="ch2"){ echo "strXML2"; ------ (QueryString 2 from database to generate chart2 XML) } else { echo "Data not found"; } Pass this "dataChartXML.php?chart=ch1" as a parameter in the setXMLData method as XML will be generated dynamically, that will check the condition while it will pass the querystrings to respective charts. setXMLData("dataChartXML.php?chart=ch1"); ----- (for 1st chart). setXMLData("dataChartXML.php?chart=ch2");------( for 2nd chart). Hope this helps. Share this post Link to post Share on other sites