anychart.onDocumentReady(function () {
anychart.data.loadJsonFile(
'https://cdn.anychart.com/samples/pert-charts/house-construction-pert-chart/data.json',
var treeData = anychart.data.tree(data, 'as-table');
var chart = anychart.pert();
.horizontalSpacing('11.65%')
.padding([25, 50, 0, 50]);
var duration = Math.ceil(chart.getStat('pertChartProjectDuration'));
var deviation = Math.ceil(
chart.getStat('pertChartCriticalPathStandardDeviation')
'House Construction PERT Chart' +
'<br>Project duration: ' +
var tasks = chart.tasks();
tasks.upperLabels().format(function () {
return this.item.get('fullName');
tasks.lowerLabels().format(function () {
return timeTask(this.duration);
var tasksTooltip = tasks.tooltip();
tasksTooltip.separator(true).titleFormat(function () {
return this.item.get('fullName');
var milestones = chart.milestones();
milestones.hovered().fill(function () {
return anychart.color.lighten(this.sourceColor, 0.25);
milestones.tooltip().format(defuaultMilesoneTooltipTextFormatter);
chart.container('container');
function timeTask(duration) {
weeks = Math.floor(duration / 7);
days = Math.floor(duration - weeks * 7);
hours = Math.ceil(24 * (duration - weeks * 7 - days));
days = Math.floor(duration - weeks * 7);
hours = Math.ceil(24 * (duration - weeks * 7 - days));
var weeksPart = weeks !== 0 ? 'w:' + weeks + ' ' : '';
var daysPart = days !== 0 ? 'd:' + days + ' ' : '';
var hoursPart = hours !== 0 ? 'h:' + hours + ' ' : '';
return weeksPart + daysPart + hoursPart;
function defuaultMilesoneTooltipTextFormatter() {
if (this.successors && this.successors.length) {
for (i = 0; i < this.successors.length; i++) {
result += '\n - ' + this.successors[i].get('fullName');
if (this.predecessors && this.predecessors.length) result += '\n\n';
if (this.predecessors && this.predecessors.length) {
result += 'Predecessors:';
for (i = 0; i < this.predecessors.length; i++) {
result += '\n - ' + this.predecessors[i].get('fullName');