google.charts.load('current', {
callback: drawChart,
packages: ['corechart']
});
var maxValue = 7;
function drawChart() {
var data = new google.visualization.DataTable();
data.addColumn('date', 'Date');
data.addColumn('number', 'Count');
data.addRows([
[new Date(2017, 1, 1), 0],
[new Date(2017, 1, 2), 0],
[new Date(2017, 1, 3), 7],
[new Date(2017, 1, 4), 0],
[new Date(2017, 1, 5), 0],
]);
var options = {
title: 'Test',
legend: 'none',
width: 450,
height: 500
};
options["vAxis"] = (maxValue < 5) ? { viewWindow: { min: 0 }, ticks: [0, 1, 2, 3, 4] } :
(maxValue < 9) ? { viewWindow: { min: 0 }, ticks: [0, 2, 4, 6, 8] } :
(maxValue < 13) ? { viewWindow: { min: 0 }, ticks: [0, 3, 6, 9, 12] } : { viewWindow: { min: 0 } };
var linearChart = new google.visualization.LineChart(document.getElementById('div'));
linearChart.draw(data, options);
}
<script src="https://www.gstatic.com/charts/loader.js"></script>
<div id="div"></div>