I have callbacks:
@app.callback(Output('inter-yr', 'children'), [Input('year-slider', 'value')])
def saveYear(year):
return json.dumps(year)
@app.callback(Output('inter-d1', 'children'), [Input('main-indicator', 'value'), Input('inter-yr', 'children')])
def loadData1fromAPI(ddval1, years):
years = json.loads(years)
json1 = getIndData(ddval1, '1', str(years))
return json.dumps([json1, ddval1, years])
@app.callback(Output('inter-d2', 'children'), [Input('rel-indicator', 'value'), Input('inter-yr', 'children')])
def loadData2fromAPI(ddval2, years):
years = json.loads(years)
json2 = getIndData(ddval2, '2', str(years))
return json.dumps([json2, ddval2, years])
Changing slider cause functions loadDataNfromAPI
to call in infinite loop. It’s expensive because getIndData
gets data from database and it’s lot of them. While focus == True it’s looping. When I click somewhere it stops.
How can I unfocus slider automatically or find some other workaround? Are my callbacks correctly written? Maybe I generate but myself.