Hover template for chart with "base"

Hello!

I am creating a figure which is a Waterfall chart.

In this Waterfall chart, I am using the ‘base’ parameter.

This works perfectly for me, but I noticed a problem with the hovertemplate…
As soon as I have data below my ‘base’, the hover doesn’t work well… It doesn’t work when I am on the bar, I will let you see this in the video.

Here is the code:

fig = go.Figure(
        go.Waterfall(
            orientation="v",
            base=17.5625,
            x=x_values,
            y=y_values,
            customdata=y_values,
            hovertemplate=(
                    "%{x}<br>" + "Initial: %{initial:.2f}<br>" + "Final: %{final:.2f}<br>" + "Delta: %{delta:.2f}<extra></extra>"
            ),
        )
    )

2025-03-06_14h14_10

Hey @krowry welcome to the forums.

Could you share the data for this so we can reproduce the plot?

Hey @AIMPED,

Yes of course!

This is the values:

x_values = ['Waiting on union or regulatory problem', 'Up log wireline to depth inside drillstring',
                'Drill to depth', 'Slickline run other activities', 'Service Well Control Equipment',
                'Trip in to depth', 'Trip out to depth', 'Run in casing to depth', 'Drilling run other activities',
                'Rig up to run slickline', 'Run in slickline to depth', 'Make up BHA', 'Circulate to condition hole',
                'Waiting on cement to develop strength', 'Circulate to condition drilling fluid',
                'Smallest differences combined']
    y_values = [-4.83333333, 1.14583333, 1.125, 1.08333333, 0.75, 0.5625, 0.5, -0.45833333, 0.41666667, 0.375,
                0.35416667, -0.33333333, 0.33333333, -0.33333333, 0.29166667, 0.875]

Hi @krowry thanks for the data. I think you might have found a bug. I can reproduce this issue with plotly 6.0.0 and 5.24.1 (i had this installed first)

Would you mind opening an issue?

import plotly.graph_objects as go

x_values = ['Waiting on union or regulatory problem', 'Up log wireline to depth inside drillstring',
                'Drill to depth', 'Slickline run other activities', 'Service Well Control Equipment',
                'Trip in to depth', 'Trip out to depth', 'Run in casing to depth', 'Drilling run other activities',
                'Rig up to run slickline', 'Run in slickline to depth', 'Make up BHA', 'Circulate to condition hole',
                'Waiting on cement to develop strength', 'Circulate to condition drilling fluid',
                'Smallest differences combined']
y_values = [-4.83333333, 1.14583333, 1.125, 1.08333333, 0.75, 0.5625, 0.5, -0.45833333, 0.41666667, 0.375, 0.35416667, -0.33333333, 0.33333333, -0.33333333, 0.29166667, 0.875]

fig = go.Figure(
        go.Waterfall(
            orientation="v",
            base=17.5625,
            x=x_values,
            y=y_values,
            customdata=y_values,
            hovertemplate=(
                    "%{x}<br>" + "Initial: %{initial:.2f}<br>" + "Final: %{final:.2f}<br>" + "Delta: %{delta:.2f}<extra></extra>"
            ),
        ),
        layout={"height": 800}    

    )
fig.show()

Thanks for your answer @AIMPED !

I created the issue : Hover template for chart with "base" · Issue #5075 · plotly/plotly.py · GitHub

2 Likes

Thank you @AIMPED for helping out. And thank you @krowry for reporting this bug.