Sign in to follow this  
evanluck

setDataURL only works after running the function twice or delaying with an alert

Recommended Posts

I'm using JQuery and am running into a problem with the setDataURL function. It works the second time I execute the function but not the first. If I delay the running of the function with an alert, the function will work the first time.

 

 

 

Tried to implement a setTimeout solution but could not get that to work at all.

 

 

 

example can be seen here:

 

http://www.tscplcommunityconnect.com/services.php

 

 

 

Code excerpt is below:

 

 

 




     //updateChart method is called whenever the user clicks the button to

     //update the chart. Here, we get a reference to the chart and update it's

     //data using setDataURL method.

     function updateChart(service,percent){

        //Get reference to chart object using Dom ID

        var chartObj = getChartFromId("rankgraph");

	 //assemble new data URL from arguments -dc replace with php script DONE

	 var theURL = "services_like_me_all.php"+"?service="+service+"&percent="+percent;

	 //set new URL

	 //alert(theURL);

        chartObj.setDataURL(theURL);



     };



  function findSegmentsbyService() {

  $('#graphbox').show();

  var theService = $('#serviceselectbox').val();

  var thePercent = $('#atleast').val();

  $("#insservice").html(theService);

  $("#inspercent").html(thePercent);

  updateChart(theService,thePercent);

  };







Edited by Guest

Share this post


Link to post
Share on other sites

Hi,

 

 

 

The setDataURL function is available only after the chart is rendered.

 

 

 

This can be tracked down by placing FC_Rendered(DOMId) JavaScript function . The chart would call the function once the chart is ready for setDataURL().

 

 

 

Please call setDataURL() only after FC_Rendered() is called.

Share this post


Link to post
Share on other sites

Thank you for the reply...

 

 

 

Given my function, can you give me an example of how to implement the FC_Rendered(DOMId) function.

 

 

 

I tried and couldn't get it to work

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this