1

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
Worm
  • 1,313
  • 2
  • 11
  • 28
Shekhar
  • 102
  • 1
  • 14
  • Any luck on this problem please? – Shekhar Oct 13 '17 at 19:45
  • There are a multitude of examples to get you started with this. See the [docs](https://bokeh.pydata.org/en/latest/docs/user_guide/interaction/widgets.html#userguide-interaction-widgets) , in particular [examples](https://github.com/bokeh/bokeh/tree/0.12.9/examples) or this [question](https://stackoverflow.com/questions/46644197/histogram-with-slider-filter) or this [one](https://stackoverflow.com/questions/46420266/how-to-use-a-slider-callback-to-filter-a-columndatasource-in-bokeh-using-python), amongst others. – Alex Oct 14 '17 at 05:49
  • I used this sample https://stackoverflow.com/questions/46420266/how-to-use-a-slider-callback-to-filter-a-columndatasource-in-bokeh-using-python/46746291#46746291 The problem is my code runs smoothly but doesn't generate any graph. – Shekhar Oct 14 '17 at 15:56
  • Got this sorted!!! Thanks – Shekhar Oct 14 '17 at 18:20

1 Answers1

0
#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)
Shekhar
  • 102
  • 1
  • 14