Introduction
Creating Your First Chart
FusionCharts renders charts using JavaScript and supports XML and JSON data formats. I will take an example with JSON data format as it is the most commonly used format nowadays:
Use Case: Split of Food Sales by Category. Here's the tabular data that we are going to plot:
| Category | Sales |
| Starters | 1050700 |
| Snacks | 1250400 |
| Main Course | 1463300 |
| Desserts | 491000 |
And this is the JSON data array for the tabular data shown above:
- [
- {"Label": "Starters", "Value": "1050700"},
- {"label": "Snacks", "value": "1250400"},
- {"label": "Main Course", "value": "1463300"},
- {"label": "Desserts", "value": "491000"}
- ]
Step 2: Preparing HTML
For simple applications like displaying interactive charts on a standard web page, we will need to include JavaScript files from FusionCharts core package using <script> tag.
The actual chart needs a container inside which it will be displayed. For our purposes, we are going to use a <div> tag.
Here's the HTML code for our demo:
- <html>
- <head>
- <title>Getting Started with FusionCharts</title>
- <script type="text/javascript" src="fusioncharts/fusioncharts.js"></script>
- <script type="text/javascript" src="fusioncharts/fusioncharts.charts.js"></script>
- <script type="text/javascript" src="fusioncharts/themes/zune.js"></script>
- <!-- Location of JavaScript files may be different according to user -->
- </head>
- <body>
- <!-- Container for Chart (div element) -->
- <div id="chart-container">Awesome Chart on its way!</div>
- </body>
- </html>
Step 3: JavaScript
This is the heart of the application. This is where FusionCharts does its magic and allows us to be creative with our data. Since this is a basic tutorial I won't go into many details here. Because once you get a grip of working with FusionCharts you can start figuring things out on your own using their live example gallery as it comes with complete source code of every chart.
The final step to render the chart is to include instance from FusionCharts constructor and specify the JSON data array created above. This is how it is done for our example:
- FusionCharts.ready(function () { //FusionCharts Constructor
- var demoChart = new FusionCharts({
- //Instance
- type: "pie2d",
- renderAt: "chart-container" //ID of div element created in HTML
- height: "400",
- width: "400",
- dataFormat: "json",
- dataSource: {
- //Basic Chart Configuration & Cosmetics
- "chart": {
- "caption": "Split of Food Sales by Category",
- "subCaption": "Last Year",
- "pieRadius": "75",
- "showPercentValues": "1",
- "theme": "zune"
- },
- "data": [{
- "Label": "Starters",
- "Value": "1050700"
- },
- {
- "label": "Snacks",
- "value": "1250400"
- },
- {
- "label": "Main Course",
- "value": "1463300"
- },
- {
- "label": "Desserts",
- "value": "491000"
- }
- ]
- }
- }).render();
- });
Putting Everything Together
- <html>
- <head>
- <title>Getting Started with FusionCharts</title>
- <script type="text/javascript" src="fusioncharts/fusioncharts.js"></script>
- <script type="text/javascript" src="fusioncharts/fusioncharts.charts.js"></script>
- <script type="text/javascript" src="fusioncharts/themes/zune.js"></script>
- <!-- Location of JavaScript files may be different according to user -->
- <script type="text/javascript">
- FusionCharts.ready(function() { //FusionCharts Constructor
- var demoChart = new FusionCharts({
- //Instance
- type: "pie2d",
- renderAt: "chart-container", //ID of div element created in HTML
- height: "400",
- width: "400",
- dataFormat: "json",
- dataSource: {
- //Basic Chart Configuration & Cosmetics
- "chart": {
- "caption": "Split of Food Sales by Category",
- "subCaption": "Last Year",
- "pieRadius": "75",
- "showPercentValues": "1",
- "theme": "zune"
- },
- "data": [{
- "Label": "Starters",
- "Value": "1050700"
- }, {
- "label": "Snacks",
- "value": "1250400"
- }, {
- "label": "Main Course",
- "value": "1463300"
- }, {
- "label": "Desserts",
- "value": "491000"
- }]
- }
- }).render();
- });
- </script>
- <!-- FusionCharts Constructor & Instance -->
- </head>
- <body>
- <!-- Container for Chart (div element) -->
- <div id="chart-container">Awesome Chart on its way!</div>
- </body>
- </html>
Conclusion
- Free Trial: FusionCharts offers an unlimited free trial. There is no feature restriction. You'll need this if you want to play around with it further.
- Documentation: Documentation is a developer's best friend. Head over to the documentation page to better learn how to used FusionCharts' advanced features.
Summary
I will be hanging around in the comments section below. So don't be shy and feel free to shoot any questions you might have about this article or you can even just say hi!

Santhakumar MunuswamyPosted Jan 23, 2016, 2:19 AM
Thanks for nice share
Mohsin AzamPosted Jan 21, 2016, 6:30 AM
nice
Debasis SahaPosted Jan 21, 2016, 4:21 AM
Nice..
Muhammad Aqib ShehzadPosted Jan 20, 2016, 2:17 PM
nice one