Javascript examples for highcharts:Chart Axis
Toggle X axis and y axis
<html> <head> <title>Highcharts Demo</title> <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> <style id="compiled-css" type="text/css"> #container {/*from w w w .j a va2 s . c o m*/ min-width: 300px; max-width: 800px; height: 300px; margin: 1em auto; } </style> <script type="text/javascript"> $(function () { // Configure the chart $('#container').highcharts({ chart: { type: 'column' }, title: { text: 'Highcharts axis visibility' }, xAxis: { categories: ['Apples', 'Pears', 'Oranges', 'Peaches'] }, yAxis: { allowDecimals: false, title: { text: 'Fruit' }, visible: false }, plotOptions: { series: { stacking: 'normal', dataLabels: { enabled: true } } }, series: [{ data: [1, 3, 2, 4], name: 'Ola' }, { data: [5, 4, 5, 2], name: 'Kari' }] }); var yVis = false, xVis = true; $('#toggle-y').click(function () { yVis = !yVis; $('#container').highcharts().yAxis[0].update({ visible: yVis }); }); $('#toggle-x').click(function () { xVis = !xVis; $('#container').highcharts().xAxis[0].update({ visible: xVis }); }); }); </script> </head> <body> <script src="https://code.highcharts.com/4.1.9/highcharts.js"></script> <div id="container"></div> <button id="toggle-y">Toggle Y axis</button> <button id="toggle-x">Toggle X axis</button> </body> </html>