Skip to content

Commit

Permalink
Bookmarks (#22)
Browse files Browse the repository at this point in the history
Selection performance has been improved by removing useless code and
migrating to InteractiveUtils v3.1.1. Migrating to v3.1.1 brings us the
posibility to multi select data columns via Ctrl + Click
  • Loading branch information
ignatvilesov committed Mar 26, 2018
1 parent aea87ee commit 59c6815
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 101 deletions.
4 changes: 2 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@
"fileMatch": [
"/pbiviz.json"
],
"url": "./.api/v1.3.0/schema.pbiviz.json"
"url": "./.api/v1.11.0/schema.pbiviz.json"
},
{
"fileMatch": [
"/capabilities.json"
],
"url": "./.api/v1.3.0/schema.capabilities.json"
"url": "./.api/v1.11.0/schema.capabilities.json"
}
]
}
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
## 1.2.0
* UPD: powerbi-visuals-tools has been updated to 1.11.2 to support Bookmarks
* UPD: API has been updated to 1.11.2 to support Bookmarks
* UPD: powerbi-visuals-utils-interactivityutils has been updated to 3.2.0 to support Bookmarks
* UPD: powerbi-visuals-utils-testutils has been updated to "1.2.0" to support Bookmarks
* UPD: Improved selection performance by removing useless code
* ADD: Multi selection is supported by Ctrl + Left Click

## 1.1.2
* FIX: Bins selection performance was increased

Expand Down
14 changes: 8 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "powerbi-visuals-histogram",
"version": "1.1.2",
"version": "1.2.0",
"description": "A histogram chart plots data ranges into intervals. Useful for estimating density.",
"repository": {
"type": "git",
Expand All @@ -10,13 +10,14 @@
"powerbi-visuals"
],
"scripts": {
"postinstall": "pbiviz update 1.8.0",
"postinstall": "pbiviz update 1.11.0",
"pbiviz": "pbiviz",
"start": "pbiviz start",
"package": "pbiviz package",
"lint": "tslint -r \"node_modules/tslint-microsoft-contrib\" \"+(src|test)/**/*.ts\"",
"pretest": "pbiviz package --resources --no-minify --no-pbiviz --no-plugin",
"test": "karma start"
"test": "karma start",
"cert": "pbiviz --create-cert"
},
"author": {
"name": "Microsoft",
Expand Down Expand Up @@ -46,14 +47,15 @@
"d3": "3.5.5",
"jquery": "3.1.1",
"lodash": "4.16.2",
"powerbi-visuals-tools": "^1.8.1",
"powerbi-models": "^1.0.2",
"powerbi-visuals-tools": "1.11.2",
"powerbi-visuals-utils-chartutils": "^1.5.1",
"powerbi-visuals-utils-colorutils": "^1.0.0",
"powerbi-visuals-utils-dataviewutils": "1.2.0",
"powerbi-visuals-utils-formattingutils": "^3.0.0",
"powerbi-visuals-utils-interactivityutils": "^2.0.1",
"powerbi-visuals-utils-interactivityutils": "3.2.0",
"powerbi-visuals-utils-svgutils": "^1.1.0",
"powerbi-visuals-utils-testutils": "^1.0.2",
"powerbi-visuals-utils-testutils": "1.2.0",
"powerbi-visuals-utils-tooltiputils": "^1.0.0",
"powerbi-visuals-utils-typeutils": "^1.1.0",
"tslint": "^5.1.0",
Expand Down
4 changes: 2 additions & 2 deletions pbiviz.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
"displayName": "Histogram",
"guid": "Histogram1445664487616",
"visualClassName": "Histogram",
"version": "1.1.2",
"version": "1.2.0",
"description": "A histogram chart plots data ranges into intervals. Useful for estimating density.",
"supportUrl": "http://community.powerbi.com",
"gitHubUrl": "https://github.com/Microsoft/PowerBI-visuals-histogram"
},
"apiVersion": "1.8.0",
"apiVersion": "1.11.0",
"author": {
"name": "Microsoft",
"email": "pbicvsupport@microsoft.com"
Expand Down
61 changes: 7 additions & 54 deletions src/behavior.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,75 +55,28 @@ module powerbi.extensibility.visual {

public bindEvents(
behaviorOptions: HistogramBehaviorOptions,
selectionHandler: ISelectionHandler): void {
selectionHandler: ISelectionHandler
): void {

this.columns = behaviorOptions.columns;
this.interactivityService = behaviorOptions.interactivityService;
this.clearCatcher = behaviorOptions.clearCatcher;

this.columns.on("click", (dataPoint: HistogramDataPoint) => {
selectionHandler.handleClearSelection();
const isCtrlPressed: boolean = d3.event && (d3.event as MouseEvent).ctrlKey;

const areDataPointsSelected: boolean = HistogramBehavior.areDataPointsSelected(
this.selectedDataPoints,
dataPoint.subDataPoints);

if (!areDataPointsSelected) {
dataPoint.subDataPoints.forEach((subDataPoint: SelectableDataPoint) => {
selectionHandler.handleSelection(subDataPoint, true, true);
});

selectionHandler.syncSelectionState(false);

this.selectedDataPoints = dataPoint.subDataPoints;
} else {
this.createAnEmptySelectedDataPoints();
}
selectionHandler.handleSelection(dataPoint.subDataPoints, isCtrlPressed);
});

this.clearCatcher.on("click", () => {
selectionHandler.handleClearSelection();
this.createAnEmptySelectedDataPoints();
});
this.clearCatcher.on("click", selectionHandler.handleClearSelection.bind(selectionHandler));
}

public renderSelection(hasSelection: boolean): void {
histogramUtils.updateFillOpacity(
this.columns,
this.interactivityService,
hasSelection);
}

public static areDataPointsSelected(
selectedDataPoints: SelectableDataPoint[],
dataPoints: SelectableDataPoint[]): boolean {
if (!dataPoints
|| !selectedDataPoints
|| dataPoints.length !== selectedDataPoints.length) {

return false;
}

return selectedDataPoints.every((firstDataPoint: SelectableDataPoint) => {
return dataPoints.some((secondDataPoint: SelectableDataPoint) => {
return HistogramBehavior.areSelectionIdsTheSame(firstDataPoint, secondDataPoint);
});
});
}

private static areSelectionIdsTheSame(
firstDataPoint: SelectableDataPoint,
secondDataPoint: SelectableDataPoint): boolean {

return firstDataPoint
&& secondDataPoint
&& firstDataPoint.identity
&& secondDataPoint.identity
&& (firstDataPoint.identity as ISelectionId).equals(secondDataPoint.identity as ISelectionId);
}

private createAnEmptySelectedDataPoints(): void {
this.selectedDataPoints = [];
hasSelection
);
}
}
}
3 changes: 1 addition & 2 deletions test/_references.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,11 @@
*/

// External
/// <reference path="../typings/index.d.ts" />
/// <reference path="../node_modules/@types/jasmine/index.d.ts" />
/// <reference path="../node_modules/@types/jasmine-jquery/index.d.ts" />

// Power BI API
/// <reference path="../.api/v1.3.0/PowerBI-visuals.d.ts" />
/// <reference path="../.api/v1.11.0/PowerBI-visuals.d.ts" />

// Power BI Extensibility
/// <reference path="../node_modules/powerbi-visuals-utils-typeutils/lib/index.d.ts" />
Expand Down
34 changes: 0 additions & 34 deletions test/visualTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -909,40 +909,6 @@ module powerbi.extensibility.visual.test {
});
});

describe("HistogramBehavior", () => {
describe("areDataPointsSelected", () => {
it("method should return false when dataPoint aren't the same", () => {
let areDataPointsSelected: boolean,
firstDataPoint: SelectableDataPoint[] = [createSelectableDataPoint()],
secondDataPoint: SelectableDataPoint[] = [
createSelectableDataPoint(true, null)
];

areDataPointsSelected = HistogramBehavior.areDataPointsSelected(
firstDataPoint, secondDataPoint);

expect(areDataPointsSelected).toBeFalsy();
});

it("method should return true when dataPoint are the same", () => {
let areDataPointsSelected: boolean,
selectableDataPoint: SelectableDataPoint[] = [createSelectableDataPoint()];

areDataPointsSelected = HistogramBehavior.areDataPointsSelected(
selectableDataPoint, selectableDataPoint);

expect(areDataPointsSelected).toBeTruthy();
});
});

function createSelectableDataPoint(
selected: boolean = false,
identity: ISelectionId = createSelectionId()): SelectableDataPoint {

return { selected, identity };
}
});

describe("Capabilities tests", () => {
it("all items having displayName should have displayNameKey property", () => {
jasmine.getJSONFixtures().fixturesPath = "base";
Expand Down
3 changes: 2 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"declaration": true
},
"files": [
".api/v1.8.0/PowerBI-visuals.d.ts",
".api/v1.11.0/PowerBI-visuals.d.ts",
"node_modules/powerbi-visuals-utils-typeutils/lib/index.d.ts",
"node_modules/powerbi-visuals-utils-svgutils/lib/index.d.ts",
"node_modules/powerbi-visuals-utils-dataviewutils/lib/index.d.ts",
Expand All @@ -19,6 +19,7 @@
"node_modules/powerbi-visuals-utils-interactivityutils/lib/index.d.ts",
"node_modules/powerbi-visuals-utils-chartutils/lib/index.d.ts",
"node_modules/powerbi-visuals-utils-tooltiputils/lib/index.d.ts",
"node_modules/powerbi-models/dist/models-noexports.d.ts",
"src/dataInterfaces.ts",
"src/utils.ts",
"src/behavior.ts",
Expand Down

0 comments on commit 59c6815

Please sign in to comment.