I’m using a Datatable in my Dash app and would like to show a mathematical expression in the tooltip to explain how a value is calculated. Since the tooltip text is displayed as markdown, I expected to just use $
around the mathematical expression but this doesn’t seem to work Here is a simple example:
from dash import Dash, dash_table
import pandas as pd
from collections import OrderedDict
df = pd.DataFrame(OrderedDict([("x", [1, 2, 3]), ("x square", ["1", "4", "9"])]))
app = Dash(__name__)
app.layout = dash_table.DataTable(
data=df.to_dict('records'),
columns=[{'id': c, 'name': c} for c in df.columns],
tooltip_data=[{'x': {'value': 'This is the x value', 'type': 'markdown'},
'x square': {'value': 'This is the y value, it is caluclated as $y = x^2$', 'type': 'markdown'}}]*3,
)
if __name__ == '__main__':
app.run_server(debug=True)
This gives the following result instead of the expected x²
:
Is there a way to display math in a well-formatted way into these table tooltips?