如何在时间轴中设置浮动X轴?我的列表很长,滚动后我看到了时间轴。我想在屏幕底部显示时间轴。
答案 0 :(得分:1)
如果您在时间轴的容器或其选项中设置高度,则图表将使用内部滚动条绘制,使x轴在图表底部显示固定位置。
function drawChart() {
var data = google.visualization.arrayToDataTable([
['Name', 'Start', 'End'],
['Foo', new Date(2014, 0, 1), new Date(2014, 0, 2)],
['Bar', new Date(2014, 0, 3), new Date(2014, 0, 6)],
['Cad', new Date(2014, 0, 2), new Date(2014, 0, 3)],
['Qud', new Date(2014, 0, 7), new Date(2014, 0, 10)],
['Fiz', new Date(2014, 0, 4), new Date(2014, 0, 9)],
['Buz', new Date(2014, 0, 4), new Date(2014, 0, 5)],
['Baz', new Date(2014, 0, 3), new Date(2014, 0, 6)],
['Piz', new Date(2014, 0, 4), new Date(2014, 0, 6)],
['Pop', new Date(2014, 0, 2), new Date(2014, 0, 8)]
]);
var chart = new google.visualization.Timeline(document.querySelector('#chart_div'));
chart.draw(data, {
height: 300,
width: 600
});
}
google.load('visualization', '1', {packages: ['timeline'], callback: drawChart});