HTMLcopy
1
<label for="monthSelect">Fiscal Year - Starting Month: </label>
2
<select id="monthSelect" onchange="fiscalYear()">
3
<option value="1" selected>1 / January</option>
4
<option value="2">2 / February</option>
5
<option value="3">3 / March</option>
6
<option value="4">4 / April</option>
7
<option value="5">5 / May</option>
8
<option value="6">6 / June</option>
9
<option value="7">7 / July</option>
10
<option value="8">8 / August</option>
11
<option value="9">9 / September</option>
12
<option value="10">10 / October</option>
13
<option value="11">11 / November</option>
14
<option value="12">12 / December</option>
15
</select>
16
<div id="container"></div>
CSScopy
16
1
html, body {
2
width: 100%;
3
height: 100%;
4
margin: 0;
5
padding: 0;
6
}
7
label {
8
display: inline-block;
9
margin: 10px 0 0 10px;
10
}
11
#container {
12
position: absolute;
13
width: 100%;
14
top: 40px;
15
bottom: 0;
16
}
JavaScriptcopy
x
1
anychart.onDocumentReady(function () {
2
3
// create data
4
var data = [
5
{
6
id: "1",
7
name: "Development",
8
actualStart: "2018-01-10",
9
actualEnd: "2018-12-05",
10
children: [
11
{
12
id: "1_1",
13
name: "Analysis",
14
actualStart: "2018-01-10",
15
actualEnd: "2018-04-01"
16
},
17
{
18
id: "1_2",
19
name: "Design",
20
actualStart: "2018-04-02",
21
actualEnd: "2018-07-01"
22
},
23
{
24
id: "1_3",
25
name: "Meeting",
26
actualStart: "2018-07-02",
27
actualEnd: "2018-07-02"
28
},
29
{
30
id: "1_4",
31
name: "Implementation",
32
actualStart: "2018-07-03",
33
actualEnd: "2018-10-01"
34
},
35
{
36
id: "1_5",
37
name: "Testing",
38
actualStart: "2018-10-02",
39
actualEnd: "2018-12-05"
40
}
41
]}
42
];
43
44
// create a data tree
45
var treeData = anychart.data.tree(data, "as-tree");
46
47
// create a chart
48
chart = anychart.ganttProject();
49
50
// set the data
51
chart.data(treeData);
52
53
// set the maximum value of the scale
54
chart.getTimeline().scale().maximum("2018-12-31");
55
56
// set the container id
57
chart.container("container");
58
59
// initiate drawing the chart
60
chart.draw();
61
62
// fit elements to the width of the timeline
63
chart.fitAll();
64
});
65
66
// set the starting month of the fiscal year
67
function fiscalYear() {
68
var month = document.getElementById("monthSelect").value;
69
chart.getTimeline().scale().fiscalYearStartMonth(month);
70
}