define([
  'angular',
  'jquery',
  'config',
  'lodash',
  'services/all',
],
function (angular, $, config, _) {
  "use strict";

  var module = angular.module('grafana.controllers');

  module.controller('DashboardCtrl', function(
      $scope, $rootScope, dashboardKeybindings,
      filterSrv, dashboardSrv, dashboardViewStateSrv,
      panelMoveSrv, timer, $timeout) {

    $scope.editor = { index: 0 };
    $scope.panelNames = config.panels;

    $scope.init = function() {
      $scope.availablePanels = config.panels;
      $scope.onAppEvent('setup-dashboard', $scope.setupDashboard);

      angular.element(window).bind('resize', function() {
        $timeout(function() {
          $scope.$broadcast('render');
        });
      });

      $scope.reset_row();
    };

    $scope.setupDashboard = function(event, dashboardData) {
      timer.cancel_all();

      $rootScope.performance.dashboardLoadStart = new Date().getTime();
      $rootScope.performance.panelsInitialized = 0;
      $rootScope.performance.panelsRendered= 0;

      $scope.dashboard = dashboardSrv.create(dashboardData);
      $scope.dashboardViewState = dashboardViewStateSrv.create($scope);

      $scope.grafana.style = $scope.dashboard.style;

      $scope.filter = filterSrv;
      $scope.filter.init($scope.dashboard);

      var panelMove = panelMoveSrv.create($scope.dashboard);

      $scope.panelMoveDrop = panelMove.onDrop;
      $scope.panelMoveStart = panelMove.onStart;
      $scope.panelMoveStop = panelMove.onStop;
      $scope.panelMoveOver = panelMove.onOver;
      $scope.panelMoveOut = panelMove.onOut;

      window.document.title = 'Grafana - ' + $scope.dashboard.title;

      // start auto refresh
      if($scope.dashboard.refresh) {
        $scope.dashboard.set_interval($scope.dashboard.refresh);
      }

      dashboardKeybindings.shortcuts($scope);

      $scope.emitAppEvent("dashboard-loaded", $scope.dashboard);
    };

    $scope.isPanel = function(obj) {
      if(!_.isNull(obj) && !_.isUndefined(obj) && !_.isUndefined(obj.type)) {
        return true;
      } else {
        return false;
      }
    };

    $scope.add_row = function(dash, row) {
      dash.rows.push(row);
    };

    $scope.add_row_default = function() {
      $scope.reset_row();
      $scope.row.title = 'New row';
      $scope.add_row($scope.dashboard, $scope.row);
    };

    $scope.reset_row = function() {
      $scope.row = {
        title: '',
        height: '250px',
        editable: true,
      };
    };

    $scope.panel_path =function(type) {
      if(type) {
        return 'app/panels/'+type.replace(".","/");
      } else {
        return false;
      }
    };

    $scope.edit_path = function(type) {
      var p = $scope.panel_path(type);
      if(p) {
        return p+'/editor.html';
      } else {
        return false;
      }
    };

    $scope.setEditorTabs = function(panelMeta) {
      $scope.editorTabs = ['General','Panel'];
      if(!_.isUndefined(panelMeta.editorTabs)) {
        $scope.editorTabs =  _.union($scope.editorTabs,_.pluck(panelMeta.editorTabs,'title'));
      }
      return $scope.editorTabs;
    };

    $scope.init();
  });
});

@@ -440,16 +440,44 @@
 .panels;
+%0A    var resizeEventTimeout;
 %0A%0A    $s
@@ -618,182 +618,335 @@
 d);%0A
-%0A      angular.element(window).bind('resize', function() %7B%0A        $timeout(function() %7B%0A          $scope.$broadcast('render');%0A        %7D);%0A      %7D);%0A%0A      $scope.reset_row(
+      $scope.reset_row();%0A      $scope.registerWindowResizeEvent();%0A    %7D;%0A%0A    $scope.registerWindowResizeEvent = function() %7B%0A      angular.element(window).bind('resize', function() %7B%0A        $timeout.cancel(resizeEventTimeout);%0A        resizeEventTimeout = $timeout(function() %7B $scope.$broadcast('render'); %7D, 200);%0A      %7D
 );%0A 

Fix for plot dimension error when resizing window