dygraph.resize 不适用于指令



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

但是当我以前调整窗口大小时,图形不会自动执行此操作。PS:我也声明了css。

你是否像这样绑定了graph.resize(width,height);在graph.ready之后

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

最新更新