dygraph.resize 不适用于指令

dygraph.resize doesn't works with a directive

我使用一个指令来绘制一个 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>

指令:

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);
});

但是当我以前调整 windows 的大小时,图表不会自动执行。 PS: 我也声明 css.

你绑了吗graph.resize(width, height); graph.ready 像这样后

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