2016-01-22 61 views
1

這是一個將svg附加到gant圖表中的函數。 .on(「drag」)是允許svg在gant圖表內移動。 .on(「contextmenu」,remove)調用一個刪除svg的函數。但它不起作用。它顯示錯誤意外的令牌。符合.on(「contextmenu」)。我不能在相同的代碼中使用.on(「drag」)和.on(「contextmenu」)嗎?這裏有什麼問題?.on(「drag」,function())和.on(「contextmenu」,function())不起作用

var bodySelection = d3.select(".chart"); 

var circleSelection = bodySelection.append("rect") 

            .attr("x", this.x_start) 
            .attr("y", this.y_stage) 
            .attr("width", this.pt)     
            .attr("height", 25) 
            .attr("id",this.gantchart_id) 

            .style("fill", this.color) 
            .call(drag); 
            .on("contextmenu", remove) 
gantchart[gc_order].id = this.gantchart_id; 
gantchart[gc_order].start_point = (this.x_start-80)/5; 
gantchart[gc_order].processing_time = this.pt/5; 
index = index+1; 
gantchart.push({id: "g00", start_point: 0, next_stage: 0, index});         
gc_order = gc_order+1; 
+2

只是一個錯字,你在 – aw04

+0

之前有一行分號要進一步指定@ aw04所說的內容,你的行'.call(drag);'應該是'.call(drag)'。 –

+0

Tanq非常。!!它現在工作正常! – eyathu

回答

0

變化:

.style("fill", this.color) 
.call(drag); 
.on("contextmenu", remove) 

要:

.style("fill", this.color) 
.call(drag) 
.on("contextmenu", remove) 

刪除您的分號。對於未來的參考,

意外標記

始終是一個語法錯誤。修復語法後,錯誤消失。

+0

Tanq Concolato先生 – eyathu

+0

@eyathu歡迎您。我認爲一切正常?如果是這樣,你可以關閉這個問題嗎? ;) 謝謝。 –

相關問題