javascript - PowerBI Embedded 垂直滚动条不可见

标签 javascript html css powerbi powerbi-embedded

我嵌入了 PowerBI 报告。这是带有页面设置的 Javascript。

出于某种原因,我的报告中没有垂直滚动条。当我在工作区在线打开它时,滚动条工作得很好。我已经尝试在 PowerBi 中的不同“查看”选项之间切换,但这似乎没有什么不同。

<H2>PowerBI</H2>
<p><i>User: {{username}} | AccessLevel: {{access_level}}</i></p>
<div id="reportContainer" style="height: 80vh;"></div>

<script type="text/javascript">
window.onload = function () {
 
// Get models. models contains enums that can be used.
var models = window['powerbi-client'].models;

var embedConfiguration = {
    type: 'report',
    id: '{{txtembedreportid}}',
    embedUrl: '{{txtreportembed}}',
    tokenType: models.TokenType.Embed,
    accessToken: '{{txtaccesstoken}}',
    settings: {
            layoutType: models.LayoutType.Custom,
            customLayout: {
                pageSize: {
                    type: models.PageSizeType.Widescreen,
                }
            },
            panes:{
                bookmarks: {
                    visible: false
                },
                fields: {
                    expanded: false
                },
                filters: {
                    expanded: false,
                    visible: false
                },
                pageNavigation: {
                    visible: true
                },
                selection: {
                    visible: true
                },
                syncSlicers: {
                    visible: true
                },
                visualizations: {
                    expanded: false
                }
           }
    }
};

var $reportContainer = $('#reportContainer');
var report = powerbi.embed($reportContainer.get(0), embedConfiguration);
report.fullscreen(); 
            }
</script>

最佳答案

尝试在 customLayout 对象中添加值为“FitToWidth”的“displayOption”属性,因为此选项将尝试根据页面的总可用大小来调整报告,并在必要时为剩余部分引入滚动条。

同时将 pageSizeType 对象中的“宽屏”更改为“自定义”

所有更改后,您的 embedConfiguration 将如下所示。

var embedConfiguration = {
    type: 'report',
    id: '{{txtembedreportid}}',
    embedUrl: '{{txtreportembed}}',
    tokenType: models.TokenType.Embed,
    accessToken: '{{txtaccesstoken}}',
    settings: {
            layoutType: models.LayoutType.Custom,
            customLayout: {
                displayOption: models.DisplayOption.FitToWidth, // Add "FitToWidth"
                pageSize: {
                    type: models.PageSizeType.Custom, // Change to "Custom"
                }
            },
            panes:{
                bookmarks: {
                    visible: false
                },
                fields: {
                    expanded: false
                },
                filters: {
                    expanded: false,
                    visible: false
                },
                pageNavigation: {
                    visible: true
                },
                selection: {
                    visible: true
                },
                syncSlicers: {
                    visible: true
                },
                visualizations: {
                    expanded: false
                }
           }
    }
};

引用文档:https://learn.microsoft.com/en-us/javascript/api/overview/powerbi/custom-layout

关于javascript - PowerBI Embedded 垂直滚动条不可见,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66527385/

相关文章:

javascript - sortBy 保留键名

jquery - 一旦悬停,如何阻止无序列表跳转?

css - Typo3:在 lib 中捕获默认生成的 css

html - 将网站拆分为 3 个响应式三 Angular 形

php - 样式数组到常规 CSS

jquery - 可滚动的标签按钮

javascript - 如何在 onclick 事件后在其顶部包含图像的同一单元格上显示文本

javascript - ArcGIS JavaScript API 4.11 - 打印导致 asp.net 中的回发问题

javascript - 使用 momentJS 确定任意时区中指定日期的星期几

javascript - 如何使用 Chart.js API 创建两个饼图?