플롯 대시 (0.18.3)를 파이썬 (3.x)으로 사용하여 라이브 업데이트를 사용하려고하지만 플롯을 너무 자주 업데이트하지 않아도됩니다 (한두 번 하루가 필요합니다.)라이브 업데이트로 플롯 대쉬의 첫 번째 업데이트
import dash
import pandas as pd
import plotly.graph_objs as go
import dash.dependencies as ddp
import dash_core_components as dcc
import dash_html_components as html
def plot_figure(data):
layout = dict(
title="Figure w/ plotly",
)
fig = dict(data=data, layout=layout)
return fig
def serve_layout():
return html.Div(children=[
html.Div([
html.H1("Plotly test with Live update",
style={"font-family": "Helvetica",
"border-bottom": "1px #000000 solid"}),
], className='banner'),
html.Div([dcc.Graph(id='plot')],),
dcc.Interval(id='live-update', interval=interval),
],)
second = 1000
minute = 60
hour = 60
day = 24
interval = 1/2*day*hour*minute*second
app = dash.Dash()
app.layout = serve_layout
@app.callback(
ddp.Output('plot', 'figure'),
[],
[],
[ddp.Event('live-update', 'interval')])
def gen_plot():
ind = ['a', 'b', 'c', 'd']
df = pd.DataFrame({'one' : pd.Series([4., 3., 2., 1.], index=ind),
'two' : pd.Series([1., 2., 3., 4.], index=ind)})
trace = [go.Scatter(x=df.index, y=df['one'])]
fig = plot_figure(trace)
return fig
if __name__ == '__main__':
app.run_server(debug=True)
문제는 첫째 아무것도 표시되지 않습니다에, 그것은 반나절 후, 그래서 단지 interval
후 업데이트입니다 :
serve_layout
함수를 추가하여 업데이트했지만 효과가없는 것으로 보입니다.
페이지를 처음 액세스 한 다음 처음 업데이트 할 때마다 interval
에 어떻게 업데이트 할 수 있습니까?