bokeh生成html显示不了,Bokeh HTML template formatter not working

问题

Please have a look at the page:

https://docs.bokeh.org/en/latest/docs/reference/models/widgets.tables.html#bokeh.models.widgets.tables.HTMLTemplateFormatter

I have been trying to use that formatter for a datatable of mine, but am having a problem : the location of the table file is appended before the actual link.

How create a url link with the formatter that correctly redirect to the target page?

EDIT:

Here is the code I am using: (this is the bokeh package from python):

from bokeh.io import output_file, show

from bokeh.layouts import widgetbox

from bokeh.models import ColumnDataSource

from bokeh.models.widgets import DataTable, DateFormatter, TableColumn, HTMLTemplateFormatter

from datetime import datetime

from pandas import Timestamp

start, end = datetime(2018,4,18), datetime(2018,4,18,23,59)

input = {

'datetime': [Timestamp('2018-04-18 00:34:16')],

'event': ['Barbara Bush, former US First Lady, 1925-2018'],

'url': ['https://www.ft.com/content/336e7f52-4189-11e8-93cf-67ac3a6482fd']}

output_file("data_table.html")

source = ColumnDataSource(input)

columns = [

TableColumn(

field="datetime",

title="Datetime",

width = 50,

formatter = DateFormatter(format = '%Y-%m-%d %H:%M')),

TableColumn(

field='event',

title='Event',

width = 150,

formatter = HTMLTemplateFormatter(template = '”>'))]

data_table = DataTable(source=source, columns=columns, width=1000, height=1000)

show(widgetbox(data_table))

This create the following table:

You can see in the inspect pane that the link is correct.

However, when clicking on it, it redirect to the page:

回答1:

It's because the href value isn't a valid URL, so it's treated as a path relative to your domain. Add another slash:

https://www.google.com/search

Instead of

https:/www.google.com/search

In the second example, the "double-quote" characters around the href attribute are the more stylized versions of double quotes, and aren't valid HTML. Use this instead:

HTMLTemplateFormatter(template = ''))]

来源:https://stackoverflow.com/questions/50086517/bokeh-html-template-formatter-not-working

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值