Skip to content

Commit

Permalink
Merge pull request #67 from starschema/#52-Support-rendering-Events-API
Browse files Browse the repository at this point in the history
add rendering events
  • Loading branch information
szilardhuber authored May 19, 2023
2 parents f6bb77a + 3c90b28 commit b115012
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/visual.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import DataView = powerbiVisualsApi.DataView;
import VisualObjectInstanceEnumerationObject = powerbiVisualsApi.VisualObjectInstanceEnumerationObject;
import ISelectionManager = powerbiVisualsApi.extensibility.ISelectionManager;
import ISelectionId = powerbiVisualsApi.visuals.ISelectionId
import IVisualEventService = powerbiVisualsApi.extensibility.IVisualEventService;

import { featureCollection } from "@turf/helpers"
import bbox from "@turf/bbox"
Expand Down Expand Up @@ -95,6 +96,7 @@ export class MapboxMap implements IVisual {
private tooltipServiceWrapper: ITooltipServiceWrapper;
private selection: Selection<any>;
private selectionManager: ISelectionManager;
private events: IVisualEventService;

constructor(options: VisualConstructorOptions) {
this.target = options.element;
Expand Down Expand Up @@ -122,7 +124,7 @@ export class MapboxMap implements IVisual {
this.tooltipServiceWrapper = createTooltipServiceWrapper(options.host.tooltipService, options.element);

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

this.events = options.host.eventService;
}

updateZoom(settings: MapboxSettings) {
Expand Down Expand Up @@ -380,18 +382,21 @@ export class MapboxMap implements IVisual {

public update(options: VisualUpdateOptions) {
// TODO fetch all data instead of first page
this.events.renderingStarted(options);
this.settings = MapboxMap.parseSettings(options && options.dataViews && options.dataViews[0]);

const dataView: DataView = options.dataViews[0];

if (!dataView) {
console.error('No dataView received from powerBI api')
this.events.renderingFailed(options);
return
}

if (!this.validateOptions(options)) {
this.errorDiv.style.display = 'block';
this.removeMap();
this.events.renderingFailed(options);
return false;
}

Expand Down Expand Up @@ -441,6 +446,7 @@ export class MapboxMap implements IVisual {
this.errorDiv.innerHTML = (e && e.error && e.error.message) ? e.error.message : Templates.MissingToken;
this.errorDiv.style.display = 'block';
this.removeMap();
this.events.renderingFailed(options);
})
this.map.setStyle(this.mapStyle);
}
Expand All @@ -449,8 +455,10 @@ export class MapboxMap implements IVisual {
this.manageDrawControlElements()
}
this.updateLayers(dataView)
this.events.renderingFinished(options);
return;
}
this.events.renderingFinished(options);
}

private manageDrawControlElements() {
Expand Down

0 comments on commit b115012

Please sign in to comment.