Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/389.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 海图+;按下按钮前,绘出仪表板图显示_Javascript_Highcharts_Plotly Dash - Fatal编程技术网

Javascript 海图+;按下按钮前,绘出仪表板图显示

Javascript 海图+;按下按钮前,绘出仪表板图显示,javascript,highcharts,plotly-dash,Javascript,Highcharts,Plotly Dash,我已经用highchart嵌入了详细的破折号。我的要求是,当我按下应用按钮时,应显示图形。但是当我运行代码时,图形显示出来了 import dash import dash_alternative_viz as dav import dash_html_components as html from dash.dependencies import Input, Output import random external_scripts = [ "https://code.h

我已经用highchart嵌入了详细的破折号。我的要求是,当我按下应用按钮时,应显示图形。但是当我运行代码时,图形显示出来了

import dash
import dash_alternative_viz as dav
import dash_html_components as html
from dash.dependencies import Input, Output
import random

external_scripts = [
    "https://code.highcharts.com/highcharts.js",
    "http://code.highcharts.com/highcharts-more.js",
    "http://code.highcharts.com/maps/modules/map.js",
    "http://code.highcharts.com/maps/modules/data.js",
    "http://www.highcharts.com/samples/data/maps/world.js",
    "https://code.highcharts.com/modules/draggable-points.js"

]
app = dash.Dash(__name__,external_scripts=external_scripts)

app.layout = html.Div([
  html.Button(id="my_button", children="Apply!"),
  dav.HighChart(id="my_highchart")
])

@app.callback(
  Output("my_highchart", "options"), [Input("my_button", "n_clicks")])
  
def random_chart(n_clicks):

  return {
      'title': { 'text': 'Highcharts draggable demo' },
      'series': [{
        'data': [29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4,30.9, 41.5, 189, 162.2, 90.0, 45.0, 105.6, 136.5, 389.4, 500.1, 25.6, 69.4],
        'color':'white',
        'marker': {
                'fillColor': 'blue',
                  },
        'cursor': 'move',
          'dragDrop': {
            'draggableX': False,
            'draggableY': True
               }
    }]
  }
  
if __name__ == "__main__":
   app.run_server( port = 8052, debug=True)
我不知道会出什么问题,有人能帮我吗

谢谢,
Meera

默认情况下,所有回调都在Dash中初始化时执行。您可以通过
Dash
对象的
prevent\u initial\u callbacks
关键字参数绕过所有回调的此行为

app = Dash(..., prevent_initial_callbacks=True)
或者在每次回调的基础上,通过回调修饰符的
prevent\u initial\u call
关键字参数

@app.callback(Output(...), Input(...)], prevent_initial_call=True)

谢谢@emher,现在一切正常。