1
votes

Currently my data set is in the format: Date, Currency, Price which I am filtering at Currency level and then using it to generate graphs.

I want to improve it so that all the filtering is done using Python widget/Dropdown boxes?

I'm new to Python/Bokeh so I need some help.

Date      Currency    Price
1/1/2017  AUDUSD      1.01
2/1/2017  AUDUSD      1.02
3/1/2017  AUDUSD      1.03
1/1/2017  USDJPY      1.01
2/1/2017  USDJPY      1.02
3/1/2017  USDJPY      1.03
1/1/2017  CADUSD      1.01
2/1/2017  CADUSD      1.02
3/1/2017  CADUSD      1.03
1
Any luck on this problem please? - Shekhar
There are a multitude of examples to get you started with this. See the docs , in particular examples or this question or this one, amongst others. - Alex
I used this sample stackoverflow.com/questions/46420266/… The problem is my code runs smoothly but doesn't generate any graph. - Shekhar
Got this sorted!!! Thanks - Shekhar

1 Answers

0
votes
#Creating CCyPair wise menu
menu = Select(options=['AUDUSD','USDJPY'], value='AUDUSD')
#Function for dataframe
def get_all_price_dataset(src,name):
  df = src[(src.CCYPair == name) & (src.TYPE == 'Prices')].copy()
  return df
# Function to update Plot
def update_plot(attrname, old, new):
  newccy = menu.value
  side = buysellmenu.value
  datevalue = datemenu.value
  src_data_table = 
  ColumnDataSource(get_all_dataset(Combined,newccy,side,datevalue))
  DisplayData.data.update(src_data_table.data)
  #On change in menu,function gets called.
  menu.on_change('value', update_plot)
  #Displaying Menu and Plot.
  layout = layout([menu],
                  [plot])
  curdoc().add_root(layout)