我知道散景服务器很快就要大修了,但我需要设置一个情节。我在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)
然后我在相应的芹菜任务中有这个:
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
在设置步骤。这有必要吗?
变通办法:
# 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
这是一个合理的方法吗?