繁体   English   中英

在D3 V4中添加自定义刷柄?

[英]Adding custom brush handles in D3 V4?

我正在尝试在我正在研究的D3项目中为画笔的手柄添加一些自定义元素 - 期望的最终结果在这里 - 我被D3 V4从画笔手柄的<g>元素移动所困扰到<rect>元素。 V4文档说您可以使用.handle--*类添加,删除或修改画笔句柄,但我无法使其工作。 例如,当我调用时:

const brushContainer = d3.select('#brushContainer');
brushContainer.call(d3.brushX());
brushContainer.selectAll('.handle').remove();
brushContainer.append('rect')
  .attr('class', 'handle handle--w');

我收到以下错误:

TypeError: undefined is not an object (evaluating 'd.type')

请注意,我不一定希望上面的代码能够正常工作,但我无法在文档或源代码中找到任何有用的示例或任何线索。

编辑:我只是想要独立地附加所需的<g> ,然后在brush d3.event.selection它们的x属性更改为d3.event.selection 我希望能够使用<g>作为句柄,这种方法使它们没有点击处理程序,但如果这是Canonical Right Answer,我会继续这样做。

是的,您应该使用画笔事件独立添加和定位手柄。

https://github.com/d3/d3-brush/issues/14

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM