简体   繁体   中英

Highcharts tooltip for all series

Here is my highcharts code which is working fine and tooltip shows only when hover one series, but I need to change it so that the same tooltip shows when hover any series in the chart, any help please. [jsfiddle][1]

 [1]: https://jsfiddle.net/khalifa/kktwdwf6/

tooltip will be as

tooltip: {
    useHTML: true,// enables html property
    shared: true,// enables shared tooltip
    formatter: function() {
      var s = '<b>' + this.x + '</b><br>';

      $.each(this.points, function(e) {
        //console.log(this.point.marker.symbol)

        var str = this.point.marker.symbol;
        if (str != 'circle') {
          str = str.substring(0, str.length - 1);
          var img = str.slice(4);
          var w = this.y;
          w = w - 20;
          n = '<img src ="' + img + '"/><br>'
        } else {
          n = '●';
        }
        s += 'Question ID: <b>' + this.series.name + '</b><br/>' +

          n + '</b><br/>';
      });

      return s;
    },
  },

Also you have to define markers with each data point

     data: [{
    y: 11.7,
    marker: {
      symbol: 'circle'
    }
  }, {
    y: 11.8,
    marker: {
      symbol: 'circle'
    }
  }],

Fiddle demo

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM