Skip to content

Commit

Permalink
Merge pull request #13 from Microsoft/allowInteractions
Browse files Browse the repository at this point in the history
added allowInteractions sample
  • Loading branch information
AviSander committed Apr 5, 2017
2 parents 92fc6ba + e12bbf9 commit 59a4793
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions src/barChart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -234,21 +234,25 @@ module powerbi.extensibility.visual {
(tooltipEvent: TooltipEventArgs<number>) => null);

let selectionManager = this.selectionManager;
let allowInteractions = this.host.allowInteractions;

//This must be an anonymous function instead of a lambda because
//d3 uses 'this' as the reference to the element that was clicked.
bars.on('click', function(d) {
selectionManager.select(d.selectionId).then((ids: ISelectionId[]) => {
bars.attr({
'fill-opacity': ids.length > 0 ? BarChart.Config.transparentOpacity : BarChart.Config.solidOpacity
});
// Allow selection only if the visual is rendered in a view that supports interactivity (e.g. Report)
if (allowInteractions) {
selectionManager.select(d.selectionId).then((ids: ISelectionId[]) => {
bars.attr({
'fill-opacity': ids.length > 0 ? BarChart.Config.transparentOpacity : BarChart.Config.solidOpacity
});

d3.select(this).attr({
'fill-opacity': BarChart.Config.solidOpacity
d3.select(this).attr({
'fill-opacity': BarChart.Config.solidOpacity
});
});
});

(<Event>d3.event).stopPropagation();
(<Event>d3.event).stopPropagation();
}
});

bars.exit()
Expand Down

0 comments on commit 59a4793

Please sign in to comment.