現在、Angularのカスタムディレクティブを使用して、親divのサイズを監視してangle-nvd3グラフのサイズを変更しています。これは動作しますが、サイズ変更された1つのグラフでも、すべてのグラフを再描画する必要があります。AngularJsディレクティブの継承リンク関数
派生カスタムディレクティブのupdateHeight関数とupdateWidth関数をオーバーライドして、個々のグラフをリフレッシュすることができますので、別々のディレクティブを作成してコードを複製する必要はありません。
angular.module('app.graphs').directive('flexibleDiv', function() {
return {
scope: {
opts: '='
},
link: function (scope, element, attr) {
// Watching height of parent div
scope.$watch(function() {
return element.parent(0).height();
}, updateHeight);
// Watching width of parent div
scope.$watch(function() {
return element.parent(0).width();
}, updateWidth);
function updateHeight() {
scope.$parent.scatter_api.refresh();
scope.$parent.focus_api.refresh();
scope.$parent.scatter_twoaxis_api.refresh();
}
function updateWidth() {
scope.$parent.scatter_api.refresh();
scope.$parent.focus_api.refresh();
scope.$parent.scatter_twoaxis_api.refresh();
}
}
}
<div class="widget-body no-padding" flexible-div>
<nvd3-scatter-chart data="scatter_data" api="scatter_api"></nvd3-scatter-chart>
</div>
</div>
おかげで、私はこれが今 – ganeshran
それは魔法のように動作しようとするでしょう@george。ありがとうございました!! – ganeshran