Skip to content

Commit b5b2d82

Browse files
committed
[update] draft for inbuilt timeline extra elements guide
1 parent dc634aa commit b5b2d82

File tree

2 files changed

+118
-9
lines changed

2 files changed

+118
-9
lines changed

data/desktop/baselines.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ Custom Elements in Timeline Area
66
dhtmlxGantt provides the [built-in functionality](desktop/inbuilt_baselines.md) that allows rendering such extra elements as baselines,
77
deadlines and task constraints by default. In case, you need to extend or modify the default features, you can add custom elements into timeline manually as described below.
88

9+
Displaying additional elements is usually done by creating a displayable layer and placing custom elements there
10+
(using the absolute positioning to put custom elements next to the related task).
11+
912
**To add one more layer to the timeline area**, use the api/gantt_addtasklayer.md method. As a parameter, the method takes a function that:
1013

1114
- Takes a task object;

data/desktop/inbuilt_baselines.md

Lines changed: 115 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@ By default, dhtmlxGantt renders elements of the timeline area as layers and does
99
1. Timeline's grid
1010
2. Links
1111
3. Tasks
12+
4. Additional elements
1213

13-
Displaying additional elements, such as a baseline or deadline marker, is usually done by creating a displayable layer and placing custom elements there
14-
(using the absolute positioning to put custom elements next to the related task).
14+
Gantt includes such built-in elements as baselines, deadlines and time constraints. Instead of the default extra elements,
15+
you can also [create custom ones as additional layers](desktop/baselines.md).
1516

1617
Baselines
1718
----------------
@@ -21,7 +22,58 @@ Gantt API provides built-in support for baseline entities, greatly simplifying t
2122

2223
![Inbuilt baselines](desktop/inbuilt_baselines.png)
2324

24-
### Loading Baselines with Tasks
25+
{{sample 04_customization/15_baselines.html}}
26+
27+
### Customizing baselines
28+
29+
In case, the default baselines functionality doesn't suit your project requirements, you can disable it using the api/gantt_baselines_config.md configuration option.
30+
31+
~~~js
32+
gantt.config.baselines = false;
33+
~~~
34+
35+
After that you can customize the display of baselines in one of the following ways:
36+
37+
1\. Using the **gantt.config.baselines** configuration object
38+
39+
The **baselines** configuration option also allows customizing the rendering of baselines in the Gantt chart when set as an object.
40+
The object configuration contains the following properties:
41+
42+
- **datastore** (*string*) - the name of the datastore used for storing baseline entries. For related functionality, see the `getDatastore` method.
43+
- **render_mode** (*boolean | string*) - determines how baselines are displayed:
44+
- `false` - baselines are not shown.
45+
- `"taskRow"` - baselines are displayed in the same row as the task bar.
46+
- `"separateRow"` - baselines are shown in a separate subrow, expanding the task row height.
47+
- `"individualRow"` - each baseline is displayed in its own subrow beneath the task.
48+
- **dataprocessor_baselines** (*boolean*) - specifies whether baseline updates trigger the DataProcessor as individual entries.
49+
- **row_height** (*number*) - defines the height of the subrow for baselines, applicable only when `render_mode` is set to `"separateRow"` or `"individualRow"`.
50+
- **bar_height** (*number*) - sets the height of the baseline bar.
51+
52+
For example:
53+
54+
~~~js
55+
gantt.config.baselines = {
56+
datastore: "baselines",
57+
render_mode: false,
58+
dataprocessor_baselines: false,
59+
row_height: 16,
60+
bar_height: 8
61+
};
62+
gantt.init("gantt_here");
63+
~~~
64+
65+
If you dynamically modify the display settings of the **gantt.config.baselines** config, you should use the api/gantt_adjusttaskheightforbaselines.md method
66+
for proper display of baseline elements.
67+
68+
~~~js
69+
const task = gantt.getTask(taskId);
70+
gantt.adjustTaskHeightForBaselines(task); /*!*/
71+
gantt.render();
72+
~~~
73+
74+
2\. [Creating a custom baseline element](desktop/baselines.md) for adding into the timeline.
75+
76+
### Loading baselines with tasks
2577

