admin管理员组文章数量:1410737
I am developing with the BokehJS library and need some help since the documentation for the JS side of the library is pretty thin.
In python you can change the text alignment via the following mand,
p = figure(title='Title',plot_width=500, plot_height=200, tools='')
p.title.text_align = 'center'
In JS there is no parable attribute.
var plt = Bokeh.Plotting;
var p = plt.figure({ title: "Title",height: 300,width: 300,tools: ''});
p.title.<???>
I believe the anchor function is responsible for setting the alignment but I need help.
I am developing with the BokehJS library and need some help since the documentation for the JS side of the library is pretty thin.
In python you can change the text alignment via the following mand,
p = figure(title='Title',plot_width=500, plot_height=200, tools='')
p.title.text_align = 'center'
In JS there is no parable attribute.
var plt = Bokeh.Plotting;
var p = plt.figure({ title: "Title",height: 300,width: 300,tools: ''});
p.title.<???>
I believe the anchor function is responsible for setting the alignment but I need help.
Share Improve this question asked Jun 27, 2017 at 15:49 DavidDavid 1172 silver badges14 bronze badges2 Answers
Reset to default 8There is a strict 1-1 correspondence maintained between the Python Bokeh models, and the corresponding BokehJS models (this is maintained under test). So the Python Reference Guide is not a terrible reference for BokehJS as well.
However, in this particular case, it's not text_align
that want. Instead you should use:
p.title.align = 'center'
The uninteresting reason is that text_align
has a specific meaning to the HTML canvas, that does not really correspond well to aligning titles.
As an aside, BokehJS used to be purely a hidden implementation detail, which is why the docs for it are thin. We are definitely interested in developing it better as a standalone JS library, including improving the documentation, but that takes people-time, which is currently spread very thin. If you'd be interested in helping improve BokehJS please reach out on GitHub or the Discourse.
Ok, I figured out the solution through navigating the attributes in the chrome developer tools.
var plt = Bokeh.Plotting;
var p = plt.figure({ title: "Title",height: 300,width: 300,tools: ''});
p.attributes["above"][0]['align']='center';
The code above centers the title text as I desired. In the case above, the plot attribute in the "above" position is the Title.
本文标签: javascriptBokehJS Title Text AlignmentStack Overflow
版权声明:本文标题:javascript - BokehJS Title Text Alignment - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744878145a2630040.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论