Search code examples
javascriptangularjs-directivedygraphs

dygraph.resize doesn't works with a directive


I use a directive to draw a dygraph .

<i>
    <div ng-switch-when="1" id="graph-div">
        <div id = "labels" align = "center"  onchange="resizeElements()"></div>
        <graphdrawarea data="plotData" events="plotEvents" options="plotOptions" index="serieOfRangeSelectorIndex"></graphdrawarea>
    </div>
<i>

directive:

scope.options.width=elm[0].parentElement.clientWidth;
$scope.graph = new Dygraph(elm.children()[0].childNodes[0],scope.data , scope.options );
$scope.graph.ready(function() {
    $scope.graph.setAnnotations(scope.events);
});

but when i used to resize the windows, the graph doesn't do it automatically. PS: I also declare the css.


Solution

  • did you tied graph.resize(width, height); after graph.ready like this

    graph.ready(function(){
        graph.resize(1016,320);
    });