繁体   English   中英

将日期字段传递到Google图表时间轴

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM