Skip to content

Commit badfacd

Browse files
savvinsergeyignatvilesov
authored andcommitted
Fixed behavior when completion values display in tooltip though completion field doesn't have any field (#88)
1 parent 8957a5b commit badfacd

File tree

5 files changed

+65
-22
lines changed

5 files changed

+65
-22
lines changed

CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
## 1.8.4
2+
* Fixed behavior when completion values display in tooltip though
3+
the %Completion doesn't have any field
14
## 1.8.3
25
* Reverted 1.8.2 fix caused selection issue.
36
* Fixed viewport clearing if no data in dataView

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.8.3",
3+
"version": "1.8.4",
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.8.3",
7+
"version": "1.8.4",
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

+17-12
Original file line numberDiff line numberDiff line change
@@ -531,7 +531,6 @@ module powerbi.extensibility.visual {
531531
*/
532532
private static getTooltipInfo(
533533
task: Task,
534-
locale: string,
535534
formatters: GanttChartFormatters,
536535
durationUnit: string): VisualTooltipDataItem[] {
537536

@@ -558,10 +557,12 @@ module powerbi.extensibility.visual {
558557
value: durationLabel
559558
});
560559

561-
tooltipDataArray.push({
562-
displayName: "Completion",
563-
value: formatters.completionFormatter.format(task.completion)
564-
});
560+
if (task.completion) {
561+
tooltipDataArray.push({
562+
displayName: "Completion",
563+
value: formatters.completionFormatter.format(task.completion)
564+
});
565+
}
565566

566567
if (task.resource) {
567568
tooltipDataArray.push({ displayName: "Resource", value: task.resource });
@@ -704,6 +705,7 @@ module powerbi.extensibility.visual {
704705
values.Task.forEach((categoryValue: PrimitiveValue, index: number) => {
705706
let duration: number = settings.general.durationMin;
706707
let durationUnit: string = settings.general.durationUnit;
708+
let taskProgressShow: boolean = settings.taskCompletion.show;
707709
let color: string = taskColor || Gantt.DefaultValues.TaskColor;
708710
let completion: number = 0;
709711
let taskType: TaskTypeMetadata = null;
@@ -737,14 +739,17 @@ module powerbi.extensibility.visual {
737739
}
738740

739741
completion = ((group.Completion && group.Completion.values[index])
740-
&& Gantt.convertToDecimal(group.Completion.values[index] as number)) || 0;
742+
&& taskProgressShow
743+
&& Gantt.convertToDecimal(group.Completion.values[index] as number)) || null;
741744

742-
if (completion < Gantt.ComplectionMin) {
743-
completion = Gantt.ComplectionMin;
744-
}
745+
if (completion !== null) {
746+
if (completion < Gantt.ComplectionMin) {
747+
completion = Gantt.ComplectionMin;
748+
}
745749

746-
if (completion > Gantt.ComplectionMax) {
747-
completion = Gantt.ComplectionMax;
750+
if (completion > Gantt.ComplectionMax) {
751+
completion = Gantt.ComplectionMax;
752+
}
748753
}
749754
}
750755
});
@@ -814,7 +819,7 @@ module powerbi.extensibility.visual {
814819
} while (task.daysOffList.length && datesDiff - DaysInAWeekend > DaysInAWeek);
815820
}
816821

817-
task.tooltipInfo = Gantt.getTooltipInfo(task, host.locale, formatters, durationUnit);
822+
task.tooltipInfo = Gantt.getTooltipInfo(task, formatters, durationUnit);
818823

819824
tasks.push(task);
820825
});

test/visualTest.ts

+43-8
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,48 @@ module powerbi.extensibility.visual.test {
319319
});
320320
});
321321

322+
describe("Verify tooltips have no completion info", () => {
323+
function checkCompletionEqualNull(done: () => void) {
324+
visualBuilder.updateRenderTimeout(dataView, () => {
325+
let tasks = d3.select(visualBuilder.element.get(0)).selectAll(".task").data();
326+
for (let task of tasks) {
327+
for (let tooltipInfo of task.tooltipInfo) {
328+
if (tooltipInfo.displayName === GanttData.ColumnCompletePrecntege) {
329+
expect(tooltipInfo.value).toEqual(null);
330+
}
331+
}
332+
}
333+
334+
done();
335+
});
336+
}
337+
338+
it("TaskCompletion setting is switched off", (done) => {
339+
dataView = defaultDataViewBuilder.getDataView([
340+
GanttData.ColumnTask,
341+
GanttData.ColumnStartDate,
342+
GanttData.ColumnDuration,
343+
GanttData.ColumnCompletePrecntege]);
344+
345+
dataView.metadata.objects = {
346+
taskCompletion: {
347+
show: false
348+
}
349+
};
350+
351+
checkCompletionEqualNull(done);
352+
});
353+
354+
it("Completion data unavailable", (done) => {
355+
dataView = defaultDataViewBuilder.getDataView([
356+
GanttData.ColumnTask,
357+
GanttData.ColumnStartDate,
358+
GanttData.ColumnDuration]);
359+
360+
checkCompletionEqualNull(done);
361+
});
362+
});
363+
322364
it("Verify Font Size set to default", (done) => {
323365
visualBuilder.updateRenderTimeout(dataView, () => {
324366
let element = d3.select(visualBuilder.element.get(0));
@@ -710,18 +752,11 @@ module powerbi.extensibility.visual.test {
710752
});
711753

712754
describe("Task Completion", () => {
713-
beforeEach(() => {
714-
dataView.metadata.objects = {
715-
taskCompletion: {
716-
show: true
717-
}
718-
};
719-
});
720-
721755
it("color", (done) => {
722756
let color: string = GanttBuilder.getRandomHexColor();
723757
dataView.metadata.objects = {
724758
taskCompletion: {
759+
show: true,
725760
fill: GanttBuilder.getSolidColorStructuralObject(color)
726761
}
727762
};

0 commit comments

Comments
 (0)