Timeline view minimum time_step


#1

hello, is possible in the timeline view to set as minimum time_step the current month instead of minutes?

Thanks


#2

Hello @scaondhtmlx ,

If you meant changing the x_unit of the timeline view, yes you can set it to month, as follows:

scheduler.createTimelineView({
    name: "timeline",
    x_unit: "month",

Here is full list of possible values:
https://docs.dhtmlx.com/scheduler/api__scheduler_createtimelineview.html#:~:text=x_unit%20-%20(minute%2C%20hour%2C%20day%2C%20week%2C%20month%2C%20year)%20the%20measuring%20unit%20of%20the%20X-Axis.%20By%20default%2C%20'minute'

Demo:
http://snippet.dhtmlx.com/5/d0a14f1c7

If you mean, that time_step when you drag/resize event should be equal to month, you can do it by changing the time_step config, like follows:

scheduler.config.time_step = 60*24*30;

Here is a demo:
http://snippet.dhtmlx.com/5/1caef5777

If you meant something different, could you please clarify the question?

Kind regards,


#3

it’s not exaclty what I’m looking.
I’m looking for a way to have an events covering exactly the month is in. so if I create an event in March start_date = 1 March and end_date = 31 March

it’s possible with round_position true but if I move or copy an event created on march to february it doesn’t auto resize the event to the February’s lenght

not sure if is possible to achieve that result


#4

Hello @scaondhtmlx ,

Thank you for the clarification. There is no built-in option for that, but it can be implemented with a custom solution. The logic could be to manually set event’s start/end dates on drag end : onBeforeEventChanged event(or any other required action, like event creation), here is a full list of scheduler events:
https://docs.dhtmlx.com/scheduler/api__refs__scheduler_events.html

The code for the drag rounding may look like follows:

function endOfMonth(date){
	return new Date(date.getFullYear(), date.getMonth() + 1, 1);
}

scheduler.attachEvent("onBeforeEventChanged", function(ev, e, is_new, original){
  ev.start_date = scheduler.date.month_start(new Date(ev.start_date))
  ev.end_date =   endOfMonth(ev.start_date);
  return true;
});

Here is a demo(drag event to the next month, so it ways will be resized to start/end of month):
http://snippet.dhtmlx.com/5/aa5b6fd30

Kind regards,