我试图做一个简单的实时股票数据可视化使用博凯。我已经创建了对象数据类型Candle
,它具有属性time
、highest
、lowest
、open
和close
。candle1
、candle2
和candle3
是Candle
的实例。我使用下面的代码显示一个包含这3个实例数据的图。如果我想在显示完图表(调用show(plot))后添加第四个蜡烛,我应该怎么做?我认为我没有做到这一点,因为html包含静态数据,但我不知道如何做我想做的事情。你知道吗
目标是每分钟收到一支蜡烛,并将其添加到图表中。你知道吗
plot = figure(x_axis_type="datetime", width = 1000, height= 300, title ="Live Chart", sizing_mode ='scale_both')
plot.segment(candle1.time, candle1.highest, candle1.time, candle1.lowest, color="black")
plot.segment(candle2.time, candle2.highest, candle2.time, candle2.lowest, color="black")
plot.vbar(candle1.time, 0.5 *60*60*1000, candle1.open, candle1.close,fill_color="#00ff80", line_color="black")
plot.vbar(candle2.time, 0.5 * 60 * 60 * 1000, candle2.open, candle2.close, fill_color="#00ff80",
line_color="black")
output_file("candlestick.html", title="Candle example")
show(plot)
只是一个更新:我使用一个ColumnDataSource、stream函数和一个自动回调实现了这一点。你知道吗
相关问题 更多 >
编程相关推荐