Skip to content

Commit 059b949

Browse files
author
Ng Yew Choong
committed
Release 0.8.0.
Resize graph on window resize.
1 parent 2cf3ccc commit 059b949

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "angular-rickshaw",
3-
"version": "0.7.0",
3+
"version": "0.8.0",
44
"main": "rickshaw.js",
55
"authors": [
66
"Nick Ng <ngyewch@gmail.com>"

rickshaw.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
/* global Rickshaw */
2626

2727
angular.module('angular-rickshaw', [])
28-
.directive('rickshaw', function($compile) {
28+
.directive('rickshaw', function($compile, $window) {
2929
return {
3030
restrict: 'EA',
3131
scope: {
@@ -35,13 +35,14 @@ angular.module('angular-rickshaw', [])
3535
},
3636
// replace: true,
3737
link: function(scope, element, attrs) {
38+
var mainEl;
3839
var graphEl;
3940
var graph;
4041
var settings;
4142

4243
function update() {
4344
if (!graph) {
44-
var mainEl = angular.element(element);
45+
mainEl = angular.element(element);
4546
mainEl.append(graphEl);
4647
mainEl.empty();
4748
graphEl = $compile('<div></div>')(scope);
@@ -77,6 +78,7 @@ angular.module('angular-rickshaw', [])
7778
}
7879
}
7980

81+
graph.setSize();
8082
graph.render();
8183

8284
if (scope.features && scope.features.xAxis) {
@@ -157,6 +159,14 @@ angular.module('angular-rickshaw', [])
157159
seriesWatch();
158160
featuresWatch();
159161
});
162+
163+
angular.element($window).on('resize', function() {
164+
scope.$broadcast('rickshaw::resize');
165+
});
166+
167+
scope.$on('rickshaw::resize', function() {
168+
update();
169+
});
160170

161171
update();
162172
},

0 commit comments

Comments
 (0)