簡體   English   中英

如何在工具提示中訪問系列數據

[英]How can i access data from series in tooltip

我正在使用highcharts網絡圖,我想訪問數據中存在的value字段以將其懸停在節點上時顯示它。 我無法使用this.point.value來訪問它。有人可以幫助我解決此問題嗎?

這是我的代碼:

tooltip: {
  formatter: function () {
    return '<b>' + 'Tree' + '</b><br>' +
      'Name: ' + this.point.name + '<br>' +
      'Description: ' + this.point.value;
  }
},

series: [{
  dataLabels: {
    enabled: true
  },
  data: [
    {
      from: 'location',
      to: 'addr',
      value: 'This is sample data'
    }
  ]
}]

您可以使用this.point.linksFrom[0].value 檢查下面發布的代碼和演示。

碼:

Highcharts.chart('container', {
  chart: {
    type: 'networkgraph'
  },
  tooltip: {
    formatter: function() {
      var text = '<b>' + 'Tree' + '</b><br>' +
        'Name: ' + this.point.name + '<br>';

      if (this.point.linksFrom[0]) {
        text += 'Description: ' + this.point.linksFrom[0].value;
      }

      return text;
    }
  },
  series: [{
    dataLabels: {
      enabled: true
    },
    data: [{
      from: 'location',
      to: 'addr',
      value: 'This is sample data'
    }, {
      from: 'point2',
      to: 'addr',
      value: 'Another data'
    }]
  }]
});

演示:
https://jsfiddle.net/BlackLabel/cohnks96/1/

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM