FusionCharts Suite shares a great chemistry with Javascript. What does this mean for you? Quite a lot actually. You can combine the two of them to:
This list is by no means a comprehensive list of the things you can do with FusionCharts and Javascript combined. It is meant to give you a small idea of things and fire up your imagination before we go behind the scenes.
Also, you might appreciate that since FusionCharts and Javascript have infinite possibilities together, it will not be possible to discuss everything at length in this post itself. While we have provided relevant links for more information wherever it is apt; whenever you need more info on anything, please check out the section FusionCharts and Javascript in our online documentation. Ready? Here we go.
The FusionCharts download package consists of the chart swfs and the FusionCharts Javascript class called FusionCharts.js among other things. These are the only 2 resources we need to concern ourselves with to explore the power of FusionCharts and Javascript.
The chart swfs as is evident are the individual chart files. FusionCharts.js is the FusionCharts Javascript class which allows easy embedding of charts in the webpages without the cryptic <object> and <param> tags.
Security Issues: Adobe Flash Player, by default, restricts SWF files on local filesystem to make any JavaScript class, or vice-versa to protect the end user from “evil” SWFs. You can get around this by running the Javascript code either from the server (either remote or localhost) or by configuring the Flash Player to allow SWFs present in specific folders to raise JavaScript class by adding the folder to https://www.macromedia.com/support/documentation/en/flashplayer/help/settings_manager04.html
Now that we are done with the securty issues, let us take an example straightaway to understand how the chart swf and FusionCharts.js act in conjunction. This example illustrates 3 concepts:
Don’t worry if you can’t make head or tail of the APIs and events we are talking about – we will discuss them in details later on.
So the HTML for the page having the chart embedded in it would be:
//FusionCharts// < ![CDATA[ var chart1 = new FusionCharts("../../FusionCharts/Column3D.swf", "chart1Id", "400", "300", "0", "1"); chart1.setDataXML(""); chart1.render("chart1div"); // ]]>
In the above code, we are first creating a Column3D chart using FusionCharts JavaScript class. We set the DOM ID of the chart as chart1Id. It is this ID using which the chart will now be recognized in the HTML page. You need to make sure that each chart on the page gets a different ID, else the browser would start behaving weirdly, to say the least.
The FusionCharts constructor function, which helps you embed a chart easily using Javascript looks as under:
var chart1 = new FusionCharts("../../FusionCharts/Column3D.swf", "chart1Id", "400", "300", "0", "1"); The parameters passed to it in order are: URL of the swf file of the chart type, its DOM ID, chart width and height, debugMode and registerWithJS – both of which accept boolean values.
To register the chart with JavaScript, we set the registerWithJS parameter to 1.
Now, we’ve provided a basic XML data document to the chart using its setDataXML method. Finally, we render the chart, and track the same to display an alert box when the chart has finished rendering and raises the FC_Rendered event.
Now that we have a basic grasp of things, let us take a look at the events that FusionCharts v3.1 exposes. Barring the first 2, everything has been newly introduced in FusionCharts v3.1:
The last 3 events are typically used to show an error message to the user, or to take a corrective measure.
All the events can be tracked the same way as the FC_Rendered event was tracked using the DOMId of the chart in the example earlier.
All the charts in the FusionCharts expose a number of APIs which allow you to print the chart, export the chart as image/PDF, get an attribute or the entire data of the chart and the like.
These APIs are not a part of FusionCharts.js, but built into the chart swfs themselves and as such, you do not need to include FusionCharts.js in your HTML code to make use of these APIs.
The APIs exposed by all charts in FusionCharts with their respective functions are:
Except the first 2 APIs, all the other APIs have been newly introduced in FusionCharts v3.1.
Now that you know about the tremendous chemistry that FusionCharts shares with Javascript, make the most out of it.
With this post concludes the How to get the most out of v3.1 series. We hope this indeed helps you get the best out of our products. If there is any feature you want us to go into further details, just let us know in the Comments section and we will be onto it.
You can build complex web applications easily with Angular. But it’s a challenge to present…
JavaScript charts help transform raw data into clear, interactive visualizations that users can easily understand.…
Modern web applications depend on data visualization to transform complex information into clear, actionable insights.…
Data is a big part of modern software. Companies use charts to track sales, monitor…
Every day, businesses get more data than ever before. Looking at endless rows and columns…
Building interactive React charts from scratch can quickly become complicated. It becomes even more challenging…
View Comments
but these charts using Flash for displaying, just use JS for control it, right?
whatever, I think these charts are very nice and cool, thank you very much for sharing.
And can you share these charts on my JavaScript library?
Awaiting your response. Thank
Hi,
Nice to know you like the charts.
Yes, you are right -- the charts use Javascript for embedding and more controls.
Sharing the charts on the Javascript library -> can you please drop us a mail at support@fusioncharts.com and then we could pursue this further?
Sanket
FusionCharts Team
I wish you converted all your products into HTML5.
Using JS, Canvas, SVG should give the same results with greater flexibility to the user.
@Drazick: Yes once HTML5 becomes more widespread, we will take a call on that. Right now everyone seems to be very happy with Flash :)
Yes! Looking forward to HTML5 using JS and SVG! This will also open my webapps for iPhone!
René: We have just started work on the HTML5 version. Will post more updates when we have something more concrete...
@Sanket: If you had the HTML5 version, we would not use the Flash version. So from my point of view, flash is very good until you come up with a HTML5 based version. So it's more not because we are happy with the Flash version, but more like we use the Flash version because you don't have made the HTML5 version yet.
I will look forward to see you introduce the HTML5 version, because your product is the best. And as @Kristian stated, the HTML5 version will open our webapps to none flash enabled platforms.
Hi Sanket - we have a Fusion charts enabled BI dashboard. We want to enable the same on Iphones - is this possible? I am hearing that Iphone does not support flash. Do you have any iphone app or plugin that we can use to quickly enable our dashboard on iphone?
Thanks!
@Lina:
Right now all the components we have are Flash based and hence wouldn't work on the iPhone. We have however just started working on an HTML 5 version as well. When there is something more concrete on that, we will surely let everyone know about it.
@Sanket - Thanks for your reply. Good to know that HTML 5 version is being worked upon. In the meantime, I know that the Fusion chart graphs can also be displayed as a .png or .jpeg format. Is it possible to enable our BI application on the iphone in this format or even this will not work ? Any examples for this OR implementation stories at other customer sites would be extremely helpful for us to make the right choice!
Thanks!
Lina