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
var data = [
3
{id: "1", optimistic: 1, pessimistic: 10, mostLikely: 6, name: "A"},
4
{id: "2", optimistic: 3, pessimistic: 8, mostLikely: 5, name: "B"},
5
{id: "3", optimistic: 1, pessimistic: 4, mostLikely: 3, name: "D"},
6
{id: "4", optimistic: 2, pessimistic: 12, mostLikely: 5, name: "AD", dependsOn: ["1", "3"]},
7
{id: "5", optimistic: 4, pessimistic: 16, mostLikely: 10, name: "BC", dependsOn: ["2", "3"]}
8
];
9
10
var chart = anychart.pert();
11
chart.data(data, "as-table");
12
13
tasks = chart.tasks();
14
15
// set vertical spacing between tasks
16
chart.verticalSpacing("20%");
17
18
// Set expected time
19
chart.expectedTimeCalculator(function () {
20
return (this.pessimistic + this.optimistic + this.mostLikely)/3;
21
});
22
23
// get project duration
24
var duration = chart.getStat("pertChartProjectDuration");
25
26
// set the chart title to show the duration
27
chart.title("The duration equals " + duration);
28
chart.container("container");
29
chart.draw();
30
});