Skip to content

Commit 65dddb4

Browse files
committed
Merge branch 'chartjs-2.0'
Fix #123 and #428 # Conflicts: # .dockerignore # .travis.yml # Dockerfile # README.md # angular-chart.js # angular-chart.less # bower.json # dist/angular-chart.css # dist/angular-chart.js # dist/angular-chart.js.tar.gz # dist/angular-chart.min.css # dist/angular-chart.min.css.map # dist/angular-chart.min.js # dist/angular-chart.min.js.map # examples/charts.html # examples/charts.template.html # gulpfile.js # package.json # test/fixtures/coverage.js # test/test.unit.js
2 parents b43ac41 + e7b5484 commit 65dddb4

81 files changed

Lines changed: 2696 additions & 1340 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.codeclimate.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ languages:
44
PHP: false
55
exclude_paths:
66
- "dist/*"
7-
- "bower_components/*"
87
- "node_modules/*"
98
- "gulpfile.js"
109
- "examples/*"

.dockerignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
1-
bower_components/
21
coverage/
32
node_modules/

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
.idea/
22
node_modules/
33
test/fixtures/shots/
4-
bower_components/
54
coverage/
65
examples/bundle.js
6+
examples/commonjs.bundle.js

.jscsrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,11 @@
7171
"disallowKeywords": [ "with" ],
7272

7373
"excludeFiles": [
74-
"bower_components/**",
7574
"node_modules/**",
7675
"dist/**",
7776
"coverage/**",
7877
"examples/bundle.js",
78+
"examples/commonjs.bundle.js",
7979
"examples/smoothscroll.min.js",
8080
"test/fixtures/coverage.js"
8181
]

.jshintignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
bower_components/
21
node_modules/
32
dist/
43
tmp/
54
examples/bundle.js
5+
examples/commonjs.bundle.js
66
examples/smoothscroll.min.js
77
coverage/
88
test/fixtures/coverage.js

.jshintrc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
"trailing" : true, // Prohibit trailing whitespaces.
77
"white" : false, // Check against strict whitespace and indentation rules.
88
"indent" : 2, // {int} Number of spaces to use for indentation
9+
"maxcomplexity" : 10, // {int} Max number for cyclomatic complexity
10+
"maxdepth" : 2, // {int} Max number for nesting blocks
911
"newcap" : true, // true: Require capitalization of all constructor functions e.g. `new F()`
1012
"quotmark" : "single", // Quotation mark consistency
1113
"-W058" : true, // Missing '()' invoking a constructor

.travis.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
language: node_js
21
sudo: required
32
services:
43
- docker
@@ -9,10 +8,12 @@ script:
98
after_success:
109
- docker start angular-chart.js
1110
- docker exec -it angular-chart.js npm run codeclimate
12-
- docker stop angular-chart.js
11+
after_script:
12+
- docker stop angular-chart.js ||true
1313
- docker rm angular-chart.js
1414
env:
1515
global:
1616
- secure: YWABlINoIkwl9RFLOW9G0lATEP3aiXXi+DS6TWfvQWWG/jkS5sn7IqWC2U67LjwQ0lDg0yevo3ZD7FyYQ5lr8AVuScAZ6P2o2dm9t/HBKGTG4u016dxbWWYVZ8MAlKT7TfjVD8iDzcWyZedsbpuyaNNp4pGr/CNcvq7TGdJLNkU=
1717
- CI=1
1818
- REPORTER=list
19+
- TOLERANCE=0.001

Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
FROM jtblin/debian-node-graphicsmagick:stretch-node-v4.4.3-gm-v1.3.23
1+
FROM jtblin/debian-node-graphicsmagick:stretch-node-v4.4.7-gm-v1.3.24
22
WORKDIR /src
33
ADD . ./
44
RUN chown -R node:node /src
55
USER node
6-
RUN npm install && npm install bower && ./node_modules/bower/bin/bower install
6+
RUN npm install
77
CMD ["npm", "test"]

README.md

Lines changed: 75 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -9,26 +9,24 @@
99

