I’m building custom hovertemplates for the hover text in my bar chart + choropleth map. I can’t figure out how to access each bar’s Y value which the examples show as {y} as in the line below which doesn’t work:
fig_bar.update_traces(hovertemplate=f'<br>{y}<br> killed per<br> million in {state}')
On a somewhat unrelated note, is there a way to return HTML tags to an HTML.H2 component? I want to insert a paragraph tag or two with programatically-determined text.
Awesome, I love easy solutions, thanks! I still need an f-string for my python variables but mixing dash vars (or whatever these are called) with an f-string was not a problem:
fig_bar.update_traces(hovertemplate=<br>%{y}<br> killed per<br> million in' + f'{state}'
I’m Still not sure how to return tags that format the text with it (I’ve got the callback and output set up already). I just want to do this, but it treats the html tag as part of the literal text when I return it to the component: text = 'Great News: ' + '<br />There were no hispanics were killed in STATE!'
By contrast, putting basic html tags in my hovertemplate text works great.
I found this post which suggests 2 options: a) dcc.Markdown(), which I can’t use; or b) dangerously-set-inner-html. I’m hoping there’s a more dash-friendly way to do this…
Thanks. I’m using those now, but sometimes I need to return text formatted with raw html. I’ll dig into dangerously-set-inner-html if I can’t hack around the current issue.