diff options
Diffstat (limited to 'www/lib/tc-angular-chartjs')
| -rw-r--r-- | www/lib/tc-angular-chartjs/.bower.json | 49 | ||||
| -rw-r--r-- | www/lib/tc-angular-chartjs/LICENSE-APACHE-2.0 | 13 | ||||
| -rw-r--r-- | www/lib/tc-angular-chartjs/LICENSE-MIT | 25 | ||||
| -rw-r--r-- | www/lib/tc-angular-chartjs/README.md | 119 | ||||
| -rw-r--r-- | www/lib/tc-angular-chartjs/bower.json | 39 | ||||
| -rw-r--r-- | www/lib/tc-angular-chartjs/dist/tc-angular-chartjs.js | 140 | ||||
| -rw-r--r-- | www/lib/tc-angular-chartjs/dist/tc-angular-chartjs.min.js | 6 |
7 files changed, 391 insertions, 0 deletions
diff --git a/www/lib/tc-angular-chartjs/.bower.json b/www/lib/tc-angular-chartjs/.bower.json new file mode 100644 index 00000000..ad34751c --- /dev/null +++ b/www/lib/tc-angular-chartjs/.bower.json @@ -0,0 +1,49 @@ +{ + "name": "tc-angular-chartjs", + "version": "1.0.9", + "description": "Add Chart.js charts to your angular application", + "homepage": "http://carlcraig.github.io/tc-angular-chartjs/", + "author": "Carl Craig <carlcraig@3c-studios.com>", + "main": "dist/tc-angular-chartjs.min.js", + "ignore": [ + "**/.*", + "node_modules", + "demo", + "src", + "bower_components", + "test", + "Gruntfile.js", + "package.json" + ], + "dependencies": { + "angular": "~1.x", + "Chart.js": "^1.0.0-beta" + }, + "devDependencies": { + "angular-mocks": "~1.x" + }, + "licenses": [ + { + "type": "MIT", + "url": "https://raw.github.com/carlcraig/tc-angular-chartjs/master/LICENSE-MIT" + }, + { + "type": "Apache-2.0", + "url": "https://raw.github.com/carlcraig/tc-angular-chartjs/master/LICENSE-APACHE-2.0" + } + ], + "repository": { + "type": "git", + "url": "https://github.com/carlcraig/tc-angular-chartjs.git" + }, + "_release": "1.0.9", + "_resolution": { + "type": "version", + "tag": "v1.0.9", + "commit": "15269c4370dda4d9570daa10cdaebca7226fb71c" + }, + "_source": "git://github.com/carlcraig/tc-angular-chartjs.git", + "_target": "~1.0.9", + "_originalSource": "tc-angular-chartjs", + "_direct": true +} diff --git a/www/lib/tc-angular-chartjs/LICENSE-APACHE-2.0 b/www/lib/tc-angular-chartjs/LICENSE-APACHE-2.0 new file mode 100644 index 00000000..36fb5bbe --- /dev/null +++ b/www/lib/tc-angular-chartjs/LICENSE-APACHE-2.0 @@ -0,0 +1,13 @@ +Copyright (c) 2014 Carl Craig + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License.
\ No newline at end of file diff --git a/www/lib/tc-angular-chartjs/LICENSE-MIT b/www/lib/tc-angular-chartjs/LICENSE-MIT new file mode 100644 index 00000000..84c82a69 --- /dev/null +++ b/www/lib/tc-angular-chartjs/LICENSE-MIT @@ -0,0 +1,25 @@ +Copyright (c) 2014 Carl Craig + +Permission is hereby granted, free of charge, to any +person obtaining a copy of this software and associated +documentation files (the "Software"), to deal in the +Software without restriction, including without +limitation the rights to use, copy, modify, merge, +publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice +shall be included in all copies or substantial portions +of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF +ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED +TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT +SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR +IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE.
\ No newline at end of file diff --git a/www/lib/tc-angular-chartjs/README.md b/www/lib/tc-angular-chartjs/README.md new file mode 100644 index 00000000..3910579c --- /dev/null +++ b/www/lib/tc-angular-chartjs/README.md @@ -0,0 +1,119 @@ +tc-angular-chartjs +================== + +[](https://travis-ci.org/carlcraig/tc-angular-chartjs) + +[Documentation](http://carlcraig.github.io/tc-angular-chartjs/) + +### Add Chart.js to your angular applications + +tc-angular-chartjs provides you with directives for all chartjs chart types. + +- Line Charts +- Bar Charts +- Radar Charts +- Polar Area Charts +- Pie Charts +- Doughnut Charts + +You can see all the [Chart.js Documentation](http://www.chartjs.org/docs/) on their website. + +Installation +============ + +Grab the latest version of `Chart.js` and `tc-angular-chartjs`. + +Load `Chart.js` and `tc-angular-chartjs` as you would with normal scripts. + +```html +<script type="text/javascript" src="js/Chart.js"></script> +<script type="text/javascript" src="js/angular.js"></script> +<script type="text/javascript" src="js/tc-angular-chartjs.js"></script> +``` + +Require `tc.chartjs` in your application modules where you require `Chart.js`. + +```javascript +angular.module( 'app', ['tc.chartjs']); +``` + +Basic Usage +=========== + +There are 6 different directives. + +- tc-chartjs +- tc-chartjs-line +- tc-chartjs-bar +- tc-chartjs-radar +- tc-chartjs-polararea +- tc-chartjs-pie +- tc-chartjs-doughnut + +Just place one of these directives on a `canvas` element to create a Chart.js chart. + +```html +<canvas tc-chartjs-doughnut width="350" height="350"></canvas> +``` + +You will also want to give the chart some `data` and `options`. These can be provided +by assigning $scope variables to `chart-options` and `chart-data` attributes on the same canvas element. + +```html +<canvas tc-chartjs-doughnut chart-data="myData" chart-options="myOptions" width="350" height="350"></canvas> +``` +```javascript +$scope.myData = [ + { value : 50, color : "#F7464A" }, + { value : 90, color : "#E2EAE9" }, + { value : 75, color : "#D4CCC5" }, + { value : 30, color : "#949FB1"} +]; + +$scope.myOptions = { + // Chart.js options can go here. +}; +``` + +Using the `tc-chartjs` directive +================================ + +When using the `tc-chartjs` directive you will need to add an additional attribute to +say which type of chart should be created. + +Just attach a `chart-type=""` attribute to the canvas element. + +```html +<canvas tc-chartjs chart-type="doughnut" chart-data="data" chart-options="options" width="350" height="350"></canvas> +``` + +Available Types: + +- line +- bar +- radar +- polararea +- pie +- doughnut + +Passing another value to chart-type than the above will try to create a chart of +that type, which is useful if you have extended Chart.js with custom chart types, +e.g. through plugins. + +Contributing +============ + +- [Open a Pull Request (PR)](https://github.com/carlcraig/tc-angular-chartjs/pull/new/master) +- Make sure your PR is on a new branch you created from the latest version of master branch +- Please do not open a PR from your master branch +- Open a PR even if your code is incomplete to start a discussion and to collect feedback +- Please make sure all unit tests pass, and add new tests for any added features. + + +License +======= + +tc-angular-chartjs is dual licensed with the Apache-2.0 or MIT license. + +See LICENSE-APACHE-2.0 and LICENSE-MIT for more details. + diff --git a/www/lib/tc-angular-chartjs/bower.json b/www/lib/tc-angular-chartjs/bower.json new file mode 100644 index 00000000..b1271f1f --- /dev/null +++ b/www/lib/tc-angular-chartjs/bower.json @@ -0,0 +1,39 @@ +{ + "name": "tc-angular-chartjs", + "version": "1.0.9", + "description": "Add Chart.js charts to your angular application", + "homepage": "http://carlcraig.github.io/tc-angular-chartjs/", + "author": "Carl Craig <carlcraig@3c-studios.com>", + "main": "dist/tc-angular-chartjs.min.js", + "ignore": [ + "**/.*", + "node_modules", + "demo", + "src", + "bower_components", + "test", + "Gruntfile.js", + "package.json" + ], + "dependencies": { + "angular": "~1.x", + "Chart.js": "^1.0.0-beta" + }, + "devDependencies": { + "angular-mocks": "~1.x" + }, + "licenses": [ + { + "type": "MIT", + "url": "https://raw.github.com/carlcraig/tc-angular-chartjs/master/LICENSE-MIT" + }, + { + "type": "Apache-2.0", + "url": "https://raw.github.com/carlcraig/tc-angular-chartjs/master/LICENSE-APACHE-2.0" + } + ], + "repository": { + "type": "git", + "url": "https://github.com/carlcraig/tc-angular-chartjs.git" + } +} diff --git a/www/lib/tc-angular-chartjs/dist/tc-angular-chartjs.js b/www/lib/tc-angular-chartjs/dist/tc-angular-chartjs.js new file mode 100644 index 00000000..16c490c1 --- /dev/null +++ b/www/lib/tc-angular-chartjs/dist/tc-angular-chartjs.js @@ -0,0 +1,140 @@ +/** + * tc-angular-chartjs - v1.0.9 - 2014-10-14 + * Copyright (c) 2014 Carl Craig <carlcraig@3c-studios.com> + * Dual licensed with the Apache-2.0 or MIT license. + */ +(function() { + "use strict"; + angular.module("tc.chartjs", []).directive("tcChartjs", TcChartjs).directive("tcChartjsLine", TcChartjsLine).directive("tcChartjsBar", TcChartjsBar).directive("tcChartjsRadar", TcChartjsRadar).directive("tcChartjsPolararea", TcChartjsPolararea).directive("tcChartjsPie", TcChartjsPie).directive("tcChartjsDoughnut", TcChartjsDoughnut).directive("tcChartjsLegend", TcChartjsLegend).factory("TcChartjsFactory", TcChartjsFactory); + function TcChartjs(TcChartjsFactory) { + return new TcChartjsFactory(); + } + TcChartjs.$inject = [ "TcChartjsFactory" ]; + function TcChartjsLine(TcChartjsFactory) { + return new TcChartjsFactory("line"); + } + TcChartjsLine.$inject = [ "TcChartjsFactory" ]; + function TcChartjsBar(TcChartjsFactory) { + return new TcChartjsFactory("bar"); + } + TcChartjsBar.$inject = [ "TcChartjsFactory" ]; + function TcChartjsRadar(TcChartjsFactory) { + return new TcChartjsFactory("radar"); + } + TcChartjsRadar.$inject = [ "TcChartjsFactory" ]; + function TcChartjsPolararea(TcChartjsFactory) { + return new TcChartjsFactory("polararea"); + } + TcChartjsPolararea.$inject = [ "TcChartjsFactory" ]; + function TcChartjsPie(TcChartjsFactory) { + return new TcChartjsFactory("pie"); + } + TcChartjsPie.$inject = [ "TcChartjsFactory" ]; + function TcChartjsDoughnut(TcChartjsFactory) { + return new TcChartjsFactory("doughnut"); + } + TcChartjsDoughnut.$inject = [ "TcChartjsFactory" ]; + function TcChartjsFactory() { + return function(chartType) { + var directive = { + restrict: "A", + scope: { + data: "=chartData", + options: "=chartOptions", + type: "@chartType", + legend: "=chartLegend", + chart: "=chart" + }, + link: link + }; + return directive; + function link($scope, $elem, $attrs) { + var ctx = $elem[0].getContext("2d"); + var chart = new Chart(ctx); + var chartObj; + var showLegend = false; + var autoLegend = false; + var exposeChart = false; + var legendElem = null; + for (var attr in $attrs) { + if (attr === "chartLegend") { + showLegend = true; + } else if (attr === "chart") { + exposeChart = true; + } else if (attr === "autoLegend") { + autoLegend = true; + } + } + $scope.$watch("data", function(value) { + if (value) { + if (chartObj) { + chartObj.destroy(); + } + if (chartType) { + chartObj = chart[cleanChartName(chartType)]($scope.data, $scope.options); + } else if ($scope.type) { + chartObj = chart[cleanChartName($scope.type)]($scope.data, $scope.options); + } else { + throw "Error creating chart: Chart type required."; + } + if (showLegend) { + $scope.legend = chartObj.generateLegend(); + } + if (autoLegend) { + if (legendElem) { + legendElem.remove(); + } + angular.element($elem[0]).after(chartObj.generateLegend()); + legendElem = angular.element($elem[0]).next(); + } + if (exposeChart) { + $scope.chart = chartObj; + } + } + }, true); + } + function cleanChartName(type) { + var typeLowerCase = type.toLowerCase(); + switch (typeLowerCase) { + case "line": + return "Line"; + + case "bar": + return "Bar"; + + case "radar": + return "Radar"; + + case "polararea": + return "PolarArea"; + + case "pie": + return "Pie"; + + case "doughnut": + return "Doughnut"; + + default: + return type; + } + } + }; + } + function TcChartjsLegend() { + var directive = { + restrict: "A", + scope: { + legend: "=chartLegend" + }, + link: link + }; + return directive; + function link($scope, $elem) { + $scope.$watch("legend", function(value) { + if (value) { + $elem.html(value); + } + }, true); + } + } +})(); diff --git a/www/lib/tc-angular-chartjs/dist/tc-angular-chartjs.min.js b/www/lib/tc-angular-chartjs/dist/tc-angular-chartjs.min.js new file mode 100644 index 00000000..b132aeef --- /dev/null +++ b/www/lib/tc-angular-chartjs/dist/tc-angular-chartjs.min.js @@ -0,0 +1,6 @@ +/** + * tc-angular-chartjs - v1.0.9 - 2014-10-14 + * Copyright (c) 2014 Carl Craig <carlcraig@3c-studios.com> + * Dual licensed with the Apache-2.0 or MIT license. + */ +!function(){"use strict";function a(a){return new a}function b(a){return new a("line")}function c(a){return new a("bar")}function d(a){return new a("radar")}function e(a){return new a("polararea")}function f(a){return new a("pie")}function g(a){return new a("doughnut")}function h(){return function(a){function b(b,d,e){var f,g=d[0].getContext("2d"),h=new Chart(g),i=!1,j=!1,k=!1,l=null;for(var m in e)"chartLegend"===m?i=!0:"chart"===m?k=!0:"autoLegend"===m&&(j=!0);b.$watch("data",function(e){if(e){if(f&&f.destroy(),a)f=h[c(a)](b.data,b.options);else{if(!b.type)throw"Error creating chart: Chart type required.";f=h[c(b.type)](b.data,b.options)}i&&(b.legend=f.generateLegend()),j&&(l&&l.remove(),angular.element(d[0]).after(f.generateLegend()),l=angular.element(d[0]).next()),k&&(b.chart=f)}},!0)}function c(a){var b=a.toLowerCase();switch(b){case"line":return"Line";case"bar":return"Bar";case"radar":return"Radar";case"polararea":return"PolarArea";case"pie":return"Pie";case"doughnut":return"Doughnut";default:return a}}var d={restrict:"A",scope:{data:"=chartData",options:"=chartOptions",type:"@chartType",legend:"=chartLegend",chart:"=chart"},link:b};return d}}function i(){function a(a,b){a.$watch("legend",function(a){a&&b.html(a)},!0)}var b={restrict:"A",scope:{legend:"=chartLegend"},link:a};return b}angular.module("tc.chartjs",[]).directive("tcChartjs",a).directive("tcChartjsLine",b).directive("tcChartjsBar",c).directive("tcChartjsRadar",d).directive("tcChartjsPolararea",e).directive("tcChartjsPie",f).directive("tcChartjsDoughnut",g).directive("tcChartjsLegend",i).factory("TcChartjsFactory",h),a.$inject=["TcChartjsFactory"],b.$inject=["TcChartjsFactory"],c.$inject=["TcChartjsFactory"],d.$inject=["TcChartjsFactory"],e.$inject=["TcChartjsFactory"],f.$inject=["TcChartjsFactory"],g.$inject=["TcChartjsFactory"]}(); |
