luftikus143 Report post Posted October 3, 2007 Hi there, I am using the example "Combining FusionCharts, PHP & Javascript (dataURL) method". But for the var chartObj = getChartFromId("name_of_chart"); I get the error: getChartFromID is not defined My code is: < div id="chartdiv" align="center"> .... javascript opening here.... var chart = new FusionCharts("http://localhost/etc/FusionCharts_Evaluation/Charts/Bubble.swf", "ChartId", "1000", "700", "0", "0"); chart.setDataURL("<?php echo $strDataURL; ?>"); chart.render("chartdiv"); function updateChart(year) { var strURL = "graph_scatter-data.php?selectedID=1510&selectedYear=" + year + "&xaxis="; strURL = unescape(strURL); var chartObj = getChartFromID("ChartId"); alert(chartObj); chartObj.setDataURL(strURL); } .... javascript close here.... < a href="#" onclick="updateChart('1995');">older year< /a> I tried it both with "ChartID" and "chartdiv", but neither worked. (I guess ChartID should be the right one.) Can you help me? Share this post Link to post Share on other sites
Arni XET Report post Posted October 3, 2007 It seems that in the new FusionCharts() line, the last paramwter is set to '0'. That should be a '1'. It registers the chart with Javascript. Try that. Share this post Link to post Share on other sites
luftikus143 Report post Posted October 4, 2007 Thanks, but no change, same error message... Share this post Link to post Share on other sites
Pallav Report post Posted October 5, 2007 Hi, Can you make sure that FusionCharts.js is properly included in the page? Ideally, the error message should have been different for improper usage. But, if it's giving "getChartFromID is not defined", that means the function has not been registered. Share this post Link to post Share on other sites
luftikus143 Report post Posted October 8, 2007 It is correctly included... Stef Share this post Link to post Share on other sites
Pallav Report post Posted October 9, 2007 Can you give us a live link to the page so that we can directly debug? Share this post Link to post Share on other sites
luftikus143 Report post Posted October 9, 2007 Unfortunately not, as it is installed only locally... I can see if I can switch it over to the production machine however... Share this post Link to post Share on other sites
luftikus143 Report post Posted October 9, 2007 Ok, so here is the URL. And at the bottom of the page is the link "year before", which calls the updateChart function. Thanks for any clarification! Stef Share this post Link to post Share on other sites
Pallav Report post Posted October 9, 2007 Can you try putting this code block in the section of your document: function updateChart(year) { var strURL = "graph_scatter-data.php?selectedID=1510&selectedYear=" + year + "&xaxis="; strURL = unescape(strURL); var chartObj = getChartFromID("ChartId"); chartObj.setDataURL(strURL); } Share this post Link to post Share on other sites
luftikus143 Report post Posted October 9, 2007 Thanks a lot for having a look. But I don't see a difference between my code and yours above... Stef Share this post Link to post Share on other sites
FusionCharts Support Report post Posted October 11, 2007 Hi, I hope the browser error prompt was right . There is no method called getChartFromID . The function's name is getChartFromId(). The D makes the difference. moreover use escape() function instead of unescape() to encode the URL. function updateChart(year) { var strURL = "graph_scatter-data.php?selectedID=1510&selectedYear=" + year + "&xaxis="; strURL = escape(strURL); var chartObj = getChartFromId("ChartId"); chartObj.setDataURL(strURL); } Share this post Link to post Share on other sites
luftikus143 Report post Posted October 11, 2007 Wow, that's it!! Great. Thanks a lot!! Stef Share this post Link to post Share on other sites
luftikus143 Report post Posted October 11, 2007 I've implemented an automatic call of the update function, so that it displays every second or so the selected variables with another year. Is there a way to avoid that the whole chart is being reloaded? It looks a bit ugly and is surely pretty tiresome. Here is again the URL. And then click on "automatic change" above the listing of the years. Thanks for any advice! Share this post Link to post Share on other sites
FusionCharts Support Report post Posted October 12, 2007 Hi, YOu can try using AJAX (getting data from URL) to retrieve the XML in a javascript variable. Then use setDataXML() method to reload the chart data from that variable. Remember to set animation='0' i.e. off if you are feeling that the you need less delay. This process may take the same delay but it wont erase the chart and go for a long retrieving data prompt. Because data will be retrieved by AJAX and not chart. In that time the old chart willl remain in display. When you get the data in js variable you set it to the chart and the char refreshes the data in a swish...... Share this post Link to post Share on other sites
luftikus143 Report post Posted October 15, 2007 You can try using AJAX Are there any existing examples with AJAX? So that one can reuse the code? Thanks for any hints! Share this post Link to post Share on other sites
FusionCharts Support Report post Posted October 31, 2007 (edited) Hi, Here is a simple AJAX sample using FusionCharts and ASP. Read Post : http://www.fusioncharts.com/forum/Topic2576-28-1.aspx#bm2797 Edited October 31, 2007 by Guest Share this post Link to post Share on other sites