google.charts.load('current', {
packages: ['corechart']
}).then(function () {
var data = google.visualization.arrayToDataTable([
['x', 'y'],
[0, 0],
[1, 1],
[2, 2],
[3, 3],
[4, 4]
]);
var options = {
pointSize: 4
};
var explorer = {
axis: 'horizontal',
maxZoomIn: 0.25,
maxZoomOut: 4
};
$('#explorer-option').on('click', function () {
if ($('#explorer-label').html() === 'Enable') {
options.explorer = explorer;
drawChart();
$('#explorer-label').html('Disable');
$('#explorer-icon').removeClass('ui-icon-circle-check');
$('#explorer-icon').addClass('ui-icon-circle-close');
} else {
options.explorer = null;
drawChart();
$('#explorer-label').html('Enable');
$('#explorer-icon').removeClass('ui-icon-circle-close');
$('#explorer-icon').addClass('ui-icon-circle-check');
}
});
var container = document.getElementById('chart_div');
drawChart();
function drawChart() {
var chart = new google.visualization.LineChart(container);
chart.draw(data, options);
}
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://www.gstatic.com/charts/loader.js"></script>
<link rel="stylesheet" href="https://code.jquery.com/ui/1.12.0/themes/base/jquery-ui.css"/>
<button class="ui-button ui-widget ui-corner-all" id="explorer-option">
<span id="explorer-icon" class="ui-icon ui-icon-circle-check"></span> <span id="explorer-label">Enable</span>
</button>
<div id="chart_div"></div>