Table of Contents
//Adding jQuery reference
//Adding FusionCharts reference
//Declaring array to hold the data in the list
var source=[ ];
var country =[ ];
var population =[ ];
//Performing AJAX call for with REST Endpoint for fetching data from List
$(function () {
getListData();
});
function getListData() {
var siteUrl = _spPageContextInfo.webAbsoluteUrl;
var fullUrl = siteUrl + "/_api/web/lists/getbytitle('PopulationInfo')/items";
$.ajax({
url: fullUrl,
type: "GET",
headers: {
"accept": "application/json;odata=verbose",
"content-type": "application/json;odata=verbose",
},
success: onQuerySucceeded,
error: onQueryFailed
});
}
function onQuerySucceeded(data) {
//Storing fetched data in declared array
$.each(data.d.results, function (key, value) {
country.push(value.Country);
population.push(value.Population);
});
for(var i=0;i<country .length;i++) {
var dd = { };
dd.label=country[i];
dd.value=population[i];
source.push(dd);
}
//Declaring FusionCharts constructor and requisite JSON structure
FusionCharts.ready(function () {
var revenueChart = new FusionCharts({
type: 'column2d',
renderAt: 'chart-container',
width: '550',
height: '350',
dataFormat: 'json',
dataSource: {
"chart": {
"caption": "Top Most Populated country in the world",
"subCaption": "World Population",
"xAxisName": "Country",
"yAxisName": "Population",
"paletteColors": "#0075c2",
"bgColor": "#ffffff",
"borderAlpha": "20",
"canvasBorderAlpha": "0",
"usePlotGradientColor": "0",
"plotBorderAlpha": "10",
"placevaluesInside": "1",
"rotatevalues": "1",
"valueFontColor": "#ffffff",
"showXAxisLine": "1",
"xAxisLineColor": "#999999",
"divlineColor": "#999999",
"divLineIsDashed": "1",
"showAlternateHGridColor": "0",
"subcaptionFontBold": "0",
"subcaptionFontSize": "14"
},
"data":source
}
}).render();
});
}
function onQueryFailed() {
alert('Error!');
}
hh
To create pie charts and generate statistical data, you’ll find this list of the best…
To implement FusionCharts in a dynamically resizing flexbox layout, ensure that the chart's dimensions are…
At FusionCharts, we believe in empowering developers and businesses with cutting-edge data visualization tools that…
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…