Monday, 2 May 2022

Svelte Gantt Chart - Separate via months

I'm trying to have a gantt chart with all 12 months in it. I'm doing this by setting the from & to values to currentDate.clone().endOf('year') & currentDate.clone().endOf('year'). But the gantt chart stopping appearing when setting these values, if I print out the dates they are valid & weirdly if I change the values to startOf('week') & endOf('week)` it renders the chart fine. Is this possible to do?

Package I'm using: https://github.com/ANovokmet/svelte-gantt

Edit: My code is based on this index.js file: https://github.com/ANovokmet/svelte-gantt/blob/gh-pages/index.js

It might be simpler to ask, how can I modify it to show months instead of hours/days?

function time(input) {
  return moment(input, "MMMM DD YYYY");
}

const currentStart = time(responseData.currentDate);
const currentEnd = time(responseData.currentDate);

gantt.$set({
   fitWidth: false,
   columnUnit: 'month',
   rowPadding: 6,
   rowHeight: 52,
   columnOffset: 28.8,
   magnetOffset: 15,
   from: currentStart.clone().startOf('year'),
   to: currentStart.clone().endOf('year'),
   minWidth: 800,
   headers: [{ unit: 'month', format: 'MMMM YYYY' }, { unit: 'day', format: 'ddd DD' }]
});


from Svelte Gantt Chart - Separate via months

No comments:

Post a Comment