Last active
April 16, 2020 13:06
-
-
Save franklinbaldo/1c7df601f96bbc361fc533781348be4c to your computer and use it in GitHub Desktop.
python example GOOGLE CHARTS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<title>Static example</title> | |
<script src="http://www.google.com/jsapi" type="text/javascript"></script> | |
<script> | |
google.load("visualization", "1", {packages:["table"]}); | |
google.setOnLoadCallback(drawTable); | |
function drawTable() { | |
var jscode_data = new google.visualization.DataTable(); | |
jscode_data.addColumn("string", "Name", "name"); | |
jscode_data.addColumn("number", "Salary", "salary"); | |
jscode_data.addColumn("boolean", "Full Time Employee", "full_time"); | |
jscode_data.addRows(4); | |
jscode_data.setCell(0, 0, "Jim"); | |
jscode_data.setCell(0, 1, 800, "$800"); | |
jscode_data.setCell(0, 2, false); | |
jscode_data.setCell(1, 0, "Bob"); | |
jscode_data.setCell(1, 1, 7000, "$7,000"); | |
jscode_data.setCell(1, 2, true); | |
jscode_data.setCell(2, 0, "Mike"); | |
jscode_data.setCell(2, 1, 10000, "$10,000"); | |
jscode_data.setCell(2, 2, true); | |
jscode_data.setCell(3, 0, "Alice"); | |
jscode_data.setCell(3, 1, 12500, "$12,500"); | |
jscode_data.setCell(3, 2, true); | |
var jscode_table = new google.visualization.Table(document.getElementById('table_div_jscode')); | |
jscode_table.draw(jscode_data, {showRowNumber: true}); | |
var json_table = new google.visualization.Table(document.getElementById('table_div_json')); | |
var json_data = new google.visualization.DataTable({ | |
"cols": [ | |
{ | |
"id": "name", | |
"label": "Name", | |
"type": "string" | |
}, | |
{ | |
"id": "salary", | |
"label": "Salary", | |
"type": "number" | |
}, | |
{ | |
"id": "full_time", | |
"label": "Full Time Employee", | |
"type": "boolean" | |
} | |
], | |
"rows": [ | |
{ | |
"c": [ | |
{ | |
"v": "Jim" | |
}, | |
{ | |
"v": 800, | |
"f": "$800" | |
}, | |
{ | |
"v": false | |
} | |
] | |
}, | |
{ | |
"c": [ | |
{ | |
"v": "Bob" | |
}, | |
{ | |
"v": 7000, | |
"f": "$7,000" | |
}, | |
{ | |
"v": true | |
} | |
] | |
}, | |
{ | |
"c": [ | |
{ | |
"v": "Mike" | |
}, | |
{ | |
"v": 10000, | |
"f": "$10,000" | |
}, | |
{ | |
"v": true | |
} | |
] | |
}, | |
{ | |
"c": [ | |
{ | |
"v": "Alice" | |
}, | |
{ | |
"v": 12500, | |
"f": "$12,500" | |
}, | |
{ | |
"v": true | |
} | |
] | |
} | |
] | |
}, 0.5); | |
json_table.draw(json_data, {showRowNumber: true}); | |
} | |
</script> | |
</head> | |
<body> | |
<H1>Table created using ToJSCode</H1> | |
<div id="table_div_jscode"></div> | |
<H1>Table created using ToJSon</H1> | |
<div id="table_div_json"></div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment