Sign in to follow this  
codeMonkey

Simple Javascript Link Error

Recommended Posts

I am new to FusionCharts and am running into some basic problems executing javascript functions when a user clicks on data items in my graph. I just want an alert box to appear when the user clicks on a column in a column chart. I tried copying and pasting some sample code from the documentation website, but the page does execute correctly. The chart loads correctly and looks great but when I click on the column, nothing happens. I used the sample code from the following link: http://www.fusioncharts.com/docs/?DrillDown/JavaScript.html

After that didn't work, i went about it another way and tried to imbed javascript methods directly into the xml file, but that didn't work either. This must be a very simple error that I am making so I was wondering if anyone would be kind enough to help me out. I tried it in both IE and Firefox and it seems like the function is never getting called.

 

Here is the html file:

<html>

<head>

<title>JavaScript Link Example</title>

<script language="JavaScript" src="../FusionCharts/FusionCharts.js"></script>

<script LANGUAGE="JavaScript">

 

function myJS(myVar){

window.alert(myVar);

}

 

</SCRIPT>

</head>

<body bgcolor="#ffffff">

<div id="chartdiv" align="center">The chart will appear within this DIV.

This text will be replaced by the chart.</div>

<script type="text/javascript">

var myChart = new FusionCharts("../FusionCharts/Column2D.swf",

"myChartId", "500", "300", "1", "1");

myChart.setXMLUrl("data.xml");

myChart.render("chartdiv");

 

</script>

</body></html>

 

 

Here is the xml file:

 

<chart caption='ABC Bank Branches' subCaption='(In Asian Countries)' yaxislabel='Branches' xaxislabel='Country'>

<set label='Hong Kong' value='235' link="JavaScript:alert('hello');"/>

<set label='Japan' value='123' link='j-myJS-Japan, 123'/>

</chart>

 

 

 

Edited by codeMonkey

Share this post


Link to post
Share on other sites
Guest Angshu

Hi,

 

Welcome to FusionCharts Forum!smile.gif

 

First of all, we would like to thank you for showing interest in FusionCharts.

 

Please find the sample zip file attached for your reference.

 

Hope this helps.smile.gif

JSLink Sample.zip

Share this post


Link to post
Share on other sites

I downloaded the files that you posted and opened the html file, but it had the same problem. The chart displayed correctly, but when I clicked on the columns, nothing happened. I tried viewing the file in IE v 7 and FireFox, but it didn't work in either of them. Is there a setting that I need to change in order to enable javascript functions as links?

Edited by codeMonkey

Share this post


Link to post
Share on other sites

Hi,

 

Flash Player Global Security settings needs to be enabled, if you are running the application from local file system (C:\ or D:\) and not from web server (local or live).

 

Flash Player's Global Security setting blocks invoking/calling JavaScript from SWF (Flash Movie) by default. So you need to reset your setting into Global Security Setting panel and enable it.

 

Please refer to the following page for further details on the Flash Player Global Security settings:

http://www.fusioncharts.com/Tools/FlashPlayerSecuritySetup/HowToSetup.html

 

I hope this helps. Looking forward to your feedback.

Share this post


Link to post
Share on other sites

Flash Player Global Security settings needs to be enabled, if you are running the application from local file system (C:\ or D:\) and not from web server (local or live).

Thanks! I have been trying to figure this out for a couple days and that was exactly what I needed to do, it works great now.

Share this post


Link to post
Share on other sites
Guest Angshu

Hi,

 

Glad to know that you have managed to resolve your problem.

 

Happy FusionCharting!biggrin.gif

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