Today button -> show 2 days back

Hello All,
in the timeline is shown a red line the day Today. How can I, when I click on Today, show two days back?
Current → click Today button
left 08.11.2022 (current today red line), 09.11.2022, 10.11.2022 etc.
New: → click Today button
left 06.11.2022, 07.11.2022, 08.11.2022 (current today red line), 09.11.2022, 10.11.2022 etc.

Does anyone have an idea about this?

THANKS

Hello @thomas-9991 ,

This issue could have occurred if your timeline has the x_start different then 0, like follows:

scheduler.createTimelineView({
  name:	"timeline",
  x_unit:	"day",
  x_date:	"%d",
  x_step:	1,
  x_size: 12,
  x_start: 2,

Here is a demo:
https://snippet.dhtmlx.com/gelr7zpl

If it’s not you case, could you please provide more details on your config, or reproduce the issue in the demo above:
open the demo => reproduce the issue => click the “Save” button => send me the new link.

Kind regards,

Hello Siarhei,
thanks for your message. I used your code and it works only partially correct.

x_start: -2, is -2 days for me, because additionally two days before today must be displayed. If I click on the “Next” button one day further is displayed.
If I click on the “Back” button, it jumps three days back. But it should only jump back one day.

scheduler.createTimelineView({
  name:	"timeline",
  x_unit:	"day",
  x_date:	"%d",
  x_step:	1,
  x_size: 12,
  x_start: -2,
  x_length: 1,
  y_unit:	sections,
  y_property:	"section_id",
  render:"bar",
});

I have also tried this on the demo and it is the same behavior.
https://snippet.dhtmlx.com/gelr7zpl

How can I change it so that forward and back always moves one day and the today button has two days offset.

THANKS & best regards

Another problem - when I create “x_start: -2”:
I click on “Today” today’s date is displayed two days from the left - all correct.
If I click on “Next” the days do not move into the future. I cannot reach a date e.g. in the next year with this setting. Why not?

scheduler.createTimelineView({
  name:	"timeline",
  x_unit:	"day",
  x_date:	"%d",
  x_step:	1,
  x_size: 12,
  x_start: -2,
  x_length: 1,
  y_unit:	sections,
  y_property:	"section_id",
  render:"bar",
});

https://snippet.dhtmlx.com/gelr7zpl

If I enter “x_start: 0” it works correctly. Clicking the “next” button moves the calendar one day. And when I click on “back”, the calendar moves back by one day.
Is this a bug?

thank you

Hi Thomas,
I can suggest the following solution. Please try when you click on the “Today” button to change the display date of the view (using the onBeforeTodayDisplayed handler), this can be done using the setCurrentView method:

scheduler.attachEvent("onBeforeTodayDisplayed", function (){
    const mode = scheduler.getState().mode;
    
    if (mode == "timeline") {
        scheduler.setCurrentView(scheduler.date.add(new Date(), -2, 'day'), "timeline");

        return false;
    }

    return true;
});

For example, I used the following configuration:

scheduler.plugins({
    limit: true,
    timeline: true
});

scheduler.config.mark_now = true;
...
scheduler.createTimelineView({
    section_autoheight: false,
    name: "timeline",
    x_unit: "day",
    x_date: "%d",
    x_step: 1,
    x_size: 12,
    x_start: 0,
    x_length: 1,
    y_unit: sections,
    y_property:	"section_id",
    folder_dy: 30,
    dy: 60,
    render: "bar",
});

Here is example: DHTMLX Snippet Tool