Skip to content

Instantly share code, notes, and snippets.

@patrixd
Last active January 1, 2016 12:49
Show Gist options
  • Save patrixd/8147467 to your computer and use it in GitHub Desktop.
Save patrixd/8147467 to your computer and use it in GitHub Desktop.
An example of a Google Chart in an app using RequireJS and BackboneJS
var listData = ["LABEL C", "LABEL D", "LABEL E"];
listData = listData.concat(
_.map(this.model.toJSON(), function (item) {
return [item.PropertyName, parseFloat(item.PropertyC), parseFloat(item.PropertyD), parseFloat(item.PropertyE)];
}, this)
);
data = google.visualization.arrayToDataTable(listData);
// Create and draw the visualization.
var ac = new google.visualization.ComboChart($container[0]);
ac.draw(data, {
seriesType: "bars",
isStacked: true,
chartArea: { left: "5%", width: "80%" },
colors: ["red", "blue", "green"],
fontSize: 12,
series: { 1: { type: "line" }, 2: { type: "line"} }
});
@patrixd
Copy link
Author

patrixd commented Dec 27, 2013

To load google api I use the next line in the define of the view
'goog!visualization,1,packages:[corechart]',
goog is defined in paths of requireJs definition with propertyParser and async from https://github.com/millermedeiros/requirejs-plugins

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment