下面的图表是静态的,但是由于我会在我的Flask应用程序上每秒推送数据,所以我想知道如何使其成为动态的。我试图搜索示例,但我找到的只有Javascript,而不是Python。在
Python可以用这个图表实时更新吗?有什么建议吗?在def index():
rng = pd.date_range('1/1/2011', periods=7500, freq='H')
ts = pd.Series(np.random.randn(len(rng)), index=rng)
graphs = [
dict(
data=[
dict(
x=[1, 2, 3],
y= arr,
type='scatter'
),
],
layout=dict(
title='first graph'
)
)
]
ids = ['graph-{}'.format(i) for i, _ in enumerate(graphs)]
graphJSON = json.dumps(graphs, cls=plotly.utils.PlotlyJSONEncoder)
return render_template('index.html',
ids=ids,
graphJSON=graphJSON)