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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
shailendrakr
Microsoft Employee
Microsoft Employee

Resize ggplot based custom visual

Hello,

 

I built a custom visual using ggplot in R, following the instructions from here: https://docs.microsoft.com/en-us/power-bi/developer/visuals/funnel-plot-from-r The visual shows up on PowerBI but is extremely big. When I resize the visual, the visual gets cut off - it does not become smaller to fit the space that is available. 

What am i doing wrong?

 

I am using ggplot on R 4.x, and PowerBI desktop Version: 2.85.681.0 64-bit (September 2020)

2 REPLIES 2
sogrbilja
New Member

I found a solution to this. In the src folder you will find the visual.ts file, open it and in the constructor comment out :

//this.imageElement.className = "rcv_autoScaleImage";

 

and change onResizing to look like this:

    public onResizing(finalViewport: IViewport😞 void {
        this.imageDiv.style.height = finalViewport.height + "px";
        this.imageDiv.style.width = finalViewport.width + "px";
        this.imageElement.style.height = finalViewport.height + "px";
        this.imageElement.style.width = finalViewport.width + "px";
    }
 
Because it is actually outputting an image and CSS is not good so we have to change it. Now my R visual is perfect again!
sogrbilja
New Member

I have the exact same problem here. When the script is run directly on the PowerBI desktop then it works. But when I pack it with pbiviz then it is not showing properly. Hopefully, someone will answer this soon. Thanks

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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

Top Solution Authors
Top Kudoed Authors