As for how to customize Fullcalendar Scheduler's duration - fullcalendar

thanks in advance.
I'm struggling with custimizing fullcalendar scheduler stuff.
I just want to display weektimetable like below.
(FYI, below's CSS is just edited by me, of course it's not the answer I want.)
As you see, in the case of the original fullcalendar scheduler's weekshot, you can't have the same y-point by one event, and I want to customize this.
please your advice, thanks
enter image description here
enter image description here

Without seeing the exact event data you're using to create this scenario, it's hard to be sure exactly what the issue is. But here's my suggestion:
I think you are wanting to get two events side by side, but as long as their times overlap, you never can. Even if the times don't overlap, if the end of event 1 and the start of event 2 fall somewhere in the middle of a slot, they will still appear to overlap.
Let's illustrate the point using the snippet below:
There are two calendars in the demo (scroll down to see the second one). Both calendars have identical resources and events.
The first resource contains events which overlap onto the same day.
So they will never be shown side-by-side.
The second resource contains events which don't overlap. One ends
just before midday, and the second starts at midday on the same day.
On the first calendar they are still shown as overlapping, because the calendar only shows things in 1-day intervals. Within that whole day context, the events still overlap. There is only 1 slot for that day into which they can be placed.
However on the second calendar, the events in the second resource will be shown side-by-side, because the slot duration (12 hours) is now short enough to allow
the events to be placed into separate slots based on their start/end times.
$(function() { // document ready
$('#calendar1').fullCalendar({
schedulerLicenseKey: 'GPL-My-Project-Is-Open-Source',
defaultView: 'timeline',
header: {
left: 'prev,next today',
center: 'title',
right: 'timeline'
},
slotDuration: {
days: 1
},
resources: [{
"id": 1,
"title": "Screenshot 1"
},
{
"id": 2,
"title": "Screenshot 2"
},
],
events: [{
id: '1',
resourceId: "1",
start: '2017-06-01',
end: '2017-06-04',
title: 'event 1'
},
{
id: '2',
resourceId: "1",
start: '2017-06-03',
end: '2017-06-06',
title: 'event 2'
},
{
id: '3',
resourceId: "2",
start: '2017-06-01',
end: '2017-06-03T12:00',
title: 'event 3'
},
{
id: '4',
resourceId: "2",
start: '2017-06-03T12:00',
end: '2017-06-06',
title: 'event 4'
}
]
});
$('#calendar2').fullCalendar({
schedulerLicenseKey: 'GPL-My-Project-Is-Open-Source',
defaultView: 'timeline',
header: {
left: 'prev,next today',
center: 'title',
right: 'timeline'
},
slotDuration: {
hours: 12
},
resources: [{
"id": 1,
"title": "Screenshot 1"
},
{
"id": 2,
"title": "Screenshot 2"
},
],
events: [{
id: '1',
resourceId: "1",
start: '2017-06-01',
end: '2017-06-04',
title: 'event 1'
},
{
id: '2',
resourceId: "1",
start: '2017-06-03',
end: '2017-06-06',
title: 'event 2'
},
{
id: '3',
resourceId: "2",
start: '2017-06-01',
end: '2017-06-03T12:00',
title: 'event 3'
},
{
id: '4',
resourceId: "2",
start: '2017-06-03T12:00',
end: '2017-06-06',
title: 'event 4'
}
]
});
});
<link href="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.css" rel="stylesheet" />
<link href="https://cdnjs.cloudflare.com/ajax/libs/fullcalendar/3.4.0/fullcalendar.min.css" rel="stylesheet" media="all" />
<link href='https://fullcalendar.io/js/fullcalendar-scheduler-1.6.2/scheduler.min.css' rel='stylesheet' />
<script type='text/javascript' src='https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.11.0/moment.min.js'></script>
<script type='text/javascript' src='https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js'></script>
<script src="https://code.jquery.com/ui/1.12.0/jquery-ui.min.js" integrity="sha256-eGE6blurk5sHj+rmkfsGYeKyZx3M4bG+ZlFyA7Kns7E=" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/fullcalendar/3.4.0/fullcalendar.min.js"></script>
<script src='https://fullcalendar.io/js/fullcalendar-scheduler-1.6.2/scheduler.min.js'></script>
<div id='calendar1'></div>
<br/><br/>
<div id='calendar2'></div>
So, in conclusion, to get the effect you want, you must ensure that
Your events do not overlap either by date or time, and
The configured slot duration is sufficiently small to allow the
calendar to place the events side-by-side in separate slots.

