简体   繁体   中英

highstock Get all data from current hovered time

I feel i've been searching the whole internet now to try and find the easiest way to get all the data from multiple lines, when hovering over a specific time in an highstock chart.

Can someone help me with that? :)

You can get information about hovered points by using mouseOver event or tooltip.formatter

Example for getting multiple points information when tooltip is shared :

 tooltip: {
    formatter: function() {
      let tooltip = this.points.reduce(function(s, point) {
        return s + '<br/>' + point.series.name + ': ' +
          point.y + 'm';
      }, '<b>' + new Date(this.x) + '</b>');

      inf.innerHTML = tooltip;
      return tooltip;
    },
    shared: true
  },

Demo:

https://jsfiddle.net/BlackLabel/veqj67yf/

https://jsfiddle.net/BlackLabel/quympake/

API Reference: https://api.highcharts.com/highcharts/series.line.point.events.mouseOver https://api.highcharts.com/highcharts/tooltip.formatter

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