Hi !
I’m getting started with Dash, and I am currently encountering my first big issue.
I want to plot data on a ScatterPolar. I have some dropdown and input before, that defines the data that has to be displayed.
So far, I have an empty graph (not a ScatterPolar, just a regular one). At the point where I should get my ScatterPlot with my new data, the regular graph disapear, and I can see the the webpage adjust itself (I wanted a big Scatterplot), but nothing is visible.
import dash
import dash_core_components as dcc
import dash_html_components as html
from dash.dependencies import Input, Output, State
import dash_daq as daq
import plotly.graph_objs as go
external_stylesheets = ['https://codepen.io/chriddyp/pen/bWLwgP.css']
app = dash.Dash(__name__, external_stylesheets=external_stylesheets)
app.layout = html.Div([
html.Div([
html.H1(children='Welcome to B.E.R.T.'),
daq.PowerButton(id='my-daq-powerbutton', on=False)
], style={'padding': 50}),
html.Div([
dcc.Dropdown(
id='type-dropdown',
options=[{'label': i, 'value': i} for i in options])
]),
html.Div([
html.Hr(),
html.Div(id='display-selected-dropdown')
]),
html.Div([
dcc.Input(id='text-input', type='text', value='Mettre le texte ici'),
html.Hr(),
html.Div(id='output-state')
]),
html.Div([
html.Hr(),
html.H5(children='You can now analyze for topics'),
html.Button(id='get-topics-button', n_clicks=0, children='Get Topics'),
html.Div(id='topics'),
html.Div([dcc.Graph(id='my-graph')])
])
@app.callback(
dash.dependencies.Output('my-graph', 'figure'),
[dash.dependencies.Input('get-topics-button', 'n_clicks')],
[dash.dependencies.State('output-state', 'children'),
dash.dependencies.State('type-dropdown', 'value')])
def get_topics(n_clicks, text, selected_dropdown,):
if n_clicks>0:
####### Here I am assigning values to the w's and the t's. I am skipping this part because it is using long external algorithms. I know that the values are assigned, and I get them with the .format() function in a return #######
t_results = [[w1, w2, w3], [w4, w5, w6], [w7, w8, w9], [w10, w11, w12], [w13, w14, w15]]
r_results = [R1, R2, R3, R4, R5]
return {
'data': [go.Scatterpolar(
r = [R1, R2, R3, R4, R5],
theta = [[w1, w2, w3], [w4, w5, w6], [w7, w8, w9], [w10, w11, w12], [w13, w14, w15]],
fill = 'toself',
name = 'Group A'
)],
'layout': go.Layout(
polar = dict(
radialaxis = dict(
visible = True,
range = [0, 1]
)
),
showlegend = False
)
}
Any help would be greatly appreciated !
Thanks