Difference between revisions of "Bokeh-Server: Coba pakai curdoc"
		
		
		
		
		
		Jump to navigation
		Jump to search
		
				
		
		
	
Onnowpurbo (talk | contribs)  | 
				Onnowpurbo (talk | contribs)   | 
				||
| Line 1: | Line 1: | ||
| + | Sumber: http://bokeh.pydata.org/en/0.11.0/docs/user_guide/server.html  | ||
| + | |||
| + | |||
coba.py  | coba.py  | ||
| Line 43: | Line 46: | ||
      raise IOError("Cannot push session document because we failed to connect to the server (to start the server, try the 'bokeh serve' command)")  |       raise IOError("Cannot push session document because we failed to connect to the server (to start the server, try the 'bokeh serve' command)")  | ||
  IOError: Cannot push session document because we failed to connect to the server (to start the server, try the 'bokeh serve' command)  |   IOError: Cannot push session document because we failed to connect to the server (to start the server, try the 'bokeh serve' command)  | ||
| + | |||
| + | |||
| + | |||
| + | |||
| + | ==Referensi==  | ||
| + | |||
| + | * http://bokeh.pydata.org/en/0.11.0/docs/user_guide/server.html  | ||
Latest revision as of 07:05, 23 February 2016
Sumber: http://bokeh.pydata.org/en/0.11.0/docs/user_guide/server.html
coba.py
import numpy as np
from numpy import pi
from bokeh.client import push_session
from bokeh.driving import cosine
from bokeh.plotting import figure, curdoc
x = np.linspace(0, 4*pi, 80)
y = np.sin(x)
p = figure()
r1 = p.line([0, 4*pi], [-1, 1], color="firebrick")
r2 = p.line(x, y, color="navy", line_width=4)
# open a session to keep our local document in sync with server
session = push_session(curdoc())
@cosine(w=0.03)
def update(step):
    r2.data_source.data["y"] = y * step
    r2.glyph.line_alpha = 1 - 0.8 * abs(step) 
curdoc().add_periodic_callback(update, 50)
session.show() # open the document in a browser
session.loop_until_closed() # run forever
Saat callback ada error
 Cannot push session document because we failed to connect to the server (to start the server, try the 'bokeh serve' command)
File "session.py", line 269, in push:
raise IOError("Cannot push session document because we failed to connect to the server (to start the server, try the 'bokeh serve' command)") Traceback (most recent call last):
  File "/root/anaconda2/lib/python2.7/site-packages/bokeh/application/handlers/code_runner.py", line 71, in run
    exec(self._code, module.__dict__)
  File "/home/onno/coba.py", line 16, in <module>
    session = push_session(curdoc())
  File "/root/anaconda2/lib/python2.7/site-packages/bokeh/client/session.py", line 63, in push_session
    session.push(document)
  File "/root/anaconda2/lib/python2.7/site-packages/bokeh/client/session.py", line 269, in push
    raise IOError("Cannot push session document because we failed to connect to the server (to start the server, try the 'bokeh serve' command)")
IOError: Cannot push session document because we failed to connect to the server (to start the server, try the 'bokeh serve' command)