Skip to content

Instantly share code, notes, and snippets.

@benjamingr benjamingr/code from view
Last active Aug 29, 2015

Embed
What would you like to do?
<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>
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
};
});
<section class="d3overview" ng-class="{ 'full-screen': settings.fullScreen }">
<div class="graph" tr-loading="stock.ispricesLoading"></div>
<!--- ... svg here ... --->
</section>
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
You can’t perform that action at this time.