Skip to content

Commit

Permalink
Fix error when the visual doesn't display chart without values dataset (
Browse files Browse the repository at this point in the history
  • Loading branch information
zBritva authored and ignatvilesov committed Sep 28, 2017
1 parent 6b39a8a commit cb0d4f4
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 8 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 1.5.1

* Fix error when the visual doesn't display chart without values dataset

## 1.5.0

* Added 'Display unit' property to configure value formatting for data labels
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-sankey",
"version": "1.5.0",
"version": "1.5.1",
"description": "Sankey is a type of flow diagram in which the width of the series is in proportion to the quantity of the flow. Use it to find major contributions to an overall flow.",
"repository": {
"type": "git",
Expand Down
4 changes: 2 additions & 2 deletions pbiviz.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"visual": {
"name": "SankeyDiagram",
"displayName": "Sankey 1.5.0",
"displayName": "Sankey 1.5.1",
"guid": "SankeyDiagram1446463184954",
"visualClassName": "SankeyDiagram",
"version": "1.5.0",
"version": "1.5.1",
"description": "Sankey is a type of flow diagram in which the width of the series is in proportion to the quantity of the flow. Use it to find major contributions to an overall flow.",
"supportUrl": "http://community.powerbi.com",
"gitHubUrl": "https://github.com/Microsoft/powerbi-visuals-sankey"
Expand Down
16 changes: 11 additions & 5 deletions src/visual.ts
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ module powerbi.extensibility.visual {
settings,
dataView.categorical.categories[SankeyDiagram.SourceCategoryIndex].source.displayName,
dataView.categorical.categories[SankeyDiagram.DestinationCategoryIndex].source.displayName,
dataView.categorical.values[SankeyDiagram.FirstValueIndex].source.displayName
dataView.categorical.values ? dataView.categorical.values[SankeyDiagram.FirstValueIndex].source.displayName : null
);

let cycles: SankeyDiagramCycleDictionary = this.checkCycles(nodes);
Expand Down Expand Up @@ -773,18 +773,24 @@ module powerbi.extensibility.visual {
formattedLinkWeight = linkWeight.toString();
}

return [
let tooltips: VisualTooltipDataItem[] = [
{
displayName: sourceNodeDisplayName || SankeyDiagram.RoleNames.rows,
value: sourceNodeName
}, {
displayName: destinationNodeDisplayName || SankeyDiagram.RoleNames.columns,
value: destinationNodeName
}, {
},
];

if (valueDisplayName) {
tooltips.push({
displayName: valueDisplayName || SankeyDiagram.RoleNames.values,
value: formattedLinkWeight
}
];
});
}

return tooltips;
}

private static updateValueOfNode(node: SankeyDiagramNode): void {
Expand Down
27 changes: 27 additions & 0 deletions test/visualTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,33 @@ module powerbi.extensibility.visual.test {
});
});

it("update without weight values", (done) => {
dataView.categorical.values = undefined;
visualBuilder.updateRenderTimeout(dataView, () => {
const sourceCategories: PrimitiveValue[] = dataView.categorical.categories[0].values,
destinationCategories: PrimitiveValue[] = dataView.categorical.categories[1].values;

expect(visualBuilder.linksElement).toBeInDOM();
expect(visualBuilder.linkElements.length).toBe(sourceCategories.length);

let nodes: SankeyDiagramNode[] = visualBuilder.instance
.converter(dataView)
.nodes
.filter( (node: SankeyDiagramNode) => {
if (node.links.length > 0) {
return true;
}

return false;
});

expect(visualBuilder.nodesElement).toBeInDOM();
expect(visualBuilder.nodeElements.length).toEqual(nodes.length);

done();
});
});

it("nodes labels on", (done) => {
dataView.metadata.objects = {
labels: {
Expand Down

0 comments on commit cb0d4f4

Please sign in to comment.