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
3
// create data
4
var data = [
5
{id: "A", optimistic: 1, pessimistic: 10, mostLikely: 6, name: "A"},
6
{id: "AB", optimistic: 2, pessimistic: 4, mostLikely: 3, name: "AB", dependsOn: ["A"]},
7
{id: "AC", optimistic: 3, pessimistic: 8, mostLikely: 6, name: "AC", dependsOn: ["A"]},
8
{id: "BD", optimistic: 2, pessimistic: 12, mostLikely: 5, name: "BD", dependsOn: ["AB"]},
9
{id: "CE", optimistic: 2, pessimistic: 12, mostLikely: 6, name: "CE", dependsOn: ["AC"]},
10
{id: "DF", optimistic: 4, pessimistic: 18, mostLikely: 12, name: "DF", dependsOn: ["BD"]},
11
{id: "EF", optimistic: 3, pessimistic: 10, mostLikely: 5, name: "EF", dependsOn: ["CE"]},
12
{id: "F", optimistic: 3, pessimistic: 10, mostLikely: 5, name: "F", dependsOn: ["BD", "CE"]}
13
];
14
15
// create a chart
16
var chart = anychart.pert();
17
18
// set chart data
19
chart.data(data, "as-table");
20
21
chart.milestones().labels().fontSize(10);
22
chart.verticalSpacing(80);
23
chart.horizontalSpacing("19%");
24
chart.milestones().size(30);
25
26
chart.milestones().labels(false);
27
28
chart.tasks().upperLabels().format("ES: {%earliestStart}, LS: {%latestStart}");
29
30
chart.tasks().lowerLabels().format("EF: {%earliestFinish}, LF: {%latestFinish}");
31
32
// expected time calculation
33
chart.expectedTimeCalculator(function () {
34
return (2*this.optimistic + 6*this.mostLikely + 6*this.pessimistic)/14;
35
});
36
37
duration = Math.round(chart.getStat("pertChartProjectDuration"));
38
39
chart.title("The duration is " + duration);
40
41
// set the container id for the chart
42
chart.container("container");
43
44
// initiate drawing the chart
45
chart.draw();
46
});