Jonathan Report post Posted August 10, 2011 Hello! What I want to achive: I want to draw and update a chart (or different charts) and depending on a few attributes I want the chart type to be different (so in one scenario i want it to be a combi chart and in the other a combi chart with double Y). The solution I found for this is to check wich chart type I want everytime I update the data and create a new chart with the right type. What the problem is: When I do this I get "Error in Loading Data" about 50% of the time (or more). This is how a bit of the the javascript code looks like: var oldFc = getChartFRomId("myChartId"); oldFc.dispose(); var newFc; if(useCombiChartDoubleY) { newFc = new FusionCharts("MSCombi2D.swf", "myChartId", myWidht, myHeight, "0", "1", {wMode : "transparent"}); } else { newFc = new FusionCharts("MSCombiDY2D.swf", "myChartId", myWidht, myHeight, "0", "1", {wMode : "transparent"}); } newFc.setDataURL(myUrl); newFc.render("myChartDiv"); I have alterd between setDataURL and setXMLUrl and noticed no difference. I have tried to use the old chart object and just updated the xmlurl and if I do that it works perfect with the setDataURL method but not at all with the setXMLUrl method. The problem then is that i cant modify the chart type. Any directions or guidelines are appreciated. Share this post Link to post Share on other sites
Guest Angshu Report post Posted August 10, 2011 Hi, Welcome to FusionCharts Forum! Please find a sample zip file attached for your reference. Hope this helps. ChangeChartType .zip Share this post Link to post Share on other sites
Jonathan Report post Posted August 10, 2011 Hi Changing the chart type works, but the problem seems to be on how i provide my own xml. When i first create the chart i use setDataURL and it works and displays my xml from my url. But when i tried your suggestion of getting the xml from the old chart it is just empty. Short example: var myFirstFusionChart = new FusionCharts("myChartId, myChartType,...) myFirstFusionChart.setDataURL(myUrl); myFirstFusionChart.render(myChartDiv); //This first three lines works and displays my chart with my data //Later when i call my update script and i try to get the chart xml it is empty if(FusionCharts("myChartId"); { width = FusionCharts("myChartId").width; height = FusionCharts("myChartId").height; chartXML = FusionCharts("myChartId").getXMLData(); FusionCharts("myChartId").dispose(); } //With this code width and height gets values but chartXML is empty Share this post Link to post Share on other sites
Jonathan Report post Posted August 10, 2011 Hi I went of track with the problem I think. With the code I have now I am able to change the chart type to my desired type. The problem is when i call setDataURL and then render i sometimes get "Error in Loading Data" but not all the time (sometimes it displays my data and sometimes i get the error). The url i provide generates the xml when it is called, is it possible that my url dont generate the XML fast enough? (So when the chart tries to render the xml is not finished). Share this post Link to post Share on other sites
Guest Angshu Report post Posted August 10, 2011 Hi, Thanks for your response. Please try the same by using setXMLUrl() method instead of setDataURL() method. Hope this works. Share this post Link to post Share on other sites
Jonathan Report post Posted August 10, 2011 Hi Both methods give the same result. I think it is wierd that it doesn't work, I generate others charts with very similar code and they works fine. Do you know if it could be a problem if the url provided to the chart generate the xml when it is called? Thank you for your patience with my problem Share this post Link to post Share on other sites
Jonathan Report post Posted August 11, 2011 Hi I solved the problem and it was on our side in the method that generated the xml. Thank you Angshu for helping me even if it was not a problem with the fusionchart framework Regards Jonathan Share this post Link to post Share on other sites
Guest Angshu Report post Posted August 11, 2011 Hi, Glad to know that you have managed to resolve your problem. Happy FusionCharting! Share this post Link to post Share on other sites