In my d3 chart, Zoom selection disappears when I change the brush and click on not selected range

﹥>﹥吖頭↗ 提交于 2020-04-17 20:25:54

问题


In my d3 chart, Zoom selection disappears when I change the brush and click on not selected range.

This is my working code - https://codesandbox.io/s/eager-shirley-cxq99

When I changed the selection above and clicked on unselected selection zoom selection disappear.

Please guide me what is wrong with my code.


回答1:


Just un-comment this part in your code to actually produce the zoom rect, which gets used in the brushed function.

    svg
      .append("rect")
      .attr("class", "zoom")
      .attr("width", containerWidth - 20)
      .attr("height", height)
      .attr("transform", "translate(0,20)")
      .call(zoom);

See working codesandbox.io



来源:https://stackoverflow.com/questions/61203923/in-my-d3-chart-zoom-selection-disappears-when-i-change-the-brush-and-click-on-n

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!