andregesser
Posts: 2
Joined: Mon Jun 17, 2024 1:56 pm

Automatic scroll to the current date line

Hey guys,

I would like to know if it is possible to make the gantt chart scroll, horizontally, automatically go to the current date indicator line (plotLine). Maintaining the possibility of scrolling both to the beginning of the oldest item and to the end.

I attached an image, indicating how the chart should look, always keeping the indicator in the middle of the chart:
Attachments
Highcharts_Gantt.jpg
Highcharts_Gantt.jpg (60.22 KiB) Viewed 530 times
bastss
Site Moderator
Posts: 1301
Joined: Wed Oct 17, 2018 10:59 am

Re: Automatic scroll to the current date line

Hello,

Thank you for contacting us!

I prepared a demo where the first part of the requirement is done: https://jsfiddle.net/BlackLabel/co879p1k/ - logic in the load event sets the extremes in the middle of the data with the month range (can be change ofc).

API: https://api.highcharts.com/gantt/xAxis. ... etExtremes
API: https://api.highcharts.com/gantt/chart.events.load
API: https://api.highcharts.com/gantt/scrollbar

I am not sure if I understood well the thing with the plot line: https://api.highcharts.com/gantt/xAxis.plotLines, should be in the middle only at the beginning or should be static there even if the zoom or series range will be changed by the scrollbar?

Kind regards!
Sebastian Wędzel,
Highcharts Developer
andregesser
Posts: 2
Joined: Mon Jun 17, 2024 1:56 pm

Re: Automatic scroll to the current date line

Thank you very much Sebastian for your explanations!

We're almost there!

My question is about keeping the current date indicator on the graph (the red line on the y-axis) always visible to the user, while maintaining the possibility of scrolling the graph, on the x-axis, to the start date of the oldest item and to the date of the last item that will remain on the graph.
Attachments
Highcharts_Gantt.jpg
Highcharts_Gantt.jpg (72.3 KiB) Viewed 493 times
bastss
Site Moderator
Posts: 1301
Joined: Wed Oct 17, 2018 10:59 am

Re: Automatic scroll to the current date line

Sebastian Wędzel,
Highcharts Developer

Return to “Highcharts Gantt”