所以我正在使用Rickshaw图形库,我想知道如何动态地将点添加到图形中。
我有一个像这样实例化的图:
@seriesData = [ [], [], [] ]
random = new Rickshaw.Fixtures.RandomData(150)
for (var i = 0; i < 50; i++) {
random.addData(self.seriesData)
}
@graph = new Rickshaw.Graph(
element: document.getElementById("chart")
width: 550
height: 300
renderer: 'area'
series: [
{
color: "#c05020"
data: self.seriesData[0]
name: 'One'
}, {
color: "#30c020"
data: self.seriesData[1]
name: 'Two'
}, {
color: "#2791d7"
data: self.seriesData[2]
name: 'Three'
}
]
)
@graph.render()
hoverDetail = new Rickshaw.Graph.HoverDetail(
graph: self.graph
)
legend = new Rickshaw.Graph.Legend(
graph: self.graph
element: document.getElementById('legend')
)
shelving = new Rickshaw.Graph.Behavior.Series.Toggle(
graph: self.graph
legend: legend
)
axes = new Rickshaw.Graph.Axis.Time(
graph: self.graph
)
axes.render()
我有数据通过 socket.io 进来,如下所示:
app.on('data',
(one, two, three) =>
// Dynamically add data points to graph
)
我想知道如何将这三个点附加到图表中。我找不到这个库的任何好的文档。我知道它建立在 之上d3.js
,但我不确定如何将这些方法合并到我的图表中。
任何帮助,将不胜感激。