holoviz / holoviews

With Holoviews, your data visualizes itself.
https://holoviews.org
BSD 3-Clause "New" or "Revised" License
2.71k stars 403 forks source link

Custom Hovertool multi-level index #3461

Open pjvalla opened 5 years ago

pjvalla commented 5 years ago

Have one question when using a custom hovertool on an aggregated set of points.

here are the column names of the points type (Notice the multi-level index):

<bound method Dataset.columns of :Points   [Discrete Freq,Spectral Slice]   (PowerdB)>

Using the built in hover works fine.

waterfall

But I need to round the "Spectral Slice" values. I was going about it like this.

hover_water = HoverTool(tooltips=[('Discrete Freq', '@{Discrete Freq}'), ('Spectral Slice', '@{Spectral Slice}{int}'), ('Power dB', '@{PowerdB}')])
opts_hover = dict(tools=[hover_water], alpha=0, hover_alpha=0.2, fill_alpha=0)
extents = ret_extents(self.xrange, self.yrange)
agg = aggregate(self.points, width=width, height=height, dynamic=False, x_range=self.xrange, y_range=self.yrange,
                aggregator=ds.max('PowerdB'), x_sampling=self.step_size, y_sampling=1)
return hv.QuadMesh(agg, extents=extents).options(**opts_hover)

This returns an invalid hovertool.

waterfall_invalid

Is there a way to reference the muli-level index?

pjvalla commented 5 years ago

Should I just attach the 2 files needed to run it?

aditya08 commented 4 years ago

I had a similar problem and was able to perform rounding by using the format string '{0f}' (inplace of '{int}'.

In context: hover_water = HoverTool(tooltips=[('Discrete Freq', '@{Discrete Freq}'), ('Spectral Slice', '@{Spectral Slice}{0f}'), ('Power dB', '@{PowerdB}')])