🚀 Gen 5 of the leading AI app deployment platform launches October 6. Click for the livestream.

Python,Plotly: hover shows wrong info and dictionary for colors is not working

I have 2 issues regarding the histogram which i created on dash. So, my histogram changes based on the selected value from dropwdown menu. Actually it works, but when the cursor on histogram it shows wrong data, for example if i choose prj-1 and prj-2, then the hover text for phase3 is ‘phase1’

My second issue is reletad colors in following line:

 color_dict = {'phase1': '#9400D3', 'phase2': '#32CD32', 'phase3': '#FF8000','phase4': '#4682B4'}

i created the dictionary with colors for phases from dataframe. but when i write

marker': {
            'color': color_dict
        }

it shows me all histogram bars in same colors

here is my all code:

import dash
from dash.dependencies import Input, Output
import dash_core_components as dcc
import dash_html_components as html
import pandas as pd
def gantt_fig(df,val):
    if isinstance(val, str):
        df = df.loc[df['prjID']==val]
    else:
        df = df[df['prjID'].isin(val)]
    return df
df = pd.DataFrame({'prjID': ['prj-1', 'prj-1','prj-2', 'prj-2', 'prj-2','prj-3', 'prj-3', 'prj-4'],
               'prjPhase': ['phase1', 'phase2','phase1', 'phase3', 'phase2', 'phase2','phase1', 'phase4']})
options = df['prjID'].unique()
activities = df['prjPhase'].unique()
app = dash.Dash()
app.layout = html.Div([
    dcc.Dropdown(id='my-dropdown',options=[{'label': name, 'value': name} for name in options],
        value=options[0], multi=True),
    dcc.Graph(id='my-graph')])

@app.callback(Output('my-graph', 'figure'), [Input('my-dropdown', 'value')])
def update_graph(dropdownproject):
    fig = gantt_fig(df, dropdownproject)
    df2= fig
    color_dict = {'phase1': '#9400D3', 'phase2': '#32CD32', 'phase3': '#FF8000','phase4': '#4682B4'}
    figure = {
        'data': [
        {
            'x': df2['prjPhase'],
            'text': df2['prjPhase'],
            'type': 'histogram',
            'marker': {
                'color': color_dict
            }}]}
    return figure
if __name__ == '__main__':
    app.run_server(debug=True)