3,479
个编辑
第15行: | 第15行: | ||
} | } | ||
appendTimeline(); | appendTimeline(); | ||
$(document).ready(function() { | |||
// 确保仅在有时间轴的页面中执行 | |||
if ($("#visualization").length) { | |||
const container = document.getElementById("visualization"); | |||
// 解析项目和日期 | |||
const itemsArray = $(container).data("items").split(";"); | |||
const items = new vis.DataSet(itemsArray.map((item, index) => { | |||
const [content, start] = item.split(","); | |||
return { id: index + 1, content: content.trim(), start: start.trim() }; | |||
})); | |||
// Configuration for the Timeline | |||
const options = {}; | |||
// Create a Timeline | |||
const timeline = new vis.Timeline(container, items, options); | |||
} | |||
}); |