Exists an efficient colour mapping from string to int for callback?

Hi all,

regarding the exercise of chapter 4 from our dash-online-course the callback solution isn’t working,
you will get error message with debug=True setting;
I have an issue with an appropriate, efficient way of mapping the string colour value to a needed int value.

Exists a specific concept with Plotly - Dash beside implementing our own mapping dictionary?

My callback is by now:

# returns the selected slider title size and title colour
    Output(component_id='our-markdown', component_property='style'),
    Input(component_id='our-radio', component_property='value'),
    Input(component_id='our-slider', component_property='value'),
def update_markdown(value_slider, value_radio):
    title_style = {
                   'fontSize': 12+2*int(value_slider),
                   'color': value_radio,
    return title_style

In advance, thanks for help and information!

Hi @Ilo2023

It’s hard to know without seeing the rest of the code, but function arguments need to be in the same order as the Inputs, so first is the Radio, then the Slider.

try changing your callback function to:

def update_markdown(value_radio, value_slider):

@AnnMarieW: Thanks for your hint, changing the input sequence has been the solution :slight_smile:

1 Like

hi @Ilo2023
I’m not sure what exercise you’re referring to because we’re currently in session 1 and I can’t see any callback exercise.

I just sent you a private message to find out more.