Full calendar business hours - fullcalendar

I am trying to use business hour option, but I can't able to reflect the changes.
I want to display multiple business hours. Here is the code:
$('#calendar').fullCalendar({
header: {
left: 'prev,next today',
center: 'title',
right: 'month,agendaWeek,agendaDay'
},
defaultDate: '2014-11-12',
editable: true,
eventLimit: true, // allow "more" link when too many events
businessHours:
[
{
start: '10:00', // a start time (10am in this example)
end: '12:00', // an end time (12pm in this example)
dow: [1, 2, 3, 4]
// days of week. an array of zero-based day of week integers (0=Sunday)
// (Monday-Thursday in this example)
},
{
start: '12:00', // a start time (12pm in this example)
end: '18:00', // an end time (6pm in this example)
dow: [1, 2, 3, 4]
// days of week. an array of zero-based day of week integers (0=Sunday)
// (Monday-Thursday in this example)
}]
});

like so
businessHours:
{
start: '11:00',
end: '12:00',
dow: [ 1, 2, 3, 4, 5]
},
in order to use different hours for different shifts -> use background events
events:
[
{
id: 'available_hours',
start: '2015-1-13T8:00:00',
end: '2015-1-13T19:00:00',
rendering: 'background'
},
{
id: 'work',
start: '2015-1-13T10:00:00',
end: '2015-1-13T16:00:00',
constraint: 'available_hours'
}
]
For more information, see this link,
http://fullcalendar.io/docs/event_ui/eventConstraint/
There's several different ways you can approach this, depending on how you use the calendar. Hopefully the flexibility of the constraints will help you get what you need done.
Pretty glad this feature finally showed up!

