Cannot get data for first render in Power BI custom visual (React)

13 Views Asked by At

After insert my custom visual

export class Visual implements IVisual {
  constructor(options: VisualConstructorOptions) {
     console.log("constructor");
  }
  
  update(options: VisualUpdateOptions) {
     console.log("update");
  } 
}

When user first open this view, only constructor is called, until user has other interactions, e.g. resize the page, select other filters, etc, the update method is called.

But I need this custom visual to be rendered when user first landing on the page, I checked the doc (https://learn.microsoft.com/en-us/power-bi/developer/visuals/power-bi-visuals-concept) Custom visual

It does not mention that the update will be called at first render, so how can I get the data when a user first lands on the page?

Currently the only way works for me is to manually call options.host.refreshHostData(); in constructor, but I'm not sure whether is a correct way of doing it.

My env:

  1. Power BI service with custom visual (React.JS)
  2. pbiviz v5.4.2
0

There are 0 best solutions below