I tried to created custom Keywords for call back and create graph based on this

What is wrong with my code?

import dash
import dash_core_components as dcc
import dash_html_components as html
from dash.dependencies import Input,Output
import plotly.graph_objs as go
import pandas as pd

app = dash.Dash()

Keywords = [ “BR” , “Pier”, “Area”, " N61", “Airtran”, “Footing”, “BackFill”, " Span", “N62”, “Deck”, " Pile", “N62”, “N63”, “F/R/P”, “Excavate”, “Cap”]

app.layout = html.Div([
html.H1(‘Project Schedule Dashboard’),
html.H3(‘Enter a Keyword:’),
dcc.Input(id=‘my_stock_ticker’,value=‘Please enter a keyword’ ),
dcc.Graph(id = ‘graph’),
dcc.Dropdown(id = ‘picker’, options = Keywords, value = “Pile”)


Keywords = [ “BR” , “Pier”, “Area”, " N61", “Airtran”, “Footing”, “BackFill”, " Span", “N62”, “Deck”, " Pile", “N62”, “N63”, “F/R/P”, “Excavate”, “Cap”]
options = []

for Keyword in Keywords:

app.layout = html.Div([dcc.Dropdown(id=‘my-dropdown’,options=Keyword, value=Keywords),html.Div(id=‘output-container’)])

dash.dependencies.Output(‘output-container’, ‘children’),
[dash.dependencies.Input(‘my-dropdown’, ‘value’)])

def get_for_activity(select_text):
return df[df[‘Activity Name’].str.contains(select_text)]

df_year = get_for_activity('select_text')

for Activity_Type in df_year['Activity Type'].unique():
    df_at= df_year.loc[df_year['Activity Type'] == 'Finish Milestone']
    Current_Finish = go.Scatter(x = df_year['Activity Name'],y = df_year['Finish'],mode = 'lines', name = 'Current Finish')
    BaseLine_Finish = go.Scatter(x = df_year['Activity Name'],y = df_year['BL1 Finish'],mode = 'lines',name = 'BL1 Finish')
    Milestones = go.Scatter(x = df_at['Activity Name'],y = df_at['Primary Constraint Date'],mode = 'markers',name = 'Planned Milestones')
    Milestones_CF = go.Scatter(x = df_at['Activity Name'],y = df_at['Finish'],mode = 'markers',name = 'Milestones_CF')
    return {'data':[Current_Finish, BaseLine_Finish,Milestones, Milestones_CF],
       'layout':go.Layout(title = 'Project Level Analysis')}

if name == ‘main’:

Graph is blank

  1. You need to combine the two app.layout assignments. Assigning the second one replaces the first one.
  2. The function that returns the data is a callback function, but you call it below instead - this won’t work. You need to make it a non-callback function and call it inside of your actual callback.
  3. The function that returns the figure is not a callback function. You need to make it a callback function that fires when the ‘select_text’ changes, gets the data using get_for_activity and outputs to the ‘figure’ property of your graph.
  4. Your dcc.Dropdown options needs to be the options list of dictionaries that you made. The value property could be Keyword (assuming it is left over from the for loop).

There may be other issues, but I see these first.

Thanks Russell. I am very new to Plotly. Is there any platform, where i can learn about Plotly ?