Sign in to follow this  
sudhanshu

Javascript_Linked_Json_Chart

Recommended Posts

Hi,

I am using json to build chart. I want to call a JavaScript function when I click on a linked chart .

Please tell me what is the syntax or a piece of example code to do that.

My chart is

{'chart':{'caption':'IT Spend Effectiveness','xaxisname':'Geography','yaxisname':'uptime','unescapeLinks' : '0' },' bgColor':'DFE8F6', 'canvasBgColor':'DFE8F6',

'data':[

{ 'label':'Americas ','value':'142.512077294686','link':'JavaScript-alert(Hi)' },

{ 'label':'Asia ','value':'142.512077294686','link':'JavaScript-alert('Hi')' },

, { 'label':'Europe ','value':'142.512077294686','link':'JavaScript-alert-Hi;' }]

}.

When I am clicking on the bars it's showing error.

Thanks for your reply in advance.

post-19267-0-24214500-1310973448_thumb.jpg

Share this post


Link to post
Share on other sites
Guest Angshu

Hi,

 

Welcome to FusionCharts Forum!smile.gif

 

Please find the sample code below:

 

 
{
       "chart": { 
               "caption" : "Weekly Sales Summary" ,
               "xAxisName" : "Week",
               "yAxisName" : "Sales",
               "numberPrefix" : "{:content:}quot;
       },

       "data" : 
               [
                 { "label" : "Week 1", "value" : "14400", "link" :"JavaScript: isJavaScriptCall=true; alert('hi JS!'); myJS('USA',235);"},
                 { "label" : "Week 2", "value" : "19600" },
                 { "label" : "Week 3", "value" : "24000" },
                 { "label" : "Week 4", "value" : "15700" }
               ]
} 

 

 

More Details at:http://www.fusioncha.../Drilldown.html

 

Hope this helps.smile.gif

Share this post


Link to post
Share on other sites

Thanks for your input Angshu :)

 

But this piece of code is not working. I already have tried this earlier. Is there anyway we can try this using j-myJavaScriptFunction-parameters kind of notation.

 

Thanks

Edited by sudhanshu

Share this post


Link to post
Share on other sites

Hi,

 

The format is very simple.

 

All you would need to do is to use link property of the data.

 

The format is either of these two:

 

J-jsFunctionName-parameterAsString

 

or

 

JavaScript:javascript code

 

You seem to have mixed both of these:JavaScript-alert(Hi). This is invald.

 

Again, you can not pass Hi without putting it inside a quote or apostrophe to pass it as string. Presently it would be taken as a variable name. JavaScript rules!

 

But, additionally, if you are running it from local file system you would need to set up Flash Player global security settings. Check out this post for more information : http://forum.fusioncharts.com/topic/10016-flash-player-103-global-security-settings/page__pid__39164#entry39164

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