Skip to content

Instantly share code, notes, and snippets.

@fforres
Created June 9, 2015 18:30
Show Gist options
  • Save fforres/0f462d7684fd4f67dbd4 to your computer and use it in GitHub Desktop.
Save fforres/0f462d7684fd4f67dbd4 to your computer and use it in GitHub Desktop.
function stackedHorizontalBarGraphVentas() {
return {
restrict: 'E',
scope: {
selectedTab: "=",
graphTotalData: "=",
graphMetaData: "=",
graphData: '='
},
controller: function($scope, $window) {
$scope.w = angular.element($window);
$scope.theData = [
20, 40, 50
]
},
templateUrl: "lib/custom/charts/stackedHorizontarBarChart/chart.html",
link: function($scope, element, attrs) {
$scope.attrs = attrs;
$scope.element = element;
$scope.isChild = attrs.ischild == "" ? true : false;
$scope.$watch(
function() {
return $scope.selectedTab;
},
function(newValue, oldValue) {
if (newValue != oldValue) {
//HAY UN CAMBIO DE TAB
$scope.redrawGraphs($scope.theData[Math.floor((Math.random() * 4))])
}
});
window.onresize = function() {};
$scope.getTheRest = function(data) {
$scope.graph = stackedHorizontalBarChartVentas
.draw($scope.element.find(".chart")[0])
.data(data)
.onClick($scope.callback)
.render()
}
$scope.callback = function() {
console.log(this)
}
$scope.getTheRest({
graphData: $scope.graphData,
graphTotalData: $scope.graphTotalData,
graphMetaData: $scope.graphMetaData,
isChild: $scope.isChild
})
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment