【发布时间】:2016-06-27 05:30:25
【问题描述】:
我正在尝试使用 Bokeh 显示字符串表(我已经在 vplot+tabs 中使用散景图,并且想要在 vplot 中也有一个数据表)。
我的字符串是多行的,因为有 '\n' 字符,但是当尝试在 Bokeh DataTable 中显示这些字符时,换行符会被删除。有什么办法可以避免这种情况?
jupyter python3 notebook 中的示例代码:
import bokeh
from bokeh.plotting import figure, output_notebook, show, vplot
from bokeh.io import output_file, show, vform
from bokeh.models import ColumnDataSource
from bokeh.models.widgets import DataTable, StringFormatter, TableColumn
output_notebook()
table_data = ColumnDataSource(dict(strings=['[ -1.23456, \n \
7.89012, \n \
3.456789 \n \
]', \
'[ -1.23456, \n \
7.89012, \n \
3.456789 \n \
]']
))
columns = [TableColumn(field="strings", title="Strings", formatter=StringFormatter(text_color='#BB0000')) ]
tableplot = DataTable(source=table_data, columns=columns)
show(vform(tableplot))
(注意:此示例代码也在https://github.com/seltzered/Bokeh-multiline-datatable-demo
环境:Python 3.5、Jupyter 1.0 / Notebook 4.1.0、散景 0.11.1
小更新:尚未解决,但意识到 table/slickgrid 的 web 布局似乎为后面的行设置了硬高度值(25px/行)和偏移量,所以我认为这是一个预期的限制。
【问题讨论】:
-
只是为了澄清我的示例:我不希望该示例中的数据有单独的行单元格(这可以通过传入实际数组而不是格式化字符串来解决) - 我'我只是在寻找出现的换行符。