2678
Baselines can be loaded directly alongside tasks, streamlining data management and display. Check the example below:
2779

@@ -56,11 +108,38 @@ gantt.parse({
56108

57109
Once baselines are loaded, Gantt will automatically display them in the timeline without any additional configuration.
58110

59-
{{sample 04_customization/15_baselines.html}}
111+
### Getting task baselines
112+
113+
You can get the baselines of a particular task using the api/gantt_gettaskbaselines.md method.
114+
115+
~~~js
116+
gantt.getTaskBaselines(5);
117+
~~~
60118

61-
### Using the lightbox
119+
The method will return an array of baselines objects of the specified task from the datastore.
62120

63-
You can manage baselines via the lightbox control. Adding, editing and deleting baselines is avalable directly from the task details.
121+
~~~js
122+
[
123+
{
124+
task_id: 5,
125+
id: 1,
126+
duration: 2,
127+
start_date: "03-04-2019 00:00",
128+
end_date: "05-04-2019 00:00"
129+
},
130+
{
131+
task_id: 5,
132+
id: 2,
133+
duration: 1,
134+
start_date: "06-04-2019 00:00",
135+
end_date: "07-04-2019 00:00"
136+
}
137+
]
138+
~~~
139+
140+
### Baselines in the lightbox
141+
142+
You can manage baselines via the lightbox control. Adding, editing and deleting baselines is available directly from the task details.
64143

65144
~~~js
66145
gantt.config.lightbox.sections = [
@@ -72,7 +151,7 @@ gantt.config.lightbox.sections = [
72151

73152
![Baseline lightbox](desktop/baselines_lightbox.png)
74153

75-
### Baseline Rendering Modes
154+
### Baseline rendering modes
76155

77156
Gantt offers three modes for displaying baselines. You can choose the rendering mode that suits best for your needs
78157
by setting the **gantt.config.baselines.render_mode** configuration option to the corresponding value. There are three modes available:
@@ -107,12 +186,26 @@ gantt.config.baselines.render_mode = "individualRow";
107186

108187
![Individual row mode](desktop/baselines_individual_row.png)
109188

189+
### Setting baseline text
190+
191+
To specify a text that should be displayed inside the baseline element, use the api/gantt_baseline_text_template.md template:
192+
193+
~~~js
194+
gantt.templates.baseline_text = function(task, baseline, index) {
195+
return "Baseline #" + (index + 1);
196+
};
197+
~~~
198+
110199
Deadlines and constraints
111200
--------------------------
112201

113202
In project management, tracking deadlines and understanding task constraints are vital for timely delivery.
114203
DHTMLX Gantt comes with built-in visualization for deadlines and constraints, enhancing the ability to manage project timelines effectively.
115204

205+
![Deadlines](desktop/deadlines.png)
206+
207+
{{sample 04_customization/14_deadline.html}}
208+
116209
### Deadlines visualization
117210

118211
Gantt supports a numeric **task.deadline** field. When specified, it displays a visual indicator on the chart, thereby simplifying the tracking of task deadlines.
@@ -132,6 +225,19 @@ gantt.parse({
132225
});
133226
~~~
134227

135-
![Deadlines](desktop/deadlines.png)
228+
### Customizing deadlines
229+
230+
In case, the default deadlines functionality doesn't suit your project requirements, you can disable it using the api/gantt_deadlines_config.md configuration option.
231+
232+
~~~js
233+
gantt.config.deadlines = false;
234+
~~~
235+
236+
After that you can customize the display of deadlines by [creating a custom deadline element](desktop/baselines.md) for adding into the timeline.
237+
238+
The **gantt.config.deadlines** config enables or disables the display of deadline elements for tasks. If enabled, Gantt will check the **task.deadline** property,
239+
and if it contains a valid date, the deadline element will be displayed in the timeline.
240+
241+
242+
136243

137-
{{sample 04_customization/14_deadline.html}}

0 commit comments

Comments
 (0)