Sign in to follow this  
zaerick

Javascript On Datalabels

Recommended Posts

Hello,

 

I am trying to call javascript function/code when the user clicks on a category label using the known workaround.

( ex <category label="< a href=\"Javascript:func();void();\" > the_label < /a >" > ).

 

My problem occurs when using IE. When a user clicks on the label in IE, IE fires an onbeforeunload event

handler which we use to clear the session. Is there an alternative method or work around to

get label (category) clicking functionality? Or perhaps a suggestion on how I can prevent it from firing onbeforeunload?

The unloading of a page doesn't occur in ff, safari, or chrome.

 

Thank you.

Share this post


Link to post
Share on other sites

Hello,

 

Unfortunately, that does not help. My issue is with adding javascript code to category labels, (labels along the x-axis) not

adding javascript to data points.

 

There is no link property for category labels as far as I know and so I'm using the workarounds explained in these posts

link1, link 2, link 3, link 4

 

I've managed to get it working in firefox, safari, and chrome, but as usual IE9 is the one causing the problem.

 

By inspecting the DOM, it appears that FusionCharts internally parses the category labels for links and creates

tspans with an onclick that modifies location.href. It is because it modifies location.href that it causes onbeforeunload

to fire.

 

Is there an expected time frame for when the link property will be added to categories? Or a different workaround than

that mentioned in those forum posts.

 

Thanks.

Share this post


Link to post
Share on other sites
Guest Angshu

Hi,

 

Thanks for your response.

 

Could you please try once by setting labelDisplay='NONE' attribute inside the <chart> element of the XML code?

 

I am afraid, FusionCharts does not natively support adding links to category labels, as of now.

 

We would get back to you once there is any news from our end regarding the same.

 

Hope this helps.

Share this post


Link to post
Share on other sites

Hello,

 

That doesn't help. I am able to call a javascript function, but the problem is that in IE, it attempts

to unload the page before calling the function.

 

Please let me know when this feature has been added.

 

Thanks.

Share this post


Link to post
Share on other sites
Guest Angshu

Hi,

 

Thanks for your response.

 

 

Instead of using simple links, you can also set JavaScript links using FusionCharts. That is, you can invoke a JavaScript function present in the same page (in which the chart is present) when the end viewer clicks a data element on the chart.

 

For a live example, please visit: http://docs.fusioncharts.com/charts/Code/DrillDown/JSExample.html

 

This feature works for data elements only, not for data labels.

 

However, you can provide simple link to the category labels using STYLES features and anchor tags in Flash charts.

 

Hope this helps.

Share this post


Link to post
Share on other sites

Hello,

 

Unfortunately we require links on the data labels for various reasons, which is why we chose fusion charts over other charting libraries in the first place.

 

Is there perhaps a way to set attributes of the anchor tag itself? For example, the target attribute, or rel, or name?

 

Awaiting for your response.

Share this post


Link to post
Share on other sites

Hi,

 

Apologies for the delayed response.

 

As mentioned earlier, I am afraid, FusionCharts does not natively support adding links to data labels, as of now.

 

As a work around, try using the anchor tag to define a link for the data labels. This work around works only for JavaScript charts.

 

Sample demo: http://jsfiddle.net/shamasis/yh8Uc/embedded/result/

 

Hope this helps.

 

 

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