FusionCharts Forum: setDataURL() example in docs not working - FusionCharts Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

setDataURL() example in docs not working

#1 User is offline   DelvarWorld 

  • Forum Newbie
  • Group: Members
  • Posts: 3
  • Joined: 18-July 07

Posted 18 July 2007 - 10:35 AM

For the docs that come with the demo version of FusionCharts, there's the "setDataURL()" example under the"FusionCharts and Javascript" folder. This demo explains the file Download Package > Code > JavaScript > Basics. However, when I try to run this file in my browser (ChangeDataURL()), it gives me the error "chartObj.setDataURL is not a function." I've tried it both in Firefox and IE with the same result. Is this feature disabled in the demo? Why is the help file example throwing an error?
0

Other Replies To This Topic

#2 User is offline   Pallav 

  • FusionCharts Team
  • Group: Administrators
  • Posts: 2386
  • Joined: 08-December 06

Posted 20 July 2007 - 02:16 AM

Just copy-paste the files to a server and run (either localhost or remote).
Thanks,
Pallav Nadhani
Co-founder & CEO, FusionCharts Team
0

Other Replies To This Topic

#3 User is offline   lauvshree 

  • Forum Newbie
  • Group: Members
  • Posts: 6
  • Joined: 26-August 07

Posted 28 August 2007 - 12:27 AM

I tried to run it from the server. Yet getting the same javascript error mentioned earlier. "chartObj.setDataURL is not a function".
Lavanya Sriram
0

Other Replies To This Topic

#4 User is offline   lauvshree 

  • Forum Newbie
  • Group: Members
  • Posts: 6
  • Joined: 26-August 07

Posted 28 August 2007 - 12:48 AM

The chartObj object is a HTMLEmbedElement object and not a FusionChart Object. This explains why the setDataURL/setDataXML gives an error when invoked on this object. But can you tell us how to go about resolving this?
Lavanya Sriram
0

Other Replies To This Topic

#5 User is offline   lauvshree 

  • Forum Newbie
  • Group: Members
  • Posts: 6
  • Joined: 26-August 07

Posted 28 August 2007 - 01:05 AM

Here's how we go about it. In FusionCharts.js replace chartObj.setDataXML(strDataXML); with this.addVariable("dataURL",strDataXML). That works!!
Lavanya Sriram
0

Other Replies To This Topic

#6 User is offline   errodr 

  • Junior Member
  • PipPip
  • Group: Members
  • Posts: 19
  • Joined: 13-February 07

Posted 31 August 2007 - 10:54 AM

Any chance of getting an actual answer from InfoSoft? What exactly do I have to do to my JS to get this dynamic update to work???



Please don't tell me to run it on the server, I have already tried.



Here is the error I am getting: chartObj.setDataURL is not a function



A real answer would be great!!!
0

Other Replies To This Topic

#7 User is offline   Pallav 

  • FusionCharts Team
  • Group: Administrators
  • Posts: 2386
  • Joined: 08-December 06

Posted 02 September 2007 - 02:58 AM

If you're getting an error that setDataURL/setDataXML is not a function of the chart object, please make sure of the following:

1. Please make sure that you're using FusionCharts v3 charts, as the JavaScript API was introduced in this version. To check whether you're using v3, just match your SWF name with the names listed at http://www.fusioncharts.com/Docs/Contents/ChartList.html

2. Please ensure that you've set registerWithJS flag to 1. For more information on how to do this, please see http://www.fusioncharts.com/Docs/Contents/JS_Overview.html. Basically, you need to set the last parameter in the following code to 1:
var chart1 = new FusionCharts("FusionCharts/Column3D.swf", "chart1Id", "400", "300", "0", "1");

3. Please make sure that you're not placing the chart inside a FORM element. When the chart is inside a FORM element, the browser cannot access the chart using DOM.

4. Please make sure that you're not calling the setDataURL/setDataXML method before the chart has loaded and rendered. You need to use FC_Rendered function of chart to track the loading of chart as explained at http://www.fusioncharts.com/Docs/Contents/JS_Overview.html. The page's body onLoad event would NOT work, as the chart starts loading after the body has finished loading.

5. Please make sure that you're NOT running the chart from local file system (C: , D:). Instead, run the chart from behind a server (localhost - IIS, Apache etc.). This is because the Flash Player security settings do not allow Chart to JavaScript interaction, unless otherwise specifically set.

Thanks,
Pallav Nadhani
Co-founder & CEO, FusionCharts Team
0

Other Replies To This Topic

#8 User is offline   bmabey 

  • Forum Newbie
  • Group: Members
  • Posts: 3
  • Joined: 07-September 07

