Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions examples/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,7 @@
</head>
<body ng-controller="MainController">

<select ng-model="chartType">
<option value="pie">pie</option>
<option value="bar">bar</option>
<option value="line">line</option>
<option value="point">point</option>
<option value="area">area</option>
<select ng-model="chartType" ng-options="type for type in availableCharts">
</select>

<span ng-show="chartType==='pie'">
Expand Down
4 changes: 3 additions & 1 deletion examples/main.controller.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
angular.module('example', ['angularCharts']);

function MainController($scope) {
function MainController($scope, acChartLogic) {
$scope.data1 = {
series: ['Sales', 'Income', '<i>Expense</i>', 'Laptops', 'Keyboards'],
data: [{
Expand Down Expand Up @@ -57,4 +57,6 @@ function MainController($scope) {
},
lineLegend: 'traditional'
}

$scope.availableCharts = acChartLogic.getAvailableCharts();
}
42 changes: 13 additions & 29 deletions src/angular-charts.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,34 +8,6 @@ angular.module('angularCharts', ['angularChartsTemplates']);
*/
angular.module('angularCharts').directive('acChart', function($templateCache, $compile, $rootElement, $window, $timeout, $sce, acChartLogic) {

var defaultColors = [
'rgb(255,153,0)',
'rgb(220,57,18)',
'rgb(70,132,238)',
'rgb(73,66,204)',
'rgb(0,128,0)',
'rgb(0, 169, 221)',
'steelBlue',
'rgb(0, 169, 221)',
'rgb(50, 205, 252)',
'rgb(70,132,238)',
'rgb(0, 169, 221)',
'rgb(5, 150, 194)',
'rgb(50, 183, 224)',
'steelBlue',
'rgb(2, 185, 241)',
'rgb(0, 169, 221)',
'steelBlue',
'rgb(0, 169, 221)',
'rgb(50, 205, 252)',
'rgb(70,132,238)',
'rgb(0, 169, 221)',
'rgb(5, 150, 194)',
'rgb(50, 183, 224)',
'steelBlue',
'rgb(2, 185, 241)'
];

/**
* Utility function that gets the child that matches the classname
* because Angular.element.children() doesn't take selectors
Expand Down Expand Up @@ -79,7 +51,7 @@ angular.module('angularCharts').directive('acChart', function($templateCache, $c
position: 'left',
htmlEnabled: false
},
colors: defaultColors,
colors: acChartLogic.getDefaultColors(),
innerRadius: 0, // Only on pie Charts
lineLegend: 'lineEnd', // Only on line Charts
lineCurveType: 'cardinal',
Expand All @@ -106,6 +78,12 @@ angular.module('angularCharts').directive('acChart', function($templateCache, $c
var box = {
height: 0,
width: 0,
margin: {
top: 0,
right: 40,
bottom: 20,
left: 40
},
chartContainer: null,
legendContainer: null,
yMaxData: null,
Expand Down Expand Up @@ -147,6 +125,12 @@ angular.module('angularCharts').directive('acChart', function($templateCache, $c
prepareData();
setHeightWidth();
setContainers();
box.margin = {
top: 0,
right: 40,
bottom: 20,
left: 40
};
acChartLogic.callChartFunction(chartType, config, box, domFunctions, series, points);
setYMaxData();
drawLegend();
Expand Down
Loading