Created
March 6, 2014 00:41
-
-
Save jparker/9379914 to your computer and use it in GitHub Desktop.
Load remote data as DataTable for Google Chart
This file contains hidden or 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
jQuery.ajax | |
async: false | |
dataType: 'json' | |
url: '/path/to/data.json' | |
success: (data) -> | |
google.load 'visualization', '1', {packages: ['corechart']} | |
google.setOnLoadCallback -> | |
table = new google.visualization.DataTable() | |
table.addColumn 'datetime', 'Timestamp' | |
table.addColumn 'number', 'Memory Total' | |
jQuery.each data, (i, row) -> | |
table.addRow [new Date(row.timestamp), row.memory_total] | |
options = {title: 'Memory Usage', vAxis: {format: '# MB', minValue: 0}} | |
chart = new google.visualization.LineChart document.getElementById 'chart_div' | |
chart.draw table, options |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment