我一直在使用here的TimelineJS和数据检索的JSON版本。它工作得很好,但我不能调整时间线的开始日期。
在文档中,它说要这样设置JSON文件:
{
"timeline":
{
"headline":"The Main Timeline Headline Goes here",
"type":"default",
"startDate":"1888",
"text":"<p>Intro body text goes here, some HTML is ok</p>",我已经复制了这一点,但只是更改了细节,例如:
{
"timeline":
{
"headline":"HOT LATIN EVENTS",
"type":"default",
"startDate":"2012,09,30",
"text":"Scroll through a list of Latin Music events>>> ",
"date": [
{
"startDate":"2012,08,24",
"headline":"PELIGRO Y SU BANDA - Melbourne",
"text":"<p><strong>Copacaban International</strong>, 139 Smith Street, Fitzroy, 3065</p>",
"asset":
{
"media":"http://www.clavecontraclave.com/Peligro%20-%20Melbourne%20klein.jpg",
"credit":"",
"caption":""
}
},我也试着在startDate中使用了一年(例如: 2011),但没有效果。时间线从下面的第一个事件开始。
有人知道这是怎么回事吗?
谢谢
发布于 2013-11-09 01:46:39
我还没有找到直接为时间轴指定开始日期的方法,但您可以迭代时间轴幻灯片以找到最接近的匹配项,然后使用该幻灯片的索引作为start_at_slide值。例如:
var timeline_dates = data_source.timeline.date;
var start_index = 0;
var target_date = new Date(); //set whatever date you want as your start date
for(x in timeline_dates) {
var slide_date = new Date( timeline_dates[x].startDate );
if( slide_date < target_date) start_index++;
}然后,当你实例化你的时间线时,你可以这样使用它:
createStoryJS({
type: 'timeline',
width: '800',
height: '400',
source: data_source,
embed_id: 'timeline_container',
start_at_slide: start_index
});https://stackoverflow.com/questions/12632085
复制相似问题