Quantcast
Channel: 🎛️ Dash - Plotly Community Forum
Viewing all articles
Browse latest Browse all 6271

Circular Dependencies error is there a workable solution

$
0
0

I need some input how to solve this problem, please.

I have a checkbox.
I don’t want that all boxes are empty.
If all are uncheked I want one box to be automatically checked on (and maybe inactivated until other box has been checked).
If any other box is checked, 'default box (‘BBB’ in example) can be unchecked.

Here is a code I’m playing with. Code seems to work but I keep getting Circular Dependencies error, and can’t figure out the solution.

Here is a code.

 import dash
import dash_html_components as html
import dash_core_components as dcc
from dash.dependencies import Input, Output
from jupyter_dash import JupyterDash


app = JupyterDash(__name__)

app.layout = html.Div([
                        html.Div([
                                    dcc.Store(id="aggregate_checkbox_data"),

                                    dcc.Checklist(  id='checklist_1',
                                                    options=[{'label': x, 'value': x*3, 'disabled':False} for x in ['A', 'B', 'C']],
                                                    value=['BBB'], 
                                                    style={'color':'yellow'}),
                            
                                    html.Div(id='display_temp',style={'color':'red'}),      
                                 ]),
                      ])


# ------------------------------------------------------------------------------
# ------------------------------------------------------------------------------

## C1
@app.callback([ 
                Output('aggregate_checkbox_data', 'data'),
#                 Output('display_temp', 'children')
                ],
                [Input(component_id='checklist_1', component_property='value')],
              )
def eliminate_empty_values(checklist_values):
    if len(checklist_values) == 0:
        checklist_values = ['BBB']
    return checklist_values, # checklist_values


## C2
@app.callback([
                Output('display_temp', 'children'),
                Output(component_id='checklist_1', component_property='value')
              ],
              [Input('aggregate_checkbox_data', 'data')],
             )
def funk(checklist_values):
    return checklist_values, checklist_values





app.run_server(mode='jupyterlab', port = 8090, dev_tools_ui=True, #debug=True,
          dev_tools_hot_reload =True, threaded=True) 

1 post - 1 participant

Read full topic


Viewing all articles
Browse latest Browse all 6271

Trending Articles