          chart.yAxis1.showMaxMin(true)
              .tickFormat($filter('roundedCurrency'))
 
-         d3.select(svgElement)
-             .datum(data)
-           .transition().duration(500).call(chart)
+         updateGraph(chart, svgElement, entity)
 
-         nv.utils.windowResize(chart.update)
-
-         chart
+  updateGraph = (chart, svgElement, entity) ->
+    data = processData(entity)
+    d3.select(svgElement)
+        .datum(data)
+      .transition().duration(500).call(chart)
 
   processData = (entity) ->
     autorizado = entity.autorizado

angular.module('InescApp').directive 'monthlyGraph', ['$filter', ($filter) ->
  buildGraph = (svgElement, entity) ->
     nv.addGraph () ->
         data = processData(entity)
         chart = nv.models.multiChart()
               .x((d,i) -> d.x)
               .color(['#E74C3C','#C0392b','#3498DB'])

    year: '='
  link: (scope, element, attributes) ->
    scope.$watch 'entity.autorizado', ->
      entity = scope.entity
      if entity? and entity.autorizado?
        buildOrUpdateGraph(chart, element[0], entity)
]

