Last active
January 1, 2016 12:49
-
-
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
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
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"} } | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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