Adjust the content to align with the dimensions of the Angular PowerBI client's

I have created some reports in Power BI with an iframe height of 80rem, which is fine. However, I am encountering an issue where if the report's height is lower, it leaves a blank space that I would like to eliminate.

https://i.sstatic.net/mabKQ.png

I have experimented with CSS, but adjusting the iframe height causes other reports to be cut off. Removing the height setting results in the report displaying at a fixed size of 300w x 150h. I have also attempted to utilize pages layout, display options, and visual layouts without success. The guide I am following is available here: https://github.com/Microsoft/PowerBI-JavaScript/wiki/Custom-Layout

After reading about pages layout, I believe this issue can be resolved using that method, but I am unsure how to implement it. Do you have a solution for this? Thank you in advance.

The configuration for Power BI is as follows:

  this.config = {
        accessToken: accessToken && accessToken.currentValue ? accessToken.currentValue : this.config.accessToken,
        tokenType: tokenType && tokenType.currentValue ? this.getTokenType(tokenType.currentValue) : this.config.tokenType,
        embedUrl: embedUrl && embedUrl.currentValue ? embedUrl.currentValue : this.config.embedUrl,
        type: type && type.currentValue ? type.currentValue : this.config.type,
        id: id && id.currentValue ? id.currentValue : this.config.id,
        filters: filtersExternal && filtersExternal.currentValue ? filtersExternal.currentValue : this.config.filters,
        ...this.fixedConfig
    };

And Fixed config:

 // Fixed configuration
fixedConfig: IEmbedConfiguration = {
    settings: {
        navContentPaneEnabled: false,
        filterPaneEnabled: false,
        customLayout: {
            pageSize: {
                type: models.PageSizeType.Custom,
                height: 600,
                width: 1300
            }
        }
    }
};

Answer №1

Successfully resizing the Power BI report in the UI with this method

 this.reportService.getReportObject(reportName).subscribe(res => {
       
        this.reportmodel = res;
        this.config = {
            type: res.reportType,
            id: res.id,
            accessToken: res.embedToken.token,
            embedUrl: res.embedUrl,
            permissions: pbi.models.Permissions.All,
            tokenType: pbi.models.TokenType.Embed,
            viewMode: pbi.models.ViewMode.View,
            settings: {
                filterPaneEnabled: false,
                navContentPaneEnabled: navigation,
                layoutType: pbi.models.LayoutType.Custom,
                customLayout: {
                   displayOption: pbi.models.DisplayOption.FitToWidth
                }
            }
        };
        this.hideloader(); 
        this.pbiContainerElement =  document.getElementById('pbi-container');
        this.powerBiService = new NgxPowerBiService();
        this.powerBiService.reset(this.pbiContainerElement);
        const reportobj = this.powerBiService.embed(this.pbiContainerElement, this.config) as pbi.Report;
        reportobj.off('loaded');
        reportobj.on('loaded', () => {
            reportobj.setPage(this.reportmodel.pageName);
                 });
    },
    err => {
        this.hideloader();
        console.log(err);
        this.dashboardLoadError = true;
        throw new Error('Exception occured while rendering the dashboard:' + err);
    });

Answer №2

Good Morning,

After some investigation, I have found that the issue I was facing was related to maintaining a 16:9 aspect ratio on certain screens, which resulted in a significant decrease in height. The solution turned out to be very simple - adjusting the height of the container div of the iframe based on the width of the screen:

    @media only screen and (max-width: 1600px) {
        // TODO: Define a variable
        height: 60rem;
    }
    @media only screen and (max-width: 1300px) {
        // TODO: Define a variable
        height: 55rem;
    }
    @media only screen and (max-width: 800px) {
        // TODO: Define a variable
        height: 35rem;
    }

This adjustment ensures that the iframe adapts to the content of the report.

Here is my HTML code for the div and iframe:

    <div class="tn-powerbi__frame" [ngClass]="{ 'tn-powerbi__frame--fullscreen': fullscreen,'tn-powerbi__frame--insurtech': reportId===20  }" #powerbiFrame></div>

Best Regards, Iván Allué

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

I am unable to view the data in the autocomplete drop-down menu

I'm currently encountering an issue with my autocomplete feature. Whenever I click on the input field, a dropdown menu should appear with all available options to choose from. However, I am having trouble with the visibility of these fields. I have t ...

Center-align the content in Material UI Typography by using the variant attribute for the caption

I'm struggling to center the content of my Typography elements with default and caption variants using the align="center" property. The alignment doesn't seem to be working properly, especially for the variant as caption. Here is a snip ...

Setting up Scss and purgeCss configuration in Next.js custom postCSS configuration: A step-by-step guide

