|
|
|
@ -167,9 +167,8 @@ function adjustDataToZoom(dates, data, chartScaleRange, zoomLevel) {
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// If there are remaining data points after the loop, add them to the result
|
|
|
|
|
if (aggregateValue > 0) { |
|
|
|
|
newData.push(aggregateValue); |
|
|
|
|
newData.push(+(Math.round(aggregateValue+ "e+2") + "e-2")); |
|
|
|
|
newDates.push(dates[data.length - 1]); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -179,32 +178,23 @@ function adjustDataToZoom(dates, data, chartScaleRange, zoomLevel) {
|
|
|
|
|
}; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function calculateMonthDifference(startDate, endDate) { |
|
|
|
|
let startYear = startDate.getFullYear(); |
|
|
|
|
let startMonth = startDate.getMonth(); |
|
|
|
|
let endYear = endDate.getFullYear(); |
|
|
|
|
let endMonth = endDate.getMonth(); |
|
|
|
|
|
|
|
|
|
let totalMonths = (endYear - startYear) * 12 + (endMonth - startMonth); |
|
|
|
|
return totalMonths; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
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]); |
|
|
|
|
|
|
|
|
|
// gantt.eachTask(function(task){
|
|
|
|
|
// let plannedEarlier = task.planned_start < task.start_date;
|
|
|
|
|
// let plannedLater = task.planned_end > task.end_date;
|
|
|
|
|
|
|
|
|
|
// if (plannedEarlier) {
|
|
|
|
|
// minDate = new Date(Math.min(minDate.getTime(), task.planned_start.getTime()));
|
|
|
|
|
// } else {
|
|
|
|
|
// minDate = new Date(Math.min(minDate.getTime(), task.start_date.getTime()));
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
// if (plannedLater) {
|
|
|
|
|
// maxDate = new Date(Math.max(maxDate.getTime(), task.planned_end.getTime()));
|
|
|
|
|
// } else {
|
|
|
|
|
// maxDate = new Date(Math.max(maxDate.getTime(), task.end_date.getTime()));
|
|
|
|
|
// }
|
|
|
|
|
// })
|
|
|
|
|
|
|
|
|
|
var padding = { |
|
|
|
|
left: 0, |
|
|
|
|
right: 0 |
|
|
|
@ -212,9 +202,20 @@ function getScalePaddings(values) {
|
|
|
|
|
|
|
|
|
|
if(dataRange.start_date){ |
|
|
|
|
var yScaleLabelsWidth = 48; |
|
|
|
|
// fine tune values in order to align chart with the scale range
|
|
|
|
|
padding.left = gantt.posFromDate(minValueDate); |
|
|
|
|
padding.right = scale.full_width - gantt.posFromDate(maxValueDate); |
|
|
|
|
let monthDifference = calculateMonthDifference(minValueDate, maxValueDate); |
|
|
|
|
if(monthDifference >= 0 && monthDifference <= 3) { |
|
|
|
|
padding.left = gantt.posFromDate(minValueDate) +5; |
|
|
|
|
padding.right = scale.full_width - gantt.posFromDate(maxValueDate) - yScaleLabelsWidth; |
|
|
|
|
} |
|
|
|
|
if(monthDifference >= 4 && monthDifference <= 7) { |
|
|
|
|
padding.left = gantt.posFromDate(minValueDate) - 2; |
|
|
|
|
padding.right = scale.full_width - gantt.posFromDate(maxValueDate) - yScaleLabelsWidth; |
|
|
|
|
} |
|
|
|
|
if(monthDifference >= 8) { |
|
|
|
|
padding.left = gantt.posFromDate(minValueDate) - 2; |
|
|
|
|
padding.right = scale.full_width - gantt.posFromDate(maxValueDate) - yScaleLabelsWidth; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
padding.top = gantt.config.row_height - 12; |
|
|
|
|
padding.bottom = gantt.config.row_height - 12; |
|
|
|
|
} |
|
|
|
@ -226,18 +227,8 @@ 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();
|
|
|
|
|
|
|
|
|
|
// chartScale.forEach(function(date){
|
|
|
|
|
// scaleLabels.push(dateToStr(date));
|
|
|
|
|
// });
|
|
|
|
|
// }
|
|
|
|
|
values.planned = values.planned.map(value => +(Math.round(value + "e+2") + "e-2")); |
|
|
|
|
values.real = values.real.map(value => +(Math.round(value + "e+2") + "e-2")); |
|
|
|
|
values.dates.forEach(function(date){ |
|
|
|
|
var dateScale = new Date(date); |
|
|
|
|
scaleLabels.push(dateToStr(dateScale)); |
|
|
|
|