24-4.handing events & control flow 操作事件 控制流

170 阅读1分钟

Handling Events

  • selection.on - add or remove event listeners.添加或删除事件侦听器
  • selection.dispatch - dispatch a custom event.指定自定义事件。
  • d3.pointer - get the pointer’s position of an event.获取事件的指针位置。
  • d3.pointers - get the pointers’ positions of an event.获取事件指针的位置。

Control Flow

  • selection.each - call a function for each element.为每个元素调用一个函数。
  • selection.call - call a function with this selection.使用此选项调用函数。
  • selection.empty - returns true if this selection is empty.如果此选择为空,则返回true。
  • selection.nodes - returns an array of all selected elements.返回所有选定元素的数组。
  • selection.node - returns the first (non-null) element.返回第一个(非空)元素。
  • selection.size - returns the count of elements.返回元素的计数。
  • selection[Symbol.iterator] - iterate over the selection’s nodes.迭代选择的节点。