Charts can send messages to javascript. This enables reading the status of a chart, controlling it from javascript, and synchronizing it with other web page elements.

When flash sends multiple messages to javascript around the same time, only the last message gets received. To work around this limitation, activate only the messages you need, or use Javascript to Flash communication to query the chart until you receive a response.

Web Page Preparation

Before using javascript, give each chart in the web page a unique ID to determine which chart is sending and receiving messages. Add the ID in 3 different places in the flash code of each chart:

If flash sends messages to a javascript function that does not exist, some browsers generate warning messages. To avoid this, add flash_to_javascript to the chart's XML Source to activate only the messages that have javascript functions to receive them:

Loaded_Chart: A boolean that indicates whether to send a message to a javascript function called Loaded_Chart right after the chart is loaded. This can be used to send the XML Source code to the chart from javascript. Valid values are true or false. The default is false (don't send this feedback to javascript).

Render_Count: A boolean that indicates whether to send a message to a javascript function called Render_Count after each time the chart gets rendered. Valid values are true or false. The default is false (don't send this feedback to javascript).

Scrolled_Chart: A boolean that indicates whether to send a message repeatedly to a javascript function called Scrolled_Chart as the chart gets scrolled. This can be used to receive the scrolling information of a chart, and make other charts scroll in sync with it (see scroll and Javascript to Flash). Valid values are true or false. The default is false (don't send this feedback to javascript).

Stopped_Scrolling: A boolean that indicates whether to send a message once to a javascript function called Stopped_Scrolling when scrolling stops. The default is false (don't send this feedback to javascript).

Toggled_Legend: A boolean that indicates whether to send a message to a javascript function called Toggled_Legend when the legend is clicked on or off. The default is false (don't send this feedback to javascript).

Javascript Functions

To receive the chart messages activated by flash_to_javascript, add the javascript functions to the web page before the <body> tag:

<!-- web page -->
<HTML>
<SCRIPT LANGUAGE=JavaScript>
<!--
function Loaded_Chart( id ){
//id is the chart's ID that sends a message
if(id=="my_chart_1"){ ... }
}
function Render_Count( id, count ){
//id is the chart's ID that sends a message// count is the number of times the chart has been rendered// count returns zero if the chart has never been rendered// count returns 1 if the chart has been rendered only once after the initial load// count returns 1 plus the number updates if the chart has been updated with the update function...
}
function Scrolled_Chart( id, start, span ){
//id is the chart's ID that sends a message//start is the position of the scroll bar in percent//span is the visible area of the chart in percent...
}
function Stopped_Scrolling( id, start, span ){
//id is the chart's ID that sends a message//start is the position of the scroll bar in percent//span is the visible area of the chart in percent...
}
function Toggled_Legend( id, legend_index, series_on ){
//id is the chart's ID that sends a message//legend_index is the clicked legend//series_on is a boolean indicating if the corresponding series is on or off...
}
-->
</script>
<BODY bgcolor="#FFFFFF">
<P>This is my web page.</P>
</BODY>
</HTML>

Link to Javascript

To make a javascript respond to a click on a link, omit the link's target and set the url to a javascript function:

To make a javascript respond to a click on a chart via link_data, set link-data's target to javascript, and set the url to a javascript function. To pass the click-variables to the javascript function, any occurrences of _col_, _row_, _value_, _category_, _series_, _x_, _y_, and _id_ in the URL are replaced with the actual values (_id_ is the chart's ID):