dynamically change axis from linear to logarithmic in line Chart - Javascript highcharts

Javascript examples for highcharts:Line Chart

Description

dynamically change axis from linear to logarithmic in line Chart

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/highcharts.js"></script> 
      <script type="text/javascript">
    $(window).load(function(){// w  w w.ja  v  a 2 s.c  om
$(function () {
        $('#container').highcharts({
            chart: {
            },
            title: {
                text: 'Logarithmic axis demo'
            },
            xAxis: {
                tickInterval: 1
            },
            yAxis: {
                type: 'logarithmic',
                //minorTickInterval: 0.1
            },
            tooltip: {
                headerFormat: '<b>{series.name}</b><br />',
                pointFormat: 'x = {point.x}, y = {point.y}'
            },
            series: [{
                data: [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],
                pointStart: 1
            }]
        });
    $("#b").click(function(){
        $('#container').highcharts().yAxis[0].update({ type: 'linear'});
    });
    });
    });

      </script> 
   </head> 
   <body> 
      <button id="b">change!</button> 
      <div id="container" style="min-width: 400px; height: 400px; margin: 0 auto"></div>  
   </body>
</html>

Related Tutorials