Posted 07 September 2007 - 11:05 AM

I have having similar issues. I am using the code exactly as given in the examples. They all work perfectly fine in Firefox and Safari but do not work in IE. The problem is with the getChartFromId function. In Firefox that function returns another function which the setDataURL function works on. However, in IE the getChartFromId is returning an object which doesn't support the function setDataURL. I have gone through the checklist above and doubled checked that it is being registered with JS (I even used the FC_Rendered function to verify this) and that the chart is not in a form tag. When is curious is that it works in all the browsers except IE. I am using the Prototype JS library in my app. Are there known issues with Prototype interfering with your JS libraries in IE? If you have any further suggestions on how I might resolve this issue please let me know. Thanks,



Ben
0

Other Replies To This Topic

#9 User is offline   Pallav 

  • FusionCharts Team
  • Group: Administrators
  • Posts: 2386
  • Joined: 08-December 06

Posted 10 September 2007 - 11:46 AM

Ben,

We've not yet cross tested FusionCharts library with Prototype library - Our namespaces for the JavaScript class are entirely different, and as such I think we shouldn't have any conflicts.

Thanks,
Pallav Nadhani
Co-founder & CEO, FusionCharts Team
0

Other Replies To This Topic

#10 User is offline   bmabey 

  • Forum Newbie
  • Group: Members
  • Posts: 3
  • Joined: 07-September 07

Posted 13 September 2007 - 03:33 PM

Yeah, I didn't think that would be a problem. I have no idea why this code is not working in IE. I have the following:




function update_fusion(obj_id, url){

 //Sometimes, the above URL and XML data gets cached by the browser.

 //If you want your charts to get new XML data on each request,

 //you can add the following line:

 url = url + "&currTime=" + getTimeForURL();

 //getTimeForURL method is defined below and needs to be included

 //This basically adds a ever-changing parameter which bluffs

 //the browser and forces it to re-load the XML data every time.

 //URLEncode it - NECESSARY.

 url = escape(url);

 //Get reference to chart object using Dom ID "FactoryDetailed"

 var chartObj = getChartFromId(obj_id);

 //Send request for XML

 chartObj.setDataURL(url);

}



/**

* getTimeForURL method returns the current time

* in a URL friendly format, so that it can be appended to

* dataURL for effective non-caching.

*/

function getTimeForURL(){

 var dt = new Date();

 var strOutput = "";

 strOutput = dt.getHours() + "_" + dt.getMinutes() + "_" + dt.getSeconds() + "_" +

 dt.getMilliseconds();

 return strOutput;

}





As I said before IE does work correctly with getChartFromId(). The error says that the Object doesn't support this property or method.
0

Other Replies To This Topic

#11 User is offline   bmabey 

  • Forum Newbie
  • Group: Members
  • Posts: 3
  • Joined: 07-September 07

Posted 13 September 2007 - 04:22 PM

In Firefox (where the code works) here is the output from FireBug:



>>> getChartFromId('chart_pipeline_overview');

function()

>>> getChartFromId('chart_pipeline_overview').setDataURL('http://www.google.com');

>>>



In IE 7.0, when I use Firebug (Lite) the output for the same commands is as follows:

>>> getChartFromId('chart_pipeline_overview');

object#chart_pipeline_overview

>>> getChartFromId('chart_pipeline_overview').setDataURL('http://www.google.com');

undefined



Please help! It seems that the problem lies in the getChartFromId function. I looked at your online demos and I couldn't see what you were doing differently.

-Ben
0

Other Replies To This Topic

#12 User is offline   Sudipto Choudhury 

  • Supreme Being
  • Group: Administrators
  • Posts: 1886
  • Joined: 19-March 07

Posted 17 September 2007 - 01:38 AM

Hi all,

Can you please attach the full code that you are using to use setDataURL() and getting this error. Please also specify the browser & OS being used and the error message.



IF you want to dynamically (may be repetetively) update the chart after loading it with some data.. you can try the sample attach i here :(rename txt to html)







what i have done :

1. used registerWithJS option.

2. used FC_rendered() function to trap the chart object. (Its essential**)

3. After FC_Rendered() is fired (i.e. the full chart is loaded) i intenet to chage its values dynamically and then called setDataURL().

[ this u can change to any serverside script page too to get dynamic XML]





4. * i used setInterval() to continuously update the chart after 3 seconds.

Attached File(s)


Regards,

Sudipto Choudhury
FusionCharts Team

Follow us on Twitter

I code, therefore I am.

0

Other Replies To This Topic

