Skip to content

Commit 5d5c1e6

Browse files
committed
jtblin#232 - make module factory return a module name
Allow doing something like this: ``` var angular = require('angular'); var app = angular.module('app', [ require('angular-chart') ]); ```
1 parent a5d5b0f commit 5d5c1e6

16 files changed

+78
-9
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ node_modules/
33
test/fixtures/shots/
44
coverage/
55
examples/bundle.js
6+
examples/commonjs.bundle.js

.jscsrc

+1
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@
7575
"dist/**",
7676
"coverage/**",
7777
"examples/bundle.js",
78+
"examples/commonjs.bundle.js",
7879
"examples/smoothscroll.min.js",
7980
"test/fixtures/coverage.js"
8081
]

.jshintignore

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ node_modules/
22
dist/
33
tmp/
44
examples/bundle.js
5+
examples/commonjs.bundle.js
56
examples/smoothscroll.min.js
67
coverage/
78
test/fixtures/coverage.js

.jshintrc

+2
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

README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ script and options.
1717
## Chart.js 2.0 and 1.0.0-alpha branch
1818

1919
This is the `1.0.0-alpha` branch which requires Chart.js 2.0.0 version. Following semantic versioning,
20-
there are numerous breaking changes in this version notably:
20+
there are numerous **breaking changes** in this version notably:
2121

2222
* all options now need to use the `chart-` prefix
2323
* `chart-colours` is now `chart-colors` and `chart-get-colour` is now `chart-get-color`
@@ -28,6 +28,7 @@ there are numerous breaking changes in this version notably:
2828
* obviously all Chart.js breaking changes as well in how options are set, etc.
2929
* disabling the `responsive` option doesn't work via global `Chart.defaults.global.responsive` anymore,
3030
but must be set via standard options e.g. `ChartJsProvider.setOptions({ responsive: false });`
31+
* factory now returns a module name instead of a module instance
3132

3233
### npm
3334

angular-chart.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@
4848
.directive('chartRadar', ['ChartJsFactory', function (ChartJsFactory) { return new ChartJsFactory('radar'); }])
4949
.directive('chartDoughnut', ['ChartJsFactory', function (ChartJsFactory) { return new ChartJsFactory('doughnut'); }])
5050
.directive('chartPie', ['ChartJsFactory', function (ChartJsFactory) { return new ChartJsFactory('pie'); }])
51-
.directive('chartPolarArea', ['ChartJsFactory', function (ChartJsFactory) { return new ChartJsFactory('polarArea'); }]);
51+
.directive('chartPolarArea', ['ChartJsFactory', function (ChartJsFactory) { return new ChartJsFactory('polarArea'); }])
52+
.name;
5253

5354
/**
5455
* Wrapper for chart.js

dist/angular-chart.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@
4848
.directive('chartRadar', ['ChartJsFactory', function (ChartJsFactory) { return new ChartJsFactory('radar'); }])
4949
.directive('chartDoughnut', ['ChartJsFactory', function (ChartJsFactory) { return new ChartJsFactory('doughnut'); }])
5050
.directive('chartPie', ['ChartJsFactory', function (ChartJsFactory) { return new ChartJsFactory('pie'); }])
51-
.directive('chartPolarArea', ['ChartJsFactory', function (ChartJsFactory) { return new ChartJsFactory('polarArea'); }]);
51+
.directive('chartPolarArea', ['ChartJsFactory', function (ChartJsFactory) { return new ChartJsFactory('polarArea'); }])
52+
.name;
5253

5354
/**
5455
* Wrapper for chart.js

dist/angular-chart.js.tar.gz

22 Bytes
Binary file not shown.

dist/angular-chart.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/angular-chart.min.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/amd.html

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
<head lang="en">
44
<meta charset="UTF-8">
55
<title>AMD</title>
6-
<link rel="stylesheet" href="../dist/angular-chart.css">
76
<link href="bootstrap.css" rel="stylesheet">
87
</head>
98
<body ng-app="examples">

examples/commonjs.html

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head lang="en">
4+
<meta charset="UTF-8">
5+
<title>CommonJS</title>
6+
<link href="bootstrap.css" rel="stylesheet">
7+
</head>
8+
<body ng-app="app">
9+
<br/>
10+
<div class="container">
11+
<div class="row" ng-controller="CommonJSCtrl">
12+
<div class="col-lg-6 col-sm-12">
13+
<div class="panel panel-default">
14+
<div class="panel-heading">CommonJS</div>
15+
<div class="panel-body">
16+
<canvas class="chart chart-line" chart-data="data" chart-series="series" chart-labels="labels"></canvas>
17+
</div>
18+
</div>
19+
</div>
20+
</div>
21+
</div>
22+
23+
<script src="commonjs.bundle.js"></script>
24+
</body>
25+
</html>

examples/commonjs.js

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
(function () {
2+
'use strict';
3+
4+
var angular = require('angular');
5+
6+
var app = angular.module('app', [
7+
require('angular-chart')
8+
]);
9+
10+
app.controller('CommonJSCtrl', ['$scope', function ($scope) {
11+
$scope.labels = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'];
12+
$scope.series = ['Series A', 'Series B'];
13+
$scope.data = [
14+
[65, 59, 80, 81, 56, 55, 40],
15+
[28, 48, 40, 19, 86, 27, 90]
16+
];
17+
}]);
18+
19+
})();

examples/webpack.commonjs.js

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
(function () {
2+
'use strict';
3+
4+
// install with npm: npm i --save angular-chart.js
5+
// build with `npm bin`/webpack --config examples/webpack.commonjs.js --display-modules --progress
6+
module.exports = {
7+
entry: './examples/commonjs.js',
8+
output: {
9+
filename: './examples/commonjs.bundle.js'
10+
},
11+
resolve: {
12+
alias: {
13+
'angular-chart': '../angular-chart.js' // not required when you install with npm
14+
}
15+
}
16+
};
17+
18+
})();

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
"sinon-chai": "^2.7.0",
5858
"testatic": "^0.1.0",
5959
"tmp-sync": "^1.1.0",
60-
"webpack": "^1.12.15",
60+
"webpack": "^1.13.1",
6161
"webshot": "^0.18.0"
6262
},
6363
"dependencies": {

test/fixtures/coverage.js

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)