How to make fullcalendar responsive? - php

Is there any method , we can use to enable a fully responsive mode in full-calendar ?.
I have searched the docs, but couldn't find any link as of now.
https://fullcalendar.io/docs/

This is not a complete foolproof solution, but for minor adjustments I've used the javscript/jQuery approach.
After the page is completely loaded I simply identify the fullcalendar element and add the bootstrap responsive classes (or any other which use in your project).
// add the responsive classes after page initialization
window.onload = function () {
$('.fc-toolbar.fc-header-toolbar').addClass('row col-lg-12');
};
// add the responsive classes when navigating with calendar buttons
$(document).on('click', '.fc-button', function(e) {
$('.fc-toolbar.fc-header-toolbar').addClass('row col-lg-12');
});

As of time of writing, the examples on fullcalendar.io do not appear to be responsive in any useful fashion (even the one based on bootstrap). I suspect that we will have to write our own code/css to get the responsive behaviour we need.
There is a window resize event which might be helpful, see here :
How can I get Adam Shaw's FullCalendar to display responsive in a rails 4 app
Other than that, I think we're on our own for the time being.

I've faced the same problem with full calendar. Then end up creating a bootstrap 4 responsive calendar with the help of others.
I took Joseph Trumbull's Codepen project and modified a little. I needed it only for viewing, not for dynamic events. Joseph's approach is probably most responsive and free calendar I've come across so far.
Modify as needed.
var debugMode = true;
var showUEConsoleLog = true;
var apiDebugEndPoint = 'http://localhost:54384/api/lm-classes';
var apiLiveEndPoint = 'http://cranesapi.venturiscc.com:65000/api/lm-classes';
var apiEndPoint = debugMode ? apiDebugEndPoint : apiLiveEndPoint;
$(document).ready(function() {
$('#calendar').calendar();
});
(function($) {
var Calendar = function(elem, options) {
this.elem = elem;
this.options = $.extend({}, Calendar.DEFAULTS, options);
this.init();
};
Calendar.DEFAULTS = {
datetime: undefined,
dayFormat: 'DDD',
weekFormat: 'DDD',
monthFormat: 'MM/DD/YYYY',
view: undefined
};
Calendar.prototype.init = function() {
if (!this.options.datetime || this.options.datetime === 'now') {
this.options.datetime = moment();
}
if (!this.options.view) {
this.options.view = 'month';
}
this.initScaffold().initStyle().render();
};
Calendar.prototype.initScaffold = function() {
var $elem = $(this.elem),
$view = $elem.find('.calendar-view'),
$currentDate = $elem.find('.calendar-current-date');
if (!$view.length) {
this.view = document.createElement('div');
this.elem.appendChild(this.view);
} else {
this.view = $view[0];
}
if ($currentDate.length > 0) {
var dayFormat = $currentDate.data('day-format'),
weekFormat = $currentDate.data('week-format'),
monthFormat = $currentDate.data('month-format');
this.currentDate = $currentDate[0];
if (dayFormat) {
this.options.dayFormat = dayFormat;
}
if (weekFormat) {
this.options.weekFormat = weekFormat;
}
if (monthFormat) {
this.options.monthFormat = monthFormat;
}
}
return this;
};
Calendar.prototype.initStyle = function() {
return this;
};
Calendar.prototype.render = function() {
switch (this.options.view) {
case 'day':
this.renderDayView();
break;
case 'week':
this.renderWeekView();
break;
case 'month':
this.renderMonthView();
break;
default:
this.renderMonth();
}
};
Calendar.prototype.renderDayView = function() {
//$(this.elem).append('Day View');
};
Calendar.prototype.renderWeekView = function() {
//$(this.elem).append('Week View');
};
Calendar.prototype.renderMonthView = function() {
var datetime = this.options.datetime.clone(),
month = datetime.month();
datetime.startOf('month').startOf('week');
var $view = $(this.view);
var rows = document.createElement('div');
rows.className = 'calendar-view row border border-right-0 border-bottom-0';
$view.html('');
var week = 0,
i;
var endOfMonthMarker = false;
while (week < 6) {
for (i = 0; i < 7; i++) {
var dateHolder = document.createElement('div');
var dateHolderScafold = document.createElement('h5');
dateHolderScafold.className = 'row align-items-center';
var dateHolder_Date = document.createElement('span');
dateHolder_Date.className = 'date col-1';
dateHolder_Date.appendChild(document.createTextNode(datetime.format('D')));
dateHolderScafold.appendChild(dateHolder_Date);
var dateHolder_Day = document.createElement('small');
dateHolder_Day.className = 'col text-center text-muted';
dateHolder_Day.appendChild(document.createTextNode(datetime.format('dddd')));
dateHolderScafold.appendChild(dateHolder_Day);
var dateHolder_Span = document.createElement('span');
dateHolder_Span.className = 'col-1';
dateHolderScafold.appendChild(dateHolder_Span);
dateHolder.appendChild(dateHolderScafold);
var eventHolder = document.createElement('div');
eventHolder.className = 'events-holder d-flex align-content-end flex-wrap';
dateHolder.appendChild(eventHolder);
if (month !== datetime.month()) {
dateHolder.className = 'calendar-prior-months-date day col-lg p-2 border border-left-0 border-top-0 text-truncate d-none d-lg-inline-block bg-light text-muted';
} else {
var dateClass = datetime.date() + '-' + (datetime.month() + 1) + '-' + datetime.year();
var weekEnd = i === 0 || i === 6 ? ' weekend ' : '';
dateHolder.className = 'day col-lg p-2 border border-left-0 border-top-0 text-truncate grid ' + weekEnd + dateClass + ' ' + (isToday(datetime) ? 'moment-today' : '');
}
rows.appendChild(dateHolder);
datetime.add(1, 'day');
if (month !== datetime.month() && week >= 4 && i === 6) {
endOfMonthMarker = true;
}
}
var weekEndDiv = document.createElement('div');
weekEndDiv.className = 'w-100';
rows.appendChild(weekEndDiv);
week++;
if (endOfMonthMarker) break;
}
$view[0].appendChild(rows);
if (this.currentDate) {
$(this.currentDate).html(
this.options.datetime.format(this.options.monthFormat)
);
}
var monthValue = datetime.month();
var yearValue = datetime.year();
if (datetime.month() === 0) {
monthValue = 12;
yearValue--;
}
this.fetchMonthlyEvents(monthValue, yearValue);
};
Calendar.prototype.fetchMonthlyEvents = function(month, year) {
var $this = this;
$this.renderDailyEvents(data);
};
Calendar.prototype.renderDailyEvents = function(data) {
_.each(data.EventsList, function(v, k, obj) {
var dateSelector = '.' + v.StartDate + '> .events-holder';
var dateTemplate = v.StartDate === v.EndDate ? 'Date: ' + v.StartDate : v.StartDate + ' - ' + v.EndDate;
var tooltipTemplate = '<div>' +
'<div>' + v.CourseName + '</div>' +
'<hr>' +
'<div>' + v.CityTownSuburb + ', ' + v.StateProvince + '</div>' +
'<div>Availibility: ' + v.Availibility + '</div>' +
'<div>' + dateTemplate + '</div>' +
'<div>Time: ' + v.StartTime + ' - ' + v.EndTime + '</div>' +
'</div>';
var eventTemplate = '<a class="event p-1 pl-2 pr-2 mb-1 text-truncate small bg-' + v.ColourCode + ' text-white" data-toggle="tooltip" data-placement="top" data-html="true" title="' + tooltipTemplate + '">' +
'<span class="course-name text-truncate small text-white">' + v.CourseName + '</span>' +
'</a>';
$(dateSelector).parent().addClass('show-only-list');
$(dateSelector).append(eventTemplate);
});
// Activate Tooltips
$('#calendar .event').tooltip();
};
Calendar.prototype.next = function() {
switch (this.options.view) {
case 'day':
this.options.datetime.add(1, 'day');
this.render();
break;
case 'week':
this.options.datetime.endOf('week').add(1, 'day');
this.render();
break;
case 'month':
this.options.datetime.endOf('month').add(1, 'day');
this.render();
break;
default:
break;
}
};
Calendar.prototype.prev = function() {
switch (this.options.view) {
case 'day':
break;
case 'week':
break;
case 'month':
this.options.datetime.startOf('month').subtract(1, 'day');
this.render();
break;
default:
break;
}
};
Calendar.prototype.today = function() {
this.options.datetime = moment();
this.render();
};
Calendar.prototype.grid = function() {
$('#calendar > header').children('div:last').addClass('d-lg-flex');
$('#calendar .calendar-view > div').removeClass('list').addClass('grid');
$('#calendar .day small').addClass('d-sm-none');
$('#calendar .day > p').addClass('d-sm-none');
$('#calendar .calendar-view .events-holder').addClass('d-flex');
$('#calendar .calendar-view .events-holder > a').removeClass('d-block rounded');
$('.calendar-prior-months-date').addClass('d-lg-inline-block');
};
Calendar.prototype.list = function() {
$('#calendar > header').children('div:last').removeClass('d-lg-flex');
$('#calendar .calendar-view > div').removeClass('grid').addClass('list');
$('#calendar .day small').removeClass('d-sm-none');
$('#calendar .day > p').removeClass('d-sm-none');
$('#calendar .calendar-view .events-holder').removeClass('d-flex');
$('#calendar .calendar-view .events-holder > a').addClass('d-block rounded');
$('.calendar-prior-months-date').removeClass('d-lg-inline-block');
};
var isToday = function(DateToCheck) {
return DateToCheck.date() === moment().date() && DateToCheck.month() === moment().month() && DateToCheck.year() === moment().year();
};
function Plugin(option) {
return this.each(function() {
var $this = $(this),
data = $this.data('bs.calendar'),
options = typeof option === 'object' && option;
if (!data && option !== 'weekend') {
data = new Calendar(this, options);
$this.data('bs.calendar', data);
}
switch (option) {
case 'today':
data.today();
break;
case 'prev':
data.prev();
break;
case 'next':
data.next();
break;
case 'grid':
data.grid();
break;
case 'list':
data.list();
break;
default:
break;
}
});
}
var noConflict = $.fn.calendar;
$.fn.calendar = Plugin;
$.fn.calendar.Constructor = Calendar;
$.fn.calendar.noConflict = function() {
$.fn.calendar = noConflict;
return this;
};
// Calendar Events
$('[data-toggle="calendar"]').click(function() {
var $this = $(this),
$elem = $this.parents('.calendar'),
action = $this.data('action');
if (action) {
$elem.calendar(action);
}
});
})(jQuery);
var data = {
"EventsList": [{
"EventId": "EVT-37431-C3EQQF",
"CourseId": 2,
"CourseName": "Counterbalanced/Vertical Mast Forklift Operator Training",
"StartDate": "23-10-2019",
"StartTime": "7:59",
"EndDate": "23-10-2019",
"EndTime": "4:00",
"CityTownId": 4,
"CityTownSuburb": "KITIMAT",
"StateProvinceId": 1,
"StateProvince": "BC",
"Availibility": 5,
"ColourCode": 0
}, {
"EventId": "EVT-37389-ADNY11",
"CourseId": 4,
"CourseName": "In-House Instructor Training",
"StartDate": "23-10-2019",
"StartTime": "8:30",
"EndDate": "23-10-2019",
"EndTime": "4:30",
"CityTownId": 2,
"CityTownSuburb": "CASSIDY (NANAIMO)",
"StateProvinceId": 1,
"StateProvince": "BC",
"Availibility": 10,
"ColourCode": 1
}, {
"EventId": "EVT-37615-K64XTI",
"CourseId": 1,
"CourseName": "Aerial Work Platform (Non OSSA) Operator Training",
"StartDate": "24-10-2019",
"StartTime": "7:59",
"EndDate": "24-10-2019",
"EndTime": "4:00",
"CityTownId": 11,
"CityTownSuburb": "EDMONTON",
"StateProvinceId": 3,
"StateProvince": "AB",
"Availibility": 5,
"ColourCode": 5
}, {
"EventId": "EVT-37497-FI7OMG",
"CourseId": 3,
"CourseName": "Fall Protection Training (FPG - Interprovincial)",
"StartDate": "24-10-2019",
"StartTime": "7:59",
"EndDate": "24-10-2019",
"EndTime": "4:00",
"CityTownId": 8,
"CityTownSuburb": "CALGARY",
"StateProvinceId": 3,
"StateProvince": "AB",
"Availibility": 13,
"ColourCode": 6
}, {
"EventId": "EVT-37358-0Q5OUT",
"CourseId": 1,
"CourseName": "Aerial Work Platform (Non OSSA) Operator Training",
"StartDate": "25-10-2019",
"StartTime": "7:59",
"EndDate": "25-10-2019",
"EndTime": "4:00",
"CityTownId": 1,
"CityTownSuburb": "COQUITLAM",
"StateProvinceId": 1,
"StateProvince": "BC",
"Availibility": 5,
"ColourCode": 5
}, {
"EventId": "EVT-37395-4NSE1T",
"CourseId": 2,
"CourseName": "Counterbalanced/Vertical Mast Forklift Operator Training",
"StartDate": "25-10-2019",
"StartTime": "8:30",
"EndDate": "25-10-2019",
"EndTime": "4:30",
"CityTownId": 2,
"CityTownSuburb": "CASSIDY (NANAIMO)",
"StateProvinceId": 1,
"StateProvince": "BC",
"Availibility": 9,
"ColourCode": 0
}, {
"EventId": "EVT-37332-SZPAPC",
"CourseId": 2,
"CourseName": "Counterbalanced/Vertical Mast Forklift Operator Training",
"StartDate": "26-10-2019",
"StartTime": "7:59",
"EndDate": "26-10-2019",
"EndTime": "4:00",
"CityTownId": 1,
"CityTownSuburb": "COQUITLAM",
"StateProvinceId": 1,
"StateProvince": "BC",
"Availibility": 3,
"ColourCode": 0
}, {
"EventId": "EVT-37558-6NGE05",
"CourseId": 2,
"CourseName": "Counterbalanced/Vertical Mast Forklift Operator Training",
"StartDate": "28-10-2019",
"StartTime": "7:59",
"EndDate": "28-10-2019",
"EndTime": "4:00",
"CityTownId": 9,
"CityTownSuburb": "KELOWNA",
"StateProvinceId": 1,
"StateProvince": "BC",
"Availibility": 7,
"ColourCode": 0
}, {
"EventId": "EVT-37385-P7VDVX",
"CourseId": 1,
"CourseName": "Aerial Work Platform (Non OSSA) Operator Training",
"StartDate": "29-10-2019",
"StartTime": "8:30",
"EndDate": "29-10-2019",
"EndTime": "4:30",
"CityTownId": 2,
"CityTownSuburb": "CASSIDY (NANAIMO)",
"StateProvinceId": 1,
"StateProvince": "BC",
"Availibility": 2,
"ColourCode": 5
}, {
"EventId": "EVT-37415-XZGJ81",
"CourseId": 1,
"CourseName": "Aerial Work Platform (Non OSSA) Operator Training",
"StartDate": "29-10-2019",
"StartTime": "7:59",
"EndDate": "29-10-2019",
"EndTime": "4:00",
"CityTownId": 3,
"CityTownSuburb": "PRINCE GEORGE",
"StateProvinceId": 1,
"StateProvince": "BC",
"Availibility": 8,
"ColourCode": 5
}, {
"EventId": "EVT-38873-986VRF",
"CourseId": 1,
"CourseName": "Aerial Work Platform (Non OSSA) Operator Training",
"StartDate": "30-10-2019",
"StartTime": "8:30",
"EndDate": "30-10-2019",
"EndTime": "4:30",
"CityTownId": 2,
"CityTownSuburb": "CASSIDY (NANAIMO)",
"StateProvinceId": 1,
"StateProvince": "BC",
"Availibility": 10,
"ColourCode": 5
}, {
"EventId": "EVT-38325-0BA77E",
"CourseId": 2,
"CourseName": "Counterbalanced/Vertical Mast Forklift Operator Training",
"StartDate": "30-10-2019",
"StartTime": "7:59",
"EndDate": "30-10-2019",
"EndTime": "4:00",
"CityTownId": 15,
"CityTownSuburb": "CAMBRIDGE",
"StateProvinceId": 5,
"StateProvince": "ON",
"Availibility": 7,
"ColourCode": 0
}, {
"EventId": "EVT-37504-DQ0V2G",
"CourseId": 4,
"CourseName": "In-House Instructor Training",
"StartDate": "30-10-2019",
"StartTime": "7:59",
"EndDate": "30-10-2019",
"EndTime": "4:00",
"CityTownId": 8,
"CityTownSuburb": "CALGARY",
"StateProvinceId": 3,
"StateProvince": "AB",
"Availibility": 2,
"ColourCode": 1
}, {
"EventId": "EVT-37571-JHFJJI",
"CourseId": 6,
"CourseName": "Telehandler/Variable Reach Rough Terrain Forklift Operator Training",
"StartDate": "30-10-2019",
"StartTime": "7:59",
"EndDate": "30-10-2019",
"EndTime": "4:00",
"CityTownId": 9,
"CityTownSuburb": "KELOWNA",
"StateProvinceId": 1,
"StateProvince": "BC",
"Availibility": 5,
"ColourCode": 7
}, {
"EventId": "EVT-38752-EPZED9",
"CourseId": 7,
"CourseName": "Skid Steer Loader Operator Training",
"StartDate": "30-10-2019",
"StartTime": "7:59",
"EndDate": "30-10-2019",
"EndTime": "4:00",
"CityTownId": 1,
"CityTownSuburb": "COQUITLAM",
"StateProvinceId": 1,
"StateProvince": "BC",
"Availibility": 7,
"ColourCode": 9
}, {
"EventId": "EVT-38094-3911Y9",
"CourseId": 13,
"CourseName": "Practical Rigging Training (AB)",
"StartDate": "30-10-2019",
"StartTime": "7:59",
"EndDate": "30-10-2019",
"EndTime": "4:00",
"CityTownId": 8,
"CityTownSuburb": "CALGARY",
"StateProvinceId": 3,
"StateProvince": "AB",
"Availibility": 10,
"ColourCode": 12
}, {
"EventId": "EVT-38327-3N7EL6",
"CourseId": 16,
"CourseName": "Blended Online - Counterbalanced/Vertical Mast Forklift Operator Training",
"StartDate": "30-10-2019",
"StartTime": "12:29",
"EndDate": "30-10-2019",
"EndTime": "4:00",
"CityTownId": 15,
"CityTownSuburb": "CAMBRIDGE",
"StateProvinceId": 5,
"StateProvince": "ON",
"Availibility": 10,
"ColourCode": 13
}, {
"EventId": "EVT-38326-R5M0MA",
"CourseId": 18,
"CourseName": "Blended Online - Stand-Up Reach Truck Operator Training",
"StartDate": "30-10-2019",
"StartTime": "12:29",
"EndDate": "30-10-2019",
"EndTime": "4:00",
"CityTownId": 15,
"CityTownSuburb": "CAMBRIDGE",
"StateProvinceId": 5,
"StateProvince": "ON",
"Availibility": 10,
"ColourCode": 14
}, {
"EventId": "EVT-38126-05LC7C",
"CourseId": 22,
"CourseName": "ALS - Elevated Work Platform (OSSA)",
"StartDate": "30-10-2019",
"StartTime": "7:59",
"EndDate": "30-10-2019",
"EndTime": "4:00",
"CityTownId": 13,
"CityTownSuburb": "FORT MCMURRAY",
"StateProvinceId": 3,
"StateProvince": "AB",
"Availibility": 1,
"ColourCode": 4
}, {
"EventId": "EVT-38372-Y4UUBQ",
"CourseId": 1,
"CourseName": "Aerial Work Platform (Non OSSA) Operator Training",
"StartDate": "31-10-2019",
"StartTime": "7:59",
"EndDate": "31-10-2019",
"EndTime": "4:00",
"CityTownId": 9,
"CityTownSuburb": "KELOWNA",
"StateProvinceId": 1,
"StateProvince": "BC",
"Availibility": 7,
"ColourCode": 5
}, {
"EventId": "EVT-37634-KJR31N",
"CourseId": 2,
"CourseName": "Counterbalanced/Vertical Mast Forklift Operator Training",
"StartDate": "31-10-2019",
"StartTime": "7:59",
"EndDate": "31-10-2019",
"EndTime": "4:00",
"CityTownId": 11,
"CityTownSuburb": "EDMONTON",
"StateProvinceId": 3,
"StateProvince": "AB",
"Availibility": 1,
"ColourCode": 0
}, {
"EventId": "EVT-38114-3VQSY2",
"CourseId": 20,
"CourseName": "ALS - Counterbalanced/Vertical Mast and Telehandler/Rough Terrain Forklift Operator Training",
"StartDate": "31-10-2019",
"StartTime": "7:59",
"EndDate": "31-10-2019",
"EndTime": "4:00",
"CityTownId": 13,
"CityTownSuburb": "FORT MCMURRAY",
"StateProvinceId": 3,
"StateProvince": "AB",
"Availibility": 1,
"ColourCode": 8
}],
"LastUpdated": "23-10-2019"
}
#calendar .calendar-view .moment-today {
border: 2px solid #00ff90 !important;
}
#calendar .calendar-view>.list {
flex-basis: auto;
height: auto;
display: none;
}
#calendar .calendar-view>.list h5 {
background-color: #eee;
padding: 3px 5px 5px;
margin: -8px -8px 8px -8px;
}
#calendar .calendar-view>.list.show-only-list {
display: block;
}
#calendar .calendar-view .bg-0 {
background-color: #343a40;
}
#calendar .calendar-view .bg-1 {
background-color: #007bff;
}
#calendar .calendar-view .bg-2 {
background-color: #6610f2;
}
#calendar .calendar-view .bg-3 {
background-color: #6f42c1;
}
#calendar .calendar-view .bg-4 {
background-color: #e83e8c;
}
#calendar .calendar-view .bg-5 {
background-color: #dc3545;
}
#calendar .calendar-view .bg-6 {
background-color: #fd7e14;
}
#calendar .calendar-view .bg-7 {
background-color: #ffc107;
}
#calendar .calendar-view .bg-8 {
background-color: #28a745;
}
#calendar .calendar-view .bg-9 {
background-color: #20c997;
}
#calendar .calendar-view .bg-10 {
background-color: #17a2b8;
}
#calendar .calendar-view .bg-11 {
background-color: #f8f9fa;
}
#calendar .calendar-view .bg-12 {
background-color: #6c757d;
}
#calendar .calendar-view .bg-13 {
background-color: #343a40;
}
#calendar .calendar-view .bg-14 {
background-color: #007bff;
}
#calendar .calendar-view .bg-15 {
background-color: #6c757d;
}
#calendar .calendar-view .bg-16 {
background-color: #28a745;
}
#calendar .calendar-view .bg-17 {
background-color: #17a2b8;
}
#calendar .calendar-view .bg-18 {
background-color: #ffc107;
}
#calendar .calendar-view .bg-19 {
background-color: #dc3545;
}
#media (max-width: 991px) {
.display-4 {
font-size: 1.5rem;
}
.day h5 {
background-color: #eee;
padding: 3px 5px 5px;
margin: -8px -8px 8px -8px;
}
.date {
padding-left: 4px;
}
.calendar-view>div {
display: none;
}
.calendar-view>div.show-only-list {
display: block;
}
.calendar-view>div.show-only-list .events-holder>a {
display: block;
border-radius: .25rem;
width: 100%;
}
}
#media (min-width: 992px) {
#calendar .calendar-view .day.grid {
min-height: 9vw;
}
#calendar .calendar-view .day.grid h5 small {
display: none;
}
#calendar .calendar-view .day.grid .events-holder a {
width: 25px;
height: 25px;
border-radius: 15px;
margin-right: 2px;
}
#calendar .calendar-view .day.grid .events-holder .course-name {
display: none;
}
#calendar .calendar-view .day.calendar-prior-months-date h5 small {
display: none;
}
}
<!doctype html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css" rel="stylesheet" />
<link href="./calendar-styles.min.css" rel="stylesheet" />
<title>Responsive Calender</title>
</head>
<body>
<div class="container">
<div class="container-fluid calendar" id="calendar">
<header>
<div class="row">
<div class="col-sm-9 d-flex justify-content-between align-items-center my-2">
<!-- Calendar "prev" button -->
<button data-toggle="calendar" data-action="prev" class="btn btn-default">
<i class="fa fa-chevron-left"></i>
</button>
<h4 class="calendar-current-date display-4 text-center" data-day-format="MM/DD/YYYY" data-week-format="MM/DD/YYYY" data-month-format="MMMM, YYYY"></h4>
<!-- Calendar "next" button -->
<button data-toggle="calendar" data-action="next" class="btn btn-default">
<i class="fa fa-chevron-right"></i>
</button>
</div>
<div class="col-sm-3 d-flex justify-content-between align-items-center my-2">
<button data-toggle="calendar" data-action="grid" class="btn btn-default d-none d-lg-block">
<i class="fa fa-calendar"></i>
</button>
<button data-toggle="calendar" data-action="list" class="btn btn-default d-none d-lg-block">
<i class="fa fa-list"></i>
</button>
<!-- Calendar "today" button -->
<button data-toggle="calendar" data-action="today" class="btn btn-default">
Today
</button>
</div>
</div>
<div class="row d-none d-lg-flex p-1 bg-dark text-white">
<h5 class="col-sm p-1 text-center">Sunday</h5>
<h5 class="col-sm p-1 text-center">Monday</h5>
<h5 class="col-sm p-1 text-center">Tuesday</h5>
<h5 class="col-sm p-1 text-center">Wednesday</h5>
<h5 class="col-sm p-1 text-center">Thursday</h5>
<h5 class="col-sm p-1 text-center">Friday</h5>
<h5 class="col-sm p-1 text-center">Saturday</h5>
</div>
</header>
</div>
<br />
</div>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script type="text/javascript" src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
<script type="text/javascript" src="https://momentjs.com/downloads/moment.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.9.1/underscore-min.js"></script>
</body>
</html>

