pyrite Report post Posted July 25, 2011 Hello, I'm trying to update a chart with new JSON data, and also change the chart's subcaption to reflect the new data. This code works, sort of, it changes the subcaption, then refreshes the chart with the new data and puts it back to the old subcaption. What am I doing wrong? <html> <head> <title>On-Time Delivery by Work Area</title> <script type="text/javascript" src="/configurator/js/fc/Charts/FusionCharts.js"></script> </head> <body> <div style="float: right"> <select id="selmonth" onchange="chgmonth();"> <?php $s = ''; for ($i = 1; $i <= 12; $i++) { if ($i <= date("n")) { if ($i == date("n")) { $s = ' selected="selected"'; } echo '<option value="'.$i.'"'.$s.'>'.date("F Y", mktime(0, 0, 0, $i+1, 0, date("Y"), 0)).'</option>'; } } ?> </select> </div> <p> </p> <div id="chartContainer">FusionCharts will load here!</div> <script type="text/javascript"> <!-- var myChart = new FusionCharts( "/configurator/js/fc/Charts/MSColumnLine3D.swf", "otdbyworkareaytdchart", "95%", "95%", "0", "1" ); myChart.setJSONUrl("/configurator/metrics/getotdbyworkareaytd"); myChart.render("chartContainer"); function chgmonth() { chartReference = FusionCharts("otdbyworkareaytdchart"); var action = document.getElementById('selmonth'); chartReference.setChartAttribute( "subcaption" , action.options[action.selectedIndex].text ); chartReference.setJSONUrl("/configurator/metrics/getotdbyworkareaytd/"+action.value); } // --> </script> </body> </html> Share this post Link to post Share on other sites
Guest Angshu Report post Posted July 26, 2011 Hi, Welcome to FusionCharts Forum! It seems that you are providing the old subcaption when the chart refreshes with the new data. Please try the same by providing the subcaption you are looking for while updating the chart. Hope this helps. Share this post Link to post Share on other sites
pyrite Report post Posted July 28, 2011 I don't understand what you just said, but: myChart.setJSONUrl("/configurator/metrics/getotdbyworkareaytd"); This returns the chart data in JSON format, with a subcaption set. The code above changes the JSON data, but I am trying to override the subcaption after I call setJSONUrl(). And it works for a second, but then goes back to the subcaption defined in the JSON data instead of the one set by setChartAttribute. Share this post Link to post Share on other sites
pyrite Report post Posted July 29, 2011 I solved the problem by just not using setChartAttribute, and setting the subcaption in the JSON everytime the data changes instead. Share this post Link to post Share on other sites
Guest Angshu Report post Posted July 29, 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