AngularJS: Google Charts Pie
by s911131
HTML
<script src="http://www.google.com/jsapi?ext.js"></script>
<body ng-controller="Ctrl">
<div google-chart chart="chartObject" style="{{cssStyle}}" custom-select="handleSelect"></div>
</body>
JavaScript
google.setOnLoadCallback(function () {
angular.bootstrap(document.body, ['app']);
});
google.load('visualization', '1', {
packages: ['corechart']
});
var app = angular.module('app', ['googlechart']);
app.controller('Ctrl', function ($scope) {
$scope.handleSelect=function(selection){
console.log(selection);
};
$scope.chartObject = {
"type": "LineChart",
"displayed": true,
"data": {
"cols": [
{
"id": "month",
"label": "Month",
"type": "string",
"p": {}
},
{
"id": "laptop-id",
"label": "Laptop",
"type": "number",
"p": {}
},
{
"id": "desktop-id",
"label": "Desktop",
"type": "number",
"p": {}
},
{
"id": "server-id",
"label": "Server",
"type": "number",
"p": {}
},
{
"id": "cost-id",
"label": "Shipping",
"type": "number"
}
],
"rows": [
{
"c": [
{
"v": "January"
},
{
"v": 19,
"f": "42 items"
},
{
"v": 12,
"f": "Ony 12 items"
},
{
"v": 7,
"f": "7 servers"
},
{
"v": 4
}
]
},
{
"c": [
{
"v": "February"
},
{
"v": 13
},
{
"v": 1,
"f": "1 unit (Out of stock this month)"
},
{
"v": 12
},
{
"v": 2
}
]
...