◐ Shell
clean mode source ↗

Implement `hovertemplate` for `candlestick` and `ohlc` traces by emilykl · Pull Request #7619 · plotly/plotly.js

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>',
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
        }
    ], 
);