How to use the powerbi-client.service function in powerbi-client

To help you get started, we’ve selected a few powerbi-client examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github SharePoint / sp-dev-fx-webparts / samples / js-powerbi-embedded / src / webparts / powerBiEmbedded / PowerBiEmbeddedWebPart.ts View on Github external
// embed configuration.
    // generate the access token with "powerbi create-embed-token -r"
    // get the report id via "powerbi get-reports"
    var embedConfiguration = {
      type: 'report',
      accessToken: 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ2ZXIiOiIwLjIuMCIsImF1ZCI6Imh0dHBzOi8vYW5hbHlzaXMud2luZG93cy5uZXQvcG93ZXJiaS9hcGkiLCJpc3MiOiJQb3dlciBCSSBOb2RlIFNESyIsIndjbiI6IlBvd2VyQkktUm9sYW5kIiwid2lkIjoiN2JmNmU0ZDMtNjJkZi00YmY1LWJhZDQtYjA0OTI3OWQ0NmQxIiwicmlkIjoiY2NhMGVjYjQtYjc4Yi00Njk4LWJlYzQtZjc3YmU4OGY0YTFmIiwibmJmIjoxNDczNzI2MTcyLCJleHAiOjE0NzM3Mjk3NzJ9.tI-yc_YGuw0krR0T-FNZ9e1ueyMcdQLlbP5L2o3K2I0',
      id: 'cca0ecb4-b78b-4698-bec4-f77be88f4a1f',
      embedUrl: 'https://embedded.powerbi.com/appTokenReportEmbed'
    };

    // grab a reference to the HTML element containing the report
    var reportContainer = document.getElementById('reportContainer');

    // construct a PBI service; according to the documentation this should be already available as a global variable,
    // but in my case that did not work.
    let powerbi = new pbi.service.Service(pbi.factories.hpmFactory, pbi.factories.wpmpFactory, pbi.factories.routerFactory);
    var report = powerbi.embed(reportContainer, embedConfiguration);

    // attach an event handler for the
    document.getElementById("fullscreen").addEventListener("click", () => {
      var report = powerbi.get(reportContainer);

      report.fullscreen();
    });
  }

powerbi-client

JavaScript library for embedding Power BI into your apps. Provides service which makes it easy to embed different types of components and an object model which allows easy interaction with these components such as changing pages, applying filters, and res

MIT
Latest version published 4 months ago

Package Health Score

83 / 100
Full package analysis