TimelineChart
Feature
This feature allows drawing line charts on top of the timeline area. Feature consists of two parts: chart and data providers. Chart provider is responsible for rendering the chart, while data provider is responsible for providing data for the chart. Feature itself manages the interaction between them, and tracks lifecycle events of the Gantt chart.
targetElement.innerHTML = '<p>This demo shows the timeline chart feature</p>'; const gantt = new Gantt({ appendTo : targetElement, height : 350, startDate : '2019-07-07', endDate : '2019-07-29', features : { timelineChart : true }, rowHeight : 60, project : new ProjectModel({ startDate : '2019-07-07', duration : 30, events : [ { id : 1, name : 'Project A', duration : 30, expanded : true, children : [ { id : 11, name : 'Child 1', duration : 1, leaf : true, rollup : true, cls : 'child1' }, { id : 12, name : 'Child 2', duration : 3, leaf : true, rollup : true, cls : 'child1' }, { id : 13, name : 'Child 3', duration : 0, rollup : true, leaf : true, cls : 'child1' } ] } ], dependencies : [{ id : 1, lag : 1, fromEvent : 11, toEvent : 12 }, { id : 2, lag : 1, fromEvent : 12, toEvent : 13 }] }) }); Default implementation uses SVGChartProvider for rendering the chart using SVG elements, and GanttDataProvider as a data source. Those can be replaced and customized by setting the chartProviderClass and dataProviderClass configs. Custom implementation should subclass corresponding base classes: TimelineChartProviderBase, TimelineChartDataProviderBase and implement required methods.
For more information on how to create custom chart provider, see this guide.
Feature will track timeline element resize and scroll and notify the chart provider about them. Chart element normally would be repositioned vertically to always stay in the view. And horizontally it will be scrollable along with the timeline.
Feature will also track project model and time axis view model changes to request data for the chart from the data provider and pass it to the chart provider for rendering.
Simple usage example:
// Simple configuration
const gantt = new Gantt({
features : {
timelineChart : true
}
});
Chart and data providers can be configured separately.
const gantt = new Gantt({
features : {
timelineChart : {
chartConfig : {
tooltipTemplate : function({ dataset, date }) {
return `
<div>${dataset.label}: ${DateHelper.as('d', parseInt(dataset.value))} days</div>
<div>${DateHelper.format(date, this.gantt.displayDateFormat)}</div>
`;
}
},
dataProviderConfig : {
defaultDataset : 'progress'
}
}
}
});
This feature is disabled by default.
Configs
Configs are options you supply in a configuration object when creating an instance of this class-
Configuration for the chart provider.
-
Class providing chart rendering functionality.
-
Configuration for the data provider.
-
Class providing data for the chart.
-
Datasets to be displayed on the chart. Available datasets should be returned by the datasets accessor of the data provider. Changing this property will trigger chart repaint with the new dataset. Set to empty array to not draw anything.
Has a corresponding runtime selectedDatasets property.
-
Internal listeners, that cannot be removed by the user.
-
The widget which this plugin is to attach to.
Has a corresponding runtime client property.
-
Set to
falseto disable localization of this object.
Properties
Properties are getters/setters or publicly accessible variables on this class-
Identifies an object as an instance of AttachToProjectMixin class, or subclass thereof.
-
Identifies an object as an instance of Events class, or subclass thereof.
-
Identifies an object as an instance of Localizable class, or subclass thereof.
-
Identifies an object as an instance of TimelineChart class, or subclass thereof.
-
A class property getter for the default values of internal properties for this class.
-
Returns metadata for datasets available in the data provider.
-
An empty array that can be used as a default value.
-
An empty object that can be used as a default value.
-
Datasets to be displayed on the chart. Available datasets should be returned by the datasets accessor of the data provider. Changing this property will trigger chart repaint with the new dataset. Set to empty array to not draw anything.
Has a corresponding selectedDatasets config.
-
Identifies an object as an instance of InstancePlugin class, or subclass thereof.
-
Identifies an object as an instance of TimelineChart class, or subclass thereof.
-
Returns a copy of the full configuration which was used to configure this object.
-
This property is set to
truebefore theconstructorreturns. -
This property is set to
trueon entry to the destroy method. It remains on the objects after returning fromdestroy(). If isDestroyed istrue, this property will also betrue, so there is no need to test for both (for example,comp.isDestroying || comp.isDestroyed). -
The Widget which was passed into the constructor, which is the Widget we are providing extra services for.
Has a corresponding client config.
-
Get the global LocaleHelper
-
Get the global LocaleManager
Functions
Functions are methods available for calling on the class-
This optional class method is called when a class is mixed in using the mixin() method.
-
Registers this class type with its Factory
-
Internal function used to hook destroy() calls when using thisObj
-
Internal function used restore hooked destroy() calls when using thisObj
-
Auto detaches listeners registered from start, if set as detachable
-
Internal function used to run a callback function after an event is triggered
-
Removes all listeners registered to this object by the application.
-
This will merge a feature's (subclass of InstancePlugin) keyMap with it's client's keyMap.