.on(“drag”,function())和.on(“contextmenu”,function())不起作用
问题描述:
这是一个将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;
答
变化:
.style("fill", this.color)
.call(drag);
.on("contextmenu", remove)
要:
.style("fill", this.color)
.call(drag)
.on("contextmenu", remove)
删除您的分号。对于未来的参考,
意外标记
始终是一个语法错误。修复语法后,错误消失。
+0
Tanq Concolato先生 – eyathu
+0
@eyathu欢迎您。我认为一切正常?如果是这样,你可以关闭这个问题吗? ;) 谢谢。 –
只是一个错字,你在 – aw04
之前有一行分号要进一步指定@ aw04所说的内容,你的行'.call(drag);'应该是'.call(drag)'。 –
Tanq非常。!!它现在工作正常! – eyathu