Custom Range Picker View
Usage
theme: 'ios' You can turn auto theming on and let it decide based on the platform.
Usage
themeVariant: 'light' You can turn auto dark mode on based on system settings.
Usage
clickToCreate: true,
// click to create is on dragToCreate: true,
// drag to create is on dragToMove: true,
// reordering is on dragToResize: true,
// resizing is on eventDelete: true
// deleting is on Fine-tune drag & drop with these options, which are false by default.
Usage
locale: localeEn Selecting the locale loads the localized settings and the translated UI text.
Custom Range Picker View
The timeline comes with built-in support for day, week, month and year views. For those situations where a custom range makes more sense, it is possible to override the calendar navigation component with a range picker.
The calendar header can be easily customized and a two-way synchronization needs to be kept between the timeline and range picker.
Demo

Code
import { CommonModule } from '@angular/common';
import { HttpClient } from '@angular/common/http';
import { Component, OnInit } from '@angular/core';
import { FormsModule } from '@angular/forms';
import {
formatDate,
MbscCalendarEvent,
MbscDateType,
MbscEventcalendarOptions,
MbscEventcalendarView,
MbscModule,
setOptions ,
} from '@mobiscroll/angular';
setOptions({
locale: ,
theme: ' ',
themeVariant: ' '
});
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
standalone: true,
imports: [CommonModule, FormsModule, MbscModule],
})
export class AppComponent implements OnInit {
constructor(private http: HttpClient) {}
startDate!: Date;
endDate!: Date;
refDate!: Date;
selectedDate: MbscDateType = new Date();
rangeValue: any = [];
rangeText = '';
myEvents: MbscCalendarEvent[] = [];
view = 'calendar';
calView: MbscEventcalendarView = {
timeline: {
type: 'day',
size: 14,
eventDisplay: 'fill',
},
};
calendarOptions: MbscEventcalendarOptions = {
resources: [
{
id: 1,
name: 'Resource A',
color: '#e20000',
},
{
id: 2,
name: 'Resource B',
color: '#76e083',
},
{
id: 3,
name: 'Resource C',
color: '#4981d6',
},
{
id: 4,
name: 'Resource D',
color: '#e25dd2',
},
{
id: 5,
name: 'Resource E',
color: '#1dab2f',
},
{
id: 6,
name: 'Resource F',
color: '#d6d145',
},
],
onPageLoaded: (args) => {
const end = args.lastDay;
this.startDate = args.firstDay;
this.endDate = new Date(end.getFullYear(), end.getMonth(), end.getDate() - 1, 0);
setTimeout(() => {
// Set button text
this.rangeText = this.getFormattedRange(this.startDate, this.endDate);
// Set range value
this.rangeValue = [this.startDate, this.endDate];
// Navigate the calendar
this.selectedDate = this.startDate;
});
},
};
onClose(): void {
const date = this.rangeValue;
if (date[0] && date[1]) {
// Navigate the calendar
this.selectedDate = date[0];
this.startDate = date[0];
this.endDate = date[1];
// Set calendar view
this.refDate = date[0];
this.calView = {
timeline: {
type: 'day',
size: this.getNrDays(date[0], date[1]),
eventDisplay: 'fill',
},
};
} else {
this.rangeValue = [this.startDate, this.endDate];
}
}
// Returns the formatted date
getFormattedRange(start: any, end: any): string {
return (
formatDate('MMM D, YYYY', new Date(start)) +
(end && this.getNrDays(start, end) > 1 ? ' - ' + formatDate('MMM D, YYYY', new Date(end)) : '')
);
}
// Returns the number of days between two dates
getNrDays(start: any, end: any): number {
return Math.round(Math.abs((end.setHours(0) - start.setHours(0)) / (24 * 60 * 60 * 1000))) + 1;
}
ngOnInit(): void {
this.http
.jsonp<MbscCalendarEvent[]>('https://trial.mobiscroll.com/timeline-events/?vers=5', 'callback')
.subscribe((resp: MbscCalendarEvent[]) => {
this.myEvents = resp;
});
}
}
<mbsc-eventcalendar
[data]="myEvents"
[view]="calView"
[headerTemplate]="customTemplate"
[options]="calendarOptions"
[(selectedDate)]="selectedDate"
[refDate]="refDate"
>
<ng-template #customTemplate>
<div
[(ngModel)]="rangeValue"
mbsc-datepicker
select="range"
display="anchored"
[showOverlay]="false"
[touchUi]="true"
[buttons]="[]"
(onClose)="onClose()"
>
<mbsc-button variant="flat" class="mbsc-calendar-button">
<span class="mbsc-calendar-title">{{rangeText}}</span>
</mbsc-button>
</div>
<div class="md-custom-range-view-controls">
<mbsc-calendar-prev></mbsc-calendar-prev>
<mbsc-calendar-today></mbsc-calendar-today>
<mbsc-calendar-next></mbsc-calendar-next>
</div>
</ng-template>
</mbsc-eventcalendar>
.md-custom-range-view-controls {
display: flex;
flex: 1 0 auto;
justify-content: flex-end;
align-items: center;
}