【发布时间】:2017-07-11 14:30:08
【问题描述】:
我有一个谷歌图表,我只想在图表上向用户显示 7 天的数据,他们应该能够看到前 7 天的数据。
例如,如果我有 2017 年 1 月 7 日至 2017 年 7 月 15 日的数据
grpah 最初应仅显示 2017 年 8 月 7 日至 2017 年 7 月 15 日。但如果用户愿意,他们可以返回之前的 2017 年 1 月 7 日到 2017 年 8 月 7 日的结果。
现在我正在显示所有 14 天的数据,这似乎不太好
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<title>
Google Visualization API Sample
</title>
</script> <script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
<script type="text/javascript">
// Load google charts
google.charts.load('current', {'packages':['corechart','line']});
google.charts.setOnLoadCallback(seven_day_compare);
// Draw the chart and set the chart values
function seven_day_compare() {
var data = google.visualization.arrayToDataTable(
[["Date","likes","share"],["2017-07-01",30,20],["2017-07-02",20,20],["2017-07-03",16,10],["2017-07-4",10,15],["2017-07-5",31,66],["2017-07-6",20,15],["2017-07-7",2,5],["2017-07-8",8,6],["2017-07-09",30,20],["2017-07-10",20,20],["2017-07-11",16,10],["2017-07-12",10,15],["2017-07-13",31,66],["2017-07-14",20,15],["2017-07-15",2,5],["2017-07-16",8,6]]
);
// Optional; add a title and set the width and height of the chart
var options = {'title':'Compare like and share', 'width':550, 'height':400,'pointSize': 10,'hAxis':{
'slantedText': true,
'slantedTextAngle':30},'vAxis':{}};
// Display the chart inside the <div> element with id="differnt"
var chart = new google.visualization.LineChart(document.getElementById('chart'));
chart.draw(data, options);
}
</script>
</head>
<body style="font-family: Arial;border: 0 none;">
<div id = "chart"></div>
</body>
</html>
所以基本上我想把图表分成 7 天的时间段 谷歌图表是否可能。或任何其他建议
【问题讨论】:
标签: javascript google-visualization