![require(esm) Backported to Node.js 20, Paving the Way for ESM-Only Packages](https://cdn.sanity.io/images/cgdhsj6q/production/be8ab80c8efa5907bc341c6fefe9aa20d239d890-1600x1097.png?w=400&fit=max&auto=format)
Security News
require(esm) Backported to Node.js 20, Paving the Way for ESM-Only Packages
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
angular-calendar-timeline
Advanced tools
A timeline for angular 13 that shows tasks or events on a timeline in different modes: days, weeks, and months.
[soon]
A timeline component for angular 13.0+ that shows tasks or events on a timeline in different modes: days, weeks, and months.
This library DOESN'T use big dependencies like JQuery or Moment.js. It`s almost a pure Angular library.
Install through npm:
npm install --save angular-timeline-calendar
Then import the timeline module into your module where you want to use timeline.
Don't forget to call forChild() method:
import { NgModule } from '@angular/core';
import { TimelineModule } from 'angular-timeline-calendar';
@NgModule({
imports: [
TimelineModule.forChild(),
],
})
export class MyModule {
}
That's it, you can then use it in your component as:
import { ITimelineItem } from "angular-timeline-calendar";
@Component({
template: `<timeline-calendar [items]="items"> </timeline-calendar>`
})
export class MyTimelineComponent implements AfterViewInit {
items: ITimelineItem[] = [];
}
Change localization is very simple:
import localeUk from "@angular/common/locales/uk";
registerLocaleData(localeUk);
@Component({
template: `<timeline-calendar locale="uk"></timeline-calendar>`
})
In case you need to change the format of the dates in the header, you can provide custom formatters:
import { NgModule } from '@angular/core';
import { TimelineModule, IScaleFormatter } from 'angular-timeline-calendar';
const myCustomFormatter: IScaleFormatter = {
formatColumn(column: IScaleColumn, columnWidth: number, locale: string): string {
return column.date.toString();
}
}
@NgModule({
imports: [
TimelineModule.forChild({
dayScaleFormatter: myCustomFormatter, // For days mode
weekScaleFormatter: myCustomFormatter, // For weeks mode
monthScaleFormatter: myCustomFormatter, // For months mode
}),
],
})
export class MyModule {
}
You can change current zoom by calling changeZoom() method in TimelineComponent. Also, you can set your own zooms array:
import { AfterViewInit, ViewChild } from "@angular/core";
import { TimelineComponent, ITimelineZoom } from "angular-timeline-calendar";
@Component({
template: `<timeline-calendar [zooms]="zooms"></timeline-calendar>`
})
export class MyTimelineComponent implements AfterViewInit {
zooms: ITimelineZoom[] = [] // set custom array of zooms;
@ViewChild(TimelineComponent) timeline: TimelineComponent;
ngAfterViewInit(): void {
// Change current zoom to any from zooms array.
this.timeline.changeZoom(this.timeline.zooms[0]);
// Change current zoom by one step next.
this.timeline.changeZoom(this.timeline.zoomIn());
}
}
This is not all API of component. Maybe later I will add some documentation. Currently, you can see comments inside TimelineComponent.
The library allows you to add custom view modes, for example, years, hours, minutes, etc. All you have to do is extends two classes: ScaleGeneratorsManager and DivisionsAdaptorsManager.
ScaleGeneratorsManager returns a scale generator depending on the current zoom. The function of this generator is to build the header with columns and dates inside each column. Each view mode has its own generator, so it is the reason why we need some "manager".
DivisionsAdaptorsManager contains adaptors for different view modes. Those Adaptors use a common interface, and they are necessary for calculating operations with dates.
Here is an example of how it should look, when you want to add some additional view modes:
import { NgModule } from '@angular/core';
import {
TimelineModule,
TimelineDivisionType,
IScaleFormatter,
IScaleGenerator,
ScaleGeneratorsManager,
IScaleGeneratorsManager,
DivisionsAdaptorsManager,
IDivisionsAdaptorsManager
} from 'angular-timeline-calendar';
enum CustomZoomDivisionsType {
Day = TimelineDivisionType.Day,
Week = TimelineDivisionType.Week,
Month = TimelineDivisionType.Month,
Custom = 'Custom'
}
class CustomScaleGeneratorsManager extends ScaleGeneratorsManager
implements IScaleGeneratorsManager<CustomZoomDivisionsType> {
getGenerator(division: CustomZoomDivisionsType): IScaleGenerator {
if (division === CustomZoomDivisionsType.Custom) {
return {...}; // your custom logic here
}
return super.getGenerator(zoom);
};
}
class CustomDivisionsAdaptorsManager extends DivisionsAdaptorsManager
implements IDivisionsAdaptorsManager<CustomZoomDivisionsType> {
getAdaptor(division: CustomZoomDivisionsType): IDivisionAdaptor {
if (division === CustomZoomDivisionsType.Custom) {
return {...} // custom adaptor;
}
return super.getAdaptor(division);
}
}
@NgModule({
imports: [
TimelineModule.forChild({
scaleGeneratorsManager: CustomScaleGeneratorsManager,
divisionsAdaptorsManager: CustomDivisionsAdaptorsManager,
}),
],
})
export class MyModule {
}
If you have some issues go here: https://github.com/oOps1627/angular-calendar-timeline
FAQs
A timeline for angular 13 that shows tasks or events on a timeline in different modes: days, weeks, and months.
The npm package angular-calendar-timeline receives a total of 424 weekly downloads. As such, angular-calendar-timeline popularity was classified as not popular.
We found that angular-calendar-timeline demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
Security News
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.