#13 User is offline   bielmenezes 

  • Forum Newbie
  • Group: Members
  • Posts: 1
  • Joined: 19-September 07

Posted 19 September 2007 - 09:36 AM

I had the same problem with IE7, the problem was the name of the variable in the method updateChart.










My old code:



grafico1=false;



function FC_Rendered(DOMId){



switch(DOMId){

case "grafico1":

grafico1 = true;

break;

}

return;

}



function updateChart(idOperadora){



if(grafico1){

//DataURL for the chart

var strURL = "../../gerarGraficoKPIB?operadora=" + idOperadora +"&action=detalhe";



strURL = strURL + "&currTime=" + getTimeForURL();

strURL = escape(strURL);



var chartObj = getChartFromId("grafico1");

chartObj.setDataURL(strURL);



} else {

alert("Please wait for the charts to load.");

return;

}

}

}



<%

String chartCode = FusionChartsCreator.createChart(

"FusionCharts/Pie3D.swf",

"../../gerarGraficoKPIB?action=geral", "", "grafico1",

400, 250, false, true);

%> <%=chartCode%>








The new code that works is:



graf=false;





function FC_Rendered(DOMId){

switch(DOMId){

case "grafico1":

graf= true;

break;

}

return;

}



function updateChart(idOperadora){



if(graf){

//DataURL for the chart

var strURL = "../../gerarGraficoKPIB?operadora=" + idOperadora +"&action=detalhe";



strURL = strURL + "&currTime=" + getTimeForURL();

strURL = escape(strURL);



var chartObj = getChartFromId("grafico1");

chartObj.setDataURL(strURL);



} else {

alert("Please wait for the charts to load.");

return;

}

}

}



<%

String chartCode = FusionChartsCreator.createChart(

"FusionCharts/Pie3D.swf",

"../../gerarGraficoKPIB?action=geral", "", "grafico1",

400, 250, false, true);

%> <%=chartCode%>








My only change is avoid that id and variable names are equals..
0

Other Replies To This Topic

#14 User is offline   lordcraan 

  • Forum Newbie
  • Group: Members
  • Posts: 1
  • Joined: 09-November 07

Posted 09 November 2007 - 01:53 PM

I encountered the "setDataURL is not a function" error as well.



One of Pallav's previous posts mentioned:



Quote

2. Please ensure that you've set registerWithJS flag to 1. For more information on how to do this, please see http://www.fusioncha..._Overview.html. Basically, you need to set the last parameter in the following code to 1:

var chart1 = new FusionCharts("FusionCharts/Column3D.swf", "chart1Id", "400", "300", "0", "1");




In my controller that is responsible for contructing the chart I was using:



renderChart("/flash/Column2D.swf?ChartNoDataText=Please select a District to view detailed data.", "", "", "FactoryDetailed", 300, 250, "0", "1")




but I found that switching "0" to false and "1" to true will fix the error.



Hope this helps.





--craan
0

Other Replies To This Topic

#15 User is offline   Sudipto Choudhury 

  • Supreme Being
  • Group: Administrators
  • Posts: 1886
  • Joined: 19-March 07

Posted 10 November 2007 - 10:18 PM

Hi all,
 
TO set RegisterWithJS :
 
This code is required in Javascript :
 
var chart1 = new FusionCharts("FusionCharts/Column3D.swf", "chart1Id", "400", "300", "0", "1");
 
while using ASP/PHP etc. -

renderChart("/flash/Column2D.swf?ChartNoDataText=Please select a District to view detailed data.", "", "<chart></chart>", "FactoryDetailed", 300, 250, false, true)


Regards,

Sudipto Choudhury
FusionCharts Team

Follow us on Twitter

I code, therefore I am.

0

Other Replies To This Topic

#16 User is offline   timvasil 

  • Forum Newbie
  • Group: Members
  • Posts: 3
  • Joined: 30-December 07

Posted 03 January 2008 - 01:41 AM

FusionCharts is using Adobe's ExternalInterface API to communicate between JavaScript and the SWF chart. For some reason, ExternalInterface isn't working correctly on IE under some conditions.  I happen to be using the ExtJS library with GWT; either framework may be doing some DOM manipulations under the covers that are freaking out Adobe--but I haven't verified this.

A couple things to try:

  1. Ensure that the ID and name attributes of the OBJECT and/or EMBED tags do not have characters such as . (period), -, +, *, /, and .  Amusingly, this is because Adobe's ExternalInterface API is using a bunch of eval() JavaScript methods and these special characters get interpreted as JavaScript operators.  Yeah, great work, Adobe.
     
  2. Hook up the ExternalInterface functions you need manually.  For example, here's the modified setDataXML function in FusionCharts.js to do the trick (code in red has been added):

