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 September 15. Request your voucher.

Reply
cch1
Frequent Visitor

embed dashboard pageview.fitToWidth doesn't work

I receive the following error when we try to use the models.PageView.fitToWidth setting in an embedded dashboard's configuration details.  Is there a setting for dashboards?  I'm using v2.0.2 of the power bi api

 

Unable to get property 'fitToWidth' of undefined or null reference

 

var config = {
                type: 'dashboard',
                tokenType: models.TokenType.Embed,
                accessToken: accessToken,
                embedUrl: embedUrl,
                pageView: models.PageView.fitToWidth,
                id: embedDashboardId
            };
1 ACCEPTED SOLUTION
Eric_Zhang
Microsoft Employee
Microsoft Employee


@cch1 wrote:

I receive the following error when we try to use the models.PageView.fitToWidth setting in an embedded dashboard's configuration details.  Is there a setting for dashboards?  I'm using v2.0.2 of the power bi api

 

Unable to get property 'fitToWidth' of undefined or null reference

 

var config = {
                type: 'dashboard',
                tokenType: models.TokenType.Embed,
                accessToken: accessToken,
                embedUrl: embedUrl,
                pageView: models.PageView.fitToWidth,
                id: embedDashboardId
            };

@cch1

Thanks for reporting that. I can reproduce the same issue. I've found the reason is that the model doesn't contain such "PageView" attribute when trying to debug by "console.log(models);". As a workaround, use the constants "fitToWidth"/"oneColumn"/"actualSize" instead.

View solution in original post

1 REPLY 1
Eric_Zhang
Microsoft Employee
Microsoft Employee


@cch1 wrote:

I receive the following error when we try to use the models.PageView.fitToWidth setting in an embedded dashboard's configuration details.  Is there a setting for dashboards?  I'm using v2.0.2 of the power bi api

 

Unable to get property 'fitToWidth' of undefined or null reference

 

var config = {
                type: 'dashboard',
                tokenType: models.TokenType.Embed,
                accessToken: accessToken,
                embedUrl: embedUrl,
                pageView: models.PageView.fitToWidth,
                id: embedDashboardId
            };

@cch1

Thanks for reporting that. I can reproduce the same issue. I've found the reason is that the model doesn't contain such "PageView" attribute when trying to debug by "console.log(models);". As a workaround, use the constants "fitToWidth"/"oneColumn"/"actualSize" instead.

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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