Skip to content

Commit

Permalink
Packages update + context menu support (#30)
Browse files Browse the repository at this point in the history
  • Loading branch information
EugeneElkin committed Dec 24, 2020
1 parent 9151159 commit 85a596a
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 3 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
@@ -1,3 +1,6 @@
## 2.0.7
* Context menu support

## 2.0.6
* API 3.4
* Packages update
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
@@ -1,7 +1,7 @@
{
"name": "DualKpi",
"displayName": "Dual KPI",
"version": "2.0.6",
"version": "2.0.7",
"description": "Dual KPI efficiently visualizes two measures over time. It shows their trend based on a joint timeline, while absolute values may use different scales, for example Profit and Market share or Sales and Profit. Each KPI can be visualized as line chart or area chart. The visual has dynamic behavior and can show historical value and the change from the latest value when you hover over it. It also has small icons and labels to convey KPI definitions and alerts about data freshness. Customize colors, titles, axis properties, tooltips, and more, to create visually appealing and functional executive dashboards.",
"author": {
"name": "Microsoft",
Expand Down
2 changes: 1 addition & 1 deletion pbiviz.json
Expand Up @@ -4,7 +4,7 @@
"displayName": "Dual KPI",
"guid": "PBI_CV_3C80B1F2_09AF_4123_8E99_C3CBC46B23E0",
"visualClassName": "DualKpi",
"version": "2.0.6",
"version": "2.0.7",
"description": "Dual KPI efficiently visualizes two measures over time. It shows their trend based on a joint timeline, while absolute values may use different scales, for example Profit and Market share or Sales and Profit. Each KPI can be visualized as line chart or area chart. The visual has dynamic behavior and can show historical value and the change from the latest value when you hover over it. It also has small icons and labels to convey KPI definitions and alerts about data freshness. Customize colors, titles, axis properties, tooltips, and more, to create visually appealing and functional executive dashboards.",
"supportUrl": "http://community.powerbi.com",
"gitHubUrl": "https://github.com/Microsoft/powerbi-visuals-dualkpi"
Expand Down
18 changes: 18 additions & 0 deletions src/visual.ts
Expand Up @@ -62,6 +62,7 @@ import ILocalizationManager = powerbi.extensibility.ILocalizationManager;
import VisualConstructorOptions = powerbi.extensibility.visual.VisualConstructorOptions;
import VisualUpdateOptions = powerbi.extensibility.visual.VisualUpdateOptions;
import IColorPalette = powerbi.extensibility.IColorPalette;
import ISelectionManager = powerbi.extensibility.ISelectionManager;

import IValueFormatter = ValueFormatter.IValueFormatter;
import valueFormatter = ValueFormatter;
Expand Down Expand Up @@ -235,6 +236,8 @@ export class DualKpi implements IVisual {
private tooltipServiceWrapper: ITooltipServiceWrapper;
private host: IVisualHost;

private selectionManager: ISelectionManager;

constructor(options: VisualConstructorOptions) {
if (window.location !== window.parent.location) {
require("core-js/stable");
Expand Down Expand Up @@ -269,6 +272,21 @@ export class DualKpi implements IVisual {
rootElement: options.element,
handleTouchDelay: 0
});


this.selectionManager = this.host.createSelectionManager();

const visualSelection = d3.select(this.target);
visualSelection.on("contextmenu", () => {
const mouseEvent: MouseEvent = d3.event as MouseEvent;
const eventTarget: EventTarget = mouseEvent.target;
let dataPoint: any = d3.select(<any>eventTarget).datum();
this.selectionManager.showContextMenu(dataPoint ? dataPoint.selectionId : {}, {
x: mouseEvent.clientX,
y: mouseEvent.clientY
});
mouseEvent.preventDefault();
});
}

private initMouseEvents(): void {
Expand Down

0 comments on commit 85a596a

Please sign in to comment.