Tooltip Not Working on Dash/Datatable update
See original GitHub issueFollowing the Dash Experiment (https://community.plot.ly/t/dash-datatable-tooltips/6327/3) the tooltip works on Dash version 0.39 (Datatable version 3.6.0), but not on 1.0.0+ (Datatable version 4.1.0).
I know that the naming of ‘tooltips’ has been changed in version 1.0.0 (although it’s not very clear whether it should be ‘tooltip’ or ‘tooltip_data’), but both of these don’t seem to work:
import dash
import dash_core_components as dcc
import dash_html_components as html
import dash_table as table
import pandas as pd
import textwrap
df = pd.read_csv('https://raw.githubusercontent.com/plotly/datasets/master/gapminderDataFiveYear.csv')
print(dash.__version__)
print(table.__version__)
app = dash.Dash(__name__)
app.scripts.config.serve_locally = True
app.css.config.serve_locally = True
def create_tooltip(cell):
try:
num = float(cell)
return textwrap.dedent(
'''
Tooltip for value **{value:+.2f}**.
| Multiplier | Value | Percent |
|-------|-------|---------------|
| 1 | {value_1:+.2f} | {value_1:+.2f}% |
| 2 | {value_2:+.2f} | {value_2:+.2f}% |
| 3 | {value_3:+.2f} | {value_3:+.2f}% |
'''.format(
value=num,
value_1=num,
value_2=num * 2,
value_3=num * 3
)
)
except:
return textwrap.dedent(
'''
Tooltip: **{value}**.
'''.format(value=cell)
)
app.layout = html.Div([
table.DataTable(
columns = [{'name': i, 'id': i} for i in df.columns],
data=df.to_dict('rows'),
tooltip={
col: [
{
'type': 'markdown',
'value': create_tooltip(df.loc[i, col])
}
for i in range(len(df))
]
for col in df.columns
}
)
])
if __name__ == '__main__':
app.run_server(debug=True)
I’ve tested the code above (with the term ‘tooltips’ instead of ‘tooltip’) on Dash 0.39 (Datatable version 3.6.0) and it works fine. It doesn’t however on the new version. Reading through the docs, the only change has been on the term ‘tooltips’. Unless I’m doing something horribly wrong, I think this is a bug.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:10
Top Results From Across the Web
DataTable Tooltips | Dash for Python Documentation | Plotly
DataTable Tooltips allow you to provide additional information about table cells or headers when hovering your mouse over cells.
Read more >Creating tooltip using callback for dash DataTable
Results in a syntax error as tooltip is not defined. The callback configuration will specify where the callback return value(s) go. In this...
Read more >Tooltip - Dash Plotly DataTable - YouTube
Learn how to add the tooltip to the Dash DataTable to make your dashboard app more informative and user-friendly.
Read more >Tooltip - dbc docs - Dash Bootstrap Components - Faculty AI
To use the Tooltip component, simply add it to the layout of your app, and give it the id of a component in...
Read more >dccTooltip: Tooltip component in plotly/dashR - Rdrr.io
In plotly/dashR: An Interface to the Dash Ecosystem for Authoring Reactive Web ... optional): determines if the component is loading or not ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
k finally I got it, you need to wrap the row loop outside of the column id loop (not inside)
@vlemmy I’m having similar issues…
The issue is an ambiguity in the documentation’s requirements for providing tooltip_data. Perhaps borrowing from syntax of another programming language, the format is as follows:
value to be shown
on hover"value", "type", "duration" etc.
(according to documentation)As you can see, the overlapping language creates room for error. Also, you have to operate rowwise – which isn’t intuitive.
Here’s an example (in long form):
Oh, and
tooltip_data = tooltip_data
should be used in the latest version of plotly.Hope this solves it for you!