簡體   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