2017-03-28 8 views
-1

d3でズーム機能を実装しようとしています。これは角度2で実装され、D3バージョンは3.5.17です。未解決変数d3.event.translateおよびd3.event.scale

//This is where I initialize the tree layout 
ngOnInit() { 
    this.tree = d3.layout.tree().size([this.height, this.width]); 
    this.svg = d3.select("#body").append("div") 
     .classed("svg-container", true) 
     .append("svg") 
     .attr("preserveAspectRatio", "xMinYMin meet") 
     .attr("viewBox", "0 0 " + this.width + " " + this.height) 
     .attr("width", 10 * (this.width + this.margin.right + this.margin.left)) 
     .attr("height", this.height + this.margin.top + this.margin.bottom) 
     .call(d3.behavior.zoom().scaleExtent([-8, 8]).on("zoom", this.zoom)) 
     .classed("svg-content-responsive", true) 
} 

//following is the zoom function 
public zoom =() => { 
    this.svg.attr("transform", "translate(" + d3.event.translate + ")scale(" + d3.event.scale + ")"); 
    }; 

はしかし、私はd3.event.translateとd3.event.scale変数のため、コンパイルエラー '未解決の変数d3.event.translateとd3.event.scale' を取得します。私はなぜエラーであるか、私は何かが不足しているのだろうかと思っています。

+2

は誰のことができるようにするにはどうすればよい:(はい、私はあなたがv3.xxを使用している知っているが、それはまだ適用される場合があります)bundlers内d3.eventに関する「落とし穴」D3v4のマニュアルに記載されているがありますあなたなしでお手伝いをしてください。あなたが持っているエラーを知っている? –

+0

@GerardoFurtado申し訳ありませんが、私は質問を編集しました。それはちょうど迷惑なコンパイルエラーです。 – Abhi

答えて

関連する問題