https://github.com/txbm/angular-chartjs
Directive set for the ChartJS library. Supports data bindings and attribute-level specification for chart specific options. The only Angular ChartJS module that supports ALL chart options as HTML5 attributes :)
https://github.com/txbm/angular-chartjs
Last synced: 6 months ago
JSON representation
Directive set for the ChartJS library. Supports data bindings and attribute-level specification for chart specific options. The only Angular ChartJS module that supports ALL chart options as HTML5 attributes :)
- Host: GitHub
- URL: https://github.com/txbm/angular-chartjs
- Owner: txbm
- License: mit
- Created: 2013-09-17T06:01:13.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2015-09-25T19:49:01.000Z (over 10 years ago)
- Last Synced: 2025-03-11T20:55:50.770Z (over 1 year ago)
- Language: JavaScript
- Homepage:
- Size: 1.28 MB
- Stars: 144
- Watchers: 13
- Forks: 38
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## angular-chartjs
[](https://travis-ci.org/petermelias/angular-chartjs)
[](https://coveralls.io/r/petermelias/angular-chartjs)
[](https://www.npmjs.org/package/angular-chartjs)
[](https://www.npmjs.org/package/angular-chartjs)
[](https://github.com/petermelias/angular-chartjs/issues)
A fully functional directive set for the ChartJS library. Supports data bindings and attribute-level specification for chart specific options.
### Installation
##### Using Bower
```bash
bower install ng-chartjs
```
##### Using NPM
```bash
npm install angular-chartjs
```
##### Setup
```html
```
and in your app init...
```javascript
var app = angular.module('myApp', ['chartjs']);
```
### Usage
There is a directive for each of the 6 chart types in ChartJS. Data is set on the $scope in the controller and the options can be passed in via the controller and / or overridden on the directive call.
In the template...
```html
```
In the controller...
```javascript
myapp.controller('testCtrl', function ($scope) {
$scope.someData = {
labels: [
'Apr',
'May',
'Jun'
],
datasets: [
{
data: [1, 7, 15, 19, 31, 40]
},
{
data: [6, 12, 18, 24, 30, 36]
}
]
};
$scope.someOptions = {
segementStrokeWidth: 20,
segmentStrokeColor: '#000'
};
});
```
This will result in a Doughnut chart using the dataset from the controller with a StrokeColor of #000 and a StrokeWidth of 5 because options set on the directive attributes override controller level settings for maximum flexibility.
### Examples
If you want to see an example for every chart, download the library and go to the ```test/app``` directory. Launch ```index.html``` in a browser and all of the charts will load. You will find the test controller in the ```test/app/js``` directory.
All charts and options work. No actual JS (beyond the dataset) is required to use this directive set unless you want to bulk specify many options, in which case it's better to do that in the controller.
You can also run this example online through the following plunker: http://embed.plnkr.co/pC7gJ7/preview
### Tests
```bash
gulp test
```
### Demo
Open a browser pointed at ```demo/index.html```