If you are asking about, Does full-calendar handle window resize?. If so then yes full-calendar comes with such capabilities. You can set handleWindowResize property to true, but it is true by default and you should not have to ask about it.
If you are asking about, Does full-calendar allow user interaction other than just rendering events?. Then, yes full-calendar allows you to add, delete, update events. It also comes with lot of options and methods to tweak around with your calendar. Since there are lots of such features you will have to go through the docs to find what you need.
Lastly full-calendar has a lot of callback methods/hooks that you can use to allow/prevent certain action, modify the behavior of such actions and lot more.
I hope you find what you are looking for. Good luck.

As said before fullcalendar is responsive by nature. So if you speak about to be responsive like month after weeks after day. You can juste put a js event on windows resize the view manually ?
If its not it. Tell us more

Related

filter json data in a table when checkbox clicked

I want to filter table rows when I clicked checkbox (high, low, med, small large..)from json data according to filtered value.
I am trying here filter table rows according to filter values in the Solutions.
If I clicked High checkbox, it should show only the solution of filtered value (281) ie, SolutionID(abc1234 and abc1235).
Someone can help how to achieve the filter function for json data.
I have done this with MySql and javascript with php whereclause.
Checkboxes
<input type="checkbox" id="High" name="High" onclick="applyFilter()">
<label for="High">High</label>
<input type="checkbox" id="Medium" name="Medium" onclick="applyFilter()">
<label for="Medium">Medium</label>
<input type="checkbox" id="Low" name="Low" onclick="applyFilter()">
<label for="Low">Low</label>
json data...
Nested json data have the Filter types and values. Also has solutions I can display solutions in a table. I want to filter these solutions when I clicked checkbox, it should display only particular solutions which has filter value like 281, 283 only.
{
"Program": [
{
"Id": 2,
"Name": "Solution",
"FilterTypes": [
{
"Id": 10,
"Title": "Case",
"FilterValues": [
{
"Id": 281,
"Value": "High"
},
{
"Id": 282,
"Value": "Mid"
},
{
"Id": 283,
"Value": "Low"
}
]
},
{
"Id": 10,
"Title": "Case",
"FilterValues": [
{
"Id": 284,
"Value": "Micro"
},
{
"Id": 285,
"Value": "Small"
},
{
"Id": 286,
"Value": "Large"
}
]
}
],
"Sets": [
{
"Id": 324,
"Name": "xyz",
"Solutions": [
{
"Id": 100,
"SolutionId": "abc1234",
"Title": "XYZ Solution1",
"Published": "Tested Solution1",
"Info": "This is for perticular Solution1",
"FilterValues": [
{
"FilterValueId": 281
},
{
"FilterValueId": 283
},
{
"FilterValueId": 286
}
]
},
{
"Id": 101,
"SolutionId": "abc1235",
"Title": "XYZ Solution2",
"Published": "Tested Solution2",
"Info": "This is for perticular Solution2",
"FilterValues": [
{
"FilterValueId": 282
}
]
},
{
"Id": 102,
"SolutionId": "abc1236",
"Title": "XYZ Solution3",
"Published": "Tested Solution3",
"Info": "This is for perticular Solution3",
"FilterValues": [
{
"FilterValueId": 281
},
{
"FilterValueId": 282
}
{
"FilterValueId": 286
}
]
}
]
}
]
}
]
}
Table
Table is displaying all the solutions.
<table style="border: 5px solid; padding: 0px; width: auto;" border="1">
<thead>
<tr style="background-color: #425462; color: white">
<th style="text-align: center">Solution ID</th>
<th style="text-align: center">Published</th>
<th style="text-align: center; width:10%">Info</th>
</tr>
</thead>
<?php if(count($decoded) !=0){
foreach($decoded['Programs']['Sets']['Solutions'] as $item){
?>
<tr class="solnrow1" style="background-color:;text-align: center; width: auto">
<td style="text-align: left"><?= $item['SolutionId']?></td>
<td style="text-align: left"><?= $item['Published']?></td>
<td style="text-align: left"><?= $item['Info']?></td>
</tr>
<?php
}
}
?>

