HighStock Print Setting To Hide Range Selector - Javascript highcharts

Javascript examples for highcharts:Stock Chart

Description

HighStock Print Setting To Hide Range Selector

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://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script> 
      <script type="text/javascript" src="https://code.highcharts.com/stock/highstock.src.js"></script> 
      <script type="text/javascript" src="https://code.highcharts.com/stock/modules/exporting.src.js"></script> 
      <script type="text/javascript">
$(function () {/*  w w w .  j  a  v  a2  s  .c  om*/
    Highcharts.wrap(Highcharts.Chart.prototype, 'print', function (proceed) {
        var applyMethod = function (whatToDo, margin) {
            this.extraTopMargin = margin;
            this.resetMargins();
            this.setSize(this.container.clientWidth, this.container.clientHeight, false);
            this.rangeSelector.inputGroup[whatToDo]();
            this.rangeSelector.zoomText[whatToDo]();
            $.each(this.rangeSelector.buttons, function (index, button) {
                button[whatToDo]();
            });
        };
        if (this.rangeSelector) {
            var extraMargin = this.extraTopMargin;
            applyMethod.apply(this, ['hide', null]);
            var returnValue = proceed.call(this);
            applyMethod.apply(this, ['show', extraMargin]);
            return returnValue;
        } else {
            return proceed.call(this);
        }
    });
    $.getJSON('https://www.highcharts.com/samples/data/jsonp.php?filename=aapl-c.json&callback=?', function (data) {
        // Create the chart
        window.chart = new Highcharts.StockChart({
            chart: {
                renderTo: 'container'
            },
            exporting: {
                chartOptions: {
                    rangeSelector: {
                        enabled: false
                    }
                }
            },
            title: {
                text: 'AAPL Stock Price'
            },
            series: [{
                name: 'AAPL',
                data: data,
                tooltip: {
                    valueDecimals: 2
                }
            }]
        });
    });
});

      </script> 
   </head> 
   <body> 
      <div id="container" style="height: 500px; min-width: 500px"></div>  
   </body>
</html>

Related Tutorials