stock chart after it has been cleared - Javascript highcharts

Javascript examples for highcharts:Stock Chart

Description

stock chart after it has been cleared

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">
    $(window).load(function(){//from   w w  w .j  av a 2 s  .c o  m
function createChart(data)
{
    chartoptions = {
            chart: {
                renderTo: 'container',
                alignTicks: false
            },
            rangeSelector: {
                selected: 1
            },
            title: {
                text: 'AAPL Stock Volume'
            },
            series: [{
                type: 'column',
                name: 'AAPL Stock Volume',
                data: 5,
                dataGrouping: {
                    units: [[
                        'week', // unit name
                        [1] // allowed multiples
                    ], [
                        'month',
                        [1, 2, 3, 4, 6]
                    ]]
                }
            }]
        }
chartoptions['series'][0]['data'] = data;
        // create the chart
        chart = new Highcharts.StockChart(chartoptions);
}
$.getJSON('https://www.highcharts.com/samples/data/jsonp.php?filename=aapl-v.json&callback=?', createChart);
$("#clear").click(function() { $("#container").empty(); });
$("#set").click(function() { $.getJSON('https://www.highcharts.com/samples/data/jsonp.php?filename=aapl-v.json&callback=?', createChart); });
    });

      </script> 
   </head> 
   <body> 
      <script type="text/javascript" src="https://code.highcharts.com/stock/highstock.js"></script> 
      <script type="text/javascript" src="https://code.highcharts.com/stock/modules/exporting.js"></script> 
      <div id="container" style="height: 438px; width: 770px;"></div> 
      <button id="clear">Clear</button> 
      <button id="set">Fill</button>  
   </body>
</html>

Related Tutorials