Skip to content
This repository was archived by the owner on Nov 26, 2022. It is now read-only.

Commit c8ddd07

Browse files
abarinoffcarlcraig
authored andcommitted
Inline plugins support for charts (#86)
* support for chart inline plugins was added * version 2.1.4
1 parent 48ba339 commit c8ddd07

File tree

5 files changed

+20
-10
lines changed

5 files changed

+20
-10
lines changed

README.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ You will then have access to the following directives:
4545

4646
Just place one of these directives on a `canvas` element to create a Chart.js chart.
4747

48-
You will also want to give the chart some `data` and `options`. These can be provided via the `chart-options` and `chart-data` attributes.
48+
You will also want to give the chart some `data`, `options` and `plugins`. These can be provided via the `chart-options`, `chart-data` and `chart-plugins` attributes.
4949

50-
For data structures and options please refer to [Chart.js documentation](http://www.chartjs.org/docs/)
50+
For data structures, options and inline plugins please refer to [Chart.js documentation](http://www.chartjs.org/docs/)
5151

5252
You can also handle chart clicks via the `chart-click` attribute.
5353

@@ -58,6 +58,7 @@ Example Pie Chart
5858
tc-chartjs-pie
5959
chart-data="myData"
6060
chart-options="myOptions"
61+
chart-plugins="myPlugins"
6162
chart-click="onChartClick(event)"
6263
></canvas>
6364
```
@@ -92,6 +93,11 @@ $scope.myOptions = {
9293
// e.g. Pie Chart Options http://www.chartjs.org/docs/#doughnut-pie-chart-chart-options
9394
};
9495

96+
$scope.myPlugins = [{
97+
// Chart.js inline plugins go here
98+
// e.g. http://www.chartjs.org/docs/latest/developers/plugins.html#using-plugins
99+
}];
100+
95101
$scope.onChartClick = function (event) {
96102
console.log(event);
97103
};

dist/tc-angular-chartjs.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* tc-angular-chartjs - http://carlcraig.github.io/tc-angular-chartjs/
3-
* Copyright (c) 2016 Carl Craig
3+
* Copyright (c) 2017 Carl Craig
44
* Dual licensed with the Apache-2.0 or MIT license.
55
*/
66
;(function(root, factory) {
@@ -80,6 +80,7 @@ function TcChartjsFactory() {
8080
scope: {
8181
data: '=chartData',
8282
options: '=chartOptions',
83+
plugins: '=chartPlugins',
8384
type: '@chartType',
8485
legend: '=?chartLegend',
8586
chart: '=?chart',
@@ -125,7 +126,7 @@ function TcChartjsFactory() {
125126
};
126127
}
127128

128-
$scope.$watch('[data, options]', function (value) {
129+
$scope.$watch('[data, options, plugins]', function (value) {
129130
if (value && $scope.data) {
130131
if (chartObj && typeof chartObj.destroy === 'function') {
131132
chartObj.destroy();
@@ -140,7 +141,8 @@ function TcChartjsFactory() {
140141
chartObj = new Chart(ctx, {
141142
type: type,
142143
data: angular.copy($scope.data),
143-
options: $scope.options
144+
options: $scope.options,
145+
plugins: $scope.plugins
144146
});
145147

146148
if (showLegend) {

dist/tc-angular-chartjs.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "tc-angular-chartjs",
3-
"version": "2.1.3",
3+
"version": "2.1.4",
44
"description": "AngularJS directives for Chart.js",
55
"homepage": "http://carlcraig.github.io/tc-angular-chartjs/",
66
"author": "Carl Craig <[email protected]>",

src/tc-angular-chartjs.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ function TcChartjsFactory() {
5757
scope: {
5858
data: '=chartData',
5959
options: '=chartOptions',
60+
plugins: '=chartPlugins',
6061
type: '@chartType',
6162
legend: '=?chartLegend',
6263
chart: '=?chart',
@@ -102,7 +103,7 @@ function TcChartjsFactory() {
102103
};
103104
}
104105

105-
$scope.$watch('[data, options]', function (value) {
106+
$scope.$watch('[data, options, plugins]', function (value) {
106107
if (value && $scope.data) {
107108
if (chartObj && typeof chartObj.destroy === 'function') {
108109
chartObj.destroy();
@@ -117,7 +118,8 @@ function TcChartjsFactory() {
117118
chartObj = new Chart(ctx, {
118119
type: type,
119120
data: angular.copy($scope.data),
120-
options: $scope.options
121+
options: $scope.options,
122+
plugins: $scope.plugins
121123
});
122124

123125
if (showLegend) {

0 commit comments

Comments
 (0)