我有一个为天气雷达图像创建 url 的回调。这包括一个时间戳,该时间戳四舍五入到相对于当前时间最接近的 5 分钟。示例如下所示。
'https://www.metoffice.gov.uk/weather/maps-and-charts/rainfall-radar-forecast-map#?bbox=[[50.546,-2.200],[52.140,2.944]]&model=ukmo -ukv&layer=降雨率×tep=1680109809000'
如果我将其直接粘贴到浏览器中,一切都很好。但是,当提供到 Iframe 时,我收到一条错误消息。不是找不到url,只是不喜欢显示的时间步长
Iframe 的代码如下:
dbc.Tab([
dbc.Row([
dbc.Col([
html.H1(children='Data is usually updated every 2 hours', style=style_2),
], width=2, style={'height': '100vh'}),
dbc.Col([
html.Br(), html.H1(children='Weather Forecast.', style=style_1),
html.H1(children='Current radar', style=style_2),
html.Iframe(id='radar',src=rain_radar, style={"height": "600px", "width": "100%"}),
dcc.Graph(id='forecast_rain_prob', figure=fig_forecast_rain_prob, config=config),
html.Br(),
dcc.Graph(id='forecast_daily_rain_prob', figure=fig_daily_rain_prob, config=config),
html.Br(),
dcc.Graph(id='forecast_temperature', figure=fig_tempreture, config=config),
html.Br(),
dcc.Graph(id='forecast_cloud', figure=fig_cloud, config=config),
html.Br(),
html.Br(),
dcc.Graph(id='wind_speed', figure=fig_wind, config=config),
dcc.Graph(id='wind_direction', figure=fig_wind_direction, config=config),
dcc.Interval(id="forecast_trigger", interval=1000 * 60 * 60 * 2), # milliseconds
])
])
], label="Weather forecast",tab_id='tab-7'), # end tab
真正奇怪的是,有时它确实有效。任何建议将不胜感激!
编辑: 伟大的点埃里克重新回调。是这个
@app.callback([Output('forecast_rain_prob', 'figure'), #forecast tab
Output('forecast_temperature', 'figure'),
Output('wind_speed', 'figure'),
Output('wind_direction', 'figure'),
Output('radar', 'src'),
Output('forecast_cloud','figure'),
Output('forecast_daily_rain_prob','figure')
],
Input('forecast_trigger', 'n_intervals'))
def update_forecast(n):
fig_forecast_rain_prob,fig_tempreture,fig_wind,fig_wind_direction,fig_river_forcast, fig_cloud, rain_radar, fig_daily_rain, df_daily_forecast = forecast.get_open_meteo_forecast()
update_time = datetime.now()
return fig_forecast_rain_prob,fig_tempreture,fig_wind,fig_wind_direction, rain_radar, fig_cloud,fig_daily_rain