canvas text and image is fuzzy and blurry

I am implementing graphs in materializecss using canvasJS but the text and image is fuzzy and blurry Here is the code which I have taken from the official website of canvasjs
var chart = new CanvasJS.Chart("chartContainer", {
animationEnabled: true,
theme: "light2", // "light1", "light2", "dark1", "dark2"
title:{
text: "Top Oil Reserves"
},
axisY: {
title: "Reserves(MMbbl)"
},
data: [{
type: "column",
showInLegend: true,
legendMarkerColor: "grey",
legendText: "MMbbl = one million barrels",
dataPoints: [
{ y: 300878, label: "Venezuela" },
{ y: 266455, label: "Saudi" },
{ y: 169709, label: "Canada" },
{ y: 158400, label: "Iran" },
{ y: 142503, label: "Iraq" },
{ y: 101500, label: "Kuwait" },
{ y: 97800, label: "UAE" },
{ y: 80000, label: "Russia" }
]
}]
});
chart.render();
</script>
</head>
<body>
<div id="chartContainer" style="height: 300px; width: 100%;"></div>
<script src="https://canvasjs.com/assets/script/canvasjs.min.js"></script>
</body>
</html>
Looks like the y axis text is pixelated. You can use titleFontFamily on axisY to use a font that renders more to your liking. In the snippet below I used verdana.
var chart = new CanvasJS.Chart("chartContainer", {
animationEnabled: true,
theme: "light2", // "light1", "light2", "dark1", "dark2"
title:{
text: "Top Oil Reserves"
},
axisY: {
title: "Reserves(MMbbl)",
titleFontFamily: "verdana"
},
data: [{
type: "column",
showInLegend: true,
legendMarkerColor: "grey",
legendText: "MMbbl = one million barrels",
dataPoints: [
{ y: 300878, label: "Venezuela" },
{ y: 266455, label: "Saudi" },
{ y: 169709, label: "Canada" },
{ y: 158400, label: "Iran" },
{ y: 142503, label: "Iraq" },
{ y: 101500, label: "Kuwait" },
{ y: 97800, label: "UAE" },
{ y: 80000, label: "Russia" }
]
}]
});
chart.render();
<body>
<div id="chartContainer" style="height: 300px; width: 100%;"></div>
<script src="https://canvasjs.com/assets/script/canvasjs.min.js"></script>
</body>

