I am using timeline JS in my application for displaying 2 types of reports based on the date. It is working fine but when the number of reports data are more it is difficult to find which report is belongs to which category. So I thought to use different text colour in timemarker to differentiate 2 types.
Type 1. #9467bd
Type 2. #8c651c
But I am unable to set text-color dynamically. I have referred the timeline JS documentation and found there is an option to change timemarker - color by using this class name .tl-timemarker. But I am not getting any idea to set 2 different colors.Timeline JS Doc
Please refer my code here:
HTML Code:
<div id="my-timeline"></div>
<button id='myBtn'>start</button>
JS Code:
$('#myBtn').click(function() {
var data = {
"timeline":
{
"headline":"Test Company",
"type":"default",
"text":"Test Reports",
"startDate":"2010",
"date": [
{
"startDate" : "2010,9,1",
"text":"Type 1",
"headline":"Test Header",
"asset":
{
"media": "PDF link",
"credit": "View Doc",
"caption":"Caption text goes here"
}
},
{
"startDate":"2011,10,12",
"text":"Type 2",
"headline":"Test Header",
"asset":
{
"media": "PDF link",
"credit": "View Doc",
"caption": ""
}
},
{
"startDate":"2011,10,12",
"text":"Type 2",
"headline":"Test Header",
"asset":
{
"media": "PDF link",
"credit": "View Doc",
"caption": ""
}
},
{
"startDate":"2011,10,12",
"text":"Type 2",
"headline":"Test Header",
"asset":
{
"media": "PDF link",
"credit": "View Doc",
"caption": ""
}
},
{
"startDate":"2011,10,12",
"text":"Type 1",
"headline":"Test Header",
"asset":
{
"media": "PDF link",
"credit": "View Doc",
"caption": ""
}
},
{
"startDate":"2011,10,12",
"text":"Type 2",
"headline":"Test Header",
"asset":
{
"media": "PDF link",
"credit": "View Doc",
"caption": ""
}
}
]
}
};
loadData(JSON.stringify(data));
});
function loadData(json){
addCode('jsFile='+json);
createStoryJS({
type: 'timeline',
width: '800',
height: '600',
source: jsFile,
embed_id: 'my-timeline'
});
}
//addCode(code) will create a script element and add code to it
function addCode(code){
var JS= document.createElement('script');
JS.text= code;
document.body.appendChild(JS);
}