setDataXML: function(strDataXML){
  //If being set initially
  if (this.initialDataSet==false){
  //This method sets the data XML for the chart INITIALLY.
  this.addVariable('dataXML',strDataXML);
  //Update flag
  this.initialDataSet = true;
  }else{
  //Else, we update the chart data using External Interface
  //Get reference to chart object
  var chartObj = infosoftglobal.FusionChartsUtil.getChartObject(this.getAttribute('id'));
  if (!chartObj.setDataXML)
  {
  __flash__addCallback(chartObj, "setDataXML");
  }
  chartObj.setDataXML(strDataXML);
  }
},

 


www.timvasil.com
0

Other Replies To This Topic

#17 User is offline   Sudipto Choudhury 

  • Supreme Being
  • Group: Administrators
  • Posts: 1886
  • Joined: 19-March 07

Posted 06 January 2008 - 08:10 AM

Hi,

Thanks for the valuable R&D.

Can you please try the new FusionCharts.js released with FusionCharts v3.0.5 where we try to cope up with the IE's external interface issue while using the chart inside a form.

Regards,

Sudipto Choudhury
FusionCharts Team

Follow us on Twitter

I code, therefore I am.

0

Other Replies To This Topic

#18 User is offline   timvasil 

  • Forum Newbie
  • Group: Members
  • Posts: 3
  • Joined: 30-December 07

Posted 09 January 2008 - 10:06 AM

When I ran into the problem, my web page did not have a <form> and I was already using the latest FusionCharts.js file--the one with this in the header:  "Version: 1.2 (1st November, 2007) - Added Player detection, New conditional fixes for IE, New FORM fixes for IE."

-Tim

www.timvasil.com
0

Other Replies To This Topic

#19 User is offline   mgnanamani 

  • Forum Newbie
  • Group: Members
  • Posts: 2
  • Joined: 09-January 08

Posted 09 January 2008 - 11:23 AM

I still get the error message 'feedData() not a function'. I just ran the example at http://www.fusioncha...m/gadgets/docs/ -> feeding data using javascript.



Mozilla is reporting that 'chartRef.feedData is not a function'.



I think this feedData() function is still confusing many.



As I used the example as such, there is no question of registering the object with '1' (the last argument in 'new FusionChart()'). Moreover I am running the script behind a server (Apache).



Hope to get some useful clarification.



Thanks in advance.
0

Other Replies To This Topic

#20 User is offline   Sudipto Choudhury 

  • Supreme Being
  • Group: Administrators
  • Posts: 1886
  • Joined: 19-March 07

Posted 10 January 2008 - 05:22 AM

You need to use registerWithJS to get all functions like feedData()
Regards,

Sudipto Choudhury
FusionCharts Team

Follow us on Twitter

I code, therefore I am.

0

Other Replies To This Topic

#21 User is offline   Sudipto Choudhury 

  • Supreme Being
  • Group: Administrators
  • Posts: 1886
  • Joined: 19-March 07

Posted 10 January 2008 - 05:24 AM

Moreover, try using the latest FusionCharts.js released on 22 Dec wiht v3.0.5
Regards,

Sudipto Choudhury
FusionCharts Team

Follow us on Twitter

I code, therefore I am.

0

Other Replies To This Topic

#22 User is offline   Rajroop 

  • FusionCharts Team
  • PipPipPipPipPipPipPipPip
  • Group: Members
  • Posts: 1803
  • Joined: 19-May 09

Posted 03 July 2009 - 08:09 AM

Hello :),



We are really excited to announce the release of FusionCharts for Flex v1.1 featuring the following:



- 12 new chart types: 7 new gauges including Angular gauge, LED gauge and Linear gauge, Spark chart and Bullet graphs have been added.

- All the gauges can fetch data in real-time and come with alert managers and message loggers.

- All the charts and gauges can now be natively exported as images and PDFs.

- The data for all the charts can be exported as CSV.

- Data sets can now have custom text labels instead of numeric values.

- The charts can handle a lot more events to help you manipulate them better.

- Trendlines can also have custom tool-text.

- Custom color palettes can be defined for the data plots.



Learn more about it from www.fusioncharts.com/flex and learn more on whats new from http://www.fusioncha...ionHistory.asp.



Existing customers can upgrade to the new version from www.fusioncharts.com/PUC.
Regards,

Rajroop Bhaduri

FusionCharts Team

Help us improve our documentation with your precious feedback at:
http://documentation...sioncharts.com/

Follow us @Twitter
0

Other Replies To This Topic

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic