我有一个谷歌图表,其中包含以下hAxis选项。但是我无法让视图窗口工作
此剃刀代码:
hAxis: {
format: 'HH:mm',
showTextEvery: 2,
gridlines: {
count: -1,
units: {hours: {format:['HH:mm']}}
},
viewWindow: {
min: new Date(@Model.SelectedDate.Year, @Model.SelectedDate.Month-1, @Model.SelectedDate.Day, 0),
max: new Date(@Model.SelectedDate.Year, @Model.SelectedDate.Month-1, @Model.SelectedDate.Day, 23, 59)
}
},
生成以下 html
hAxis:{
format: 'HH:mm',
showTextEvery: 2,
viewWindow: {
min: new Date(2017, 7-1, 6, 0),
max: new Date(2017, 7-1, 6, 23, 59)
},
gridlines: {
count: -1,
units: {hours: {format:['HH:mm']}}
},
},
此代码给出一个错误:getTime 不是一个函数
如何更改剃须刀代码,以便它将在图表的 javascript 部分中获取我的日期。
当我删除视图窗口部分的线条时,我的图表正在工作。所以我不认为我的数据是问题所在。
还有我的一些数据
data.addColumn('datetime', 'Tijdstip');
data.addColumn('number', 'gemeten temperatuur');
data.addRows([
[new Date(2017, 2-1, 22, 0, 0, 34), -16.56200000],
[new Date(2017, 2-1, 22, 0, 1, 38), -16.44000000],
[new Date(2017, 2-1, 22, 0, 2, 39), -16.27600000],
[new Date(2017, 2-1, 22, 0, 3, 44), -15.78500000],
[new Date(2017, 2-1, 22, 0, 4, 47), -15.74400000],
[new Date(2017, 2-1, 22, 0, 5, 52), -15.41700000],
[new Date(2017, 2-1, 22, 0, 6, 52), -15.17100000],
[new Date(2017, 2-1, 22, 0, 7, 57), -14.88500000],
[new Date(2017, 2-1, 22, 0, 8, 58), -14.35300000],
蒂亚·罗纳德
用于viewWindow
的值是有效的,不要相信这是问题所在
请参阅以下使用已发布选项的工作片段...
google.charts.load('current', {
callback: drawChart,
packages: ['corechart']
});
function drawChart() {
var data = google.visualization.arrayToDataTable([
['x', 'y0'],
[new Date(2017, 6, 6, 1), 1000],
[new Date(2017, 6, 6, 2), 2000],
[new Date(2017, 6, 6, 3), 3000],
[new Date(2017, 6, 6, 4), 4000],
[new Date(2017, 6, 6, 5), 5000],
[new Date(2017, 6, 6, 6), 6000]
]);
var options = {
hAxis:{
format: 'HH:mm',
showTextEvery: 2,
viewWindow: {
min: new Date(2017, 7-1, 6, 0),
max: new Date(2017, 7-1, 6, 23, 59)
},
gridlines: {
count: -1,
units: {hours: {format:['HH:mm']}}
},
},
};
var chart = new google.visualization.LineChart(document.getElementById('chart_div'));
chart.draw(data, options);
}
<script src="https://www.gstatic.com/charts/loader.js"></script>
<div id="chart_div"></div>