Hi Everyone,
I am trying to build a data app that would show graphs for the whole data but would color the data points selected and discolor the rest of the data points.
I am using multiselect for the selection of data, here’s the code:
grouped_data1=data.groupby(['Client']).mean().round(decimals=0)
st.write(grouped_data1)
df1=pd.DataFrame({"Client":grouped_data1.index,"Selection TAT":grouped_data1['Selection TAT'],"Offer TAT":grouped_data1['Offer TAT'],"Joining TAT":grouped_data1['Joining TAT']})
st.write(df1)
client_list=df1['Client']
client_list1=client_list.copy().to_list()
options1=st.multiselect('Client Names',client_list1)
if not options1:
filtered_data1 = df1.copy()
else:
filtered_data1 = df1.loc[df1["Client"].isin(options1)]
st.dataframe(filtered_data1, width=1000, height=500)
clients=filtered_data1['Client']
selection_tat=filtered_data1['Selection TAT']
offer_tat=filtered_data1['Offer TAT']
joining_tat=filtered_data1['Joining TAT']
fig2 = go.Figure()
fig2.add_trace(go.Scatter(x=clients, y=selection_tat,
mode='markers',
name='Selection TAT',text=selection_tat,
marker=dict(color=np.zeros([0 if i not in (options1) else 1 for i in filtered_data1]),
colorscale=[[0, 'blue'],
[1, 'red']],
size=30,
showscale=False)))
fig2.add_trace(go.Scatter(x=clients, y=offer_tat,
mode='markers',
name='Offer TAT',text=offer_tat,
marker=dict(np.zeros([0 if i not in options1 else 1 for i in filtered_data1]),
colorscale=[[0, 'blue'],
[1, 'red']],
size=30,
showscale=False)))
fig2.add_trace(go.Scatter(x=clients, y=joining_tat,
mode='markers',
name='Joining TAT',text=joining_tat,
marker=dict(np.zeros([0 if i not in options1 else 1 for i in filtered_data1]),
colorscale=[[0, 'blue'],
[1, 'red']],
size=30,
showscale=False)))
fig2.update_layout(width=1100,height=700,autosize=False,
xaxis=dict(zeroline=False),
dragmode='lasso',
hovermode='closest')
fig2.update_traces(texttemplate='%{text:.5s}',textposition='top center')
st.plotly_chart(fig2)
I am not able to achieve the same with this code instead it just shows me selected data and not all the data points, can someone please guide me on this.
Thank you.