通过JS适配器的Bokeh日期时间

问题描述 投票:0回答:1

我在Bokeh中有一个Ajax数据源,它以Unix格式返回一个日期数组。我想把它们转换成这样的格式。"2020-4-28 13:39:10",然后用日期作为x来绘制图表。 现在我的适配器将值返回为字符串,我使用DatetimeTickFormatter:

fig.xaxis.formatter = DatetimeTickFormatter(seconds=["%d/%m/ %H:%M:%S"],
                                            minutes=["%d/%m/ %H:%M:%S"],
                                            minsec=["%d/%m/ %H:%M:%S"],
                                            hours=["%d/%m/ %H:%M:%S"])

来获得正确的格式。但是Bokeh fig不接受字符串作为日期时间对象,我得到一个错误。"[bokeh] could not set initial ranges"。

我怎样才能以正确的格式从适配器解析数据到图中?谢谢!我使用的是python 3 flask应用程序。

javascript python datetime adapter bokeh
1个回答
0
投票

Bokeh fig does not accept the string as a datetime object.

Bokeh只识别和使用数字作为Unix时间戳。你看到的每一个格式化的日期只是数字的表示。

© www.soinside.com 2019 - 2024. All rights reserved.