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 selection colors
15
chart.rowSelectedFill('#FFFFCC');
16
chart.getTimeline().selectedElementFill('#CCFF99');
17
18
// set start splitter position settings
19
chart.splitterPosition(150);
20
21
22
// get chart data grid link to set column settings
23
var dataGrid = chart.dataGrid();
24
25
// set first column settings
26
var firstColumn = dataGrid.column(0);
27
firstColumn.title('#');
28
firstColumn.width(30);
29
firstColumn.cellTextSettings().hAlign('center');
30
31
// set second column settings
32
var secondColumn = dataGrid.column(1);
33
secondColumn.title('Person');
34
secondColumn.width(120);
35
secondColumn.cellTextSettings().hAlign('left');
36
secondColumn.format(function (item) {
37
return item.get('name');
38
});
39
40
// initiate chart drawing
41
chart.draw();
42
43
// zoom chart to specified date
44
chart.fitAll();
45
});
46
47
function getData() {
48
// colors
49
var moccasin_border = '#B8AA96';
50
var moccasin_bottom = '#CFC0A9';
51
var moccasin_middle = '#E6D5BC';
52
var moccasin_top = '#E8D9C3';
53
54
var rosybrown_border = '#9B9292';
55
var rosybrown_bottom = '#AFA4A4';
56
var rosybrown_middle = '#C2B6B6';
57
var rosybrown_top = '#C8BDBD';
58
59
var brown_border = '#6B5D5D';
60
var brown_bottom = '#796868';
61
var brown_middle = '#867474';
62
var brown_top = '#928282';
63
64
return [
65
{
66
"id": "1",
67
"name": "Alex Exler",
68
"periods": [
69
{"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}]}}]
70
},
71
{
72
"id": "2",
73
"name": "Philip Kineyko",
74
"periods": [
75
{"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}]}},
76
{"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}]}}]
77
},
78
{
79
"id": "3",
80
"name": "Luke Liakos",
81
"periods": [
82
{"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}]}},
83
{"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}]}}]
84
},
85
{
86
"id": "4",
87
"name": "Judy Penfold",
88
"periods": [
89
{"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}]}},
90
{"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}]}}]
91
},
92
{
93
"id": "5",
94
"name": "Patricia Darmon",
95
"periods": [
96
{"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}]}},
97
{"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}]}}]
98
}
99
];
100
}