我想在我的Power BI嵌入式报告中添加一些筛选器,我有一个HTML文件,并且需要在JavaScript中添加一些筛选器,但我没有开发经验。我只需要看一个例子,以了解如何添加它。
我认为在这行代码之后添加筛选器:var report = powerbi.embed($reportContainer.get(0), embedConfiguration);。
<head> `enter code here`
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>test</title>
<script type="text/javascript" language="javascript" src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script type="text/javascript" language="javascript" src="https://rawgit.com/Microsoft/PowerBI-JavaScript/master/dist/powerbi.min.js"></script>
</head>
<body>
<h1>test</h1>
<div id="reportContainer" style="width: 80%; height: 800px;"></div>
</body>
<script>
$(document).ready(function () {
var getEmbedToken = "https://testclienttest.azurewebsites.net/api/HttpTrigger1?code=XXXXXXXXXXXXXXXXXXX/XXXXXXXXXXXXX==";
$.ajax({
url: getEmbedToken,
jsonpCallback: 'callback',
contentType: 'application/javascript',
dataType: "jsonp",
success: function (json) {
var models = window['powerbi-client'].models;
var embedConfiguration = {
type: 'report',
id: json.ReportId,
embedUrl: json.EmbedUrl,
tokenType: models.TokenType.Embed,
accessToken: json.EmbedToken
};
var $reportContainer = $('#reportContainer');
var report = powerbi.embed($reportContainer.get(0), embedConfiguration);
},
error: function () {
alert("Error");
}
});
});
</script>
</html>
我认为在这行代码之后添加筛选器:var report = powerbi.embed($reportContainer.get(0), embedConfiguration);。