ResourceUtilization
View showing the utilization levels of the project resources. The resources are displayed in a summary list where each row can be expanded to show the events assigned for the resource.
This demo shows the Resource utilization widget:
//<code-header>
fiddle.title = 'Resource utilization';
//</code-header>
const resourceUtilization = new ResourceUtilization({
project : {
transport : {
load : {
url : 'data/SchedulerPro/examples/view/ResourceUtilization.json'
}
},
autoLoad : true
},
columns : [
{ type : 'tree', text : 'Name', field : 'name', width : 150 }
],
startDate : new Date(2020, 3, 26),
endDate : new Date(2020, 4, 15),
appendTo : targetElement,
rowHeight : 40,
tickSize : 40,
minHeight : '20em',
// display tooltip
showBarTip : true
});The view requires a Project instance to be provided:
const project = new ProjectModel({
autoLoad : true,
transport : {
load : {
url : 'examples/schedulerpro/view/data.json'
}
}
});
const resourceUtilization = new ResourceUtilization({
project,
appendTo : 'targetDiv',
rowHeight : 60,
minHeight : '20em',
flex : '1 1 50%',
showBarTip : true
});
Pairing the component
You can also pair the view with other timeline views such as the Gantt or Scheduler, using the partner config.
Changing displayed values
To change the displayed bar texts, supply a getBarText function. Here for example the provided function displays resources time left instead of allocated time
new ResourceUtilization({
getBarText(datum) {
const view = this.owner;
// get default bar text
let result = view.getBarTextDefault(...arguments);
// For resource records we will display the time left for allocation
if (result && datum.resource) {
const unit = view.getBarTextEffortUnit();
// display the resource available time
result = view.getEffortText(datum.maxEffort - datum.effort, unit);
}
return result;
},
})
Configs
246
Configs
246Common
Other
A Function which returns the tooltip text to display when hovering a bar. The following parameters are passed:
| Parameter | Type | Description |
|---|---|---|
data | Object | The backing data of the histogram rectangle |
data.rectConfig | Object | The rectangle configuration object |
data.datum | Object | The hovered bar data |
data.index | Number | The index of the hovered bar data |
data.record | ResourceUtilizationModel | The record which effort the hovered bar displays. |
Tooltip HTML content
A Function which returns a CSS class name to add to a rectangle element. The following parameters are passed:
| Parameter | Type | Description |
|---|---|---|
series | HistogramSeries | The series being rendered |
domConfig | DomConfig | The rectangle configuration object |
datum | ResourceAllocationInterval | AssignmentAllocationInterval | The datum being rendered. Either ResourceAllocationInterval object for resource records (root level records) or AssignmentAllocationInterval object for assignment records |
index | Number | The index of the datum being rendered |
renderData | ResourceUtilizationRenderData | Current render data giving access to the record, row and cell being rendered. |
CSS classes of the rectangle element
A Function which if provided returns DOM configuration object for a bar
(a RECT element representing a single "bar"-type value).
The function accepts default prepared DOM configuration
in an argument which then can be processed and returned.
new ResourceUtilization({
// Let's add left & right margins to bars
getBarDOMConfig(series, domConfig) {
// margin size is 10% of the bar width
const xMargin = 0.1 * domConfig.width;
// adjust the bar x-coordinate
domConfig.x += xMargin;
// reduce the bar width respectively
domConfig.width -= 2 * xMargin;
// return the edited domConfig
return domConfig;
},
...
})
this will refer to the
Histogram instance, not this class instance.
To access the view please use this.owner in the function:
new ResourceUtilization({
getBarText(datum) {
// "this" in the method refers core Histogram instance
// get the view instance
const resourceUtilization = this.owner;
.....
},
...
})
The following parameters are passed:
| Parameter | Type | Description |
|---|---|---|
series | HistogramSeries | The series being rendered |
domConfig | DomConfig | The rectangle DOM configuration object |
datum | ResourceAllocationInterval | AssignmentAllocationInterval | The datum being rendered. Either ResourceAllocationInterval object for resource records (root level records) or AssignmentAllocationInterval object for assignment records |
index | Number | The index of the datum being rendered |
renderData | ResourceUtilizationRenderData | Current render data giving access to the record, row and cell being rendered. |
Resulting DOM configuration object. If no value returned the bar is not displayed.
A Function which returns the text to render inside a bar.
Here for example the provided function displays resources time left instead of allocated time
new ResourceUtilization({
getBarText(datum) {
const resourceUtilization = this.owner;
// get default bar text
let result = view.getBarTextDefault();
// For resource records we will display the time left for allocation
if (result && datum.resource) {
const unit = resourceUtilization.getBarTextEffortUnit();
// display the resource available time
result = resourceUtilization.getEffortText(datum.maxEffort - datum.effort, unit);
}
return result;
},
})
Please note that the function will be injected into the underlying
Histogram component that is used under the hood
to render actual charts.
So this in the function will refer to the Histogram instance.
To access the ResourceUtilization instance please use this.owner in the function body:
new ResourceUtilization({
getBarText(datum) {
// "this" in the method refers core Histogram instance
// get the view instance
const view = this.owner;
.....
},
})
The following parameters are passed:
| Parameter | Type | Description |
|---|---|---|
datum | ResourceAllocationInterval | AssignmentAllocationInterval | The datum being rendered. Either ResourceAllocationInterval object for resource records (root level records) or AssignmentAllocationInterval object for assignment records |
index | Number | The index of the datum being rendered |
Text to render inside the bar
A Function which returns a DOM configuration object for text elements.
new ResourceUtilization({
getBarTextDOMConfig(domConfig, datum, index) {
// change text vertical location
domConfig.y = '10%';
return domConfig;
},
...
})
this will refer to the Histogram instance, not
this class instance.
To access the view please use this.owner in the function:
new ResourceUtilization({
getBarTextDOMConfig(domConfig) {
// "this" in the method refers core Histogram instance
// get the view instance
const resourceUtilization = this.owner;
.....
return domConfig;
},
...
})
The following parameters are passed:
| Parameter | Type | Description |
|---|---|---|
domConfig | DomConfig | The |
datum | ResourceAllocationInterval | AssignmentAllocationInterval | The datum being rendered. Either ResourceAllocationInterval object for resource records (root level records) or AssignmentAllocationInterval object for assignment records |
index | Number | The index of the datum being rendered |
series | HistogramSeries | The series (provided if histogram widget
singleTextForAllBars is |
renderData | ResourceUtilizationRenderData | Current render data giving access to the record, row and cell being rendered. |
The TEXT element DOM configuration object. If no value returned the text element is not
displayed.
A ProjectModel instance (or a config object) to display resource allocation of.
Note: This config is mandatory.
Set to true if you want to display resources effort values in bars
(for example: 24h, 7d, 60min etc.).
The text contents can be changed by providing getBarText function.
Content
CSS
Data
Dates
DOM
Float & align
Layout
Masking
misc
Misc
Parent histogram data collecting
Resources
Scale column
Scheduled events
State
Time axis
Tree
Zoom
Properties
210
Properties
210Common
Class hierarchy
CSS
Data
Dates
DOM
Infinite scroll
Layout
Misc
Other
Scale column
Scheduled events
Scrolling
Selection
State
Time axis
Tree
Widget hierarchy
Functions
179
Functions
179Other
The view store records wrap "real" resources and assignments. This method resolves a record to its original record resource or assignment. If the record does not wrap any record (happens for example for parent records when using TreeGroup feature) then the method returns the record itself.
| Parameter | Type | Description |
|---|---|---|
record | ResourceUtilizationModel | The view store record |
Original model
Configuration
Data
Dates
Events
Getters
Misc
Parent histogram data collecting
Rendering
Rows
Scrolling
Selection
Widget hierarchy
Zoom
Events
65
Events
65Event handlers
65
Event handlers
65Typedefs
21
Typedefs
21ResourceUtilization renderer parameters.
| Parameter | Type | Description |
|---|---|---|
histogramData | Object | Histogram data |
histogramConfig | HistogramConfig | Configuration object for the histogram widget |
cellElement | HTMLElement | null | Cell element, for adding CSS classes, styling etc.
Can be |
record | ResourceModel | Record for the row |
column | TimeAxisColumn | Owning TimeAxisColumn column |
grid | ResourceUtilization | Owning ResourceUtilization instance |
row | Row | Row object. Can be null in case of export. Use the row's API to manipulate CSS class names. |