Having trouble plotting streaming data

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!!

Kushal,

Just at a glance, my first guess is that the string date value is not understood. Can you try converting it to some actual datetime type?

Thanks.

Bryan

···

On Jun 29, 2016, at 12:50 PM, kushal gohil <[email protected]> wrote:

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!!

--
You received this message because you are subscribed to the Google Groups "Bokeh Discussion - Public" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/d46e1024-d7fe-4ee6-85ab-8028a6114709%40continuum.io\.
For more options, visit https://groups.google.com/a/continuum.io/d/optout\.