Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PowerBI report size fix #258

Merged
merged 2 commits into from
Feb 19, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 23 additions & 2 deletions modules/quanthub_core/js/qh_core-power-bi-customizer.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
const INTERVAL_TIME = 30 * 1000;
const TIME_TO_UPDATE = 2 * 60 * 1000;

const debounceCallback = (callback, wait) => {
let timeoutId = null;
return (...args) => {
window.clearTimeout(timeoutId);
timeoutId = window.setTimeout(() => {
callback(...args);
}, wait);
};
}

function applyLocaleBookmark(context) {
context.report.bookmarksManager.getBookmarks()
.then(bookmarks => bookmarks.forEach(bm => {
Expand Down Expand Up @@ -55,10 +65,21 @@ function powerbi_embed_customizeReport($, context, width = 0, height = 0, title
}
iframes[i].title = title.length > 0 ? title : 'PowerBI Embed';
iframes[i].name = name.length > 0 ? name : title.length > 0 ? title : 'PowerBI Embed';

const containerWidth = iframes[i].parentNode.offsetWidth;
const defaultAspectRatio = (19 / 32);

const iw = width <= 0 ? '100%' : width + 'px';
const ih = height <= 0 ? iw * (19 / 32) : height;
const ih = (height <= 0 || width <= 0? containerWidth * defaultAspectRatio : height) + 'px';

iframes[i].width = iw;
iframes[i].height = ih + 'px';
iframes[i].height = ih;

const onContainerResize = debounceCallback(() => {
iframes[i].height = iframes[i].parentNode.offsetWidth * defaultAspectRatio + 'px';
}, 500)

new ResizeObserver(onContainerResize).observe(iframes[i].parentNode);
}

checkTokenAndUpdate($, context);
Expand Down