rapidsai / cuxfilter

GPU accelerated cross filtering with cuDF.
https://docs.rapids.ai/api/cuxfilter/stable/
Apache License 2.0
274 stars 67 forks source link

Plot tooltips #369

Open caxelrud opened 2 years ago

caxelrud commented 2 years ago

How to add plot tooltips, since it is a parameter of figure and not an extra parameter of the plot (as bar and line)? Here an example from Bokeh documentation.

TOOLTIPS = [
    ("index", "$index"),
    ("(x,y)", "($x, $y)"),
    ("desc", "@desc"),
]
p = figure(width=400, height=400, tooltips=TOOLTIPS,
           title="Mouse over the dots")
p.circle('x', 'y', size=20, source=source)
show(p)
AjayThorve commented 2 years ago

In cuxfilter, for bar and line charts, the .chart api option exposes the bokeh plot object underneath, and can be updated using the add_tools function to add hover options.

Here is a snippet to add hover options to the bar chart:

import cudf
import cuxfilter
from bokeh.models import HoverTool

cux_df = cuxfilter.DataFrame.from_dataframe(cudf.DataFrame({'key': [0, 1, 2, 3, 4], 'val':[float(i + 10) for i in range(5)]}))
bar_chart_1 = cuxfilter.charts.bar('key', 'val', data_points=5, add_interaction=False)

d = cux_df.dashboard([bar_chart_1])

#add tools
bar_chart_1.chart.add_tools(HoverTool(tooltips=[
    ("index", "$index"),
    ("(x,y)", "($x, $y)")
]))

bar_chart_1.view()

image

exactlyallan commented 2 years ago

@AjayThorve Keep this issue open for now - I think this would be a good addition into the docs.

github-actions[bot] commented 2 years ago

This issue has been labeled inactive-30d due to no recent activity in the past 30 days. Please close this issue if no further response or action is needed. Otherwise, please respond with a comment indicating any updates or changes to the original issue and/or confirm this issue still needs to be addressed. This issue will be labeled inactive-90d if there is no activity in the next 60 days.

github-actions[bot] commented 2 years ago

This issue has been labeled inactive-90d due to no recent activity in the past 90 days. Please close this issue if no further response or action is needed. Otherwise, please respond with a comment indicating any updates or changes to the original issue and/or confirm this issue still needs to be addressed.