diff options
author | Mark Haines <mark.haines@matrix.org> | 2014-11-14 11:16:50 +0000 |
---|---|---|
committer | Mark Haines <mark.haines@matrix.org> | 2014-11-14 11:16:50 +0000 |
commit | e903c941cb1bed18026f00ed1d3495a8d172f13a (patch) | |
tree | 894da7441d913361b70da4cc13cd73ead86d2e67 /syweb/webclient/js/angular-peity.js | |
parent | Remove unused 'context' variables to appease pyflakes (diff) | |
parent | Add notification-service unit tests. (diff) | |
download | synapse-e903c941cb1bed18026f00ed1d3495a8d172f13a.tar.xz |
Merge branch 'develop' into request_logging
Conflicts: setup.py synapse/storage/_base.py synapse/util/async.py
Diffstat (limited to 'syweb/webclient/js/angular-peity.js')
-rw-r--r-- | syweb/webclient/js/angular-peity.js | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/syweb/webclient/js/angular-peity.js b/syweb/webclient/js/angular-peity.js new file mode 100644 index 0000000000..2acb647d91 --- /dev/null +++ b/syweb/webclient/js/angular-peity.js @@ -0,0 +1,69 @@ +var angularPeity = angular.module( 'angular-peity', [] ); + +$.fn.peity.defaults.pie = { + fill: ["#ff0000", "#aaaaaa"], + radius: 4, +} + +var buildChartDirective = function ( chartType ) { + return { + restrict: 'E', + scope: { + data: "=", + options: "=" + }, + link: function ( scope, element, attrs ) { + + var options = {}; + if ( scope.options ) { + options = scope.options; + } + + // N.B. live-binding to data by Matthew + scope.$watch('data', function () { + var span = document.createElement( 'span' ); + span.textContent = scope.data.join(); + + if ( !attrs.class ) { + span.className = ""; + } else { + span.className = attrs.class; + } + + if (element[0].nodeType === 8) { + element.replaceWith( span ); + } + else if (element[0].firstChild) { + element.empty(); + element[0].appendChild( span ); + } + else { + element[0].appendChild( span ); + } + + jQuery( span ).peity( chartType, options ); + }); + } + }; +}; + + +angularPeity.directive( 'pieChart', function () { + + return buildChartDirective( "pie" ); + +} ); + + +angularPeity.directive( 'barChart', function () { + + return buildChartDirective( "bar" ); + +} ); + + +angularPeity.directive( 'lineChart', function () { + + return buildChartDirective( "line" ); + +} ); |