用于Stream'消息的D3事件监听器'事件

时间:2014-05-12 09:08:03

标签: javascript html5 d3.js streaming

大家好日子,

如何实际让D3元素具有EventSource消息事件的监听器。该事件由HTML5 Streaming Event触发,如本文所述: http://www.html5rocks.com/en/tutorials/eventsource/basics/

以下是事件来源:

...
# generate event source
if (!!window.EventSource)
source = new EventSource('/stream?hashtags='+gon.hashtags)

# Add event listener to stream source
source.addEventListener('message',(e) -> ??? , false)
...

具有侦听器的元素(不同的命名空间,不同的文件):

# Create a square canvas with width equal to the div's width
svg = d3.select('#d3-canvas').append('svg')
.attr(
  width: w
  height: h
)
.on('message', () -> alert 'test')
.attr('id','d3-svg')

我想让一个D3布局通过HTML5流发送数据来监听和更新新消息。

可能有任何帮助吗?

非常感谢

0 个答案:

没有答案
相关问题