elif tab == 'tab-2':
cat,num = KVA.getObjNumCols()
cols = []
for index,i in enumerate(cat):
text1 = html.Center("{}'nin Bar Chartı".format(i))
graph1 = dcc.Graph(id={'type':'cat-graph-bar-{}'.format(i),
'index':index},
figure={})
col = dbc.Col([text1,graph1])
cols.append(col)
text2 = html.Center("{}'nin Pie Chartı".format(i))
graph2 = dcc.Graph(id={'type':'cat-graph-pie-{}'.format(i),
'index':index},
figure={})
col = dbc.Col([text2,graph2])
cols.append(col)
for index,i in enumerate(num):
text3 = html.Center("{}'nin Histogramı".format(i))
slider3 = dcc.Slider(id='my-slider{}'.format(i),
min=1,max=100,step=1,value=20)
graph3 = dcc.Graph(id='num-graph-hist-{}'.format(i),
figure={})
col = dbc.Col([text3,slider3,graph3])
cols.append(col)
returnwidget = [dbc.Row(cols)]
return returnwidget
##################
@app.callback(
output = [Output('cat-graph-bar-{}'.format(i), 'figure') for i in KVA.getObjNumCols()[0]]+
[Output('cat-graph-pie-{}'.format(i), 'figure') for i in KVA.getObjNumCols()[0]]+
[Output('num-graph-hist-{}'.format(i), 'figure') for i in KVA.getObjNumCols()[1]],
inputs = [Input('my-slider-{}'.format(i) , "value") for i in KVA.getObjNumCols()[1]])
def show_tab2(*args):
print(len(args))
totalOutput = len(KVA.getObjNumCols()[0]) + len(KVA.getObjNumCols()[0]) + len(KVA.getObjNumCols()[1])
df = px.data.iris() # iris is a pandas DataFrame
fig = px.scatter(df, x="sepal_width", y="sepal_length")
return [[fig] for i in range(totalOutput)]
I dont write all code. Basically, in tab-2 I create dynamic components which are equal to sum of numerical and categorical column number. In second part of my code doesn’t work. print(len(args)) command doesnt work.
If I change my code as making Pattern-Matching callbacks. It will work but If I drop one column from my data, then, I get error again. Expected 17 output but you give 16 bla bla.
I think the reason is, app.callback is created once. And cant change dynamically. What should i do ?