I want one pie hart and two bar graphs in same row
Below is the current code wherein i’m able to display one pie chart and one bar graph
layout=html.Div([
#html.H5(filename),
#html.H6(datetime.datetime.fromtimestamp(date)),
html.Div([
dbc.Row([
dbc.Col(html.Div([
html.H3(‘Account opened and closed’),
#dcc.Graph(id=‘g2’, figure={‘data’: [{‘y’: [1, 2, 3]}]})
dcc.Graph(
id=‘example-graph’,
figure={
‘data’:
[(go.Scatter(
x =df[‘year’].sort_values().unique() ,
y = df.No_of_accounts_open.unique(),
name = ‘Accounts open’,
line = dict( color = (‘rgb(11, 96, 167)’),
width = 4,
dash = ‘solid’)
) #for i in df.year.unique()
),
(go.Scatter(
x =df[‘year’].sort_values().unique() ,
y = df.No_of_accounts_closed.unique(),
name = ‘Accounts closed’,
line = dict( color = (‘rgb(237, 50, 40)’),
width = 4,
dash = ‘solid’)
) #for i in df.year.unique()
)],
‘layout’:
go.Layout(#barmode=‘stack’,
xaxis = {‘title’:‘Year’
},
yaxis={‘title’: ‘Amounts’
},
)
})
], className=“six columns”),width={‘size’:6}),
dbc.Col( html.Div([
html.H3('Customer Count'),
dcc.Graph(
id='example-graph',
figure={
'data':[go.Pie(labels=list(df.prediction.unique()),
values=df['Fraud_Reported'].value_counts()*100.0 /len(df))],
'layout': go.Layout(
autosize=False,
width=300,
height=300,
margin=dict(
l=10,
r=10,
b=50,
t=50,
pad=4
),
legend=dict(
traceorder="normal",
font=dict(
family="sans-serif",
size=7,
color="black"
),
)
)
})
], className="six columns"),width={'size':1}),
dbc.Col(html.Div([
html.H3('Population by Age'),
#dcc.Graph(id='g2', figure={'data': [{'y': [1, 2, 3]}]})
dcc.Graph(
id='example-grap',
style={
‘height’: 100
},
figure={
'data': [
go.Bar(
x = df.year.sort_values(),
x = ["23-32","33-42","43-52","53-62","63-72"],
y = df.groupby(pd.cut(df.age,np.arange(23,74,10)))['Fraud_Reported'].sum() ,
name=‘Principal_amount’,
marker=dict(
color=['rgba(204,204,204,0.6)',
'rgba(0,255,0,0.6)',
'rgba(255,0,255,0.6)',
'rgba(255,255,0,0.6)',
'rgba(0,0,255,0.6)',])
)
go.Bar(
x = df.year.sort_values(),
y = df[‘cif_SUM_AVG_depoist_balance’],
name=‘Deposit Balance’,
)
],
'layout': go.Layout(
autosize=False,
width=300,
height=300,
margin=dict(
l=10,
r=10,
b=50,
t=50,
pad=4
),
)
}) ,
], className="six columns"),width={'size':3}),
dbc.Col(html.Div([
html.H3('Population by no of products'),
#dcc.Graph(id='g2', figure={'data': [{'y': [1, 2, 3]}]})
dcc.Graph(
id='elephant',
figure={
'data': [
go.Bar(
x = df.year.sort_values(),
x = ["1","2"],
y = df.groupby(df.open_pl_6m)['Fraud_Reported'].sum() ,
name=‘Principal_amount’,
marker=dict(
color=['rgba(0,255,255,0.6)',
'rgba(0,255,255,0.6)',])
)
go.Bar(
x = df.year.sort_values(),
y = df[‘cif_SUM_AVG_depoist_balance’],
name=‘Deposit Balance’,
)
],
'layout': go.Layout(
autosize=False,
width=300,
height=300,
margin=dict(
l=10,
r=10,
b=50,
t=50,
pad=4
),
)
}),
], className="six columns"),width={'size':1}),
dbc.Col(html.Div([
html.H3('population to credit score'),
#dcc.Graph(id='g2', figure={'data': [{'y': [1, 2, 3]}]})
dcc.Graph(
id='example-gra',
figure={
'data': [
go.Bar(
x = df.year.sort_values(),
x = ["301-400","401-500","501-600","601-700","701-800","801-900"],
y = df.groupby(pd.cut(df['Credit Score'],np.arange(301,902,100)))['Fraud_Reported'].sum(),
name=‘Principal_amount’,
marker=dict(
color=['rgba(255,0,0,0.6)',
'rgba(204,204,204,0.6)',
'rgba(0,0,255,0.6)',
'rgba(255,255,0,0.6)',
'rgba(0,0,128,0.6)',
'rgba(0,128,0,0.6)',])
)
go.Bar(
x = df.year.sort_values(),
y = df[‘cif_SUM_AVG_depoist_balance’],
name=‘Deposit Balance’,
)
],
'layout': go.Layout(
autosize=False,
width=300,
height=300,
margin=dict(
l=10,
r=10,
b=50,
t=50,
pad=4
),
)
}) ,
], className="six columns"),width={'size':1}),
dbc.Col(html.Div([
html.H3('Population to debt to burden ratio'),
#dcc.Graph(id='g2', figure={'data': [{'y': [1, 2, 3]}]})
dcc.Graph(
id='example-gr',
figure={
'data': [
go.Bar(
x = df.year.sort_values(),
x = ["0.023-0.25","0.25-0.50","0.50-0.75","0.75-1.02"],
y = df.groupby(pd.cut(df['dbr'],np.arange(0.023,3.02,0.25)))['Fraud_Reported'].sum(),
name=‘Principal_amount’,
marker=dict(
color=['rgba(255,0,255,0.6)',
'rgba(255,0,255,0.6)',
'rgba(255,0,255,0.6)',
'rgba(255,0,255,0.6)',])
)
go.Bar(
x = df.year.sort_values(),
y = df[‘cif_SUM_AVG_depoist_balance’],
name=‘Deposit Balance’,
)
],
'layout': go.Layout(
autosize=False,
width=300,
height=300,
margin=dict(
l=10,
r=10,
b=50,
t=50,
pad=4
),
)
}) ,
], className="six columns"),width={'size':1}),
dbc.Col(html.Div([
#dcc.Graph(id='g2', figure={'data': [{'y': [1, 2, 3]}]})
dcc.Graph(
id='example',
figure={
'data': [
go.Bar(
x=df.marital_status.unique(),
y=df.groupby(by='marital_status')['Fraud_Reported'].count(),
marker=dict(
color=['rgba(204,204,204,1)',
'rgba(222,45,38,0.8)',
'rgba(223,43,39,0.9)'])
#y=(df[df.policy_issue_state==i]['customer_churn_rate'])*100,
#name=i
) #for i in df.policy_issue_state.unique()
],
'layout':
go.Layout(
autosize=False,
width=300,
height=300,
margin=dict(
l=10,
r=10,
b=50,
t=50,
pad=4
),
title='Population by marital status',
xaxis={'tickvals': ['Married','Others','Single']},
yaxis={
‘tickvals’: [5,10,15,20,25],
‘ticktext’ : [‘5%’, ‘10%’, ‘15%’, ‘20%’, ‘25%’]},
)
})
], className="six columns"),width={'size':3}),
dbc.Col(html.Div([
#dcc.Graph(id='g2', figure={'data': [{'y': [1, 2, 3]}]})
dcc.Graph(
id='exampl',
figure={
'data': [
go.Bar(
x=df.Location.unique(),
y=df.groupby(by='Location')['Fraud_Reported'].sum(),
#y=(df[df.policy_issue_state==i]['customer_churn_rate'])*100,
#name=i
) #for i in df.policy_issue_state.unique()
],
'layout':
go.Layout( autosize=False,
width=300,
height=300,
margin=dict(
l=10,
r=10,
b=50,
t=50,
pad=4
),
title='Population by Region',
xaxis={‘title’: ‘Pending Amount’},
yaxis={
‘tickvals’: [5,10,15,20,25],
‘ticktext’ : [‘5%’, ‘10%’, ‘15%’, ‘20%’, ‘25%’]},
)
})
], className="six columns"),width={'size':1}),
dbc.Col( html.Div([
html.H3(‘Tenure to churn’),
dcc.Graph(
id=‘goat’,
figure={
‘data’:[go.Pie(labels=list(df.l_tenure.unique()),
values=df[‘l_tenure’].value_counts()*100.0 /len(df))],
‘layout’:
go.Layout(#barmode=‘stack’,
title=‘Donut Chart’,
legend=dict(
traceorder=“normal”,
font=dict(
family=“sans-serif”,
size=7,
color=“black”
),
)
)
})
], className=“six columns”),width={‘size’:4}),
dbc.Col( html.Div([
html.H3(‘Customer Count’),
dcc.Graph(
id=‘example-graph’,
figure={
‘data’:[go.Pie(labels=list(df.prediction.unique()),
values=df[‘Fraud_Reported’].value_counts()*100.0 /len(df))],
‘layout’:
go.Layout(#barmode=‘stack’,
title=‘Donut Chart’,
legend=dict(
traceorder=“normal”,
font=dict(
family=“sans-serif”,
size=7,
color=“black”
),
)
)
})
], className=“six columns”),width={‘size’:1}),
]),
]),
])