$(function () {
var data = [
{ "CountryName": "China", "Pop1990": 1141, "Pop2008": 1333, "Pop2025": 1458 },
{ "CountryName": "India", "Pop1990": 849, "Pop2008": 1140, "Pop2025": 1398 },
{ "CountryName": "United States", "Pop1990": 250, "Pop2008": 304, "Pop2025": 352 },
{ "CountryName": "Indonesia", "Pop1990": 178, "Pop2008": 228, "Pop2025": 273 },
{ "CountryName": "Brazil", "Pop1990": 150, "Pop2008": 192, "Pop2025": 223 }
];
$("#chart").igPieChart({
width: "435px",
height: "435px",
dataSource: data, //JSON data defined above
valueMemberPath: "Pop2008",
labelMemberPath: "CountryName",
labelsPosition: "bestFit"
});
var element = $("#html-content-holder"); // global variable
var getCanvas; // global variable
/**
* Demonstrates how to download a canvas an image with a single
* direct click on a link.
*/
/**
* This is the function that will take care of image extracting and
* setting proper filename for the download.
* IMPORTANT: Call it from within a onclick event.
*/
function downloadCanvas(link, canvasId, filename) {
alert();
link.href = document.getElementById(canvasId).toDataURL();
link.download = filename;
}
/**
* The event handler for the link's onclick event. We give THIS as a
* parameter (=the link element), ID of the canvas and a filename.
*/
function nowSave(){
var namefile = prompt("insert name of file to save in png");
if(namefile === "") {
alert("You must enter name of file")
} else {
downloadCanvas(document.getElementById("download"), 'canvas', namefile + ".png");
}
}
$("#btn-Convert-Html2Image").on('click', function () {
html2canvas(element, {
onrendered: function (canvas) {
//$("#previewImage").append(canvas);
...
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.