UPLOAD_DIRECTORY = "Dash_Folder"
#Callback for dropdown menu
@app.callback(dash.dependencies.Output('Categories', 'value'),[dash.dependencies.Input('Categories', 'options')])
def update_output_dropdown(value):
return 'You have selected "{}"'.format(value)
#Callback for submitting everything.
@app.callback(Output('graph', 'figure'), Input('graph-with-button', 'n_clicks'), Input('Categories', 'value'))
def callback(n_clicks, value):
if (n_clicks != 0):
return calculation(n_clicks, value)
ctx = dash.callback_context
def calculation(n_clicks,value):
if os.path.exists(UPLOAD_DIRECTORY):
for file in uploaded_files():
dfs = pd.read_excel(file, sheet_name=value)
if value == 'Spikes (Oct 23)':
# Define if we analyzing Premium or Cut Spikes
# Define if the data is reliable
#Code here
app.layout = html.Div(
children=[
#Drop Down Menu for the categories.
dcc.Dropdown(
id = 'Categories',
options=[
{'label': 'Spikes (Oct 23)', 'value': 'Spikes'},
{'label': 'Fasteners', 'value': 'Fasteners'},
{'label': 'Ballast Level', 'value': 'Ballast Level'},
{'label': 'Spikes Med', 'value': 'Spikes'},
{'label': 'Fasteners Med', 'value': 'Fasteners'},
{'label': 'Ballast Level Med', 'value': 'Ballast Level'},
{'label': 'Spikes Bad', 'value': 'Spikes'},
{'label': 'Fasteners Bad', 'value': 'Fasteners'},
{'label': 'Ballast Level Bad', 'value': 'Ballast Level'}
],
placeholder="Select a category",
value = "Spikes"
),
#html.Div(id='dd-output-container', children = []),
html.Form([
#Enter button Event to trigger app callback for dropdown and upload data to submit what to calculate.
html.Div(id='graph-with-button'),
html.Button('Submit',id='submit', n_clicks=0),
]),
dcc.Graph(
id = 'graph'
),
])```
I get an error that says: Cannot read property 'layout' of null
Here is the Traceback. It is just pure gibberish.
(This error originated from the built-in JavaScript code that runs Dash apps. Click to see the full stack trace or open your browser’s console.)
TypeError: Cannot read property ‘layout’ of null
at t.value (http://127.0.0.1:8050/_dash-component-suites/dash_core_components/async-graph.v1_16_0m1617903285.js:1:12380)
at t.value (http://127.0.0.1:8050/_dash-component-suites/dash_core_components/async-graph.v1_16_0m1617903285.js:1:16413)
at callComponentWillReceiveProps (http://127.0.0.1:8050/_dash-component-suites/dash_renderer/react-dom@16.v1_9_1m1624988823.14.0.js:13111:16)
at updateClassInstance (http://127.0.0.1:8050/_dash-component-suites/dash_renderer/react-dom@16.v1_9_1m1624988823.14.0.js:13313:9)
at updateClassComponent (http://127.0.0.1:8050/_dash-component-suites/dash_renderer/react-dom@16.v1_9_1m1624988823.14.0.js:17242:22)
at beginWork (http://127.0.0.1:8050/_dash-component-suites/dash_renderer/react-dom@16.v1_9_1m1624988823.14.0.js:18755:18)
at HTMLUnknownElement.callCallback (http://127.0.0.1:8050/_dash-component-suites/dash_renderer/react-dom@16.v1_9_1m1624988823.14.0.js:182:16)
at Object.invokeGuardedCallbackDev (http://127.0.0.1:8050/_dash-component-suites/dash_renderer/react-dom@16.v1_9_1m1624988823.14.0.js:231:18)
at invokeGuardedCallback (http://127.0.0.1:8050/_dash-component-suites/dash_renderer/react-dom@16.v1_9_1m1624988823.14.0.js:286:33)
at beginWork$1 (http://127.0.0.1:8050/_dash-component-suites/dash_renderer/react-dom@16.v1_9_1m1624988823.14.0.j
Could it be because of my n_clicks? I am not sure. Does anyone have any clues?