angular - 当鼠标悬停在 Plotly.js 上时,Plotly.js 显示的不是跟踪的全名

标签 angular typescript plotly

我在 Angular 应用程序中用plotly制作了一个图表,但跟踪的名称很长。 因此,当我将鼠标悬停在图表上时,名称会通过在其后面添加 ... 来缩短。我真的不想要这个。我该如何改变这个?

这是我的代码。

 var text = "Plot_ForecastConfig";
    var layout = {
      showlegend: true,
      legend: {"orientation": "h"},
      yaxis: {
        title: 'Sales',
        titlefont: {
          family: 'Courier New, monospace',
          size: 18,
          color: '#7f7f7f'
        }
      }
    };
    var options = {
      scrollZoom: true,
      showLink: false,
      modeBarButtonsToAdd: [{
        name: 'image',
        title: 'Download plot as a png',
        icon: Plotly.Icons.camera,
        click: function () {
          Plotly.downloadImage(document.getElementById('graph'), {
            filename: text,
            format: 'png',
            height: 700,
            width: 1000
          });
        }
      }],
      modeBarButtonsToRemove: ['toImage', 'zoom2d', 'pan', 'pan2d', 'sendDataToCloud', 'hoverClosestCartesian', 'autoScale2d'],
      displaylogo: false,
      displayModeBar: true,
    };

    Plotly.newPlot('graph', this.drawing, layout, options);

最佳答案

我只需在跟踪对象中添加以下行即可显示长名称。

hoverlabel: {namelength :-1}

这是一个工作示例。

Plotly.plot('graph', [{
  y: [2,1,2],
  name: 'loooooooooooooooooooooooooong text name',
  hoverinfo: "y+name",
  hoverlabel: {namelength :-1},
}])
<script src="https://cdn.plot.ly/plotly-latest.min.js"></script>
<div id="graph"></div>

关于angular - 当鼠标悬停在 Plotly.js 上时,Plotly.js 显示的不是跟踪的全名,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45330466/

相关文章:

angular cli + windows 身份验证后端

r - 如何在plotly R中的绘图上添加文本框?

python - 动态改变 "template"layout.updatemenus[]下拉菜单

javascript - typescript 和 react-native 的 ForwardRef 错误

r - 如何使用 ggplot 或plotly 创建每个条形包含多个 x 变量的条形图?

angular - 如何在 Angular 2 应用程序中正确调用 window.matchMedia()

Angular 2 路由器辅助路由不适用于 redirectTo

typescript - ionic2 .. 类型错误 : Cannot read property 'query' of null

javascript - 无法设置未定义的属性 'someProperty' - Angular Typescript

typescript - 如何定义对象类型的真正逻辑 OR(结果中不混合不同的对象键)