Last active
August 29, 2015 13:57
-
-
Save benjamingr/9759944 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<ul> | |
<li ng-repeat="Rating in Ratings | restrict: 'ratingHistory'" ng-click="showRating(Rating)" ng-class="Rating.rating" analytics="clicked-on-Rating-History" analytics-props="Rating.analyticsProps" > | |
<!--- ... ---> | |
<div class="more-info" ng-show="Rating.show"> | |
<!--- ... ---> | |
<d3overview stock="Rating.stock" show-legend="false" show-duration="false" show-recommendations="true" /> | |
</div> | |
</li> | |
</ul> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
return { | |
// html tmplate | |
templateUrl: 'views/d3overview.html', | |
// replace the <d3overview element with the template above | |
replace: true, | |
// the directice can be used as an element | |
restrict: 'E', | |
// isolated scope with 2-ways-binding attrs | |
scope: { | |
stock: '=', | |
showLegend:'@', | |
showDuration: '@', | |
showRecommendations: '@' | |
}, | |
controller: function($scope) { | |
// graph settings | |
$scope.settings = { | |
//... | |
} | |
}, | |
link: doLink | |
}; | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<section class="d3overview" ng-class="{ 'full-screen': settings.fullScreen }"> | |
<div class="graph" tr-loading="stock.ispricesLoading"></div> | |
<!--- ... svg here ... ---> | |
</section> | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
angular.module('someAppName').directive('d3overview', function (d3Service, $location, $rootScope, $filter) { | |
//... | |
link: function(scope, element){ | |
//... | |
d3Service.d3().then(function(d3) { | |
//... | |
var resizeGraph = function() { | |
console.log(element); // always the same element, code only works for the last element in a list | |
//... | |
}; | |
//... | |
window.onresize = resizeGraph; | |
//... | |
}); | |
} | |
//... | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment