Page 1 of 1

FusionChart Events

Posted: Thu Dec 01, 2016 10:25 am
by devinst
I have a chart on a screen and would like to create event listeners to monitor for clicks on certain labels and data. I see which events I need to listen for according to the Fusion API documents but I am not sure where on the display to put the java script code to listen for the event.
Would anyone have an example to look at or some direction?
Thanks.!!

Re: FusionChart Events

Posted: Thu Dec 01, 2016 1:00 pm
by Scott Klement
I assume these are just JavaScript functions, right?

As with many things in programming, there's more than one way to do it....

1) Put the functions in a JavaScript file under /www/INSTANCE/htdocs/profoundui/userdata/custom/js. These are automatically loaded into the Visual Designer and Rich Display sessions (sessions started with /profoundui/start or the Atrium Rich Display launcher). For Genie, you'd add a <script> tag into the start.html pointing to the new JS file to make it load. This is the simplest and easiest to support -- but doesn't work for mobile.

2) Or, you can put a JavaScript file somewhere else (but accessible t0 the HTTP server) and use the "external javascript" record format property to load it.

3) Or, you could do the same as #2, but use the pui.loadJS API to load it.

4) Or, you could define the function as a global variable in your display's onload event. I would only do that if it is a fairly simple script. It has the advantage that all of the code is stored inside the display file, no need to have a separate JS file that's moved between test/prod/qa environments along with the display file. But, it can be a pain to maintain/debug.

There are probably other alternatives... but that's what comes to mind.