HTMLcopy
x
1
<script src="https://cdn.anychart.com/releases/8.10.0/js/anychart-core.min.js"></script>
2
<script src="https://cdn.anychart.com/releases/8.10.0/js/anychart-gantt.min.js"></script>
3
4
<script src="https://cdn.anychart.com/releases/8.10.0/js/anychart-data-adapter.min.js"></script>
5
6
<div id="container"></div>
CSScopy
7
1
html, body, #container {
2
width: 100%;
3
height: 100%;
4
margin: 0;
5
padding: 0;
6
}
7
JavaScriptcopy
47
1
anychart.onDocumentReady(function () {
2
anychart.data.loadJsonFile("https://gist.githubusercontent.com/shacheeswadia/21da3da501982400b8ca35690b17ea5a/raw/d17e3774c6db1502b5d95677a5656ecc43f24526/resourceChartData.json", function (data) {
3
4
// create a data tree
5
var treeData = anychart.data.tree(data, "as-tree");
6
7
// create a resource gantt chart
8
var chart = anychart.ganttResource();
9
10
// set the data
11
chart.data(treeData);
12
13
// fit the elements to the width of the timeline
14
chart.fitAll();
15
16
// set the position of the splitter to match the first column
17
chart.dataGrid().fixedColumns(true);
18
19
// enable and configure the chart title
20
var title = chart.title();
21
title.enabled(true);
22
title
23
.text("Tokyo 2020 Paralympic Schedule - Venues and Sports")
24
.fontSize(18)
25
.fontWeight(600)
26
.fontColor("#b32e3c")
27
.padding(10);
28
29
// customize the color of the bars
30
var elements = chart.getTimeline().elements();
31
elements.normal().fill("#e96a7b 0.75");
32
elements.normal().stroke("#db4e50");
33
34
// set the row height
35
chart.defaultRowHeight(25);
36
37
// set the header height
38
chart.headerHeight(95);
39
40
// set the container id
41
chart.container("container");
42
43
// draw the chart
44
chart.draw();
45
46
});
47
});