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