PercentBar

This feature visualizes the percentDone field as a progress bar on the event elements. Each progress bar also optionally has a drag handle which users can drag can change the value.

You can customize data source for the feature with valueField and displayField configs.

Percent bar
//<code-header>
fiddle.title = 'Percent bar';
//</code-header>
const schedulerPro = new SchedulerPro({
    appendTo : targetElement,

    // makes scheduler as high as it needs to be to fit rows
    autoHeight : true,

    startDate : new Date(2022, 2, 23),
    endDate   : new Date(2022, 2, 28),

    columns : [
        { field : 'name', text : 'Name', width : 100 }
    ],

    features : {
        percentBar : true
    },

    project : {
        resources : [
            { id : 1, name : 'George', eventColor : 'blue' },
            { id : 2, name : 'Rob', eventColor : 'green' }
        ],

        events : [
            {
                id          : 1,
                name        : 'Project X',
                startDate   : '2022-03-24',
                duration    : 4,
                percentDone : 80
            },
            {
                id          : 2,
                name        : 'Customer Project Y',
                startDate   : '2022-03-23T13:00',
                duration    : 4,
                percentDone : 40
            }
        ],
        assignments : [
            { id : 1, event : 1, resource : 1 },
            { id : 2, event : 2, resource : 2 }
        ]
    }
});

Restricting resizing for certain tasks

You can prevent certain tasks from having their percent done value changed by overriding the isEditable method on your EventModel or TaskModel.

class MyTaskModel extends TaskModel {
    isEditable(field) {
        // Add any condition here, `this` refers to the a task instance
        return this.field !== 'percentDone' && super.isEditable(field);
    }
};

gantt = new Gantt({
    project : {
        taskModelClass : MyTaskModel
    }
});

This feature is enabled by default in Gantt, but off by default in Scheduler Pro.

Configs

14

Common

disabledInstancePlugin
listenersEvents

Other

allowResize: Boolean= true

true to allow drag drop resizing to set the % done

displayField: String= renderedPercentDone

Field name to use to display the value

instantUpdate: Boolean= true

By default, the underlying task record is updated live as the user drags the handle. Set to false to only update the record upon drop.

showPercentage: Boolean= true

true to show a small % done label within the event while drag changing its value

valueField: String= percentDone

Field name to use as the data source

Misc

clientInstancePlugin
localeClassLocalizable
localizableLocalizable

Properties

15

Common

disabledInstancePlugin

Class hierarchy

isPercentBar: Boolean= truereadonly
Identifies an object as an instance of PercentBar class, or subclass thereof.
isPercentBar: Boolean= truereadonlystatic
Identifies an object as an instance of PercentBar class, or subclass thereof.
isEventsEvents
isInstancePluginInstancePlugin
isLocalizableLocalizable

Lifecycle

configBase

Misc

clientInstancePlugin
localeHelperLocalizable
localeManagerLocalizable

Other

Functions

28

Configuration

applyDefaultsstaticBase

Events

Lifecycle

destroystaticBase

Misc

doDisableInstancePlugin
initClassstaticBase
isOfTypeNamestaticBase
mixinstaticBase
optionalLstaticLocalizable

Other

LstaticLocalizable
onEvents
relayAllEvents
triggerEvents
unEvents

Events

9

Fired on the owning Scheduler or Gantt widget when dragging the percent bar

// Adding a listener using the "on" method
percentBar.on('percentBarDrag', ({ source, taskRecord, domEvent }) => {

});
ParameterTypeDescription
sourceTimelineBase

SchedulerPro or Gantt instance

taskRecordModel

The task record

domEventMouseEvent

Browser event

Fired on the owning Scheduler or Gantt widget if a percent bar drag-drop operation is aborted

// Adding a listener using the "on" method
percentBar.on('percentBarDragAbort', ({ source, taskRecord, domEvent }) => {

});
ParameterTypeDescription
sourceTimelineBase

SchedulerPro instance

taskRecordModel

The task record

domEventMouseEvent

Browser event

Fired on the owning Scheduler or Gantt widget when percent bar dragging starts

// Adding a listener using the "on" method
percentBar.on('percentBarDragStart', ({ source, taskRecord, domEvent }) => {

});
ParameterTypeDescription
sourceTimelineBase

SchedulerPro or Gantt instance

taskRecordModel

The task record

domEventMouseEvent

Browser event

Fired on the owning Scheduler or Gantt widget when dropping the percent bar

// Adding a listener using the "on" method
percentBar.on('percentBarDrop', ({ source, taskRecord, domEvent }) => {

});
ParameterTypeDescription
sourceTimelineBase

SchedulerPro or Gantt instance

taskRecordModel

The task record

domEventMouseEvent

Browser event

catchAllEvents
destroyEvents
disableInstancePlugin
enableInstancePlugin

Event handlers

9

Called on the owning Scheduler or Gantt widget when dragging the percent bar

new PercentBar({
    onPercentBarDrag({ source, taskRecord, domEvent }) {

    }
});
ParameterTypeDescription
sourceTimelineBase

SchedulerPro or Gantt instance

taskRecordModel

The task record

domEventMouseEvent

Browser event

Called on the owning Scheduler or Gantt widget if a percent bar drag-drop operation is aborted

new PercentBar({
    onPercentBarDragAbort({ source, taskRecord, domEvent }) {

    }
});
ParameterTypeDescription
sourceTimelineBase

SchedulerPro instance

taskRecordModel

The task record

domEventMouseEvent

Browser event

Called on the owning Scheduler or Gantt widget when percent bar dragging starts

new PercentBar({
    onPercentBarDragStart({ source, taskRecord, domEvent }) {

    }
});
ParameterTypeDescription
sourceTimelineBase

SchedulerPro or Gantt instance

taskRecordModel

The task record

domEventMouseEvent

Browser event

Called on the owning Scheduler or Gantt widget when dropping the percent bar

new PercentBar({
    onPercentBarDrop({ source, taskRecord, domEvent }) {

    }
});
ParameterTypeDescription
sourceTimelineBase

SchedulerPro or Gantt instance

taskRecordModel

The task record

domEventMouseEvent

Browser event

onDestroyEvents
onDisableInstancePlugin
onEnableInstancePlugin

Typedefs

1

CSS variables

4
NameDescription
--b-percent-bar-z-indexPercent bar z-index
--b-percent-bar-blend-modePercent bar blend mode
--b-percent-bar-handle-text-colorPercent bar handle text color
--b-percent-bar-backgroundPercent bar background. Note that for color-mix to work, this var is defined on .b-task-percent-bar