@@ -86,22 +86,6 @@ const DAYS_PER_UNIT = {
8686}
8787
8888const GANTT_VIEW_MODES = [
89- {
90- name: ' Hour' ,
91- padding: ' 7d' ,
92- step: ' 1h' ,
93- snap_at: ' 1h' ,
94- date_format: ' YYYY-MM-DD HH:' ,
95- lower_text: ' HH' ,
96- upper_text : (d , ld , lang ) =>
97- ! ld || d .getDate () !== ld .getDate ()
98- ? Intl .DateTimeFormat (lang || ' en' , { month: ' short' , day: ' numeric' }).format (d)
99- : ' ' ,
100- thick_line (date ) {
101- return date .getDay () === 1
102- },
103- upper_text_frequency: 24 ,
104- },
10589 {
10690 name: ' Day' ,
10791 padding: ' 14d' ,
@@ -123,6 +107,22 @@ const GANTT_VIEW_MODES = [
123107 return date .getDay () === 1
124108 },
125109 },
110+ {
111+ name: ' Hour' ,
112+ padding: ' 7d' ,
113+ step: ' 1h' ,
114+ snap_at: ' 1h' ,
115+ date_format: ' YYYY-MM-DD HH:' ,
116+ lower_text: ' HH' ,
117+ upper_text : (d , ld , lang ) =>
118+ ! ld || d .getDate () !== ld .getDate ()
119+ ? Intl .DateTimeFormat (lang || ' en' , { month: ' short' , day: ' numeric' }).format (d)
120+ : ' ' ,
121+ thick_line (date ) {
122+ return date .getDay () === 1
123+ },
124+ upper_text_frequency: 24 ,
125+ },
126126 {
127127 name: ' Week' ,
128128 padding: ' 1m' ,
@@ -207,6 +207,31 @@ export default {
207207 if (! card .duedate && ! card .startdate ) {
208208 undatedCards .push (card)
209209 } else {
210+ // gantt renders everything at once so large date ranges cause performance issues on render
211+ // therefore we limit the timeframe of visible tasks
212+ const duedate = new Date (card .duedate )
213+ switch (this .currentViewMode ) {
214+ case ' Hour' :
215+ if (duedate < new Date () - 2 * 24 * 3600 * 1000 ) {
216+ return
217+ }
218+ break
219+ case ' Day' :
220+ if (duedate < new Date () - 30 * 24 * 3600 * 1000 ) {
221+ return
222+ }
223+ break
224+ case ' Week' :
225+ if (duedate < new Date () - 90 * 24 * 3600 * 1000 ) {
226+ return
227+ }
228+ break
229+ case ' Month' :
230+ if (duedate < new Date () - 365 * 24 * 3600 * 1000 ) {
231+ return
232+ }
233+ break
234+ }
210235 ganttTasks .push (this .cardToGanttTask (card, index))
211236 }
212237 })
@@ -343,7 +368,6 @@ export default {
343368 })
344369
345370 this ._patchBarDuration ()
346- this .ganttInstance .change_view_mode (this .currentViewMode )
347371 this .fitColumnsToWidth ()
348372 },
349373 async updateTaskDate (task , start , end ) {
0 commit comments