2

I have been using plotly to make some standalone interactive plots that I can share and allow others to play with data.

I switched which version of the standalone .js file I use (that each html file references to save disk space) and ever since I updated that for some other new functionality the option to switch hover modes has disappeared. I think that option was very useful, allowing comparisons to be made between traces when data is very close but still allowing the user to switch to a single hover label if there are too many traces visible on the plot.

The options I am referring to are visible in the picture below. This is part of the Modebar in the top right of the plots that shows up when you hover the cursor in that area.

Modebar picture with hover label selection

The most recent version I have does not include that option (or the spikeline toggle).

Modebar picture without hover label selection

I have seen the options in the trace options to select the hover mode but I want the user to be able to toggle this option. I know the configuration options allow these to be removed, but I don't see how to add them back in. Any help would be appreciated. Link to configuration options

Modebar configuration options

1 Answer 1

4

You can use layout.modebar.add = 'v1hovermode' to add the hover mode buttons (see https://plotly.com/javascript/reference/layout/#layout-modebar-add). Alternatively, use config.modebarButtonsToAdd = ['v1hovermode'] as described here under 'Add optional shape-drawing buttons to modebar' https://plotly.com/python/configuration-options/.

const data = [
  {
    x: [1, 2, 3, 4],
    y: [10, 15, 13, 17],
    type: 'scatter'
  }
];

const layout = {
  modebar: {
    add: 'v1hovermode'
  }
};

Plotly.newPlot('myDiv', data, layout);
<head>
    <!-- Load plotly.js into the DOM -->
    <script src='https://cdn.plot.ly/plotly-2.14.0.min.js'></script>
</head>

<body>
    <div id='myDiv'><!-- Plotly chart will be drawn inside this DIV --></div>
</body>

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.