Plotly tooltip calculation for difference between hovered value and prior value

I spent a decent amount of time trying to do this with no success and I can't find any other examples/questions on this topic.

I feel like someone has to have built a chart with this functionality, so I am wondering if I can find any examples that do not include doing the calculation via SQL and adding another column.

Thanks!

I like a Friday challenge, but yep it looks very achievable. See how this works for you as a starting point.
The key is to use hovertext and then map your data to "this value minus previous" for each entry.
This is just the default chart data from Retool, the dark blue Sales bars should show diff between this entry and the one to it's left.

forum (1).json (13.7 KB)

Okay!!

I ended up breaking down my original dataset to match this sample one and then working from there. Eventually got it to work with some trial and error + google.

Will update if I figure out some creative way to put this directly into the tooltip in the UI form or if I find a solution that doesn't require my dataset to be slightly restructured via formatDataAsArray whenever this is added.

Thanks so much!