Highcharts Stock Demo

author(s): Torstein Hønsi

by sujay

HTML

<div id="tooltip">
    USD to EUR: <span>0.6945</span>
</div>
<div id="container" style="height: 400px; min-width: 600px"></div>

<script src="http://code.highcharts.com/stock/highstock.js"></script>
<script src="http://code.highcharts.com/stock/modules/exporting.js"></script>
<script type="text/javascript" src="http://www.highcharts.com/samples/data/usdeur.js"></script>

JavaScript

$(function() {
    var chart = new Highcharts.StockChart({
        
        chart: {
            renderTo: 'container'
        },
        
        plotOptions: {
            series: {
                point: {
                    events: {
                        mouseOver: function(event) {
                                                       var values = [];
                            var xValue = this.x;
                            var extremes = chart.xAxis[0].getExtremes(),
                                min = extremes.min,
                                max = extremes.max;

                            $.each(chart.series, function(i, serie) {
                                if (!serie.options.showInLegend) {
                                    return;
                                }
                                var xMin = serie.xData.indexOf(min),
                                    xMax = serie.xData.indexOf(max);

                                var data =
                                xMin !== -1 && xMax !== -1 ? serie.options.data.slice(xMin, xMax) : serie.options.data.filter(function(el) {
                                    var myXValue = el.x || el[0];
                                    return myXValue === xValue;
                                });
                                if (data.length === 1) {
                                    values.push(data[0].y || data[0][1]);
                                } else {
                                    $.each(data, function(i, value) {
                                        if (value === undefined) {
                                            return;
                                        }
                                        if (value instanceof Array && value[0] === xValue) {
                                            values.push(value[1]);
                                        } else if (typeof value === "object" && value.x == xValue) {
                                      ...