Skip to content

Instantly share code, notes, and snippets.

@AndresMWeber
Created June 25, 2019 18:53
Show Gist options
  • Save AndresMWeber/201067a738f729ca22f1f774dc276da1 to your computer and use it in GitHub Desktop.
Save AndresMWeber/201067a738f729ca22f1f774dc276da1 to your computer and use it in GitHub Desktop.
Template for updating a bokeh loop with data to plot.
class Data(object):
def __init__(self, source_file):
self.source = source_file
self.routes = None
def update(self):
self.routes = self.calculate()
return self.routes
def calculate(self):
""" Run and find the best routes and store them
"""
pass
class PlotLoop(object):
def __init__(self):
self.data = Data('data_source_file')
self.update()
def init_plot(self):
""" Initialize the plot with data from self.data
"""
plot(self.data.routes)
def update(self):
self.data.update()
self.init_plot()
loop = PlotLoop()
curdoc().add_periodic_callback(loop.update, 100)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment