Sign in to follow this  
rthere

Argument passing in Drill Down Charts

Recommended Posts

I am using the drill down chart as described in the example http://www.fusioncharts.com/docs/Contents/PHP_JS_URL.html

There is an updateChart() javascript function to which i would like to send multiple arguments. But when i tried to change the arguments to text files, I am getting error saying 'all command not found'. 'all-regr' is the argument i am trying to pass.

Here is the specific code snippet i am referring to. I am copying the definition of the updateChart as i have not changed it from the original. When the argument is a single number like $matches[2] in the case below everything works fine. But when it is a string argument, the browser is trying to execute the argument as a command. I tried various forms of escaping to no avail. I have seen the unescapeLinks comment in a different post and have tried it. But that did not fix the problem either.

Thanks for the help.

<code>

  $strXML = "<chart unescapeLinks='0' palette='4' piefillAlpha='34' pieBorderThickness='1' hoverFillColor='FDCEDA' pieBord

erColor='666666' baseFontSize='9' useHoverColor='1' showLabels='1' showValues='1' caption='LSF Usage By Project' showShadow=

'0'>";

  $strXML .= "<category label='all-regr'>";

  system("../../../../../../site_overview/mypbstree.pl -l7 -gall-regr| grep Group", $pbsProjects, $retVal);

  exec("cat text.txt", $pbsProjects, $retVal);

  $i=0;

  foreach ($pbsProjects as $projects) {

  $i += 1;

  preg_match('/Group = (.*),(d*),(d*)/', $projects, $matches);

  //Note that we're setting link as updateChart(factoryIndex) - JS Function

  $strXML .= "<category value='" . $matches[2]. "' label='" . $matches[1] . "' link='javaScript:updateChart(".$matches[1

].")'>";

  $strXML .= "</category>";

  }

  $strXML .= "</category>";

  //Finally, close <chart> element

  $strXML .= "</chart>";

 

</code>

Share this post


Link to post
Share on other sites
Guest Basundhara Ghosal

Hi,

Could you please send us the XML codes that you are using, as an attachment?

Awaiting your reply. :)

Share this post


Link to post
Share on other sites

I am using the example code that is provided in the FusionCharts v3 online documentation. Guide for Web Developers/Using with PHP/PHP, JavaScript & (dataURL) method. Here is the javascript function from the example. It doesn't work when you pass a string value into it.

 

function updateChart(factoryIndex){

 

//DataURL for the chart

 

var strURL = "FactoryData.php?factoryId=" + factoryIndex;

 

 

 

//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:

 

//strURL = strURL + "&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.

 

strURL = escape(strURL);

 

 

 

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

 

var chartObj = getChartFromId("FactoryDetailed");

 

//Send request for XML

 

chartObj.setDataURL(strURL);

 

}

 

Here is the code that sets up the link and passes the parameter to this function. If a string is passed with only one word and no spaces the error is "the string name" is not defined. If you pass it a string with two words and a space the error is "missing)after argument list. missing ) after argument list and [break on this error] updateChart(Europe District) respectively.

 

$strXML .= "";

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