Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Mestu_Paul
Helper I
Helper I

TypeError: activePage.createVisual is not a function (Power BI JavaScript API)

 

Hi everyone,

I'm trying to dynamically add a visual to an embedded Power BI report using the createVisual() method as documented here:
🔗 Microsoft Docs: Create a visual in Power BI embedded

 

 

However, when I try to execute the following code:

try {
      const pages = await this.report.getPages();
      const activePage = pages.find(p  => p.isActive);
      if(!activePage)return;
      const visualLayout = {
        x: 0,
        y: 0,
        z: 0,
        width: 300,
        height: 300
      };
      const visualResponse = await activePage.createVisual('pieChart', visualLayout, false);
      const newVisual = visualResponse.visual;
      await newVisual.update({ title: "Count of RelatedParty by TaxJurisdiction" });

      console.log(" Visual created:", newVisual);

    } catch (error) {
      console.error(" Error creating visual:", error);
    }
 

I get this error:

TypeError: activePage.createVisual is not a function
at _PowerBiService.<anonymous> (power-bi-service.service.ts:151:47)
at Generator.next (<anonymous>)
at fulfilled (main.js:10:24)

What I’ve Checked So Far:

My Power BI JavaScript API version is up to date (    "powerbi-client": "^2.23.1")

The report is properly embedded and interactive
getPages() works fine, meaning activePage is a valid object

 

Any insights or solutions would be really helpful! 🚀

Thanks in advance! 😊

1 ACCEPTED SOLUTION
Mestu_Paul
Helper I
Helper I

Installed package powerbi-report-authoring 

then import the package and its working.

 

 

View solution in original post

2 REPLIES 2
Mestu_Paul
Helper I
Helper I

Installed package powerbi-report-authoring 

then import the package and its working.

 

 

Hi @Mestu_Paul,

Thank you for tour insight's.

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.