New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hovertool safe tags #5460
Hovertool safe tags #5460
Conversation
Check if the format tag included in HoverTool templating is == safe, and will disable any HTML escaping if true. Updated docs, and updated existing example
Thanks for the PR @astraw38! My only comment is about the syntax. We already have e.g. Thoughts @mattpap @birdsarah ? |
I agree -- especially since the {} format would be overloaded with either Numbro syntax or what I added w/ 'safe'. I'll make the changes this evening -- will involve modifying the regex too. |
@bryevdv am I missing something, or is there no documentation for setting the Numbro format with HoverTool? Is that covered by docs somewhere else (perhaps another location that When I do another pass on this, I can add something in for that too, since that might have been overlooked . |
Which is a special-case (it's not even handled in |
This looks good. Though on a side note, I would recommend to stick with code formatting of the module/library, e.g. use |
I has been overlooked, it's been on to TODO for a long time, just not gotten to, so if it's easy to tack on something in this PR that would actually be very appreciated! |
Open to suggestions if you have alternatives to propose |
I don't think it would be difficult to use [] like
Personally, I would lean towards #2, but I'll let you guys make the final decision because you're by far more invested in it :) |
@astraw38 just so I understand, are you saying numbro itself has formats that use
Thoughts @mattpap @birdsarah ? |
Sorry, I originally meant that if we change any postfix formatting to use |
@astraw38 well, we can "fix up" these values on the python side during serialization. So I'd say the things to decide is what's best overall, for going forward, and let's just do that. Then we can fix up |
Yes. I'm not sure why a self-contained, perfectly valid PR is turned into unnecessary overhaul of something that works and there is just one feature that wasn't ported originally, which is this "color widget", that mostly makes sense only in hover tool context. Note that Also, if syntax is discussed, then lets start from the full syntax which is |
@mattpap I'm not trying to overhaul anything. But I wanted to take the user experience into consideration, and have a discussion about trying to avoid multiple ways to spell things for users. It seems like we are agreed that |
@astraw38 let's leave changing |
Also updated templating.coffee to use string formatting instead of concatenation.
OK @astraw38 this LGTM! If you would be inclined, it would be good to try to add some tests for the https://github.com/astraw38/bokeh/tree/master/bokehjs/test/core/util since there are none currently. If this is something you have some experience with (so that it would not be a big effort for you hopefully), or if not, but its something you'd like to learn more about, let me know! Otherwise I'm happy to merge this as-is. (I will plan to do that tomorrow if I don't hear anything) Thanks for the nice PR! |
Thank you very much @astraw38 , that's very useful ! |
Hi guys - this doesn't this to work for me. I am using the latest version from Github, and when I apply the {safe} tag for a field whose values are text, I get a "NaN" value instead of the text. Here is some code to reproduce the problem.
|
I am using the latest master with a locally built BokehJS. By the way, when I run it in a Jupyter notebook i get this message (I assume it just means I am using the development version of BokehJS ?)
|
did you set the env var |
No I didnt. I assume I would need to do this before installing bokeh ? |
right now, if you want to test this feature, you need to build Bokeh, not install it. I would suggest waiting for the next dev build to be made available as that can just be installed. Edit: maybe you mean
|
Yes, by "install" I meant "I built the js sources then I ran setup.py develop". Note that setup.py showed me a menu asking me if I wanted to use my locally-built BokehJS and I said yes, so its confusing that it's actually not using my local built version. I'll retry installing and report back when I have some success. |
@Zulko that is asking if you want to install an already-locally-built BokehJS, or if you want to build BokehJS from scratch again and install that. It's the difference between:
and
In any case it only affects what BokehJS is installed. What BokehJS is used when running things is always only dependent on the |
@bryevdv how do you set the env var? |
@bryevdv @astraw38 the custom tooltip example appears to not be rendering |
@bryevdv @astraw38 I tried running the example @Zulko mentioned and setting the env var %env BOKEH_RESOURCES=inline ipython notebook
from bokeh.io import show, output_notebook
from bokeh.plotting import ColumnDataSource, figure
from bokeh.models import HoverTool, Range1d
output_notebook()
fig = figure(tools=[HoverTool(tooltips=[("html", "@html{safe}")])])
fig.quad(left="left", top="top", bottom="bottom", right="right",
source=ColumnDataSource({"left": [1,3], "bottom": [1,3],
"right": [2,4], "top": [2,4],
"html":["<b>I'm bold</b>", "some text"]}))
show(fig) So |
It looks like it should be double quoted and not single quoted (in this file) allow for interpolation. |
Okay I opened PR #5700 to do that. Even if that PR is merged relatively soon will that change be reflected in the pip install? or will I have to build it from scratch and install? |
Hi @draperjames Thanks very much for the PR! This change will be in the next full release. As it happens, we just released |
Would you mind elaborating a little on how to install the dev build? I just posted answer to my question on stack overflow and I want to make it easy for the people I work with to install. I'd really appreciate that 😃. |
Sure, dev build install instructions here here: http://bokeh.pydata.org/en/latest/docs/installation.html#developer-builds I guess I'd forgotten, it may be possible to use pip to install, just not from PyPI. We only publish full releases to PyPI |
All pull requests must have an associated issue in the issue tracker. If there
isn't one, please go open an issue describing the defect, deficiency or desired
feature. You can read more about our issue and PR processes in the
wiki.
Check if the format tag included in HoverTool templating
is == safe, and will disable any HTML escaping if true.
Updated docs, and updated existing example