我知道Bokeh服务器即将进行大修,但我需要设置一个情节。我在Django视图中有这样的东西:
document = Document()
session.use_doc(name)
session.load_document(document)
if document.context.children:
plot = document.context.children[0]
else:
output_server(name)
plot = figure(title="Crawler Monitor", tools="pan,wheel_zoom,resize,save,hover", x_axis_type="datetime",
width=800, height=400)
document.add(plot)
session.store_document(document)
script = autoload_server(plot, session)
然后我在相应的Celery任务中有这个:
self.session.load_document(self.document)
plot = self.document.context.children[0]
plot.x_range.start = min_x
plot.x_range.end = max_x
plot.y_range.factors = active_urls
plot.segment(active_x0, active_urls, active_x, active_urls,
line_width=10, line_color="orange")
self.document.add(plot)
self.session.store_document(self.document)
不幸的是,我在尝试设置x_range
:
ValueError('expected a value of type float, int8, int16, int32, int64, int or long, got 2015-10-21T15:34:39.572000+0000 of type datetime64',)
我在设置步骤中手动初始化x_range
之前没有遇到此问题。这有必要吗?
答案 0 :(得分:0)
一种解决方法:
# manually instantiate model
plot.x_range = Range1d(min_x, max_x)
plot.x_range.start = min_x
plot.x_range.end = max_x
# same here
plot.y_range = FactorRange(*active_urls)
plot.y_range.factors = active_urls
这是一种合理的方法吗?