Strange tooltip behavior with long series - Javascript highcharts

Javascript examples for highcharts:Chart Tooltip

Description

Strange tooltip behavior with long series

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript" src="https://code.jquery.com/jquery-1.9.1.js"></script> 
      <script type="text/javascript" src="https://code.highcharts.com/stock/highstock.src.js"></script> 
      <script type="text/javascript">
    $(window).load(function(){/*from w ww  . java  2  s  .  c  o m*/
$(function () {
    var myData1 = [],
        myData2 = [];
    var numDays = 262;
    for (var v = 2; v < 86400000 * numDays; v += 86400000) {
        var theVal = Math.floor(Math.random() * 50 + 30);
        var theNameList = ["Value is " + theVal, "Date is " + v];
        myData1.push({
            x: v,
            y: theVal,
            data: theNameList
        });
        myData2.push({
            x: v,
            y: 80 - theVal,
            data: theNameList
        });
    }
    var chart = $("#chart").highcharts("StockChart", {
        chart: {
            renderTo: "chart"
        },
        series: [{
            title: "Highcharts long series example",
            data: myData1
        }, {
            title: "other data",
            data: myData2
        }],
        plotOptions: {
            line: {
                dataGrouping: {
                    enabled: false
                },
                turboThreshold: 10000
            }
        },
        tooltip: {
            formatter: function () {
                var s = "";
                s += Highcharts.dateFormat("%a %b %d, %Y", this.x);
                console.log(this);
                for (var i = 0; i < 2; i++) {
                    for (var j = 0; j < 2; j++) {
                        s += this.points[i].point.data[j] + '<br/>';
                    }
                }
                return s;
            },
            shared: true
        }
    });
});
    });

      </script> 
   </head> 
   <body> 
      <div id="chart"></div>  
   </body>
</html>

Related Tutorials