Home

Awesome

NgxTimeline check-code-coverage

The main goal of this angular library is to give you the possibility to integrate a timeline in your app. <br> Version 19.0.2 is compatible with angular 19. <br> Go here and discover all possible configurations for the timeline

image

<p align = "center"> Fig.1 - Preview of <a href="https://emanuelefricano93.github.io/frxjs-Ngx-Timeline/">Timeline example configuration page</a> </p> <br><br>

Installation

Running the following command to install the library

npm install @frxjs/ngx-timeline

Examples of Usage

After installing the library and including NgxTimelineModule in your imports module you could add one of following examples to your template in order to display your timeline

<ngx-timeline [events]="events"></ngx-timeline>
<ngx-timeline [events]="events" [langCode]="'it'"></ngx-timeline>
<ngx-timeline [events]="events" [langCode]="'it'" [enableAnimation]="false"></ngx-timeline>

Configuration

Input

Input nameExplanationMandatoryType/Supported ValuesDefault value
eventslist of events to be displayedyesNgxTimelineEventno default
langCodelanguage code use to format datesno<ul><li>'en'</li><li>'it'</li><li>'fr'</li><li>'de'</li><li>'es'</li><li>'sl'</li><li>'tr'</li><li>'pl'</li><li>'pt'</li><li>'ru'</li></ul>'en'
enableAnimationBoolean used to enable or disable the animationsnobooleantrue
reverseOrderBoolean used to reverse sort order (default older first)nobooleanfalse
virtualScrollBoolean used to enable or disable the virtual scrollnobooleanfalse
virtualScrollItemSizeNumber of pixels of a single item used for virtual scrollnonumber100
virtualScrollMaxBufferPxNumber of max pixels the buffer for the virtual scroll hasnonumber200
virtualScrollMinBufferPxMinimum ammount of the buffer rendered beyond the viewportnonumber100
groupEventLogic to be applied in order to group eventsnoenum NgxTimelineEventGroupNgxTimelineEventGroup.MONTH_YEAR
orientationOrientation of the timelinenoenum NgxTimelineOrientationNgxTimelineOrientation.VERTICAL
changeSideLogic to be applied in order to put events on LEFT or RIGHTnoenum NgxTimelineEventChangeSideNgxTimelineEventChangeSide.ON_DIFFERENT_DAY_IN_GROUP
periodCustomTemplateCustom Template displayed before a group of eventsnoTemplateRef<unknown>no default
eventCustomTemplateCustom Template displayed to show a single eventnoTemplateRef<unknown>no default
centerIconCustomTemplateCustom Template displayed to show an separator iconnoTemplateRef<unknown>no default
dateInstantCustomTemplateCustom Template displayed to show the side datenoTemplateRef<unknown>no default
innerEventCustomTemplateCustom Template displayed to show the inner eventnoTemplateRef<unknown>no default
eventDescriptionCustomTemplateCustom Template displayed to show the descriptionnoTemplateRef<unknown>no default

Output

Output nameExplanationMandatoryType/Supported ValuesDefault value
clickEmitterOutput click event emitternoOutputEmitterRef<NgxTimelineItem>no default

Types and Enums

interface NgxTimelineEvent {
  timestamp: Date;
  title?: string;
  description?: string;
  id?: any;
  itemPosition?: NgxTimelineItemPosition;
}
enum NgxTimelineEventGroup {
  YEAR = 'YEAR',
  MONTH_YEAR = 'MONTH_YEAR',
  DAY_MONTH_YEAR = 'DAY_MONTH_YEAR'
}
export enum NgxTimelineOrientation {
  HORIZONTAL = 'HORIZONTAL',
  VERTICAL = 'VERTICAL',
}
enum NgxTimelineEventChangeSide {
  ALL = 'ALL',
  ALL_IN_GROUP = 'ALL_IN_GROUP',
  ON_DIFFERENT_DAY_IN_GROUP = 'ON_DIFFERENT_DAY_IN_GROUP',
  ON_DIFFERENT_HMS_IN_GROUP = 'ON_DIFFERENT_HMS_IN_GROUP',
  ON_DIFFERENT_MONTH_IN_GROUP = 'ON_DIFFERENT_MONTH_IN_GROUP'
}

Custom Theme supported

This is an example of custom-theme that can be applied for instance via an ng-class directive to the container of the library. In this way you are redefine some variables that are defined and used inside the library and it is easier to override some properties

.custom-theme {
    --ngx-timeline-icon: black;
    --ngx-timeline-period-inner-container: black;
    --ngx-timeline-line-background: black;
}

Examples with contexts of custom templates

  <ng-template #periodCustomTemplate let-period=period let-index=index let-event=event>
    <div [ngClass]="{'transparent first-line': !index}" class="line"></div>
    <div class="period-container">
      <p>
        {{index}} - {{period | json}}
      </p>
    </div>
    <div class="line"></div>
  </ng-template>
  <ng-template #centerIconCustomTemplate let-index=index let-event=event>
    <div class="icon-container">
      <img src="assets/image.png">
    </div>
  </ng-template>
  <ng-template #innerEventCustomTemplate let-event=event>
    <div class="event" (click)="handleClick(event)">
      {{event | json}}
    </div>
  </ng-template>
  <ng-template #eventDescriptionCustomTemplate let-event=event>
    <p class="event-info-description">{{event?.eventInfo?.description}}</p>
  </ng-template>
  <ng-template #eventCustomTemplate let-event=event let-colSidePosition=colSidePosition>
    <div class="event" (click)="handleClick(event)">
      {{event | json}}
    </div>
  </ng-template>
  <ng-template #dateInstantCustomTemplate let-item=item>
    <span>
      {{item | json}}
    </span>
  </ng-template>

<br><br>

How to contribute

First of all, in order to track everything, open an issue describing the problem or a missing functionality you would like to add to the lib.

To start the contribution:

Every time you will change the code in your lib, any update will trigger the re-load of the app. When your code will be ready, create a Pull Request and put the link in a comment under the issue you opened before. Now is time to enjoy and start to code.

Thanks in advance for your contribution

How to deploy new version (for maintainers only)

After testing the fix or the new feature with 100% test coverage: