Skip to content

Conversation

@emilykl
Copy link
Contributor

@emilykl emilykl commented Nov 12, 2025

Closes #3437

This PR adds a hovertemplate attribute for ohlc and candlestick, allowing users to define a custom hover template for those traces.

hovertemplate: 'opened at %{open}<br>closed at %{close}<extra></extra>',
Screenshot 2025-11-12 at 11 12 13 AM

Notes

  • The first commit of this PR runs the biome formatter which introduces some noise into the diff. Use this link to see only the meaningful changes.

  • This PR also adds the hovertemplatefallback attribute for the two traces in question

  • hovertemplate is ignored when hoverlabel.split is set to true. (Open to suggestions here but I couldn't see an obvious way to make split: true work with the hovertemplate API.)

  • One Jasmine test added

This completes the list in #3437, although I'm not sure whether more traces have been added since then which should have a hovertemplate.

Thanks to @chriddyp for putting this on my radar!

To test

  • Create a plot like this one:
Plotly.newPlot(
    "plot", 
    [
        {
            x: [1, 2, 3, 4, 5],
            low: [21, 13, 18, 16, 22],
            high: [34, 23, 25, 26, 24],
            open: [24, 16, 22, 23, 22],
            close: [22, 18, 21, 21, 23],
            type: 'candlestick',  // or 'ohlc'
            hovertemplate: 'opened at %{open}<br>closed at %{close}<extra></extra>',
            // hoverlabel: {split: true},  
            // if the above line is uncommented, `hovertemplate` should be ignored
            // and separate hover tooltips should be shown for open, high, low, and close
        }
    ], 
);
  • Hover over the data and confirm that the hovertemplate is respected
  • Confirm that if hoverlabel.split is set to true, the hovertemplate is ignored and the previous behavior is unchanged

@robertclaus robertclaus assigned emilykl and camdecoster and unassigned emilykl Nov 12, 2025
Copy link
Contributor

@camdecoster camdecoster left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As we discussed, there's an issue with implementing the split: true logic that makes the split hover info not show up. Could you look into that?

'Show hover information (open, close, high, low) in',
'separate labels.'
].join(' ')
description: ['Show hover information (open, close, high, low) in', 'separate labels.'].join(' ')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
description: ['Show hover information (open, close, high, low) in', 'separate labels.'].join(' ')
description: 'Show hover information (open, close, high, low) in separate labels.'

emilykl and others added 4 commits November 12, 2025 16:22
Co-authored-by: Cameron DeCoster <cameron.decoster@gmail.com>
Co-authored-by: Cameron DeCoster <cameron.decoster@gmail.com>
@emilykl emilykl force-pushed the add-hovertemplate-for-candlestick branch from b63fda8 to 6c901b2 Compare November 12, 2025 23:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement hovertemplate for all traces that support hover

3 participants