Browse Source

Update padding

pull/1/head
Wahyu Ramadhan 1 year ago
parent
commit
06764c28a6
  1. 25
      view-mode/function/overlaySCurve.js

25
view-mode/function/overlaySCurve.js

@ -121,9 +121,26 @@ function getProgressLine(){
function getScalePaddings(){ function getScalePaddings(){
var scale = gantt.getScale(); var scale = gantt.getScale();
var dataRange = gantt.getSubtaskDates(); var dataRange = gantt.getSubtaskDates();
let minDate = new Date();
let maxDate = new Date();
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 chartScale = getChartScaleRange();
var newWidth = scale.col_width;
var padding = { var padding = {
left:0, left:0,
right:0 right:0
@ -132,8 +149,8 @@ function getScalePaddings(){
if(dataRange.start_date){ if(dataRange.start_date){
var yScaleLabelsWidth = 48; var yScaleLabelsWidth = 48;
// fine tune values in order to align chart with the scale range // fine tune values in order to align chart with the scale range
padding.left = gantt.posFromDate(dataRange.start_date) - yScaleLabelsWidth; padding.left = gantt.posFromDate(minDate) - yScaleLabelsWidth;
padding.right = scale.full_width - gantt.posFromDate(dataRange.end_date) - yScaleLabelsWidth; padding.right = scale.full_width - gantt.posFromDate(maxDate) - yScaleLabelsWidth;
padding.top = gantt.config.row_height - 12; padding.top = gantt.config.row_height - 12;
padding.bottom = gantt.config.row_height - 12; padding.bottom = gantt.config.row_height - 12;
} }

Loading…
Cancel
Save