phurwicz / hover

:speedboat: Label data at scale. Fun and precision included.
https://phurwicz.github.io/hover
MIT License
323 stars 19 forks source link

Enable tooltips in selection table #48

Closed robinsonkwame closed 2 years ago

robinsonkwame commented 2 years ago

In the selection table it can be difficult to evict data points when the entire text may be needed for labeling context. This especially true for meaning derived from long range dependence between phrases. Currently that table cuts off the text. Bokeh DataTable depends on strongly SlickGrid that does not easily allow row height to be dynamic. So, instead, to get full labeling text, I suggest that the text column be set with a tooltip template, eg. add a HTMLTemplateFormatter to "text" with

    if feature_key == "text":
        feature_col_kwargs["formatter"] = HTMLTemplateFormatter(
            template="""<span href="#" data-toggle="tooltip" title="<%= value %>"><%= value %></span>"""
        )

and if the text is too long yet someone wants to inspect it w/o figuring which of the many points it is they can just hover over it.

haochuanwei commented 2 years ago

This is awesome, thanks!

The suggested code looks good, please feel free to make a PR into the nightly branch. I happen to need a couple of days before being able to make write code on desktop, but I can certainly approve on mobile now and test nightly later before merging into main.

Best regards, Haochuan


From: Kwame Porter Robinson @.> Sent: Wednesday, August 24, 2022 2:05:29 AM To: phurwicz/hover @.> Cc: Subscribed @.***> Subject: [phurwicz/hover] Enable tooltips in selection table (Issue #48)

In the selection table it can be difficult to evict data points when the entire text may be needed for labeling context. This especially true for meaning derived from long range dependence between phrases. Currently that table cuts off the text. Bokeh DataTable depends on strongly SlickGridhttps://stackoverflow.com/a/44157382/3662899 that does not easily allow row height to be dynamic. So, instead, to get full labeling text, I suggest that the text column be set with a tooltip template, eg. add a HTMLTemplateFormatter to "text"https://github.com/phurwicz/hover/blob/602ba8a244266894ef821025dc0e618170b380b0/hover/core/local_config.py#L48-L49 with

if feature_key == "text":
    feature_col_kwargs["formatter"] = HTMLTemplateFormatter(
        template="""<span href="#" data-toggle="tooltip" title="<%= value %>"><%= value %></span>"""
    )

and if the text is too long yet someone wants to inspect it w/o figuring which of the many points it is they can just hover over it.

— Reply to this email directly, view it on GitHubhttps://github.com/phurwicz/hover/issues/48, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AEZTDWWGB6LN2TTF3L7K6XDV2UHGTANCNFSM57MOFVFQ. You are receiving this because you are subscribed to this thread.Message ID: @.***>

robinsonkwame commented 2 years ago

Done.

phurwicz commented 2 years ago

https://github.com/phurwicz/hover/pull/52