Hi All
Actually i have created two check list and i want if i select one checklist then second should be automatically disable , can anyone suggest how i can do that, below is my code
import os
import dash
import pandas as pd
import plotly.express as px
import dash_html_components as html
import dash_core_components as dcc
import dash_bootstrap_components as dbc
from dash.dependencies import Output, Input
from dash import html
from dash.exceptions import PreventUpdate
df = pd.read_csv("C:\Projects\Dashboard\data.csv")
Totaltestdata = df.TestResult.unique()
Totaltestcount = df.Count.unique()
Testsuitedata = df.TestSuite.unique()
Testsuitecount = df.SuiteCount.unique()
print("Printing category column")
print(df.Category.unique())
# visual = px.pie(data_frame=df, names=data, values=dat)
# visual.show()
TestResultToday = px.bar(data_frame=df, x='TodayTestResult', y=['Pass', 'Fail'])
TestResult = px.pie(data_frame=df, names=Totaltestdata, values=Totaltestcount)
TestSuite = px.pie(data_frame=df, names=Testsuitedata, values=Testsuitecount)
app = dash.Dash(__name__, external_stylesheets=[dbc.themes.BOOTSTRAP])
app.layout = html.Div([
html.Div([
html.H1("My First Dashboard", style={'text-align': 'center'}),
dcc.Checklist(options=[
{'label': 'TestResult', 'value': 'TestResult'}] ,id="TestResult",style={'display': 'inline-block','color': 'Blue', 'font-size':50}),
dcc.Checklist(options=[
{'label': 'DashBoard', 'value': 'DashBoard'}],value=['DashBoard'], id="DashBoard",style={'display': 'inline-block','color': 'Blue', 'font-size':50})
# html.Button("DashBoard", id="Dashboard",n_clicks=0),
# html.Button("Jira", id="Jira",n_clicks=0),
# html.Button("TodayTestResult", id="TestResult",n_clicks=0),
# html.Button("PreviousTestResult", id="Prevtest",n_clicks=0)
]),
html.Div([
dcc.Graph(id='TestResultOutput', style={"width": "40%", "height": "50"})
]),
html.Div([
dcc.Graph(id='DashBoard1', style={"width": "40%", "height": "50", 'display': 'inline-block'}),
dcc.Graph(id='DashBoard2', style={"width": "40%", "height": "50", 'display': 'inline-block'})
])
])
x = 0
@app.callback(
# Output(component_id='DashBoard', component_property=''),
Output('TestResultOutput','figure'),
Output(component_id='DashBoard1', component_property='style'),
Output(component_id='DashBoard2', component_property='style'),
Input('TestResult', 'value')
)
def TestResultToday_graphs(n):
if n == ['TestResult']:
print(n)
fig = TestResultToday
fig1={'display': 'none'}
fig2={'display': 'none'}
else:
fig = {'display': 'none'}
fig1 = {'display': 'inline-block'}
fig2 = {'display': 'inline-block'}
return fig,fig1,fig2
@app.callback(
# Output('TestResult', ''),
Output(component_id='DashBoard1', component_property='figure'),
Output(component_id='DashBoard2', component_property='figure'),
Output('TestResultOutput','style'),
Input(component_id='DashBoard', component_property='value')
)
def DashBoard1_graphs(n):
print(n)
if n == ['DashBoard']:
fig1 = TestResult
fig2 = TestSuite
fig = {'display': 'none'}
else:
fig1={'display': 'none'}
fig2 = {'display': 'none'}
fig={'display':'block'}
return fig1,fig2,fig
if __name__ == '__main__':
app.run(host=os.getenv("HOST", ""), port=os.getenv("PORT", "8051"))