HTMLcopy
1
<div id="container"></div>
CSScopy
6
1
html, body, #container {
2
width: 100%;
3
height: 100%;
4
margin: 0;
5
padding: 0;
6
}
JavaScriptcopy
x
1
anychart.onDocumentReady(function () {
2
var data = getData();
3
4
var chart = anychart.ganttProject();
5
chart.data(data, 'as-table');
6
7
var buttons = chart.dataGrid().buttons();
8
buttons.hovered().background(false);
9
10
// Create custom drawing functions.
11
var contentFunction = function (path) {
12
// Draw different primitives or anything else depending on the state.
13
var half = this.width / 2;
14
switch (this.state) {
15
case 'normal':
16
fill = '#dd2c00';
17
anychart.graphics.vector.primitives.diagonalCross(path.clear(), half, half, half).fill(fill);
18
break;
19
case 'hovered':
20
fill = anychart.color.lighten('#dd2c00');
21
anychart.graphics.vector.primitives.diagonalCross(path.clear(), half, half, half).fill(fill);
22
break;
23
case 'selected':
24
fill = '#00bfa5';
25
anychart.graphics.vector.primitives.cross(path.clear(), half, half, half).fill(fill);
26
break;
27
}
28
};
29
30
var normal = buttons.normal();
31
normal.background(false);
32
33
// Set content function.
34
normal.content(contentFunction);
35
36
var selected = buttons.selected();
37
selected.background(false);
38
39
// Set content function.
40
selected.content(contentFunction);
41
42
chart.title('Custom expand/collapse buttons \n Set content parameter as a function');
43
chart.container('container');
44
chart.draw();
45
chart.fitAll();
46
});
47
function getData() {
48
return [
49
{id: 1, name: 'Phase 1 - Strategic Plan', progressValue: 0.14, actualStart: '2000-02-24', actualEnd: '2000-02-27'},
50
{id: 2, name: 'Self-Assessment', parent: 1, progressValue: 0.25, actualStart: '2000-02-24', actualEnd: '2000-02-29', collapsed: true},
51
{id: 3, name: 'Define business vision', parent: 2, progressValue: 0, actualStart: '2000-02-24T24:00', actualEnd: '2000-02-25T09:00', connectTo: 4},
52
{id: 4, name: 'Identify available skills, information and support', parent: 2, progressValue: 0, actualStart: '2000-02-26T00:00', actualEnd: '2000-02-26T09:00', connectTo: 5},
53
{id: 5, name: 'Decide whether to proceed', parent: 2, progressValue: 0, actualStart: '2000-02-27', actualEnd: '2000-02-28T08:00', connectTo: 6},
54
{id: 6, name: 'Define the Opportunity', parent: 1, progressValue: 0.27, actualStart: '2000-02-28T08:00', actualEnd: '2000-02-29', collapsed: true},
55
{id: 7, name: 'Research the market and competition', parent: 6, progressValue: 0, actualStart: '2000-02-26T08:00', actualEnd: '2000-02-27'}
56
];
57
}