我想要谷歌折线图而不是年份将时间刻度(24小时)放在轴上,那么我该怎么做呢 这是Google示例折线图
<html>
<head>
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript">
google.load("visualization", "1", {packages:["corechart"]});
google.setOnLoadCallback(drawChart);
function drawChart() {
var data = google.visualization.arrayToDataTable([
['Year', 'Sales', 'Expenses'],
['2004', 1000, 400],
['2005', 1170, 460],
['2006', 660, 1120],
['2007', 1030, 540]
]);
var options = {
title: 'Company Performance'
};
var chart = new google.visualization.LineChart(document.getElementById('chart_div'));
chart.draw(data, options);
}
</script>
</head>
<body>
<div id="chart_div" style="width: 900px; height: 500px;"></div>
</body>
</html>
答案 0 :(得分:1)
您可以使用&#34; timeofday&#34; 24小时图表的数据类型。 &#34; timeofday&#34;数据类型采用4个值的数组:[hours, minutes, seconds, milliseconds]
,因此下午6:31:18将输入为[18, 31, 18, 0]
。
var data = google.visualization.arrayToDataTable([
['Time of day', 'Sales', 'Expenses'],
[[3, 30, 15, 0], 1000, 400],
[[7, 21, 56, 0], 1170, 460],
[[12, 49, 17, 0], 660, 1120],
[[19, 41, 47, 0], 1030, 540]
]);