frappe / gantt

Open Source Javascript Gantt
https://frappe.io/gantt
MIT License
4.69k stars 1.04k forks source link

[Feature Request] Add an API/option to add more custom time scales #431

Open KebabRonin opened 1 month ago

KebabRonin commented 1 month ago

Currently, all things depending on the time scale are big if/else trees, for each available time scale. This can make it tedious to add or modify view modes.

It would be nice to have a configuration object to get these settings from, so people can more easily add other time scales without the need to alter/search through the code.

The new option could look something like this:

var gantt = new Gantt(div, tasks, {
   // ...
   view_modes: [
      {
         name: 'Hour',
         step: 3600, // in unix seconds
         snap_interval: 300, // snap task dates to 5 minute intervals
         upper_text: {
            x: 10, // offset from the 'base position'
            period: 3600 * 24, // repeat the upper text for each day
            text: 'DD', // using date_utils or in some date format
            column_width: 38 // using date_utils or in some date format
         },
         lower_text: {/* similar to upper_text */}
      },
      // ... more view modes
   ]
   }
}
moradlarbi commented 6 days ago

Can you assigne this issue to me please? i want to work on it