FusionWidgets allows you to control few aspects of the message logger using its client side JavaScript API. Basically, you can do the following:

  • Show/hide the logger using client side JavaScript
  • Clear the logger using client side JavaScript

Here, we'll see how to do these.

 
Manipulating the logger using client side JavaScript

To use client side JavaScript API, you first need to make sure that you've embedded the chart with registerWithJS flag set to 1. Else, you'll get JavaScript errors stating that the object is undefined.

You'll need to initialize the chart using following code. Note the last parameter (registerWithJS) set to 1.

var myChart = new FusionCharts("RealTimeLine.swf", "ChId1", "500", "350", "0", "1");

Once the chart has loaded, initialized and rendered, you can get reference back to the chart in your JavaScript code using the code below. Here, ChId1 is the id of the chart which we've defined in the chart constructor above.

var refToChart = getChartFromId("ChId1");

You can access the chart using this function only after it has loaded. As such, we always recommend to put this code block in FC_Rendered event tracker code block. For more information, please see the section "FusionWidgets and JavaScript"

Once the reference to chart is attained, you can use any of the functions below on the chart's logger (provided it's set to on):

  • refToChart.showLog() - To show the log, if it's not already visible.
  • refToChart.hideLog() - To hide the log, if it's visible.
  • refToChart.clearLog() - To clear the contents of log.

If you get JavaScript errors when accessing the above functions, make sure of following:

  1. You've set the registerWithJS flag to 1
  2. You've enabled the message logger for the chart.
  3. You're accessing these functions after the chart has loaded (i.e., in FC_Rendered event tracker block)
  4. You're not running the chart from local file system (i.e., C:\, D:\ etc.) Instead, run it from a server (localhost or remote server)