Hallo everyone,
I wanna create a dashboard, which include 2 graphs (pie chart and scatter), but i have some problem while combining them, please, help me !
TypeError: update_graph() takes 1 positional argument but 2 were given
import dash
from dash import html as html
from dash import dcc as dcc
from dash.dependencies import Input, Output
import pandas as pd
import plotly.express as px
import seaborn as sns
#getting the dataset
data1 = pd.read_csv('C:/Users/huyho/Documents/code/Copy-of-adidas.csv')
#dash app
app = dash.Dash()
#layout
app.layout = html.Div(children = [
html.Div([
html.H1(children = 'The correlation between operating profit and six distinct types of products sold'), dcc.Dropdown(id = 'geo-dropdown',
options =[{'label': i, 'value' : i}
for i in data1['Product'].unique()],
value = "Men's Street Footwear"),
dcc.Graph(id = 'price-graph')
]),
html.Div([
html.Label(['The percentage of goods selling by six retialers']),
dcc.Dropdown(
id = 'my_dropdown',
options = [{'label':'retialers','value': 'Retailer'},
{'label':'Sales Method', 'value' :'Sales Method'}
],
value = 'Retailer',
multi = False,
clearable = False,
style = {"width":"50%"}
),
]),
html.Div([
dcc.Graph(id = 'the_graph')
]),
])
@app.callback(
Output(component_id = 'price-graph',component_property ='figure'),
Output(component_id = 'the_graph',component_property = 'figure'),
Input(component_id = 'geo-dropdown',component_property = 'value'),
Input(component_id= 'my_dropdown',component_property = 'value')
)
def update_graph(selected_product):
a = data1[data1['Product'] == selected_product]
graph = px.scatter(a, x ='Units Sold' , y = 'Operating Profit',color ="Sales Method")
return(graph)
def update_graph(my_dropdown):
dff = data1
piechart = px.pie(data_frame = dff, names = my_dropdown,hole = .3,)
return(piechart)
if __name__ == '__main__':
app.run_server(debug = True)
Best regards,
Hoang