Skip to content

Commit 2b9e95e

Browse files
committed
replace google-chart to nvd3 chart
1 parent 45f857d commit 2b9e95e

File tree

5 files changed

+35
-32
lines changed

5 files changed

+35
-32
lines changed

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"angular-ui-router": "~0.2.13",
1414
"angular-material": "~0.10.0",
1515
"angular": "~1.3.4",
16-
"angular-google-chart": "~0.0.11"
16+
"angular-nvd3": "1.0.0-rc.2"
1717
},
1818
"devDependencies": {
1919
"angular-mocks": "~1.3.4"
Lines changed: 25 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,28 @@
1-
(function(){
2-
angular
3-
.module('app')
4-
.controller('UsageController', [
5-
UsageController
6-
]);
1+
(function () {
2+
angular
3+
.module('app')
4+
.controller('UsageController', [
5+
UsageController
6+
]);
77

8-
function UsageController() {
9-
var vm = this;
8+
function UsageController() {
9+
var vm = this;
1010

11-
vm.chartOptions = {
12-
pieHole: 0.5,
13-
pieSliceTextStyle: { color: 'black' },
14-
legend: 'none',
15-
tooltip : { isHtml: true },
16-
pieSliceText: 'none',
17-
slices: { 0: { color: 'rgb(0, 150, 136)' }, 1: { color: '#E75753' }, 2: { color: 'rgb(235, 235, 235)' } }
18-
};
19-
vm.ramChart = {
20-
type: 'PieChart',
21-
options: vm.chartOptions,
22-
data: [ ['usedBy', 'percent'], ['Memory', 768660], ['Cache', 367404], ['Swap', 41924] ]
23-
};
24-
vm.storageChart = {
25-
type: 'PieChart',
26-
options: vm.chartOptions,
27-
data: [ ['usedBy', 'percent'], ['System', 126560], ['Other', 224365] ]
28-
};
29-
}
11+
vm.ramChartData = [{key: 'Memory', y: 768660}, { key: 'Cache', y: 367404}, {key: 'Swap', y: 41924 }];
12+
vm.storageChartData = [{key: 'System', y: 126560}, {key: 'Other', y: 224365 }];
13+
14+
vm.chartOptions = {
15+
chart: {
16+
type: 'pieChart',
17+
height: 130,
18+
donut: true,
19+
x: function (d) { return d.key; },
20+
y: function (d) { return d.y; },
21+
color: ['rgb(0, 150, 136)', '#E75753', 'rgb(235, 235, 235)'],
22+
showLabels: false,
23+
showLegend: false,
24+
title: '83%'
25+
}
26+
};
27+
}
3028
})();

src/app/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use strict';
22

33
angular.module('angularMaterialAdmin', ['ngAnimate', 'ngCookies', 'ngTouch',
4-
'ngSanitize', 'ui.router', 'ngMaterial', 'googlechart', 'app'])
4+
'ngSanitize', 'ui.router', 'ngMaterial', 'nvd3', 'app'])
55

66
.config(function ($stateProvider, $urlRouterProvider, $mdThemingProvider,
77
$mdIconProvider) {

src/app/stylesheets/_custom.scss

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,4 +132,9 @@ md-radio-button.md-accent.md-checked .md-label span {
132132
.material-icons.md-18 { font-size: 18px; }
133133
.material-icons.md-24 { font-size: 24px; }
134134
.material-icons.md-36 { font-size: 36px; }
135-
.material-icons.md-48 { font-size: 48px; }
135+
.material-icons.md-48 { font-size: 48px; }
136+
137+
.nvd3.nv-pie .nv-pie-title {
138+
fill: rgb(68, 68, 68);
139+
font-weight: 600;
140+
}

src/app/views/partials/usage.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
<md-content ng-controller="UsageController as vm" class="md-padding" layout="row">
22
<div flex>
3-
<div google-chart chart="vm.ramChart" style="height:130px;" />
3+
<nvd3 options="vm.chartOptions" data="vm.ramChartData"></nvd3>
44
<h4 class="donut-chart-title">RAM</h4>
55
</div>
66
<div flex>
7-
<div google-chart chart="vm.storageChart" style="height:130px;" />
7+
<nvd3 options="vm.chartOptions" data="vm.storageChartData"></nvd3>
88
<h4 class="donut-chart-title">Storage</h4>
99
</div>
1010
</md-content>

0 commit comments

Comments
 (0)