Big Gantt charts

Synchronizing multiple graphics

In this article, we will discover a step-by-step implementation on how to use the ScheduleJS API to synchronize multiple graphics together and use a single timeline for two or more graphics.

Thursday, August 3rd, 2023 - 4 minutes read

Step 1: Define our objective

To keep things simple let’s set our objective first:

  • We want to combine two instances of our <demo-schedule-booking> demonstration component. This component is capable of displaying a ScheduleJS Gantt chart.

Note that the same approach can be used with two completely different graphics.

Step 2: Create a higher-order ‘dual-gantt’ component

A good idea is to use a containerized version of our graphics to be able to handle the display of multiple graphics with ease, using components.

Now let’s start by creating a dual-gantt component and try out our <demo-schedule-booking> component.

Fow now, if our <demo-schedule-booking> component is functional, our dual-gantt component will display the following screen, which is in fact identical to the original component. 

Complex example of gantt charts

Now we can create a <div> and use our  <demo-schedule-booking> component twice in our brand new dual-gantt component:

We added CSS classes to properly display one graphic above the other and separate them with a border. Here, the gantts-container class handles the display while the first-gantt and the second-gantt classes handle specificities, like the separation border.

We now have two unsynchronized graphics inside our new dual-gantt component:

Complex example of gantt charts

To further improve the display, we adapted our <demo-schedule-booking> component to accept two new input properties:

  • displayTimeline: True by default, as we are going to use a single timeline, it is not necessary to repeat the timeline in both graphics.
  • displayButtonBar: True by default, will let us hide the button bar to only keep one button bar for both graphics.

As a ScheduleJS Gantt component, <demo-schedule-booking> also accepts additional inputs by default. Here we will use the dragToResizeInfoColumnPrevented input property to prevent any individual info-column resize for both graphics. The result should get rid of the button bar and timeline for the second graphics:

Complex example of gantt charts

Step 3: Share a single timeline object

We want to create a new timeline object and pass it down to our graphics once our dual-gantt component mounts. Here is the source code of our dual-gantt component:

Now we have to pass down our new timeline object as an input to our <demo-schedule-booking> ScheduleJS Gantt component in the dual-gantt component template:

Step 4: Register the timeline using the ScheduleJS API

The last step is to register the timeline in the <demo-schedule-booking> component.

To do so, we decided to create a setter method, which will run the registration code when the input is passed down to the component:

Final result

The following video shows the synchronized graphics:

This example is just a simple implementation of synchronized graphics. The goal of this article is to illustrate how you can quickly combine multiple graphics to build a unique screen. You can use the same principles to combine different kinds of graphics (histogram, Gantt, curve) as we do in the ScheduleJS Viewer for example! 

Please contact us if you have any UX/UI challenges or ideas for ScheduleJS!

More Implementation-related articles

Build custom tree tables in ScheduleJS using schedule-info-column-header-cell and schedule-info-column-row-cell components.

Big Gantt charts

Unlock flexible row management in ScheduleJS: control individual row heights, mix GanttLayout and ChartLayout in the same view.

JS Gantt charts Screenshot

Master drag and drop in ScheduleJS: render activities while dragging, access the drag canvas via DragViewTransversalSystemLayers.

ScheduleJS Logo

ScheduleJS 1.4 release notes. A step forward towards modern Angular app building.

Angular 16 vs Angular 18 comparison: discover what's new in Angular, the arrival of signals, Zoneless mode, zone coalescing, and their impact on your projects.

Discover the Angular Rome Conference: workshops, domain-driven design, signals, state management, micro frontends.

Discover Angular 18: zoneless mode, zone coalescing, native await, and TypeScript 5.4 compatibility.

Gantt Charts

The TOP 3 JavaScript Gantt chart. Discover their features, advantages, and disadvantages to choose the best tool for your project.

sceenschot example appli Gantt charts

Discover how ScheduleJS seamlessly integrated with Selligent CRM, enhancing scheduling efficiency for a leading beauty brand's consultants.

JS Gantt charts example

This article showcases the integration of a ScheduleJS component into an external Ag-Grid table, to demonstrate the flexibility of ScheduleJS.

S’abonner
Notification pour
guest
0 Commentaires
Commentaires
Show all comments
0
We would love to to have your toughts on this. Please leave a comment below!x