【发布时间】:2015-04-07 20:59:34
【问题描述】:
我正在尝试创建一份今天工作的人员列表,以及他们的开始和结束时间。这对有记录的人来说没问题,但我不知道如何让谷歌的时间轴图表打印某人的名字,然后在图表上没有条目。
这是文档,但它没有说明空白条目:
https://google-developers.appspot.com/chart/interactive/docs/gallery/timeline#BarsOneRow
这是我的代码示例:
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript">
google.load("visualization", "1", {packages:["timeline"]});
google.setOnLoadCallback(drawChart);
function drawChart() {
var container = document.getElementById('timeline');
var chart = new google.visualization.Timeline(container);
var dataTable = new google.visualization.DataTable();
dataTable.addColumn({ type: 'string', id: 'Employee' });
dataTable.addColumn({ type: 'date', id: 'Start' });
dataTable.addColumn({ type: 'date', id: 'End' });
dataTable.addRows([
[ 'Spiderman', new Date(2015, 04, 07, 04, 43, 49), new Date(2015, 04, 07, 06, 45, 05), ],
[ 'Iron Man', new Date(2015, 04, 07, 04, 40, 53), new Date(2015, 04, 07, 08, 45, 47), ],
[ 'Spiderman', new Date(2015, 04, 07, 09, 10, 19), new Date(2015, 04, 07, 13, 22, 02), ],
]);
var options = {
timeline: {
singleColor: '#00f',
colorByRowLabel: true,
groupByRowLabel: true,
},
backgroundColor: '#ffffff'
};
chart.draw(dataTable, options);
}
</script>
我需要做什么才能为超人添加一行,即使他那天没有工作?
【问题讨论】:
标签: javascript charts google-api