AlexMav
December 15, 2021, 10:04am
#1
Hi there. I have a timeline view with these settings:
scheduler.createTimelineView({
name: "timeline",
x_unit: "hour",
x_date: "%H:%i",
x_step: 8,
x_size: 21,
x_length:21,
event_dy:60,
resize_events:false,
y_unit: sections,
y_property: "client",
render: "bar",
second_scale:{
x_unit: "day",
x_date: "%F %d"
}
});
scheduler.date.timeline_start = scheduler.date.week_start;
So in my second scale (x-axis) i can see something like “December, 15”. But i want to make it showing “December, 15 (Wednesday)” or “December, 15 (Wed)” or something like this. What parameter or setting i have to add?
Siarhei
December 15, 2021, 1:25pm
#2
Hi @AlexMav ,
You can change the format of the second scale with the _second_scale_date
template:
https://docs.dhtmlx.com/scheduler/api__scheduler_{timelinename}_second_scale_date_template.html
In your case the code may look like follows:
var dateToStr = scheduler.date.date_to_str("%F, %d (%D)");
scheduler.templates.timeline_second_scale_date = function(date){
return dateToStr (date);;
};
Here is a demo:
http://snippet.dhtmlx.com/5/b8583cb2d
You can find a full list of timeline templates at the following link:
https://docs.dhtmlx.com/scheduler/timeline_view_templates.html
Kind regards,
AlexMav
December 20, 2021, 10:14am
#4
One more little question - is there a way to add “BR” or “\n” in x_date format? For example, i have:
second_scale:{
x_unit: "day",
x_date: "%F %d (%D)"
}
And it is working, but i want to have something like :
x_date: "%F %d \n (%D)"
to show day of week (Monday, Tuesday, etc) on a new line. I tried \n, it does not work, BR tag - also no luck. What can i do here?
AlexMav
December 20, 2021, 10:19am
#5
Oh, <br>
is working. I have to change some css (height of header) and it shows me everything. Ok