| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263 | <!DOCTYPE HTML><html>	<head>		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">		<meta name="viewport" content="width=device-width, initial-scale=1">		<title>Highcharts Example</title>		<style type="text/css">		</style>	</head>	<body><script src="https://code.jquery.com/jquery-3.1.1.min.js"></script><script src="../../code/highcharts.js"></script><script src="../../code/modules/exporting.js"></script><script src="../../code/modules/export-data.js"></script><div id="container" style="min-width: 310px; height: 400px; margin: 0 auto"></div>		<script type="text/javascript">$.getJSON(    'https://cdn.rawgit.com/highcharts/highcharts/057b672172ccc6c08fe7dbb27fc17ebca3f5b770/samples/data/usdeur.json',    function (data) {        var detailChart;        // create the detail chart        function createDetail(masterChart) {            // prepare the detail chart            var detailData = [],                detailStart = data[0][0];            $.each(masterChart.series[0].data, function () {                if (this.x >= detailStart) {                    detailData.push(this.y);                }            });            // create a detail chart referenced by a global variable            detailChart = Highcharts.chart('detail-container', {                chart: {                    marginBottom: 120,                    reflow: false,                    marginLeft: 50,                    marginRight: 20,                    style: {                        position: 'absolute'                    }                },                credits: {                    enabled: false                },                title: {                    text: 'Historical USD to EUR Exchange Rate'                },                subtitle: {                    text: 'Select an area by dragging across the lower chart'                },                xAxis: {                    type: 'datetime'                },                yAxis: {                    title: {                        text: null                    },                    maxZoom: 0.1                },                tooltip: {                    formatter: function () {                        var point = this.points[0];                        return '<b>' + point.series.name + '</b><br/>' + Highcharts.dateFormat('%A %B %e %Y', this.x) + ':<br/>' +                            '1 USD = ' + Highcharts.numberFormat(point.y, 2) + ' EUR';                    },                    shared: true                },                legend: {                    enabled: false                },                plotOptions: {                    series: {                        marker: {                            enabled: false,                            states: {                                hover: {                                    enabled: true,                                    radius: 3                                }                            }                        }                    }                },                series: [{                    name: 'USD to EUR',                    pointStart: detailStart,                    pointInterval: 24 * 3600 * 1000,                    data: detailData                }],                exporting: {                    enabled: false                }            }); // return chart        }        // create the master chart        function createMaster() {            Highcharts.chart('master-container', {                chart: {                    reflow: false,                    borderWidth: 0,                    backgroundColor: null,                    marginLeft: 50,                    marginRight: 20,                    zoomType: 'x',                    events: {                        // listen to the selection event on the master chart to update the                        // extremes of the detail chart                        selection: function (event) {                            var extremesObject = event.xAxis[0],                                min = extremesObject.min,                                max = extremesObject.max,                                detailData = [],                                xAxis = this.xAxis[0];                            // reverse engineer the last part of the data                            $.each(this.series[0].data, function () {                                if (this.x > min && this.x < max) {                                    detailData.push([this.x, this.y]);                                }                            });                            // move the plot bands to reflect the new detail span                            xAxis.removePlotBand('mask-before');                            xAxis.addPlotBand({                                id: 'mask-before',                                from: data[0][0],                                to: min,                                color: 'rgba(0, 0, 0, 0.2)'                            });                            xAxis.removePlotBand('mask-after');                            xAxis.addPlotBand({                                id: 'mask-after',                                from: max,                                to: data[data.length - 1][0],                                color: 'rgba(0, 0, 0, 0.2)'                            });                            detailChart.series[0].setData(detailData);                            return false;                        }                    }                },                title: {                    text: null                },                xAxis: {                    type: 'datetime',                    showLastTickLabel: true,                    maxZoom: 14 * 24 * 3600000, // fourteen days                    plotBands: [{                        id: 'mask-before',                        from: data[0][0],                        to: data[data.length - 1][0],                        color: 'rgba(0, 0, 0, 0.2)'                    }],                    title: {                        text: null                    }                },                yAxis: {                    gridLineWidth: 0,                    labels: {                        enabled: false                    },                    title: {                        text: null                    },                    min: 0.6,                    showFirstLabel: false                },                tooltip: {                    formatter: function () {                        return false;                    }                },                legend: {                    enabled: false                },                credits: {                    enabled: false                },                plotOptions: {                    series: {                        fillColor: {                            linearGradient: [0, 0, 0, 70],                            stops: [                                [0, Highcharts.getOptions().colors[0]],                                [1, 'rgba(255,255,255,0)']                            ]                        },                        lineWidth: 1,                        marker: {                            enabled: false                        },                        shadow: false,                        states: {                            hover: {                                lineWidth: 1                            }                        },                        enableMouseTracking: false                    }                },                series: [{                    type: 'area',                    name: 'USD to EUR',                    pointInterval: 24 * 3600 * 1000,                    pointStart: data[0][0],                    data: data                }],                exporting: {                    enabled: false                }            }, function (masterChart) {                createDetail(masterChart);            }); // return chart instance        }        // make the container smaller and add a second container for the master chart        var $container = $('#container')            .css('position', 'relative');        $('<div id="detail-container">')            .appendTo($container);        $('<div id="master-container">')            .css({                position: 'absolute',                top: 300,                height: 100,                width: '100%'            })                .appendTo($container);        // create master and in its callback, create the detail chart        createMaster();    });		</script>	</body></html>
 |