2

I would like to set min and max. date range, i used ViewWindowMode on hAxis but it doesn't work. How can I limit X date range between 2.2.2020 and 25.2.2020.

<html>
<head>
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
<script type="text/javascript">
google.charts.load("current", {packages:["timeline"], language: 'sl-SI'});
google.charts.setOnLoadCallback(drawChart);
function drawChart() {
var container = document.getElementById('example5.1');
var chart = new google.visualization.Timeline(container);
var dataTable = new google.visualization.DataTable();
dataTable.addColumn({ type: 'string', id: 'Stroj' });
dataTable.addColumn({ type: 'string', id: 'Nalog' });
dataTable.addColumn({ type: 'date', id: 'Start' });
dataTable.addColumn({ type: 'date', id: 'End' });
dataTable.addRows([
['Stroj1','10 - Material1', new Date(2020, 1, 7, 3, 0), new Date(2020, 8, 24, 7, 0)],
['Stroj2','18 - Material2', new Date(2020, 2, 11, 14, 0), new Date(2020, 2, 14, 9, 0)],
['Stroj3','17 - Material3', new Date(2020, 2, 13, 15, 0), new Date(2020, 2, 26, 3, 0)],

]);


var options = {

hAxis: {
ViewWindowMode: 'explicit',
            viewWindow: {
    min: new Date(2020, 02, 02, 23, 00),
               max: new Date(2020, 02, 25, 00, 00)
               
            },
format: 'dd. MM. yyyy | HH:mm'
}
}

chart.draw(dataTable, options);
  alert('Min ViewWindow: ' + chart.getOption('hAxis.viewWindow.min') + ', Max: ' + chart.getOption('hAxis.viewWindow.max'));
}
</script>

</head>
<body>
<div id="example5.1" style="height: 500px;"></div>
</body>
</html>

Thanks for help in advance!

WhiteHat
  • 59,912
  • 7
  • 51
  • 133
  • 1
    according to [release 43](https://developers.google.com/chart/interactive/docs/release_notes#october-2,-2015), you can use options --> `hAxis.minValue` & `hAxis.maxValue` -- but these only appear to work when the min & max values are outside the range of the data, not within the range of the data. – WhiteHat Feb 20 '20 at 14:03

0 Answers0