小编T. *_*yne的帖子

如何使用 HTMLTemplateFormatter 调整散景数据表中的数字格式?

如何调整 HTMLTamplateFormatter 中数据的数字格式。我希望数字格式为“(0,0)”。以下是错误尝试的示例代码:

    from bokeh.models import ColumnDataSource
from bokeh.models.widgets import DataTable, TableColumn, HTMLTemplateFormatter, NumberFormatter
from bokeh.io import show

dict1 = {'x':[0]*6,'y':[500,1000,-1000,1000,-5000,500],'z':[0,0,1,1,1,2]}
source = ColumnDataSource(data=dict1)

template="""
<b><div style="background:<%= 
    (function colorfromint(){
        if(z == 1){
            return("NavajoWhite")}
        else{if(z == 2){
            return("Orange")}
        else{return("")}
        }}()) %>;
       font-style:'(0,0)'"> ### this part needs fixed
<%= value %></div></b>
"""

formater =  HTMLTemplateFormatter(template=template)
columns = [
    TableColumn(field="x", title="x"),
    TableColumn(field="y", title="y",formatter=formater)
]

data_table = DataTable(source=source, columns=columns, width=800)

show(data_table)
Run Code Online (Sandbox Code Playgroud)

html datatable bokeh

1
推荐指数
1
解决办法
2868
查看次数

标签 统计

bokeh ×1

datatable ×1

html ×1