diff --git a/lib/components/GGanttTimeaxis.vue b/lib/components/GGanttTimeaxis.vue index e4595f3..7645769 100644 --- a/lib/components/GGanttTimeaxis.vue +++ b/lib/components/GGanttTimeaxis.vue @@ -74,7 +74,6 @@ export default { data() { return { axisPoints: [], - childPointCount: null, timemarker: null, hourFontSize: '11px', dayFormat: 'ddd DD MMMM', @@ -124,15 +123,15 @@ export default { initAxisMonthsAndDays() { let start = moment(this.chartStart) let end = moment(this.chartEnd) - this.childPointCount = Math.floor(end.diff(start, 'days', true)) this.axisPoints = [] while (start.isBefore(end)) { let dayCountOfMonth = start.isSame(end, 'month') ? end.date() - 1 : start.daysInMonth() - start.date() + 1 - let widthPercentage = (dayCountOfMonth / this.childPointCount) * 100 - let endDay = - start.month() === end.month() ? end.date() - 1 : start.daysInMonth() + let widthPercentage = (dayCountOfMonth / this.timeCount) * 100 + let endDay = start.isSame(end, 'month') + ? end.date() - 1 + : start.daysInMonth() this.axisPoints.push( this.getAxisMonthObject(start, widthPercentage, endDay) ) @@ -143,14 +142,13 @@ export default { initAxisDaysAndHours() { let start = moment(this.chartStart) let end = moment(this.chartEnd) - this.childPointCount = Math.floor(end.diff(start, 'hours', true)) this.axisPoints = [] while (start.isBefore(end)) { let hourCountOfDay = start.isSame(end, 'day') ? end.hour() : 24 - start.hour() - let widthPercentage = (hourCountOfDay / this.childPointCount) * 100 - let endHour = start.date() === end.date() ? end.hour() - 1 : 23 // -1 because the last hour is not included e.g if chartEnd=04:00 the last interval we display is between 03 and 04 + let widthPercentage = (hourCountOfDay / this.timeCount) * 100 + let endHour = start.isSame(end, 'day') ? end.hour() - 1 : 23 // -1 because the last hour is not included e.g if chartEnd=04:00 the last interval we display is between 03 and 04 this.axisPoints.push( this.getAxisDayObject(start, widthPercentage, endHour) ) @@ -216,7 +214,7 @@ export default { this.hourFontSize = Math.min( 9.5, - 0.75 * (this.horizontalAxisContainer.width / this.childPointCount) + 0.75 * (this.horizontalAxisContainer.width / this.timeCount) ) + 'px' }, diff --git a/package-lock.json b/package-lock.json index 947070e..91cf9af 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@tenrok/vue-ganttastic", - "version": "0.10.15", + "version": "0.10.16", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@tenrok/vue-ganttastic", - "version": "0.10.15", + "version": "0.10.16", "license": "MIT", "dependencies": { "vue": "^2.6.12" diff --git a/package.json b/package.json index b40aa24..10a1232 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@tenrok/vue-ganttastic", - "version": "0.10.15", + "version": "0.10.16", "description": "A simple and customizable Gantt chart component for Vue.js", "keywords": [ "gantt",