Skip to content

Commit

Permalink
update demo
Browse files Browse the repository at this point in the history
  • Loading branch information
maxklenk committed Nov 7, 2014
1 parent cbaace8 commit c4edf65
Show file tree
Hide file tree
Showing 6 changed files with 463 additions and 10 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,14 @@ bower install angular-chart
Add everything to your index.html:
```html
<link rel="stylesheet" href="bower_components/c3/c3.css" />
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css">
<link rel="stylesheet" type="text/css" href="bower_components/angular-circular-navigation/angular-circular-navigation.css">

<script src="bower_components/angular/angular.js"></script>
<script src="bower_components/d3/d3.js"></script>
<script src="bower_components/c3/c3.js"></script>
<script src="bower_components/angular-chart/angular-chart.js"></script>
<script src="bower_components/angular-circular-navigation/angular-circular-navigation.js"></script>
```

And specify the directive in your module dependencies:
Expand Down
21 changes: 14 additions & 7 deletions angular-chart.js
Original file line number Diff line number Diff line change
Expand Up @@ -357,9 +357,9 @@ angular.module('angularChart', [])
//
marginBottom = 30;
scope.chooseXAxis();
scope.customLegend();
scope.chooseChartType();
scope.toggleSubchartLink();
scope.customLegend();
angular.element(element).attr('style', angular.element(element).attr('style') + ' margin-bottom: ' + marginBottom + 'px');

// Apply earlier zoom
Expand Down Expand Up @@ -390,12 +390,19 @@ angular.module('angularChart', [])
if (scope.options.typeSelector) {
var el = angular.element('<div class="chooseChartType btn-group">');
el.attr('style', 'float: right');
el.append('<button ng-click="options.type = \'line\'" ng-class="{\'active\': options.type === \'line\'}" class="btn btn-default">Multi</button>');
el.append('<button ng-click="options.type = \'pie\'" ng-class="{\'active\': options.type === \'pie\'}" class="btn btn-default">Pie</button>');
el.append('<button ng-click="changeChartType(\'spline\')" ng-class="{\'active\': options.type !== \'pie\'}" class="btn btn-default">Multi</button>');
el.append('<button ng-click="changeChartType(\'pie\')" ng-class="{\'active\': options.type === \'pie\'}" class="btn btn-default">Pie</button>');
$compile(el)(scope);
element.prepend(el);
}
};
// called function
scope.changeChartType = function (type) {
scope.options.type = type;
scope.options.rows.forEach(function(element) {
element.type = type;
});
};

// Toggle Subchart
//
Expand Down Expand Up @@ -433,7 +440,7 @@ angular.module('angularChart', [])
}
marginBottom += 30;

var legend = angular.element('<div class="customLegend"><span ng-repeat="row in options.rows" class="customLegend-item"><circular options="rowEdit[$index]"></circular><span class="customLegend-label" data-id="{{row.name}}">{{row.name ? row.name : row.key}}</span></span></div>');
var legend = angular.element('<div class="customLegend"><span ng-repeat="row in options.rows" class="customLegend-item"><circular options="rowEdit[$index]"></circular><span class="customLegend-label" data-id="{{row.name}}">{{(schema[row.key] && schema[row.key].name) ? schema[row.key].name : (row.name ? row.name : row.key)}}</span></span></div>');
$compile(legend)(scope);
element.prepend(legend);

Expand Down Expand Up @@ -671,9 +678,9 @@ angular.module('angularChart', [])
// watcher of changes in options
//
scope.startDatasetWatcher = function () {
scope.$watch('dataset', function (newValue, oldValue) {
scope.updateChart();
}, true); // checks for changes inside data
// scope.$watch('dataset', function (newValue, oldValue) {
// scope.updateChart();
// }, true); // checks for changes inside data
};


Expand Down
Loading

0 comments on commit c4edf65

Please sign in to comment.