Daq Knob fires callbacks too many times!

Hi everyone,

In my app, I use a Daq Knob as a selector for a minimum value.
I have a dataframe df with a column “Values”. Here is how I define the knob :

min_value = df["Values"].min()
max_value = df["Values"].max()
init_value = df["Values"][max(0, int(2*len(df)/3))]  # I want the initial position at 2/3rd of available value. df is ordered by "Values" btw

selector = daq.Knob(id="selector", label = "Select a minimum value", min = min_value, max = max_value, value = init_value)

And below the knob, there is a card displaying how many elements of df have “Values” over what’s selected with the knob :

display_card = dbc.Card([dbc.CardBody(id="display_card")])

To display my information in the knob, I use the following callback :

@app.callback(Output(component_id="display_card", component_property="children"),
              Input(component_id ="selector", component_property="value"))  
def my_callback(knob_value):
    print("In the callback!!!") # for demonstration purpose
    n_items = len(df[df["Values"] >= knob_value])
    return_txt = "{} elements were selected".format(n_items)
    return html.Div(return_txt)

Now, execution of the callback is not very time consuming. But when I try to select a new value, the callback seems to be fired on every increment of the knob, and I get a multitude of “In the callback!!!” messages. And that’s taking a painfully long time.

So my question is : How would you go to only fire the callback once the mouse is released on the final knob value?

Many thanks in advance if you can help me :slight_smile: