FusionCharts and Flash > Handling Click Events |
You can easily handle the click events for data points on the chart in your Flash movies. That is, whenever a user clicks on a column or line point or pie etc., you can be notified of the same in your Flash movie. Here we'll see how to do this. |
Adding link to XML |
To enable your parent movie to track links in FusionCharts charts, you need to add S- before every link specified in the XML data document. This instructs the chart to convey the link to its parent SWF movie. An example is given below: <set name='John' value='49' link='S-parameter'/> Here, S- is the prefix to indicate that this link should be bubbled up to parent SWF. When this link is bubbled up, parameter is passed to the event handler. We'll see this in the example below. If you need to pass multiple parameters, one way would be to use a comma to separate each new value. Then String.split the parameter into individual values in the called function. This is a simple method that would only work with string values. Let's now put all this learning into a practical example to see its usage. |
Creating a link handler example |
In this example, we'll create a copy of MultipleCharts.fla and save it as ClickHandler.fla. We'll define the link events for both the column and line chart. Each column or line anchor, when clicked, would call a different function, which in turn would just output the name of the set. In real life scenarios, you can do better things with this data. The actions in the new movie would now contain the following: |
/** |
As you can see above, we've defined the link for each column and line chart anchor with prefix of S- . The columns and line anchors, when now clicked, will be handled by objL event listener. In this handler, we've just traced out the values received as parameters. In your code, you could pass indexes of data and then deal with it the way you want to. When you now run this code and click on any column or line point, you'll see the name of column/line anchor in output window as under: |
![]() |