Hi,
I am not able to get any sort of output(i am getting a blank box) on running this code…
from bokeh.io import gridplot,vplot,hplot
from bokeh.models import ColumnDataSource, Slider, Select
from bokeh.plotting import curdoc, figure
source = ColumnDataSource(dict(time=[],virt=[]))
def update():
##sample input in test.log [2016-06-28 10:50:23] 11806 ubuntu 20 0 2912m 2.6g 17m S 39 8.8 4:14.59 build/x86_64/bin/post_auction_runner -B rtbkit/sample.bootstrap.json --win-seconds 3600.0 --auction-seconds 900.0
with open('test.log', 'r') as f:
f.seek(0, 2)
cur = f.tell()
f.seek((cur - 198))
s = f.read(198)
arr = s.replace('\n','').replace('[','').replace(']','').split(' ')
new_data = dict(time=[arr[0]+" "+arr[1]], virt=[arr[11]])
print(new_data) # sample output {'virt': ['2912m'], 'time':['2016-06-28 13:09:57']}
source.stream(new_data)
p2 = figure(tools="xpan,xwheel_zoom,xbox_zoom,reset", x_axis_type='datetime', y_axis_location="right")
p2.x_range.follow = "end"
p2.x_range.follow_interval = 100
p2.x_range.range_padding = 5
p2.line(x='time', y='virt', alpha=0.8, line_width=2, color='black', source=source)
curdoc().add_root(gridplot([[p2]],toolbar_location="left"))
curdoc().add_periodic_callback(update, 1000)
curdoc().title = "Server Logs"
The update function is working fine… it is updating the data source but a blank box is displayed on running the app on the bokeh server…
Please help me as to Where am I going wrong?
Thanks in advance!!