different pointWidths for series in column chart

I've created a column chart from data I've retrieved from mysql.
The data are two series of data.
Chart is working.
However in the resulting graph I would like to give the series a different pointWidth.
PHP script for retrieving the Mysql data:
<?php
$con = mysql_connect("localhost","xxxx","xxxx");
if (!$con) {
die('Could not connect: ' . mysql_error());
}
mysql_select_db("pvdag", $con);
$query = mysql_query("SELECT maand, OpbrengstPV, OpbrengstTheor FROM maandgegevens where YEAR(periode) = 2013");
$category = array();
$category['name'] = 'maand';
$series1 = array();
$series1['name'] = 'OpbrengstPV';
$series2 = array();
$series2['name'] = 'OpbrengstTheor';
while($r = mysql_fetch_array($query)) {
$category['data'][] = $r['maand'];
$series1['data'][] = $r['OpbrengstPV'];
$series2['data'][] = $r['OpbrengstTheor'];
}
$result = array();
array_push($result,$category);
array_push($result,$series1);
array_push($result,$series2);
print json_encode($result, JSON_NUMERIC_CHECK);
mysql_close($con);
?>
script for generating the graph:
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>maandopbrengsten</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
// First, let's make the colors transparent
Highcharts.getOptions().colors = Highcharts.map(Highcharts.getOptions().colors, function (color) {
return Highcharts.Color(color)
.setOpacity(0.5)
.get('rgba');
});
var options = {
chart: {
renderTo: 'container',
type: 'column',
marginRight: 130,
marginBottom: 70
},
title: {
text: 'maandopbrengsten 2013',
x: -20 //center
},
subtitle: {
text: '',
x: -20
},
xAxis: {
categories: []
},
yAxis: {
title: {
text: 'opbrengst kWh'
},
plotLines: [{
value: 0,
width: 1,
color: '#808080'
}]
},
tooltip: {
formatter: function() {
return '<b>'+ this.series.name +'</b><br/>'+
this.x +': '+ this.y;
}
},
legend: {
layout: 'vertical',
align: 'top',
verticalAlign: 'top',
x: 100,
y: 0,
borderWidth: 3
},
plotOptions: {
column: {
dataLabels: {
enabled: true,
color: (Highcharts.theme && Highcharts.theme.dataLabelsColor) || 'white'
},
grouping: false,
shadow: false
}
},
series: []
}
$.getJSON("data.php", function(json) {
options.xAxis.categories = json[0]['data'];
options.series[0] = json[1];
options.series[1] = json[2];
chart = new Highcharts.Chart(options);
});
});
</script>
<script src="http://code.highcharts.com/highcharts.js"></script>
<script src="http://code.highcharts.com/modules/exporting.js"></script>
</head>
<body>
<div id="container" style="min-width: 400px; width: 75%; height: 400px; margin: 0 auto"></div>
</body>
</html>
You can set pointWidth on particular serie, not in plotOptions, like in the example:
series: [{
data: [49.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4]
}, {
pointWidth: 50,
data: [83.6, 78.8, 98.5, 93.4, 106.0, 84.5, 105.0, 104.3, 91.2, 83.5, 106.6, 92.3]
}]
http://jsfiddle.net/bwbF7/1/

