JS: Render PIE chart using Datamatic API and Google spreadsheet

var datamatic = new Datamatic("117670017722819924657"); var chart = datamatic.chart("0B3wq5VFn9PllNG5uNkdRTXF2T2s", { width: 452, height: 318 }); var sheetID = "1EYtZWp7Vc5Li_Ip-HcHd1CEhf4GbIfjLqpp0PpFbmRQ"; var getData = function () { // clean previous data on load chart.setData([]); return Datamatic.ajax.json("https://spreadsheets.google.com/feeds/list/" + sheetID + "/od6/public/values?alt=json"); }; chart.render(document.body).then(getData).then(function (sheet) { chart.setData(sheet.feed.entry.map(function (row) { return { "name": row.gsx$text.$t, "value": row.gsx$value.$t }; })); });
Showing a simple demo of how to use Datamatic PIE chart with Google spreadsheet. To edit the PIE chart colors and so on, free registration at datamatic.co is required.

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.