From 6283aae66d0aec56b2cde4b2810b5f6cd63dfb98 Mon Sep 17 00:00:00 2001 From: Damien Vitrac Date: Thu, 17 Oct 2013 11:19:42 +0200 Subject: [PATCH] Update highchart.js Ajust width automatically with parent element. --- src/directives/highchart.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/directives/highchart.js b/src/directives/highchart.js index edea628..59c5786 100755 --- a/src/directives/highchart.js +++ b/src/directives/highchart.js @@ -22,6 +22,8 @@ angular.module('chartsExample.directives',[]) } }; + var resizeAuto = attrs.resizeAuto || "true"; + //Update when charts data changes scope.$watch(function() { return scope.chartData; }, function(value) { if(!value) return; @@ -33,6 +35,14 @@ angular.module('chartsExample.directives',[]) $.extend(deepCopy, newSettings, chartsDefaults, scope.chartData); var chart = new Highcharts.Chart(newSettings); }); + + if (resizeAuto == "true") { + scope.$watch(function(){ return element.width(); }, function(){ + if(angular.isDefined(chart)) { + chart.setSize(element.width(), element.height(), false); + } + }); + } } };