Skip to content

Commit

Permalink
BUG. Duration issue with length of task == 0 (#24)
Browse files Browse the repository at this point in the history
* BUG. Duration issue with length of task == 0
* Version was increased
  • Loading branch information
savvinsergey authored and ignatvilesov committed Aug 1, 2017
1 parent 683ff83 commit 1ef43b1
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 5 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
## 1.2.0
* Added ability to set minimum of task duration
## 1.1.0
* Added ability to use hours, minutes and seconds in a 'duration'
## 1.0.2
Expand Down
7 changes: 7 additions & 0 deletions capabilities.json
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,13 @@
}
]
}
},
"durationMin": {
"displayName": "Duration min",
"displayNameKey": "Visual_DurationMinimum",
"type": {
"numeric": true
}
}
}
},
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "powerbi-visuals-gantt",
"version": "1.1.0",
"version": "1.2.0",
"description": "A Gantt chart is a type of bar chart which illustrates a project timeline or schedule. The Gantt Chart visual shows the Tasks, Start Dates, Durations, % Complete, and Resources for a project. The Gantt Chart visual can be used to show current schedule status using percent-complete shadings and a vertical \"TODAY\" line. The Legend may be used to group or filter tasks based upon data values.",
"repository": {
"type": "git",
Expand Down
2 changes: 1 addition & 1 deletion pbiviz.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"displayName": "Gantt",
"guid": "Gantt1448688115699",
"visualClassName": "Gantt",
"version": "1.1.0",
"version": "1.2.0",
"description": "A Gantt chart is a type of bar chart which illustrates a project timeline or schedule. The Gantt Chart visual shows the Tasks, Start Dates, Durations, % Complete, and Resources for a project. The Gantt Chart visual can be used to show current schedule status using percent-complete shadings and a vertical \"TODAY\" line. The Legend may be used to group or filter tasks based upon data values.",
"supportUrl": "http://community.powerbi.com",
"gitHubUrl": "https://github.com/Microsoft/powerbi-visuals-gantt"
Expand Down
11 changes: 8 additions & 3 deletions src/gantt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,6 @@ module powerbi.extensibility.visual {
private static ComplectionMax: number = 1;
private static ComplectionMin: number = 0;
private static ComplectionTotal: number = 100;
private static DurationMin: number = 1;
private static MinTasks: number = 1;
private static ChartLineProportion: number = 1.5;
private static MilestoneTop: number = 0;
Expand Down Expand Up @@ -567,8 +566,9 @@ module powerbi.extensibility.visual {
&& Gantt.isValidDate(values.StartDate[index] as Date) && values.StartDate[index] as Date)
|| new Date(Date.now());

const duration: number = group.Duration.values[index] < Gantt.DurationMin ? Gantt.DurationMin :
group.Duration.values[index] as number;
const duration: number = group.Duration.values[index] < settings.general.durationMin
? settings.general.durationMin
: group.Duration.values[index] as number;

const resource: string = values.Resource
? values.Resource[index] as string
Expand Down Expand Up @@ -792,6 +792,11 @@ module powerbi.extensibility.visual {
}
let startDate: Date = _.minBy(tasks, (t) => t.start).start;
let endDate: Date = _.maxBy(tasks, (t) => t.end).end;

if (startDate.toString() === endDate.toString()) {
endDate = new Date(endDate.valueOf() + (24 * 60 * 60 * 1000));
}

let dateTypeMilliseconds: number = Gantt.getDateType(this.viewModel.settings.dateType.type);
let ticks: number = Math.ceil(Math.round(endDate.valueOf() - startDate.valueOf()) / dateTypeMilliseconds);

Expand Down
1 change: 1 addition & 0 deletions src/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ module powerbi.extensibility.visual {
export class GeneralSettings {
groupTasks: boolean = false;
durationUnit: string = "day";
durationMin: number = 0;
}

export class LegendSettings {
Expand Down

0 comments on commit 1ef43b1

Please sign in to comment.