我正在使用 d3.js,但遇到了問題。我有一個圖表,在該圖表中我使用畫筆功能來調整軸的比例。當我刷時,我調用函數updateChart:var brush = d3.brush() .extent( [ [0,0], [width,height] ] ) .on("end", updateChart)updateChart功能在哪里:function updateChart() { extent = d3.event.selection if (!idleTimeout) return idleTimeout = setTimeout(idled, 350); x = d3.scaleTime() .domain(d3.extent(data, function(d) { return new Date(d.valueX);})) .rangeRound([0, width]); y = d3.scaleLinear() .domain([d3.min(data, function(d){return d.valueY;}), d3.max(data, function(d){return d.valueY;})]) .range([ height, 0]); }else{ x.domain([ x.invert(extent[0][0]), x.invert(extent[1][0]) ]) y.domain([ y.invert(extent[1][1]), y.invert(extent[0][1]) ]) scatter.select(".brush").call(brush.move, null) // This remove the grey brush area as soon as the selection has been done } // Update axis and circle position xAxis.transition().duration(1000).call(d3.axisBottom(x).tickFormat(multiFormat)); yAxis.transition().duration(1000).call(d3.axisLeft(y)) scatter .selectAll("circle") .transition().duration(1000) .attr("cx",function(d) {return x(new Date(d.valueX))} ) .attr("cy", function (d) { return y(d.valueY); } ) }我還有一個功能,當我把鼠標放在一個圓圈上時,它會顯示我的信息。area.on("mouseover", highlight)var highlight = function(d) { var selected_specie = d.Group d3.selectAll(".dot") .transition() .duration(200) .style("fill", "lightgrey") .attr("r", 3)問題是:當我把鼠標放在一個圓圈上時,過渡就完成了。鼠標懸停功能不允許您正確完成過渡。有什么方法可以在我進行轉換時停止監聽鼠標事件?
畫筆和過渡并存
收到一只叮咚
2021-12-02 19:10:55