Fullcalendar won't enter data from mysql table into the calendar

I am trying get Fullcalendar to take information from a mysql table and enter the informtion into the calendar. The calendar appears, but none of the information from the table is on the calendar.
Here is my code.
calendar.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<style type='text/css'>
body {
margin-top: 40px;
text-align: center;
font-size: 14px;
font-family: "Lucida Grande",Helvetica,Arial,Verdana,sans-serif;
}
#loading {
position: absolute;
top: 5px;
right: 5px;
}
#calendar {
width: 900px;
margin: 0 auto;
}
</style>
<link rel='stylesheet' type='text/css' href='fullcalendar/fullcalendar.css' />
<script type='text/javascript' src='jquery/jquery.js'></script>
<script type='text/javascript' src='jquery/ui.core.js'></script>
<script type='text/javascript' src='jquery/ui.draggable.js'></script>
<script type='text/javascript' src='fullcalendar/fullcalendar.js'></script>
<script type='text/javascript'>
$(document).ready(function() {
$('#calendar').fullCalendar({
editable: true,
events: "json-events.php",
eventDrop: function(event, delta) {
alert(event.title + ' was moved ' + delta + ' days\n' +
'(should probably update your database)');
},
loading: function(bool) {
if (bool) $('#loading').show();
else $('#loading').hide();
}
});
});
</script>
</head>
<body>
<div id='loading' style='display:none'>loading...</div>
<div id='calendar'></div>
<p>json_events.php needs to be running in the same directory.</p>
</body>
</html>
json_events.php
<?php
include("dbstuff.inc");
$conn = mysql_connect($host, $user, $pass) or die(mysql_error());
mysql_select_db($database, $conn) or die(mysql_error());
$sql= "SELECT id, title, description, url, email, Stime, Etime, eventDate, DATE_FORMAT(eventDate, '%Y-%m-%dT%H:%i' ) AS startDate
FROM events
ORDER BY startDate DESC";
$check = mysql_query($sql) or die(mysql_error());
$events = array();
while ($row = mysql_fetch_assoc($check)) {
$eventArray['id'] = $row['id'];
$eventArray['title'] = $row['title'];
$eventArray['description'] = $row['description'];
$eventArray['url'] = $row['url'];
$eventArray['email'] = $row['email'];
$eventArray['startTime'] = $row['Stime'];
$eventArray['EndTime'] = $row['Etime'];
$eventArray['title'] = $row['Stime'] . " " . $row['title'];
$eventArray['start'] = $row['startDate'];
$eventsArray['allDay'] = "";
$events[] = $eventArray;
}
echo json_encode($events);
?>
This is the data from MySQL file
[
{
"id": "1",
"title": "07:00:00 test1",
"description": "werewr",
"url": "http://www.nba.com",
"email": "someone#host.com",
"startTime": "07:00:00",
"EndTime": "09:00:00",
"start": "2013-04-22T00:00"
},
{
"id": "2",
"title": "11:00:00 test2",
"description": "hello",
"url": "http://www.nba.com",
"email": "someone#host.com",
"startTime": "11:00:00",
"EndTime": "13:00:00",
"start": "2013-04-15T00:00"
}
]
you have events: "json-events.php" and your php file it's json_events.php

