Table of Contents
<title>Fusion Charts</title> <style> .chart-container { width: 50%; float: left; padding: 30px; border: 2px solid lightgreen; } </style> <center><h1>Bar Chart</h1></center>
https://cdn.fusioncharts.com/fusioncharts/latest/fusioncharts.js https://cdn.fusioncharts.com/fusioncharts/latest/themes/fusioncharts.theme.fusion.js
const noOfLeaves = [ { id: "12", label: "Mike", value: "1", showLabel: "1" }, { id: "21", label: "Sam", value: "12", showLabel: "1" }, { id: "23", label: "Alethia", value: "3", showLabel: "1" }, { id: "32", label: "Eurnica", value: "6", showLabel: "1" }, { id: "34", label: "Antila", value: "2", showLabel: "1" }, { id: "43", label: "Ausgen", value: "5", showLabel: "1" } ];
var chartConfiguration = { type: "", renderAt: "", dataFormat: "json", dataSource: { chart: { caption: "Percentage of Employee leaves", xAxisName: "Emplyees", yAxisName: "% Leaves per year", numberSuffix: "%", theme: "fusion" }, data: employeeData }Apart from the above, let’s take a simple bar chart as an example in order to explain further. In the chartConfig JSON object, we must define the type as ‘column2d’ to generate a bar chart since we haven’t defined it initially. We’ll also have to plug in a container for the chart to be shown in. Within the content of the HTML file, add a div tag for the chart with id as ‘barchart-container.’ Javascript code for generating the bar chart is as follows:
function renderBarChart(){ chartConfig.type = 'column2d'; chartConfig.renderAt = 'barchart-container'; var fusionchartsbar = new FusionCharts(chartConfig); fusionchartsbar.render(); } FusionCharts.ready(renderBarChart);The HTML file will be defined as follows
<div class="chart-container" id="barchart-container">Bar Chart Rendering!</div>
API Method signature | Purpose |
render(chartParameters: Object) | FusionCharts uses this function as a compact constructor. |
configure(name:string , value:string) or configure(configurations: Object) | Prior rendering the chart, this method adds the chart configuration. |
render(renderAt: String) or render(renderAt: HTMLNode) | This function creates a chart within a container element that has been supplied as a parameter. |
setJSONData(JSON:Object) or setJSONData(JSON:String) | The data of the chart is changed to the JSON string or Object given. |
addEventListener(event:string, listener: function) or addEventListener(events:Array, listener: function) | This function serves as an enhanced registration model for events. |
removeEventListener(event:string, listener: function) or removeEventListener(events:Array, listener: function) | For a specific event, function removes a designated event-listener function. |
setXMLUrl(Url: String) | Sets or modifies the chart’s XML data to a given Url. |
setJSONUrl(Url: String) | Sets or modifies the chart’s JSON and data to a given Url. |
resizeTo(width:String, height:String) | This method can be used to resize an existing chart. |
var eventListener = function(eventObject, eventArguments) { console.log( eventObj.eventType + " was raised by the chart whose ID is " + eventObj.sender.id ); };Given below is how the ‘renderComplete’ event is used.
chart.addEventListener(“renderComplete”, myEventListener);
For further information on events and their implementation, please feel free to go through the FusionCharts documentation. Ever had a data set that seemed more complicated than a Rubik's cube? You’re not…
We’ve all seen them in textbooks or presentations—those overlapping circles that simplify complex information into…
We’re excited to announce the upcoming release of FusionCharts v4.1—a groundbreaking step forward in the…
Have you ever been overwhelmed by a massive data set and wondered, "How do I…
If you’ve ever tried to make sense of the stock market, you’ve probably come across…
Imagine you’re comparing the sales performance of your top product lines across different regions, or…