Skip to content

Commit c43a894

Browse files
committed
chinmaymk#114, added beautiful default colors
1 parent ce2774c commit c43a894

File tree

1 file changed

+32
-8
lines changed

1 file changed

+32
-8
lines changed

src/angular-charts.js

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,43 @@ angular.module('angularCharts', ['angularChartsTemplates']);
88
*/
99
angular.module('angularCharts').directive('acChart', function($templateCache, $compile, $rootElement, $window, $timeout, $sce) {
1010

11-
var defaultColors = ['steelBlue', 'rgb(255,153,0)', 'rgb(220,57,18)', 'rgb(70,132,238)', 'rgb(73,66,204)', 'rgb(0,128,0)'];
11+
var defaultColors = [
12+
'rgb(255,153,0)',
13+
'rgb(220,57,18)',
14+
'rgb(70,132,238)',
15+
'rgb(73,66,204)',
16+
'rgb(0,128,0)',
17+
'rgb(0, 169, 221)',
18+
'steelBlue',
19+
'rgb(0, 169, 221)',
20+
'rgb(50, 205, 252)',
21+
'rgb(70,132,238)',
22+
'rgb(0, 169, 221)',
23+
'rgb(5, 150, 194)',
24+
'rgb(50, 183, 224)',
25+
'steelBlue',
26+
'rgb(2, 185, 241)',
27+
'rgb(0, 169, 221)',
28+
'steelBlue',
29+
'rgb(0, 169, 221)',
30+
'rgb(50, 205, 252)',
31+
'rgb(70,132,238)',
32+
'rgb(0, 169, 221)',
33+
'rgb(5, 150, 194)',
34+
'rgb(50, 183, 224)',
35+
'steelBlue',
36+
'rgb(2, 185, 241)'
37+
];
1238

1339
/**
1440
* Utility function to call when we run out of colors!
1541
* @return {String} Hexadecimal color
1642
*/
1743
function getRandomColor() {
18-
var letters = '0123456789ABCDEF'.split('');
19-
var color = '#';
20-
for (var i = 0; i < 6; i++) {
21-
color += letters[Math.round(Math.random() * 15)];
22-
}
23-
return color;
44+
var r = (Math.round(Math.random() * 127) + 127).toString(16);
45+
var g = (Math.round(Math.random() * 127) + 127).toString(16);
46+
var b = (Math.round(Math.random() * 127) + 127).toString(16);
47+
return '#' + r + g + b;
2448
}
2549

2650
/**
@@ -66,7 +90,7 @@ angular.module('angularCharts').directive('acChart', function($templateCache, $c
6690
position: 'left',
6791
htmlEnabled: false
6892
},
69-
colors: [],
93+
colors: defaultColors,
7094
innerRadius: 0, // Only on pie Charts
7195
lineLegend: 'lineEnd', // Only on line Charts
7296
lineCurveType: 'cardinal',

0 commit comments

Comments
 (0)