gantt-task-react-powern 0.6.43 → 0.6.44

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1676,6 +1676,7 @@ var TopPartOfCalendar = function TopPartOfCalendar(_ref) {
1676
1676
  }, value));
1677
1677
  };
1678
1678
 
1679
+ var MONTH_LABEL_HALF_WIDTH = 32;
1679
1680
  var Calendar = function Calendar(_ref) {
1680
1681
  var dateSetup = _ref.dateSetup,
1681
1682
  locale = _ref.locale,
@@ -1937,6 +1938,8 @@ var Calendar = function Calendar(_ref) {
1937
1938
  var topDefaultHeight = headerHeight * 0.5;
1938
1939
  var dates = dateSetup.dates;
1939
1940
  var weekStartDay = (_projectCalendar$week = projectCalendar === null || projectCalendar === void 0 ? void 0 : projectCalendar.week_start) != null ? _projectCalendar$week : 1;
1941
+ var chartWidth = columnWidth * dates.length;
1942
+ var monthStartIndex = 0;
1940
1943
 
1941
1944
  for (var i = 0; i < dates.length; i++) {
1942
1945
  var date = dates[i];
@@ -1968,32 +1971,23 @@ var Calendar = function Calendar(_ref) {
1968
1971
  x: columnWidth * i + columnWidth * 0.5,
1969
1972
  className: styles$6.calendarTopText + " " + styles$6.textAnchorMiddle
1970
1973
  }, bottomValue));
1974
+ var isMonthEnd = i + 1 === dates.length || date.getMonth() !== dates[i + 1].getMonth();
1971
1975
 
1972
- if (i + 1 !== dates.length && date.getMonth() !== dates[i + 1].getMonth()) {
1976
+ if (isMonthEnd) {
1973
1977
  var topValue = shortMonth(date) + " " + date.getFullYear();
1978
+ var segmentStart = columnWidth * monthStartIndex;
1979
+ var segmentEnd = columnWidth * (i + 1);
1980
+ var xText = Math.min(Math.max((segmentStart + segmentEnd) / 2, MONTH_LABEL_HALF_WIDTH), chartWidth - MONTH_LABEL_HALF_WIDTH);
1974
1981
  topValues.push(React.createElement(TopPartOfCalendar, {
1975
1982
  key: topValue + i,
1976
1983
  value: topValue,
1977
- x1Line: columnWidth * (i + 1),
1984
+ x1Line: segmentEnd,
1978
1985
  y1Line: 0,
1979
1986
  y2Line: topDefaultHeight,
1980
- xText: topValues.length === 0 ? columnWidth * (i + 1) * 0.5 : columnWidth * (i + 1) - date.getDate() * columnWidth * 0.5,
1981
- yText: topDefaultHeight * 0.9
1982
- }));
1983
- }
1984
-
1985
- if (i + 1 === dates.length) {
1986
- var _topValue = shortMonth(date) + " " + date.getFullYear();
1987
-
1988
- topValues.push(React.createElement(TopPartOfCalendar, {
1989
- key: _topValue + "last",
1990
- value: _topValue,
1991
- x1Line: columnWidth * (i + 1),
1992
- y1Line: 0,
1993
- y2Line: topDefaultHeight,
1994
- xText: columnWidth * (i + 1) - date.getDate() * columnWidth * 0.5,
1987
+ xText: xText,
1995
1988
  yText: topDefaultHeight * 0.9
1996
1989
  }));
1990
+ monthStartIndex = i + 1;
1997
1991
  }
1998
1992
  }
1999
1993