So in this calendar, I want to change the color of event depending to their activities, so for example the long event should have a color green.
so this is the sample data i’m trying to get.
this is what I received from my backend.
{
'title': 'All Day Event very long title',
'allDay': true,
'start': new Date(2023, 1, 1),
'end': new Date(2023, 1, 6),
'event': 'regular'
},
{
'title': 'Long Event',
'start': new Date(2023, 1, 1),
'end': new Date(2023, 1, 1),
'event':'holiday',
},
Front.js
<Calendar
views={["day", "agenda", "work_week", "month"]}
selectable
localizer={localizer}
defaultDate={new Date()}
defaultView="month"
events={eventsData}
style={{ height: "95%" }}
onSelectEvent={(event) => alert(event.title)}
onSelectSlot={handleSelect}
/>
2
Answers
I think you can provide color and bgcolor attributes along with other properties on event object,
If this package doesn’t support’s it, Use Full calendar, You surely can do that on full calendar,
Try supplying on this structure.
It is possible by handling
eventPropGetter
function provided by lib and returing your style that needs to be applied.And then you only decide which event is shorter/longer by structuring like this,