第1期:
我想不出如何画出多条不同的线,除了这张图:
main_time_line = p.line(x=(start, stop), y=(0, 0))
g1 = p.square(source=source, x='examination__date', y=0, size=4,
color='black', name='g1')
hover_tool.renderers.append(g1)
g2 = p.circle(source=source, x='examination__date', y='level', size=15)
for i, (idate, ilevel, iname) in enumerate(zip(source.data['examination__date'],
source.data['level'],
source.data['examination__name'])):
vert = 'top' if ilevel < 0 else 'bottom'
horizontal = 'right' if ilevel < 0 else 'left'
yoff = -10 if ilevel < 0 else 10
p.line(x=idate, y=(0, ilevel), color='black', line_width=3)
my_txt = Label(x=idate,
y=ilevel,
text=iname,
text_align=horizontal,
text_baseline=vert,
text_font_size='13px',
y_offset=yoff)
p.add_layout(my_txt)
视觉效果或多或少和我所说的一样,但是垂直线是用for循环绘制的,这给小部件带来了问题,即:复选框只对正方形和圆形起作用。你知道吗
我猜这是因为垂直线是在没有源参数的情况下绘制的,因此通过JS回调发出更改不会更新它们的数据(源是来自pandas dataframe的ColumDataSource) 在使用source arg时,我无法按原样绘制它们。你知道吗
第2期: 假设我放弃for循环,我就无法操作文本的放置
有什么建议吗?你知道吗
对文档的进一步检查使我发现了片段和标签集,因此为了达到我想要的效果,我只需向ColumnDataSource添加一个由0组成的“零”列表。你知道吗
我相信有很多其他的方法来处理它。你知道吗
相关问题 更多 >
编程相关推荐