Related

Fullcalendar: Show additional event data in list view

I'm using fullcalendar to display a month view which shows the time and title of events (and a popover showing the description when hovered). When I click the event, I show a listday view that shows all the events for that day. That all works fine and I have this working with this code:
var calendar = new FullCalendar.Calendar(calendarEl, {
headerToolbar: {
start: 'dayGridMonth,listDay',
center: 'title',
end: 'prev,next'
},
initialView: 'dayGridMonth',
initialDate: '2023-01-12',
height: 'auto',
dayMaxEvents: 3,
moreLinkClick: 'listDay',
eventClick: function(info){
switchToListView(info)
},
eventColor: 'green',
views: {
listDay: {
displayEventEnd: true
}
},
events: [
{
title: 'All Day Event',
start: '2023-01-01'
},
{
title: 'Meeting',
description: 'My Description',
start: '2023-01-12T10:30:00',
end: '2023-01-12T12:30:00'
},
and in this code pen
I'd like to show the description text for the event in addition to the title in the listday view and I can't figure out how to do this. I don't know whether I need to use an event hook or what. I just can't make my way through the docs and examples to see what to do.
Appreciate any help.
I got this working with this use of eventDidMount.
eventDidMount: function(info) {
info.el.querySelector('.fc-list-event-title a').innerHTML += ` ${info.event.extendedProps.description}`
},
Frankly, it feels a little weird that I need to go into the depths of the rendered HTML to adjust the output instead of changing what is going INTO the generated HTML but I guess that's just how it works (??)
Thanks to #ADyson for the push in the right direction.

Error displaying an event between two months

I'm having problems with the nextDayThreshold option. Even when I´m setting it to "08:00:00", FullCalendar is duplicating events that finish at "07:00:00" on the 1st of a month, displaying it with a left arrow in timelineMonth, showing the same event in two months:
$(function() { // document ready
$('#calendar').fullCalendar({
schedulerLicenseKey: 'CC-Attribution-NonCommercial-NoDerivatives',
nextDayThreshold: '08:00:00',
header: {
left: 'today prev,next',
center: 'title',
right: 'timelineMonth'
},
defaultView: 'timelineMonth',
resourceColumns: [
{
labelText: 'first column',
field: 'title',
width: 150
}
],
resources: [{
id: 'a',
title: 'Auditorium A',
}, {
id: 'b',
title: 'Auditorium B',
eventColor: 'green'
}, {
id: 'c',
title: 'Auditorium C',
eventColor: 'orange'
}],
events: [{
id: '1',
resourceId: 'b',
start: '2018-10-31T21:00:00',
end: '2018-11-01T07:00:00',
title: 'event 1'
}]
});
});
Fiddle
Is this a bug?
Short answer: No, it's not a bug.
Long answer:
The documentation for nextDayThreshold says:
Only affects timed events that appear on whole-days. Whole-day cells
occur in month view, basicDay, basicWeek and the all-day slots in the
agenda views.
In a "timeline" view, even though the slotDuration is set to 1 day by default in a "timelineMonth" view, fullCalendar still regards these as timed slots, rather than whole-day cells. Therefore the nextDayThreshold rules do not apply. e.g. If you changed to a timelineWeek view, it still uses exactly the same layout and slots, except the slots have a different length. They're not a different kind of cell.
If we look at an updated version of your fiddle: https://jsfiddle.net/q2fk57nb/6/ which now includes a regular "month" view (I simply added right: 'timelineMonth,month' to the header) we can see that the same event in that view is confined to the 31st October, because of the nextDayThreshold rule, and the fact that the regular "month" view uses "whole-day" cells.

can't display as same as demo code with fullcalendar

I tried to apply fullcalendar to my page.
When I pasted the example code to my page, there's no header buttons and no same event styles, these events can't be drag and drop.
Using: jquery 3.3.0, moment 2.20.1, fullcalendar 3.8.0.
Do I lost some settings? Please help and figure out, thank you all.
$(function() {
$('#calendar').fullCalendar({
header: {
left: 'prev,next today',
center: 'title',
right: 'month,basicWeek,basicDay'
},
defaultDate: '2018-01-12',
navLinks: true, // can click day/week names to navigate views
editable: true,
eventLimit: true, // allow "more" link when too many events
events: [
{
title: 'All Day Event',
start: '2018-01-01'
},
{
id: 999,
title: 'Repeating Event',
start: '2018-01-09T16:00:00'
},
{
id: 999,
title: 'Repeating Event',
start: '2018-01-16T16:00:00'
},
{
title: 'Conference',
start: '2018-01-11',
end: '2018-01-13'
},
{
title: 'Meeting',
start: '2018-01-12T10:30:00',
end: '2018-01-12T12:30:00'
},
{
title: 'Lunch',
start: '2018-01-12T12:00:00'
},
{
title: 'Meeting',
start: '2018-01-12T14:30:00'
},
{
title: 'Dinner',
start: '2018-01-12T20:00:00'
},
{
title: 'Click for Google',
url: 'http://google.com/',
start: '2018-01-28'
}
]
});
});
<link href="https://cdnjs.cloudflare.com/ajax/libs/fullcalendar/3.8.0/fullcalendar.min.css" rel="stylesheet"/>
<link href="https://cdnjs.cloudflare.com/ajax/libs/fullcalendar/3.8.0/fullcalendar.print.min.css" rel="stylesheet"/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.0/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.20.1/moment.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/fullcalendar/3.8.0/fullcalendar.min.js"></script>
<div id="calendar">
</div>
I don't know precisely which example code you tried to copy, but unfortunately you didn't copy it exactly right.
This is your problem:
<link href="https://cdnjs.cloudflare.com/ajax/libs/fullcalendar/3.8.0/fullcalendar.print.min.css" rel="stylesheet" />
This overrides the default CSS (from fullcalendar.min.css) with the version intended for use when printing the page. Changes here include hiding the headers and buttons and reducing the use of colours.
What you need to do is tell the browser to only use this stylesheet when in print mode. This is done using a media query media="print", as follows:
<link href="https://cdnjs.cloudflare.com/ajax/libs/fullcalendar/3.8.0/fullcalendar.print.min.css" rel="stylesheet" media="print"/>

Background Events via JSON

How do I indicate an event as being a background event within a JSON feed (which I'm creating through AJAX). It is being rendered as a regular event, not a Background event.
JSON Feed:
[{"id":"availableForMeeting","start":"2015-02-04T09:00:00","end":"2015-02-04T20:00:00","rendering":"background","overlap":true},{"title":"Working","start":"2015-02-04T10:00:00","end":"2015-02-04T12:00:00","allDay":false,"overlap":true},{"title":"Lunch","start":"2015-02-04T12:00:00","end":"2015-02-04T14:00:00","allDay":false},{"title":"Working","start":"2015-02-04T14:00:00","end":"2015-02-04T19:00:00","allDay":false}]
You can do this in FullCalendar 2.2+ using Background Events by adding rendering: 'background' to the event (documentation). In the example below, it'd be the same for the JSON feed.
Since you stated you are indeed using rendering: 'background', I would check that
1) You are using the correct version of FullCalendar
2) There are no errors on the page
3) If neither 1 or 2, post a code snippet that shows your problem, since the one below works fine:
Also note that per the docs:
Background events that are timed will only be rendered on the time
slots in agenda view. Background events that are all-day will only be
rendered in month view or the all-day slots of agenda view.
$('#fullCal').fullCalendar({
events: [{
title: 'Main Event',
start: moment().add(3, 'h'),
end: moment().add(5, 'h'),
color:'#ff0000',
allDay: false
}, {
start: moment().add(1, 'h'),
end: moment().add(10, 'h'),
rendering: 'background'
}, {
title: 'Other Event',
start: moment().add(6, 'h'),
end: moment().add(8, 'h'),
color:'#00cc00',
allDay: false
}],
header: {
left: '',
center: 'prev title next',
right: ''
},
timezone:'local',
defaultView: 'agendaWeek'
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/moment.js/2.8.3/moment.min.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/fullcalendar/2.2.0/fullcalendar.min.css" rel="stylesheet" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/fullcalendar/2.2.0/fullcalendar.min.js"></script>
<div id="fullCal"></div>

(fullcalendar) Passing calendar background color in event object with start/stop time

I am using fullcalendar and I am looking for a way to pass background color as an event
so that my calendar app can use a combination of colored events and colored backgrounds.
I'm pretty sure this is not supported by the library, so if anyone has any notes towards coding the feature or experience working with the code, that would be helpful.
The following question is very similar to mine, but not written clearly enough to know if it's a dupe:
Fullcalendar event cell background color
Update 1
Based on the accepted answer, I use the following event specs
{
title: '',
start: moment().add(2,'h').toISOString(),
end: moment().add(5,'h').toISOString(),
color: 'rgba(63, 191, 191, 0.24)',
textColor: 'rgba(63, 191, 191, 0)',
editable: false,
durationEditable: false,
allDay: false,
fakeEvent: true
},
{
title: 'WORK DAY',
start: moment().add(1,'h').toISOString(),
end: moment().add(3,'h').toISOString(),
color: 'green',
//background-color = 'blue'
},
And get this result. Next step is trying to prevent the event overlapping display algorithm, so that the light blue appears more like a background color, less like an event.
Update 2
I have since discovered this example app that accomplishes what I needed: http://fullcalendar.io/js/fullcalendar-2.2.0/demos/background-events.html
That question you referenced isn't the same. He was looking to change the background color of any day that has an event, not the event itself. What you are trying to do is supported by the library. You can set the color of the event by passing in a color property with the event data.
All examples can be found on the FullCalendar Event Source Object page. As noted on that example page, you can set it in the array of events:
{
events: [
{
title: 'Event1',
start: '2011-04-04'
},
{
title: 'Event2',
start: '2011-05-05'
}
// etc...
],
eventColor: 'yellow', // an option!
textColor: 'black' // an option!
}
or in JSON:
{
url: '/myfeed.php',
color: 'yellow', // an option!
textColor: 'black' // an option!
}
Now, those are setting the background for every event in the source, but you can do it per event as well, the same way, like:
[
{
"title": "Free Pizza",
"allday": "false",
"borderColor": "#5173DA",
"color": "#99ABEA",
"textColor": "#000000",
"description": "Fake description for the Free Pizza",
"start": "2014-11-15T16:30:28",
"end": "2014-11-15T17:30:28",
"url": "some url"
},
{
"title": "CSS Meetup",
"allday": "false",
"borderColor": "#820F20",
"color": "#A6113C",
"textColor": "#ffffff",
"description": "Fake description",
"start": "2014-11-19T16:30:28",
"end": "2014-11-19T18:30:28",
"url": "someUrl
}
]
You can use eventColor and eventTextColor (src) to set the background for all events on the calendar, like
$('#fullCal').fullCalendar({
events: [...],
eventColor: 'yellow',
eventTextColor: 'black'
});
After further clarification it appears you want certain time slots to have colors but not be a "real" event. You can do this in FullCalendar 2.2 using the Background Events by adding rendering: 'background' to the event (documentation).
$('#fullCal').fullCalendar({
events: [{
title: 'Main Event 1',
start: moment().add(-4, 'h'),
end: moment().add(-2, 'h'),
color: '#ff0000',
allDay: false
}, {
start: moment().add(2, 'h'),
end: moment().add(5, 'h'),
rendering: 'background'
}, {
title: 'Main Event 2',
start: moment().add(5, 'h'),
end: moment().add(7, 'h'),
color: '#00cc00',
allDay: false,
fakeEvent: false
}],
header: {
left: '',
center: 'prev title next',
right: ''
},
timezone: 'local',
defaultView: 'agendaWeek'
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/moment.js/2.8.3/moment.min.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/fullcalendar/2.2.0/fullcalendar.min.css" rel="stylesheet" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/fullcalendar/2.2.0/fullcalendar.min.js"></script>
<div id="fullCal"></div>

Resources