Skip to content

Commit e482002

Browse files
savvinsergeyignatvilesov
authored andcommitted
Fixed issue with wrong tooltip data displaying without 'parent' data (#94)
1 parent 3a705e3 commit e482002

File tree

5 files changed

+49
-9
lines changed

5 files changed

+49
-9
lines changed

CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
## 1.9.1
2+
* Fixed issue with wrong tooltip data displaying without 'parent' data
3+
* Fixed issue with wrong duration in the tooltip
14
## 1.9.0
25
* Added ability to use sub tasks
36
## 1.8.6

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "powerbi-visuals-gantt",
3-
"version": "1.9.0",
3+
"version": "1.9.1",
44
"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.",
55
"repository": {
66
"type": "git",

pbiviz.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"displayName": "Gantt",
55
"guid": "Gantt1448688115699",
66
"visualClassName": "Gantt",
7-
"version": "1.9.0",
7+
"version": "1.9.1",
88
"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.",
99
"supportUrl": "http://community.powerbi.com",
1010
"gitHubUrl": "https://github.com/Microsoft/powerbi-visuals-gantt"

src/gantt.ts

+9-7
Original file line numberDiff line numberDiff line change
@@ -858,7 +858,7 @@ module powerbi.extensibility.visual {
858858
if (values.Parent) {
859859
tasks
860860
.filter((task: Task) => task.parent.indexOf(".") === -1)
861-
.forEach((task: Task) => Gantt.childrenOfTaskProcessing(tasks, task, settings, formatters, durationUnit));
861+
.forEach((task: Task) => Gantt.childrenOfTaskProcessing(tasks, task, settings, durationUnit));
862862

863863
tasks
864864
.sort((a, b) => {
@@ -872,13 +872,16 @@ module powerbi.extensibility.visual {
872872
});
873873
}
874874

875+
tasks.forEach((task: Task) => {
876+
task.tooltipInfo = Gantt.getTooltipInfo(task, formatters, durationUnit);
877+
});
878+
875879
return tasks;
876880
}
877881

878882
private static childrenOfTaskProcessing(tasks: Task[],
879883
task: Task,
880884
settings: GanttSettings,
881-
formatters: GanttChartFormatters,
882885
durationUnit: string): void {
883886
let childrenOfTask: Task[] = tasks.filter((childTask: Task) =>
884887
(childTask.parent.substr(0, task.parent.length) === task.parent &&
@@ -889,7 +892,7 @@ module powerbi.extensibility.visual {
889892
if (childrenOfTask.length) {
890893
childrenOfTask.forEach((childTask: Task) => {
891894
task.children.push(childTask.name);
892-
Gantt.childrenOfTaskProcessing(tasks, childTask, settings, formatters, durationUnit);
895+
Gantt.childrenOfTaskProcessing(tasks, childTask, settings, durationUnit);
893896
});
894897

895898
if ((!settings.subTasks.inheritParentLegend && !task.taskType) ||
@@ -898,15 +901,13 @@ module powerbi.extensibility.visual {
898901
}
899902

900903
if (settings.subTasks.parentDurationByChildren) {
901-
Gantt.setParentDurationByChildren(task, childrenOfTask);
904+
Gantt.setParentDurationByChildren(task, childrenOfTask, durationUnit);
902905
}
903906

904907
if (settings.subTasks.parentCompletionByChildren) {
905908
Gantt.setParentCompletionByChildren(task, childrenOfTask);
906909
}
907910
}
908-
909-
task.tooltipInfo = Gantt.getTooltipInfo(task, formatters, durationUnit);
910911
}
911912

912913
/**
@@ -929,9 +930,10 @@ module powerbi.extensibility.visual {
929930
* @param task Parent task
930931
* @param children Sub tasks of parent task
931932
*/
932-
private static setParentDurationByChildren(task: Task, children: Task[]): void {
933+
private static setParentDurationByChildren(task: Task, children: Task[], durationUnit: string): void {
933934
task.start = (_.minBy(children, (childTask: Task) => childTask.start)).start;
934935
task.end = (_.maxBy(children, (childTask: Task) => childTask.end)).end;
936+
task.duration = d3.time[durationUnit].range(task.start, task.end).length;
935937
}
936938

937939
/**

test/visualTest.ts

+35
Original file line numberDiff line numberDiff line change
@@ -397,6 +397,38 @@ module powerbi.extensibility.visual.test {
397397
});
398398
});
399399

400+
describe("Verify tooltips have info according 'parent' data", () => {
401+
function checkTasksHaveTooltipInfo(done: () => void) {
402+
visualBuilder.updateRenderTimeout(dataView, () => {
403+
let tasks = d3.select(visualBuilder.element.get(0)).selectAll(".task").data();
404+
for (let task of tasks) {
405+
expect(task.tooltipInfo.length).not.toEqual(0);
406+
}
407+
408+
done();
409+
});
410+
}
411+
412+
it("With parent data", (done) => {
413+
dataView = defaultDataViewBuilder.getDataView([
414+
GanttData.ColumnTask,
415+
GanttData.ColumnStartDate,
416+
GanttData.ColumnDuration,
417+
GanttData.ColumnParent]);
418+
419+
checkTasksHaveTooltipInfo(done);
420+
});
421+
422+
it("Without parent data", (done) => {
423+
dataView = defaultDataViewBuilder.getDataView([
424+
GanttData.ColumnTask,
425+
GanttData.ColumnStartDate,
426+
GanttData.ColumnDuration]);
427+
428+
checkTasksHaveTooltipInfo(done);
429+
});
430+
});
431+
400432
it("Verify Font Size set to default", (done) => {
401433
visualBuilder.updateRenderTimeout(dataView, () => {
402434
let element = d3.select(visualBuilder.element.get(0));
@@ -790,6 +822,9 @@ module powerbi.extensibility.visual.test {
790822

791823
expect(parent.start).toEqual(start);
792824
expect(parent.end).toEqual(end);
825+
826+
const newDuration: number = d3.time["day"].range(start, end).length;
827+
expect(parent.duration).toEqual(newDuration);
793828
});
794829

795830
done();

0 commit comments

Comments
 (0)