I have to show FullCaledar Time Slot for 8AM to 8PM fixed, so I have did some R&D, and apply following options, and it seems working fine!!! Cheers.
jq('#calendar').fullCalendar({
header: {
left: 'prev,next',
center: 'title',
right: 'today,month,agendaWeek,resourceDay'
},
defaultView: 'resourceDay',
allDaySlot: false,
axisFormat: 'h:mm A',
timeFormat: 'h:mm T',
minTime: '08:00:00',
maxTime: '20:00:00',
Use,
minTime: '08:00:00',
maxTime: '20:00:00'
Thanks!!!

on the other hand, you can define working hours and days.
businessHours: [{
daysOfWeek: [1, 2, 3, 6, 7],
startTime: '08:00',
endTime: '23:00'
},
{
daysOfWeek: [4],
startTime: '08:00',
endTime: '16:00'
},
{
daysOfWeek: [5],
startTime: '15:00',
endTime: '23:00'
}
]
hope it helps.

In version 4 :
businessHours: {
// days of week. an array of zero-based day of week integers (0=Sunday)
daysOfWeek: [ 1, 2, 3, 4 ], // Monday - Thursday
startTime: '10:00', // a start time (10am in this example)
endTime: '18:00', // an end time (6pm in this example)
}
You may also break your business hour declaration into parts, in an array of objects, for additional control:
businessHours: [ // specify an array instead
{
daysOfWeek: [ 1, 2, 3 ], // Monday, Tuesday, Wednesday
startTime: '08:00', // 8am
endTime: '18:00' // 6pm
},
{
daysOfWeek: [ 4, 5 ], // Thursday, Friday
startTime: '10:00', // 10am
endTime: '16:00' // 4pm
}
]
In version 3 :
businessHours: {
// days of week. an array of zero-based day of week integers (0=Sunday)
dow: [ 1, 2, 3, 4 ], // Monday - Thursday
start: '10:00', // a start time (10am in this example)
end: '18:00', // an end time (6pm in this example)
}
You may also break your business hour declaration into parts for additional control (added in v2.9.1):
businessHours: [ // specify an array instead
{
dow: [ 1, 2, 3 ], // Monday, Tuesday, Wednesday
start: '08:00', // 8am
end: '18:00' // 6pm
},
{
dow: [ 4, 5 ], // Thursday, Friday
start: '10:00', // 10am
end: '16:00' // 4pm
}
]

Related

FullCalendar Scheduler - nowIndicator only works with initialView as Day

Like the title says, I'm using the the FullCalendar Scheduler but I can't seem to make the nowIndicator to work with the initialView as resourceTimelineMonth or resourceTimelineWeek. The indicator stays at the 00:00 of the day.
It only works fine if the initialView is set to resourceTimelineDay.
My code:
<FullCalendar
v-if="employeeList && absenceList"
:options="calendarOptions"
/>
(...)
data() {
return {
employeeList: null,
absenceList: null,
calendarOptions: {
plugins: [ resourceTimelinePlugin ],
headerToolbar: {
left: 'today prev,next',
center: 'title',
right: 'resourceTimelineDay,resourceTimelineWeek,resourceTimelineMonth'
},
locales: allLocales,
locale: this.$i18n.locale,
initialView: 'resourceTimelineMonth',
resourceGroupField: 'department',
resourceAreaHeaderContent: 'Colaboradores ',
resourceOrder: 'department,title',
nowIndicator: true,
businessHours: [
{
daysOfWeek: [ 1, 2, 3, 4, 5 ],
startTime: null,
endTime: null,
}
],
height: 600,
resources: this.getEmployeesArray,
events: this.getApprovedAbsencesArray,
}
}
},

cannot add businessHours - weekends - fullcalendar v4

Here is my fullcalendar config:
defaultView="resourceTimeGridDay"
and the resources
resources={[
{
id: 'a',
title: 'Resource A',
businessHours: {
startTime: '10:00',
endTime: '18:00'
}
},
{
id: 'b',
title: 'Resource B',
businessHours: {
startTime: '11:00',
endTime: '17:00'
}
}
]}
By default weekends are marked as non-business - grey background.
How can I add businessHours for Saturday and Sunday
daysOfWeek:[0,1,2,3,4,5,6]
in the business hours fix the issue.
businessHours: [
{
daysOfWeek: [0,1,2,3,4,5,6], // enable all days
startTime: '08:00',
endTime: '18:00'
},

fullcalendar selectHelper is hidden on resize to restricted zone

the default behavor of selecthelper when resizing to a restricted zone(selectConstraint) is to hide the selectHelper, i want this to be exactly as event resize to a restricted zone(eventConstraint), where the event is visible and the size is the last allowed size.
this is the demo
http://jsfiddle.net/pu83thf9/3/
1)try to select from 10am to 2pm the selectHelper is hidden out of selectConstraint
2)try to create an event from 8-to 10 , try to resize it to 12 and don't release the mouse for 2 seconds, try now to resize it to 2pm, it's visible and not hidden like case 1
$(document).ready(function() {
$('#calendar').fullCalendar({
header: {
left: 'prev,next today',
center: 'title',
right: 'month,agendaWeek,agendaDay'
},
locale:"en",
minTime: "06:00:00",
maxTime: "20:00:00",
allDaySlot: false,
businessHours: true,
businessHours: [{
dow: [1, 2, 3, 4, 5], // Monday - Friday
start: '08:00',
end: '12:00',
}, {
dow: [1, 2, 3, 4, 5], // Monday - Friday (if adding lunch hours)
start: '13:00',
end: '17:00',
}],
selectConstraint: "businessHours",
eventConstraint: "businessHours",
defaultView: 'agendaWeek',
defaultDate: '2018-03-12',
navLinks: true, // can click day/week names to navigate views
selectable: true,
selectHelper: true,
select: function(start, end) {
var title = 'Zone';
var eventData;
if (title) {
eventData = {
title: title,
start: start,
end: end
};
$('#calendar').fullCalendar('renderEvent', eventData, true); // stick? = true
}
$('#calendar').fullCalendar('unselect');
},
editable: true,
eventOverlap :false,
selectOverlap :false,
eventLimit: true, // allow "more" link when too many events
eventRender: function (event, element, view) {
element.find(".closeon").on('click', function () {
$('#calendar').fullCalendar('removeEvents', event._id);
});}
});
});

How to disable a range of dates depends on the work hours?

I want to close a range of hours cells so that the user can't book on that specific hour, i've created a modal windows that allows the admin to set his own working hours every day all the week.
Update:
I've found a solution, i have to add this little magic to my fullcalendar
businessHours where it can take any list of hours, but the problem is how to disable the event click on the non-business hour ?
here is my new code:
$('#calendar').fullCalendar({
header: {
left: 'prev,next today',
center: 'title',
right: 'month,agendaWeek,agendaDay,listMonth',
},
defaultView: 'agendaWeek',
businessHours:
[
{
dow: [0], // Sunday
start: '08:00',
end: '13:00'
},
{
dow: [1], // Monday
start: '09:00',
end: '12:00'
}, {
dow: [2], // Tuseday
start: '13:00',
end: '15:00'
}, {
dow: [3], // Wedensday
start: '15:00',
end: '17:00'
}, {
dow: [4], // Thursday
start: '12:00',
end: '19:00'
}, {
dow: [5], // Friday
start: '10:00',
end: '15:00'
}, {
dow: [6], // Saturday
start: '11:00',
end: '20:00'
}
],
select: function(mydate, start, end, event, jsEvent, allDay, businessHours, view, element) {
var DaysOK = [1,2,3,4,5,6,7];
var mydateObj = new Date(mydate);
var chosenDay = mydateObj.getUTCDay();
if( // Clicked event hour in business hours ){
alert('You can book!);
} else {
alert('You can\'nt book');
}
}
And why console.log(businessHours) inside console gives undefined ??
Please any help or suggestions would be tons appreciated .

HighCharts scatter plot with Datetime on X Axis not plotting values correctly

I am creating a highchart scatter plot with epoch DateTime values on X-Axis and a float value on Y-Axis. The problem is when I use label formatter to convert the epoch time value to a readable time value ("DD-MMM-YYYY"), multiple labels with the same caption are created on X-Axis, and the points do not align vertically with the tick marks on the X-axis.
I have created a JSFiddle for it (Link). What can I do to resolve this problem...
$(function () {
$('#container').highcharts({
chart: {
type: 'scatter',
zoomType: 'xy'
},
title: {
text: 'Errors'
},
subtitle: {
text: 'Source: Temp Data'
},
xAxis: {
allowDecimals: false,
title: {
text: 'days',
scalable: false
},
type: 'datetime',
labels: {
formatter: function () {
return Highcharts.dateFormat('%d-%b-%y', moment.unix(this.value));
}
},
tickPixelInterval: 100
},
yAxis: {
title: {
text: 'Weight (kg)'
}
},
legend: {
layout: 'vertical',
align: 'left',
verticalAlign: 'top',
x: 100,
y: 70,
floating: true,
backgroundColor: (Highcharts.theme && Highcharts.theme.legendBackgroundColor) || '#FFFFFF',
borderWidth: 1
},
plotOptions: {
scatter: {
marker: {
radius: 5,
states: {
hover: {
enabled: true,
lineColor: 'rgb(100,100,100)'
}
}
},
states: {
hover: {
marker: {
enabled: false
}
}
},
tooltip: {
headerFormat: '<b>{series.name}</b><br>',
pointFormat: '{point.x} cm, {point.y} kg'
}
}
},
series: [{"name":"Positive Influencer","data":[[1448994600,41.40329],[1448994600,20.19966],[1449081000,32.26196],[1449167400,45.44334],[1449167400,43.79153],[1449167400,41.07479],[1449167400,24.75943],[1449167400,59.41171],[1449167400,62.26523],[1449167400,43.51655],[1449167400,41.14505],[1449253800,49.21474],[1449253800,41.14505],[1449253800,41.14505],[1449253800,59.45902],[1449340200,29.63791],[1449340200,31.5257],[1449426600,12.77947],[1449426600,16.81416],[1449426600,17.47938]],"color":"#A9D18E"},{"name":"Negative Influencer","data":[[1448908200,21.79101],[1448908200,21.79101],[1448908200,21.79101],[1448908200,17.06943],[1448908200,33.64876],[1448908200,11.28691],[1448908200,18.40087],[1448908200,16.87335],[1448908200,50.01515],[1448908200,20.16196],[1448908200,20.16196],[1448908200,20.16196],[1448908200,20.16196],[1448908200,20.16196],[1448908200,35.88634],[1448908200,20.16196],[1448908200,34.89129],[1448908200,12.91103],[1448908200,12.91103],[1448908200,12.91103],[1448908200,20.16196],[1448908200,24.0311],[1448994600,26.38517],[1448994600,11.80575],[1448994600,10],[1448994600,20.07552],[1448994600,32.33444],[1448994600,32.33444],[1448994600,20.16196],[1448994600,24.24678],[1448994600,26.86968],[1448994600,26.86968],[1449081000,16.27982],[1449081000,13.02332],[1449081000,25.71094],[1449081000,20.14183],[1449081000,11.01994],[1449081000,27.91542],[1449081000,27.91542],[1449081000,15.11342],[1449167400,29.38302],[1449167400,42.58746],[1449167400,13.3506],[1449167400,57.63139],[1449167400,46.52709],[1449167400,46.52709],[1449167400,27.91542],[1449167400,22.57789],[1449167400,20.14183],[1449167400,30.69887],[1449167400,18.12275],[1449167400,30.19594],[1449167400,30.19594],[1449253800,46.52709],[1449253800,13.3506],[1449253800,30.69887],[1449253800,12.30569],[1449253800,12.30569],[1449253800,11.81466],[1449253800,13.9246],[1449253800,11.80575],[1449253800,11.80575],[1449253800,18.12275],[1449253800,18.12275],[1449253800,27.91542],[1449253800,16.27982],[1449253800,16.27982],[1449253800,16.27982],[1449253800,16.27982],[1449253800,47.37541],[1449253800,16.27982],[1449253800,64.55871],[1449253800,42.33084],[1449253800,16.27982],[1449253800,22.57789],[1449253800,22.57789],[1449253800,16.27982],[1449253800,16.27982],[1449253800,50.01515],[1449253800,22.57789],[1449253800,12.91103],[1449253800,18.12275],[1449253800,81.70462],[1449253800,21.86977],[1449253800,22.57789],[1449253800,42.14268],[1449253800,21.1656],[1449253800,44.74439],[1449253800,30.48095],[1449253800,17.63912],[1449253800,42.34763],[1449253800,23.14725],[1449253800,28.20117],[1449340200,22.57789],[1449340200,24.12882],[1449340200,20.14183],[1449340200,22.57789],[1449340200,18.81954],[1449426600,24.12882],[1449426600,15.08914],[1449426600,21.53001],[1449426600,15.08914],[1449426600,15.08914],[1449426600,14.8175],[1449426600,15.08914],[1449426600,23.64472],[1449426600,49.31941],[1449426600,49.31941],[1449426600,49.31941],[1449426600,49.31941],[1449426600,49.31941],[1449426600,30.59185],[1449426600,30.59185],[1449426600,30.59185],[1449426600,23.64472],[1449426600,18.12275],[1449426600,18.12275],[1449426600,19.01658],[1449426600,10],[1449426600,10],[
1449426600,10]],"color":"#FF5252"}]
});
});
TL:DR
Make your x axis tick marks fall at midnight with tickInterval: (24 * 3600 * 1000)
Detailed answer
You said that you saw "multiple labels with same caption are created on X Axis". However when I view your fiddle in a recent version of Google Chrome, the x axis looks clean, though the tickmarks don't align perfectly with the days:
I suggest you try different browsers to see if your issue is caused by a particular browser version.
You said in your comment that if you maximize the chart in a larger window, some of the date labels are repeated.
I suggest you make a simpler plot to try to nail down your issue(s).
Update
If you change your formatter function to include the time as well as the date:
Highcharts.dateFormat('%d-%b-%y %H:%M', moment.unix(this.value))
each tickmark will have a different label, even if they fall on the same day:
Alternatively, customize the layout of the tick marks so that they always fall on midnight.
Update 2
I made a simplified demo to show tick marks and data both aligned with midnight. The important features are:
tickInterval: (24 * 3600 * 1000) // the number of milliseconds in a day.
and:
[Date.UTC(2015, 11, 01), 75], // pure JavaScript to return a unix time (in milliseconds since unix epoch) of midnight on the 1st of December
$(function() {
$('#container').highcharts({
chart: {
type: 'scatter',
zoomType: 'xy'
},
title: {
text: 'Datetime scatter plot demo'
},
subtitle: {
text: 'for Stack Overflow'
},
xAxis: {
tickInterval: (24 * 3600 * 1000), // the number of milliseconds in a day
allowDecimals: false,
title: {
text: 'Date',
scalable: false
},
type: 'datetime',
labels: {
formatter: function() {
return Highcharts.dateFormat('%d-%b-%y', (this.value));
}
}
},
yAxis: {
title: {
text: 'Value'
}
},
series: [{
"name": "Demo values",
"data": [
[Date.UTC(2015, 11, 01), 75],
[Date.UTC(2015, 11, 02), 70],
[Date.UTC(2015, 11, 02), 80],
[Date.UTC(2015, 11, 02), 45],
[Date.UTC(2015, 11, 03), 65],
[Date.UTC(2015, 11, 03), 40],
[Date.UTC(2015, 11, 05), 75]
]
}],
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/modules/exporting.js"></script>
<div id="container" style="min-width: 310px; height: 400px; max-width: 800px; margin: 0 auto"></div>

Resources