Reputation: 131
I am trying to make a circle plot in boke 0.12.0 in a jupyter notebook like this:
s5 = figure(toolbar_location="above", x_axis_type = 'datetime')
s5.circle([1467568091,1467568152,1467568213],[1,1,1])
s5.xaxis.formatter = DatetimeTickFormatter(formats = dict(
seconds=["%d %m %Y %H %M %S"],
minutes=["%d %m %Y %H %M %S"],
hours=["%d %m %Y %H %M %S"],
days=["%d %m %Y %H %M %S"],
months=["%d %m %Y %H %M %S"],
years=["%d %m %Y %H %M %S"],
)
)
s5.xaxis.major_label_orientation = np.pi/4
show(s5)
However its not displaying anything and i get a javascript error:
TypeError: j is undefined
inline_js</Bokeh</<["models/formatters/datetime_tick_formatter"]</o</e.prototype.doFormat()
main.min.js:60
inline_js</Bokeh</<["models/axes/axis"]</o</e.prototype._tick_label_extent()
main.min.js:59
inline_js</Bokeh</<["models/axes/axis"]</o</e.prototype._get_size()
main.min.js:59
inline_js</Bokeh</<["core/layout/side_panel"]</T()
main.min.js:56
inline_js</Bokeh</<["models/plots/plot_canvas"]</_</e.prototype.update_constraints()
main.min.js:66
inline_js</Bokeh</<["models/plots/plot_canvas"]</_</e.prototype.render()
main.min.js:66
inline_js</Bokeh</<["core/util/throttle"]</i/i()
main.min.js:57
What is going wrong here?
Upvotes: 1
Views: 293
Reputation: 34568
If you are going to replace the formats dictionary, you have to take care to make a formats dict that has every possible resolution. In this case, you have left off an entry for "milliseconds"
. The following code generates a plot:
s5 = figure(toolbar_location="above", x_axis_type = 'datetime')
s5.circle([1467568091,1467568152,1467568213],[1,1,1])
s5.xaxis.formatter = DatetimeTickFormatter(formats = dict(
seconds=["%d %m %Y %H %M %S"],
minutes=["%d %m %Y %H %M %S"],
hours=["%d %m %Y %H %M %S"],
days=["%d %m %Y %H %M %S"],
months=["%d %m %Y %H %M %S"],
years=["%d %m %Y %H %M %S"],
milliseconds=["%d %m %Y %H %M %S"],
))
s5.xaxis.major_label_orientation = np.pi/4
show(s5)
The other option is to not replace the original .formats
dict, but to set new keys/values that replace any or all of the original ones.
This definitely seems like a too-easy pitfall. If you would like to make an issue/PR on the project GitHub that does any or all of the following:
Add documentation support making it clear that all the keys need to be present, and also what those required keys are
Add a validation check to warn if all the required keys are not present
That would help all Bokeh users and certainly be appreciated. We are always happy to help new contributors with making PRs, but the best place to collaborate on that is probably the public mailing list.
Upvotes: 1