Load data from database into highchart in MVC php using JSON

I am using MVC for Entity Framework & developing aa application & I want to upload data from database to show it into highchart's column-drilldown chart ?
My Code For Binding is as below:
$result = mysql_query("select s.id, s.stage_name as stage, coalesce(sum(o.potential) * (s.stage_weight / 100),0) as w_pot FROM s_stages as s
left join opps as o
WHERE o.buy_stage = s.id");
$model["chart"]=array();
while($row = mysql_fetch_array($result)){
array_push($model["chart"],
array(
"id"=>$row["s.id"],
"name"=>$row["stage"],
"w_pot"=>$row["w_pot"]
));
}
and in view I have written code as below with its script code:
<script src="http://code.highcharts.com/highcharts.js"></script>
<script src="http://code.highcharts.com/modules/exporting.js"></script>
<div id="container" class="span6" style="min-width: 400px; height: 400px; margin: 0 auto"></div>
<script type="text/javascript">
$(function () {
var chart;
$(document).ready(function() {
var colors = Highcharts.getOptions().colors,
categories = ['MSIE', 'Firefox', 'Chrome', 'Safari', 'Opera'],
name = 'Browser brands',
data = [{
y: 55.11,
color: colors[0],
drilldown: {
name: 'MSIE versions',
categories: ['MSIE 6.0', 'MSIE 7.0', 'MSIE 8.0', 'MSIE 9.0'],
data: [10.85, 7.35, 33.06, 2.81],
color: colors[0]
}
}, {
y: 21.63,
color: colors[1],
drilldown: {
name: 'Firefox versions',
categories: ['Firefox 2.0', 'Firefox 3.0', 'Firefox 3.5', 'Firefox 3.6', 'Firefox 4.0'],
data: [0.20, 0.83, 1.58, 13.12, 5.43],
color: colors[1]
}
}, {
y: 11.94,
color: colors[2],
drilldown: {
name: 'Chrome versions',
categories: ['Chrome 5.0', 'Chrome 6.0', 'Chrome 7.0', 'Chrome 8.0', 'Chrome 9.0',
'Chrome 10.0', 'Chrome 11.0', 'Chrome 12.0'],
data: [0.12, 0.19, 0.12, 0.36, 0.32, 9.91, 0.50, 0.22],
color: colors[2]
}
}, {
y: 7.15,
color: colors[3],
drilldown: {
name: 'Safari versions',
categories: ['Safari 5.0', 'Safari 4.0', 'Safari Win 5.0', 'Safari 4.1', 'Safari/Maxthon',
'Safari 3.1', 'Safari 4.1'],
data: [4.55, 1.42, 0.23, 0.21, 0.20, 0.19, 0.14],
color: colors[3]
}
}, {
y: 2.14,
color: colors[4],
drilldown: {
name: 'Opera versions',
categories: ['Opera 9.x', 'Opera 10.x', 'Opera 11.x'],
data: [ 0.12, 0.37, 1.65],
color: colors[4]
}
}];
function setChart(name, categories, data, color) {
chart.xAxis[0].setCategories(categories, false);
chart.series[0].remove(false);
chart.addSeries({
name: name,
data: data,
color: color || 'white'
}, false);
chart.redraw();
}
chart = new Highcharts.Chart({
chart: {
renderTo: 'container',
type: 'column'
},
title: {
text: 'Browser market share, April, 2011'
},
subtitle: {
text: 'Click the columns to view versions. Click again to view brands.'
},
xAxis: {
categories:
},
yAxis: {
title: {
text: ''
}
},
plotOptions: {
column: {
cursor: 'pointer',
point: {
events: {
click: function() {
var drilldown = this.drilldown;
if (drilldown) { // drill down
setChart(drilldown.name, drilldown.categories, drilldown.data, drilldown.color);
} else { // restore
setChart(name, categories, data);
}
}
}
},
dataLabels: {
enabled: true,
color: colors[0],
style: {
fontWeight: 'bold'
},
formatter: function() {
return this.y +'%';
}
}
}
},
tooltip: {
formatter: function() {
var point = this.point,
s = this.x +':<b>'+ this.y +'% market share</b><br/>';
if (point.drilldown) {
s += 'Click to view '+ point.category +' versions';
} else {
s += 'Click to return to browser brands';
}
return s;
}
},
series: [{
name: name,
data: data,
color: 'white'
}],
exporting: {
enabled: false
}
});
});
});
</script>
Try like this:
<html>
<head>
<title>Graph</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script src="http://code.highcharts.com/highcharts.js"></script>
<script src="http://code.highcharts.com/modules/exporting.js"></script>
</head>
<body>
<?php
$result = mysql_query("select s.id, s.stage_name as stage, coalesce(sum(o.potential) * (s.stage_weight / 100),0) as w_pot FROM s_stages as s
left join opps as o
WHERE o.buy_stage = s.id");
$stagearray=array();
$wt_arr=array();
while($row = mysql_fetch_array($result)){
$sname="'".$row["stage"]."'";
array_push($stagearray,$sname);
array_push($wt_arr,$row["w_pot"]);
}
$categories=implode(",",$stagearray);
$ponts_str=implode(",",$wt_arr);
?>
<div id="container" class="span6" style="min-width: 400px; height: 400px; margin: 0 auto"></div>
<script type="text/javascript">
$(function () {
var chart;
$(document).ready(function() {
chart = new Highcharts.Chart({
chart: {
renderTo: 'container',
type: 'column'
},
title: {
text: 'Stages'
},
subtitle: {
text: ''
},
xAxis: {
categories: [<?php echo $categories;?>]
},
yAxis: {
min: 0,
title: {
text: 'Points'
}
},
legend: {
layout: 'vertical',
backgroundColor: '#FFFFFF',
align: 'left',
verticalAlign: 'top',
x: 100,
y: 70,
floating: true,
shadow: true
},
tooltip: {
formatter: function() {
return ''+
this.x +': '+ this.y +' mm';
}
},
plotOptions: {
column: {
pointPadding: 0.2,
borderWidth: 0
}
},
series: [{
name: 'Stages',
data: [<?php echo $ponts_str;?>]
}]
});
});
});
</script>
</body>
</html>

Categories