My current project is using Scss in combination with Bootstrap for design. I have implemented purgeCss to remove unused Css, and customized my postcss.config.js file as follows: module.exports = { plugins: [ "postcss-flexbugs-fixes", [ " ...

Utilizing a conditional ngIf statement in HTML or incorporating a variable within typescript for logical operations

When working with our application, we often need to display or hide a button based on specific logic. Where do you think it is best to define this logic and why? In HTML: *ngIf='logic goes here' //Or *ngIf='someBoolean' and in Type ...

The redirect feature for the authentication guard is ineffective when used on child routes

I am new to Angular and I'm working on an app where I handle my login service in the following way: export class AfterLoginService implements CanActivate { canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): boolean | Observable& ...

The alignment of input boxes is off

Apologies for the somewhat vague title, I struggled to come up with a more accurate description of my issue. Here is a basic HTML form: <html> <FIELDSET> <DIV> <SPAN class="label">Label 1</SPAN> <DIV ...

Selenium technique for navigating iframes without specific identifiers

I encountered an issue while trying to switch to an iframe on a page I am scraping. The ID has been removed from the iframe, making it difficult for me to switch to it. Unfortunately, I have not been able to find any helpful documentation on this matter. I ...

Is there a problem with scrolling when using .animate() and .prop() functions?

When scrolling one of two divs with the same class, I want the other div's scroll to reset to 0 with a smooth animation. While achieving this using .prop() is easy, using .animate() only works once and then stops. Any suggestions on how to make the sc ...

Contact the help desk and receive information that is currently unknown

There are a few issues that I'm struggling to resolve. I am utilizing SwaggerService to fetch data, but the response is coming back as undefined. import {SwaggerService} from '../../services/swagger.service'; export class TestComponent im ...

Applying CSS styles with a 1-second delay, possibly using styled-components

Embarking on my inaugural journey to construct a website/documentation, I have delved into the realms of React and enlisted the assistance of docusaurus. However, upon reloading the site, an unsettling occurrence takes place for approximately 0.5 - 1 secon ...

The components are not syncing with each other, causing discrepancies in their values. Synchronization is crucial for maintaining consistency throughout the system

How can I ensure that two instances of the same component on a page are always synchronized, so when one changes, the other also changes simultaneously? Currently, only one component updates when a button is clicked. How can I make them change together and ...

I am looking to display the <AddProduct /> element within the main-content div of a different component called Dashboard

import { useState,useEffect } from 'react'; import './App.css'; import Header from './Components/Header/Header'; import { BrowserRouter as Router, Route ,Routes} from 'react-router-dom'; import Pages from './Pag ...

Angular2-cli failing to copy files from shared folder to dist directory

Currently, I am utilizing the Angular-cli to build my angular 2 project and performing a production build using ng b -prod The ng-clig created the project, and according to what I understand, all static resources like images should be placed in the share ...

Tips for integrating a new module into the SystemJs configuration file for seamless importing in Angular

Is there a way to incorporate newly downloaded packages from npm into my Angular 2 components using SystemJS and the system.config.js file provided by a starter package? I've attempted to include links to the modules in the map and packages sections o ...

Is there a way to disable the feature of saving input values?

I am dealing with an input field that looks like this: <input name="username" placeholder="Email" type="email" autocomplete="off" /> Even though I have set the autocomplete attribute to off, the previous value still appears when I open the page: h ...

Angular static dropdown option

<input [formControl]="twitterHandle" id="twitterHandle" placeholder="twitterHandle"> Fetching the input value from the Twitter handle input field using the following code: twitterHandle = new FormControl(); this.twitterHandle.value; Similarly, if ...

Tips for positioning a hero image perfectly using HTML and CSS

I am looking to display two hero images on the index page and wondering how to align them. My goal is to have both images centered with 50px separation under the header, ensuring they are of equal height. Will using the flex property work for hero images? ...

Eliminating projectiles from disorganized list

Query If you are interested in accessing the html and css for the current website I am developing, you can locate it at /Query I am currently facing an issue with removing the bullets displayed in the top horizontal menu (Home...Contact). Despite follow ...

What causes an element with position:absolute to be placed behind the ::after pseudo-element?

Being a beginner in HTML and CSS, I recently encountered a challenge while working on some exercises. My goal was to create a website with a blur effect, so I decided to design a header with the class "showcase" and nested inside it, a div with the class " ...

Is there a single function that can handle multiple sliders sharing identical options?

Currently, I am utilizing jQuery UI to generate 6 sliders with identical options for a survey. I am curious if there exists a method to merge all these sliders into one function while maintaining the ability to operate them individually? If such a soluti ...