[英]Passing Date field to google chart timeline
我想使用Ruby on Rails在我的應用程序中填充Google圖表時間表,而我的問題是如何將日期傳遞給addrows([new Date()]]。任何提示都將不勝感激。
下面是示例代碼
var dataTable = new google.visualization.DataTable();
dataTable.addColumn({ type: 'string', id: 'Position' });
dataTable.addColumn({ type: 'string', id: 'Name' });
dataTable.addColumn({ type: 'date', id: 'Start' });
dataTable.addColumn({ type: 'date', id: 'End' });
dataTable.addRows([
[ 'book id','book title', new Date(2013, 1, 1), new Date(2013, 10,1)],]]);
chart.draw(dataTable);
}
</script>
<div id="example3.1" style="width: 1000px; height: 200px;"></div>
你可以這樣
dataTable.addRows([
[ 'book id','book title', <%= Time.now %>, <%= Time.now %>,]]);
根據您的要求,更多提示在這里-> Ruby時間格式
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.