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
// create data tree on our data
3
var treeData = anychart.data.tree(getData(), anychart.enums.TreeFillingMethod.AS_TABLE);
4
5
// create resource gantt chart
6
var chart = anychart.ganttResource();
7
8
// set container id for the chart
9
chart.container('container');
10
11
// set data for the chart
12
chart.data(treeData);
13
14
//set DataGrid and TimeLine visual settings
15
chart.dataGrid().rowOddFill('#fff');
16
chart.dataGrid().rowEvenFill('#fff');
17
chart.getTimeline().rowOddFill('#fff');
18
chart.getTimeline().rowEvenFill('#fff');
19
20
chart.listen('rowSelect', function(e) {
21
e.item.remove();
22
});
23
24
chart.rowSelectedFill('#D4DFE8');
25
chart.rowHoverFill('#EAEFF3');
26
27
// set start splitter position settings
28
chart.splitterPosition(150);
29
30
31
// get chart data grid link to set column settings
32
var dataGrid = chart.dataGrid();
33
34
// set first column settings
35
var firstColumn = dataGrid.column(0);
36
firstColumn.title('#');
37
firstColumn.width(30);
38
firstColumn.cellTextSettings().hAlign('center');
39
40
// set second column settings
41
var secondColumn = dataGrid.column(1);
42
secondColumn.title('Person');
43
secondColumn.width(120);
44
secondColumn.cellTextSettings().hAlign('left');
45
secondColumn.format(function (item) {
46
return item.get('name');
47
});
48
49
// initiate chart drawing
50
chart.draw();
51
52
// zoom chart to specified date
53
chart.fitAll();
54
});
55
56
function getData() {
57
// colors
58
var moccasin_border = '#B8AA96';
59
var moccasin_bottom = '#CFC0A9';
60
var moccasin_middle = '#E6D5BC';
61
var moccasin_top = '#E8D9C3';
62
63
var rosybrown_border = '#9B9292';
64
var rosybrown_bottom = '#AFA4A4';
65
var rosybrown_middle = '#C2B6B6';
66
var rosybrown_top = '#C8BDBD';
67
68
var brown_border = '#6B5D5D';
69
var brown_bottom = '#796868';
70
var brown_middle = '#867474';
71
var brown_top = '#928282';
72
73
return [
74
{
75
"id": "1",
76
"name": "Alex Exler",
77
"periods": [
78
{"id": "1_1", "start": 1171468800000, "end": 1171987200000, "stroke": moccasin_border, "fill": {"angle": 90, "keys": [{"color": moccasin_bottom, "position": 0}, {"color": moccasin_middle, "position": 0.38}, {"color": moccasin_top, "position": 1}]}}]
79
},
80
{
81
"id": "2",
82
"name": "Philip Kineyko",
83
"periods": [
84
{"id": "2_1", "start": 1173024000000, "end": 1173715200000, "stroke": rosybrown_border, "fill": {"angle": 90, "keys": [{"color": rosybrown_bottom, "position": 0}, {"color": rosybrown_middle, "position": 0.38}, {"color": rosybrown_top, "position": 1}]}},
85
{"id": "2_2", "start": 1173888000000, "end": 1174406400000, "stroke": moccasin_border, "fill": {"angle": 90, "keys": [{"color": moccasin_bottom, "position": 0}, {"color": moccasin_middle, "position": 0.38}, {"color": moccasin_top, "position": 1}]}}]
86
},
87
{
88
"id": "3",
89
"name": "Luke Liakos",
90
"periods": [
91
{"id": "3_1", "start": 1169740800000, "end": 1170172800000, "stroke": moccasin_border, "fill": {"angle": 90, "keys": [{"color": moccasin_bottom, "position": 0}, {"color": moccasin_middle, "position": 0.38}, {"color": moccasin_top, "position": 1}]}},
92
{"id": "3_2", "start": 1171987200000, "end": 1172505600000, "stroke": moccasin_border, "fill": {"angle": 90, "keys": [{"color": moccasin_bottom, "position": 0}, {"color": moccasin_middle, "position": 0.38}, {"color": moccasin_top, "position": 1}]}}]
93
},
94
{
95
"id": "4",
96
"name": "Judy Penfold",
97
"periods": [
98
{"id": "4_1", "start": 1171814400000, "end": 1172419200000, "stroke": moccasin_border, "fill": {"angle": 90, "keys": [{"color": moccasin_bottom, "position": 0}, {"color": moccasin_middle, "position": 0.38}, {"color": moccasin_top, "position": 1}]}},
99
{"id": "4_2", "start": 1173628800000, "end": 1174320000000, "stroke": moccasin_border, "fill": {"angle": 90, "keys": [{"color": moccasin_bottom, "position": 0}, {"color": moccasin_middle, "position": 0.38}, {"color": moccasin_top, "position": 1}]}}]
100
},
101
{
102
"id": "5",
103
"name": "Patricia Darmon",
104
"periods": [
105
{"id": "5_1", "start": 1171296000000, "end": 1171382400000, "stroke": moccasin_border, "fill": {"angle": 90, "keys": [{"color": moccasin_bottom, "position": 0}, {"color": moccasin_middle, "position": 0.38}, {"color": moccasin_top, "position": 1}]}},
106
{"id": "5_2", "start": 1174233600000, "end": 1174579200000, "stroke": moccasin_border, "fill": {"angle": 90, "keys": [{"color": moccasin_bottom, "position": 0}, {"color": moccasin_middle, "position": 0.38}, {"color": moccasin_top, "position": 1}]}}]
107
}
108
];
109
}