首页 > 解决方案 > 如何为 Plotly modeBar 设置默认选择

问题描述

我正在使用 Plotly.js 在 Angular 6 中构建一个应用程序来绘制散点图。

我需要将默认 modeBar 选择设置为“在悬停时显示最接近的数据”(文档中的 hoverClosestCartesian)。

我能够从 modeBar 中删除选项,并使用 [config] 选项删除了所有我不想要的选项。至于设置活动选项,我不知道如何改变它。

一些文档可以在这里找到==> https://github.com/plotly/plotly.js/blob/master/src/components/modebar/buttons.js

    MyConfig = {
          scrollZoom: true,
          displayLogo: false,
          modeBarButtonsToRemove:['sendDataToCloud', 'select2d', 'lasso2d', 'hoverCompareCartesian', 'toggleSpikelines']
          };

标签: angularplotly.js

解决方案


试试layout.hovermode = 'closest'https://plot.ly/javascript/reference/#layout-hovermode)。


推荐阅读