var chartEd = null;
var chartWrap = null;
var chartEditorDiv = null;
// Populates the chart div on startup and initiates global vars. Called on page load.
function chartDraw(){
// Initialize Chart editor handle
chartEd = new google.visualization.ChartEditor();
google.visualization.events.addListener(chartEd, 'ok', chartSave);
chartEditorDiv = document.getElementById('chartEditorDiv');
// Add the chart to the page
chartWrap = new google.visualization.ChartWrapper({
'chartType':'LineChart',
'dataSourceUrl':'http://spreadsheets.google.com/tq?key=pCQbetd-CptGXxxQIG7VFIQ&pub=1',
'query':'SELECT A,D WHERE D > 100 ORDER BY D',
'options': {'title':'Population Density (people/km^2)', 'legend':'none'}
});
chartWrap.draw(chartEditorDiv);
}
// User clicked 'ok' to save chart
function chartSave(){
chartEd.getChartWrapper().draw(chartEditorDiv);
}
// Onclick handler, opens the editor
function chartLoadEditor() {
chartEd.openDialog(chartWrap, {});
}
function chartPNG(){
var sIMG = chartWrap.getChart().getImageURI();
//var sIMG = chartEd.getChartWrapper().getChart().getImageURI(); // this way not working.
document.getElementById('imagePrint').innerHTML = '<img src=' + sIMG + '>'
}
google.setOnLoadCallback(chartDraw);
// Chart 2
var chart2Ed;
var chart2Wrap = null;
var chart2EditorDiv = null;
var chart2Object = null;
// Populates the chart div on startup and initiates global vars. Called on page load.
function chart2Draw(){
// Initialize Chart editor handle
chart2Ed = new google.visualization.ChartEditor();
google.visualization.events.addListener(chart2Ed, 'ok', chart2Save);
google.visualization.events.addListener(chart2Ed, 'print', chart2PNG);
chart2EditorDiv = document.getElementById('chart2EditorDiv');
// Add the chart to the page
chart2Wrap = new google.visualization.ChartWrapper({
'chartType':'LineChart',
...
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.
Fiddle Pages
Your fiddles accessible under a custom domain and a vanity path - the simplest hosting for your personal project.
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!
Get Fiddle Pages with PRO
Your fiddles accessible under a custom domain and a vanity path - the simplest hosting for your personal project.