|
|
|
@ -67,26 +67,26 @@ function getSCurveData() {
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
function toggleOverlay() { |
|
|
|
|
if(overlayControl.isOverlayVisible(lineOverlay)){ |
|
|
|
|
if (overlayControl.isOverlayVisible(lineOverlay)) { |
|
|
|
|
gantt.config.readonly = false; |
|
|
|
|
overlayControl.hideOverlay(lineOverlay); |
|
|
|
|
gantt.$root.classList.remove("overlay_visible"); |
|
|
|
|
}else{ |
|
|
|
|
} else { |
|
|
|
|
gantt.config.readonly = true; |
|
|
|
|
overlayControl.showOverlay(lineOverlay); |
|
|
|
|
gantt.$root.classList.add("overlay_visible"); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function getChartScaleRange(){ |
|
|
|
|
function getChartScaleRange() { |
|
|
|
|
var tasksRange = gantt.getSubtaskDates(); |
|
|
|
|
var cells = []; |
|
|
|
|
var scale = gantt.getScale(); |
|
|
|
|
if(!tasksRange.start_date){ |
|
|
|
|
if (!tasksRange.start_date) { |
|
|
|
|
return scale.trace_x; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
scale.trace_x.forEach(function(date){ |
|
|
|
|
scale.trace_x.forEach(function (date) { |
|
|
|
|
// if(date >= tasksRange.start_date && date <= tasksRange.end_date){
|
|
|
|
|
// cells.push(date);
|
|
|
|
|
// }
|
|
|
|
@ -128,12 +128,16 @@ function getProgressLine() {
|
|
|
|
|
realDurations = cumulativeRealDurations; |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
if (Math.floor(maxReal) > 100 || Math.floor(maxPlan) > 100) { |
|
|
|
|
if (Math.floor(maxReal) > 110 || Math.floor(maxPlan) > 110) { |
|
|
|
|
plannedDurations = plannedDurations.map((item) => { |
|
|
|
|
return item/maxPlan*100; |
|
|
|
|
return item / maxPlan * 100; |
|
|
|
|
}) |
|
|
|
|
realDurations = realDurations.map((item) => { |
|
|
|
|
return item/maxReal*100; |
|
|
|
|
if (maxPlan >= 200) { |
|
|
|
|
return item / maxPlan * 100; |
|
|
|
|
} else { |
|
|
|
|
return item / maxReal * 100; |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -176,14 +180,14 @@ function adjustDataToZoom(dates, data, chartScaleRange, zoomLevel) {
|
|
|
|
|
}; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function getScalePaddings(values){ |
|
|
|
|
function getScalePaddings(values) { |
|
|
|
|
let zoom = gantt.ext.zoom.getCurrentLevel(); |
|
|
|
|
var scale = gantt.getScale(); |
|
|
|
|
var dataRange = gantt.getSubtaskDates(); |
|
|
|
|
// let minDate = new Date();
|
|
|
|
|
// let maxDate = new Date();
|
|
|
|
|
let minValueDate = new Date(values.dates[0]); |
|
|
|
|
let maxValueDate = new Date(values.dates[values.dates.length -1]); |
|
|
|
|
let maxValueDate = new Date(values.dates[values.dates.length - 1]); |
|
|
|
|
|
|
|
|
|
// gantt.eachTask(function(task){
|
|
|
|
|
// let plannedEarlier = task.planned_start < task.start_date;
|
|
|
|
@ -203,11 +207,11 @@ function getScalePaddings(values){
|
|
|
|
|
// })
|
|
|
|
|
|
|
|
|
|
var padding = { |
|
|
|
|
left:0, |
|
|
|
|
right:0 |
|
|
|
|
left: 0, |
|
|
|
|
right: 0 |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
if(dataRange.start_date){ |
|
|
|
|
if (dataRange.start_date) { |
|
|
|
|
var yScaleLabelsWidth = 48; |
|
|
|
|
// fine tune values in order to align chart with the scale range
|
|
|
|
|
padding.left = gantt.posFromDate(minValueDate); |
|
|
|
@ -219,23 +223,23 @@ function getScalePaddings(values){
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
var myChart; |
|
|
|
|
var lineOverlay = overlayControl.addOverlay(function(container) { |
|
|
|
|
var lineOverlay = overlayControl.addOverlay(function (container) { |
|
|
|
|
var values = getProgressLine(); |
|
|
|
|
var scaleLabels = []; |
|
|
|
|
|
|
|
|
|
// if(parts[2] && parts[2] == '1'){
|
|
|
|
|
// values.dates.forEach(function(date){
|
|
|
|
|
// var dateScale = new Date(date);
|
|
|
|
|
// scaleLabels.push(dateToStr(dateScale));
|
|
|
|
|
// })
|
|
|
|
|
// } else {
|
|
|
|
|
// var chartScale = getChartScaleRange();
|
|
|
|
|
// if(parts[2] && parts[2] == '1'){
|
|
|
|
|
// values.dates.forEach(function(date){
|
|
|
|
|
// var dateScale = new Date(date);
|
|
|
|
|
// scaleLabels.push(dateToStr(dateScale));
|
|
|
|
|
// })
|
|
|
|
|
// } else {
|
|
|
|
|
// var chartScale = getChartScaleRange();
|
|
|
|
|
|
|
|
|
|
// chartScale.forEach(function(date){
|
|
|
|
|
// scaleLabels.push(dateToStr(date));
|
|
|
|
|
// });
|
|
|
|
|
// }
|
|
|
|
|
values.dates.forEach(function(date){ |
|
|
|
|
// chartScale.forEach(function(date){
|
|
|
|
|
// scaleLabels.push(dateToStr(date));
|
|
|
|
|
// });
|
|
|
|
|
// }
|
|
|
|
|
values.dates.forEach(function (date) { |
|
|
|
|
var dateScale = new Date(date); |
|
|
|
|
scaleLabels.push(dateToStr(dateScale)); |
|
|
|
|
}) |
|
|
|
@ -245,7 +249,7 @@ var lineOverlay = overlayControl.addOverlay(function(container) {
|
|
|
|
|
canvas.style.width = container.offsetWidth + "px"; |
|
|
|
|
|
|
|
|
|
var ctx = canvas.getContext("2d"); |
|
|
|
|
if(myChart){ |
|
|
|
|
if (myChart) { |
|
|
|
|
myChart.destroy(); |
|
|
|
|
} |
|
|
|
|
myChart = new Chart(ctx, { |
|
|
|
@ -276,9 +280,9 @@ var lineOverlay = overlayControl.addOverlay(function(container) {
|
|
|
|
|
layout: { |
|
|
|
|
padding: getScalePaddings(values) |
|
|
|
|
}, |
|
|
|
|
onResize: function(chart, newSize) { |
|
|
|
|
onResize: function (chart, newSize) { |
|
|
|
|
var dataRange = gantt.getSubtaskDates(); |
|
|
|
|
if(dataRange.start_date){ |
|
|
|
|
if (dataRange.start_date) { |
|
|
|
|
// align chart with the scale range
|
|
|
|
|
chart.options.layout.padding = getScalePaddings(values); |
|
|
|
|
} |
|
|
|
@ -290,7 +294,7 @@ var lineOverlay = overlayControl.addOverlay(function(container) {
|
|
|
|
|
mode: "index", |
|
|
|
|
intersect: false, |
|
|
|
|
callbacks: { |
|
|
|
|
label: function(tooltipItem, data) { |
|
|
|
|
label: function (tooltipItem, data) { |
|
|
|
|
var dataset = data.datasets[tooltipItem.datasetIndex]; |
|
|
|
|
return dataset.label + ": " + dataset.data[tooltipItem.index] + "%"; |
|
|
|
|
} |
|
|
|
@ -303,7 +307,7 @@ var lineOverlay = overlayControl.addOverlay(function(container) {
|
|
|
|
|
scales: { |
|
|
|
|
xAxes: [{ |
|
|
|
|
labels: scaleLabels, |
|
|
|
|
gridLines:{ |
|
|
|
|
gridLines: { |
|
|
|
|
display: false |
|
|
|
|
}, |
|
|
|
|
ticks: { |
|
|
|
@ -311,9 +315,9 @@ var lineOverlay = overlayControl.addOverlay(function(container) {
|
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
position:"top", |
|
|
|
|
position: "top", |
|
|
|
|
labels: scaleLabels, |
|
|
|
|
gridLines:{ |
|
|
|
|
gridLines: { |
|
|
|
|
display: false |
|
|
|
|
}, |
|
|
|
|
ticks: { |
|
|
|
@ -324,7 +328,7 @@ var lineOverlay = overlayControl.addOverlay(function(container) {
|
|
|
|
|
yAxes: [{ |
|
|
|
|
display: true, |
|
|
|
|
gridLines: { |
|
|
|
|
display:false |
|
|
|
|
display: false |
|
|
|
|
}, |
|
|
|
|
ticks: { |
|
|
|
|
display: true, |
|
|
|
|