1010
Beautiful, reactive, responsive charts for Angular.JS using [Chart.js](http://www.chartjs.org/).
1111

12-
[Demo](http://jtblin.github.io/angular-chart.js/)
13-
14-
# v0.x - Chart.js v1.1.x - stable
15-
16-
This is the stable version of angular-chart.js that uses the v1.1.x version of Chart.js.
17-
18-
# v1.0.0-beta - Chart.js v2.x
19-
20-
If you are interested by the 2.x version of Chart.js, please checkout the
21-
[chartjs-2.x branch](https://github.com/jtblin/angular-chart.js/tree/chartjs-2.0). Report issues
22-
and feedback for this version by opening issues labelled with `v1.x`.
23-
24-
See https://github.com/jtblin/angular-chart.js/issues/123 for more details and subscribe to it to get
25-
the latest progress on Chart.js 2.x integration.
12+
Have a look at the [demo site](http://jtblin.github.io/angular-chart.js/) to see examples with detailed markup,
13+
script and options.
2614

2715
# Installation
2816

29-
### bower
17+
This is the `1.x` branch which requires Chart.js 2.x version. Following semantic versioning,
18+
there are numerous **breaking changes** since 0.x, notably:
3019

31-
bower install --save angular-chart.js
20+
* all options now need to use the `chart-` prefix
21+
* `chart-colours` is now `chart-colors` and `chart-get-colour` is now `chart-get-color`
22+
* chart types are in `camelCase` e.g. `line` and `polarArea`
23+
* legend is now a Chart.js option so the `chart-legend` attribute has been removed
24+
* events emitted on creation and update are now prefixed with `chart-` e.g. `chart-create`
25+
* `$scope.$apply` is not called anymore on mouse hover functions calls
26+
* obviously all Chart.js breaking changes as well in how options are set, etc.
27+
* disabling the `responsive` option doesn't work via global `Chart.defaults.global.responsive` anymore,
28+
but must be set via standard options e.g. `ChartJsProvider.setOptions({ responsive: false });`
29+
* factory now returns a module name instead of a module instance
3230

3331
### npm
3432

@@ -37,7 +35,10 @@ the latest progress on Chart.js 2.x integration.
3735
### cdn
3836

3937
//cdn.jsdelivr.net/angular.chartjs/latest/angular-chart.min.js
40-
//cdn.jsdelivr.net/angular.chartjs/latest/angular-chart.css
38+
39+
### bower
40+
41+
bower install --save angular-chart.js
4142

4243
### manually
4344

@@ -48,46 +49,48 @@ adding the dependencies for Angular and Chart.js first:
4849

4950
```html
5051
<head>
51-
<link rel="stylesheet" href="bower_components/angular-chart.js/dist/angular-chart.css" />
52+
...
5253
<head>
5354
<body>
5455
...
5556
</body>
56-
<script src="bower_components/angular/angular.min.js"></script>
57-
<script src="bower_components/Chart.js/Chart.min.js"></script>
58-
<script src="bower_components/angular-chart.js/dist/angular-chart.min.js"></script>
57+
<script src="node_modules/angular/angular.min.js"></script>
58+
<script src="node_modules/chart.js/Chart.min.js"></script>
59+
<script src="node_modules/angular-chart.js/dist/angular-chart.min.js"></script>
5960
```
6061

6162
# Utilisation
6263

63-
There are 6 types of charts so 6 directives: `chart-line`, `chart-bar`, `chart-radar`, `chart-pie`,
64-
`chart-polar-area`, `chart-doughnut`.
65-
66-
They all use mostly the same API (`[chart-]` indicates an optional but recommended prefix):
64+
There are 8 types of charts so 8 directives: `chart-line`, `chart-bar`, `chart-horizontal-bar`, `chart-radar`,
65+
`chart-pie`, `chart-polar-area`, `chart-doughnut`, `chart-bubble`.
6766

68-
- `[chart-]data`: series data
69-
- `[chart-]labels`: x axis labels (line, bar, radar) or series labels (pie, doughnut, polar area)
70-
- `[chart-]options`: chart options (as from [Chart.js documentation](http://www.chartjs.org/docs/))
71-
- `[chart-]series`: (default: `[]`): series labels (line, bar, radar)
72-
- `[chart-]colours`: data colours (will use default colours if not specified)
73-
- `getColour`: function that returns a colour in case there are not enough (will use random colours if not specified)
74-
- `[chart-]click`: onclick event handler
75-
- `[chart-]hover`: onmousemove event handler
76-
- `[chart-]legend`: (default: `false`): show legend below the chart
67+
Here are the options for all directives:
7768

78-
*DEPRECATION WARNING*: Note that all attributes which do *not* use the `[chart-]` prefix are deprecated
79-
and may be removed in a future version.
69+
- `chart-data`: series data
70+
- `chart-labels`: x axis labels (line, bar, horizontal bar, radar, bubble) or series labels (pie, doughnut, polar area)
71+
- `chart-options`: chart options (as from [Chart.js documentation](http://www.chartjs.org/docs/))
72+
- `chart-series`: (default: `[]`): series labels (line, bar, radar)
73+
- `chart-colors`: data colors (will use default colors if not specified)
74+
- `chart-get-color`: function that returns a color in case there are not enough (will use random colors if not specified)
75+
- `chart-click`: onclick event handler
76+
- `chart-hover`: onmousemove event handler
77+
- `chart-dataset-override`: override individual datasets to allow per dataset configuration e.g. y-axis, mixed type chart
8078

8179
There is another directive `chart-base` that takes an extra attribute `chart-type` to define the type
82-
dynamically, see [stacked bar example](http://jtblin.github.io/angular-chart.js/examples/stacked-bars.html).
80+
dynamically.
81+
82+
You can create mixed type chart using the `chart-dataset-override`, see
83+
[bar-line example](http://jtblin.github.io/angular-chart.js/examples/dataset-override.html).
84+
85+
See also [stacked bar example](http://jtblin.github.io/angular-chart.js/examples/stacked-bars.html).
8386

8487
# Example
8588

8689
## Markup
8790

8891
```html
89-
<canvas id="line" class="chart chart-line" chart-data="data" chart-labels="labels"
90-
chart-legend="true" chart-series="series" chart-click="onClick"></canvas>
92+
<canvas class="chart chart-line" chart-data="data" chart-labels="labels"
93+
chart-series="series" chart-click="onClick"></canvas>
9194
```
9295

9396
## Javascript
@@ -98,12 +101,12 @@ angular.module("app", ["chart.js"])
98101
.config(['ChartJsProvider', function (ChartJsProvider) {
99102
// Configure all charts
100103
ChartJsProvider.setOptions({
101-
colours: ['#FF5252', '#FF8A80'],
104+
chartColors: ['#FF5252', '#FF8A80'],
102105
responsive: false
103106
});
104107
// Configure all line charts
105-
ChartJsProvider.setOptions('Line', {
106-
datasetFill: false
108+
ChartJsProvider.setOptions('line', {
109+
showLines: false
107110
});
108111
}])
109112
.controller("LineCtrl", ['$scope', '$timeout', function ($scope, $timeout) {
@@ -135,39 +138,44 @@ See [a simple AMD example](examples/amd.js)
135138
## CommonJS e.g. webpack
136139

137140
Module should work with CommonJS out of the box e.g. [browserify](http://browserify.org/) or
138-
[webpack](http://webpack.github.io/), see a [webpack example](examples/webpack.config.js).
141+
[webpack](http://webpack.github.io/), see a [webpack example](examples/webpack.commonjs.js).
139142

140143
# Reactive
141144

142-
angular-chart.js watch updates on data, series, labels, colours and options and will update, or destroy and recreate,
145+
angular-chart.js watch updates on data, series, labels, colors and options and will update, or destroy and recreate,
143146
the chart on changes.
144147

145148
# Events
146149

150+
angular-chart.js listens to the following events on the `scope` and acts accordingly:
151+
152+
* `$destroy`: call `.destroy()` on the chart
153+
* `$resize`: call `.resize()` on the chart
154+
147155
angular-chart.js emits the following events on the `scope` and pass the chart as argument:
148156

149-
* `create`: when chart is created
150-
* `update`: when chart is updated
151-
* `destroy`: when chart is destroyed
157+
* `chart-create`: when chart is created
158+
* `chart-update`: when chart is updated
159+
* `chart-destroy`: when chart is destroyed
152160

153161
```
154-
$scope.$on('create', function (event, chart) {
162+
$scope.$on('chart-create', function (evt, chart) {
155163
console.log(chart);
156164
});
157165
```
158166

159167
**Note**: the event can be emitted multiple times for each chart as the chart can be destroyed and
160168
created multiple times during angular `watch` lifecycle.
161169

162-
angular-chart.js listen to the scope `destroy` event and destroy the chart when it happens.
170+
angular-chart.js listens to the scope `$destroy` event and destroys the chart when it happens.
163171

164-
# Colours
172+
# Colors
165173

166-
There are a set of 7 default colours. Colours can be replaced using the `colours` attribute.
167-
If there is more data than colours, colours are generated randomly or can be provided
168-
via a function through the `getColour` attribute.
174+
There are a set of 7 default colors. Colors can be replaced using the `colors` attribute.
175+
If there is more data than colors, colors are generated randomly or can be provided
176+
via a function through the `getColor` attribute.
169177

170-
Hex colours are converted to Chart.js colours automatically,
178+
Hex colors are converted to Chart.js colors automatically,
171179
including different shades for highlight, fill, stroke, etc.
172180

173181
## Browser compatibility
@@ -176,8 +184,10 @@ For IE8 and older browsers, you will need
176184
to include [excanvas](https://code.google.com/p/explorercanvas/wiki/Instructions).
177185
You will also need a [shim](https://github.com/es-shims/es5-shim) for ES5 functions.
178186

179-
You also need to have ```height``` and ```width``` attributes for the ```<canvas>``` tag of your chart if using IE8 and older browsers. If you *do not* have these attributes, you will need a
180-
[getComputedStyle shim](https://github.com/Financial-Times/polyfill-service/blob/master/polyfills/getComputedStyle/polyfill.js) and the line ```document.defaultView = window;```, but there still may be errors (due to code in Chart.js).
187+
You also need to have ```height``` and ```width``` attributes for the ```<canvas>``` tag of your chart
188+
if using IE8 and older browsers. If you *do not* have these attributes, you will need a
189+
[getComputedStyle shim](https://github.com/Financial-Times/polyfill-service/blob/master/polyfills/getComputedStyle/polyfill.js)
190+
and the line ```document.defaultView = window;```, but there still may be errors (due to code in Chart.js).
181191

182192
```html
183193
<head>
@@ -197,7 +207,14 @@ You also need to have ```height``` and ```width``` attributes for the ```<canva
197207

198208
Please check if issue exists first, otherwise open issue in [github](https://github.com/jtblin/angular-chart.js/issues).
199209
**Ensure you add a link to a plunker, jsbin, or equivalent.**
200-
Here is a [jsbin template for 0.x](http://jsbin.com/cucoqe/1/edit?html,js,output) and [one for 1.x](http://jsbin.com/rodunob/edit?html,js,output) for convenience.
210+
211+
Here is a [jsbin template](http://jsbin.com/rodunob/edit?html,js,output) for convenience.
212+
213+
# v0.x - Chart.js v1.x - deprecated
214+
215+
This is the deprecated version of angular-chart.js that uses the v1.x version of Chart.js.
216+
If you want to use this version, please checkout the
217+
[chartjs-1.x branch](https://github.com/jtblin/angular-chart.js/tree/chartjs-1.x)
201218

202219
# Contributing
203220

@@ -215,5 +232,5 @@ Jerome Touffe-Blin, [@jtblin](https://twitter.com/jtblin), [About me](http://abo
215232

216233
# License
217234

218-
angular-chart.js is copyright 2015 Jerome Touffe-Blin and contributors.
235+
angular-chart.js is copyright 2016 Jerome Touffe-Blin and contributors.
219236
It is licensed under the BSD license. See the include LICENSE file for details.

0 commit comments

Comments
 (0)