Getting started

Updated at:

Many data-driven companies want to build their own enterprise portals or data analytics platforms. They often need to embed Quick BI into these systems to create a unified and integrated data analytics experience. For example, you can embed the Quick BI dashboard editor into your own system. This allows users to edit dashboards and return to your system without leaving the application environment.

You can use the embedded JavaScript Software Development Kit (JS SDK) provided by Quick BI to quickly integrate specific Quick BI pages into your business system. The SDK lets you use parameter settings to flexibly customize page content and navigation logic.

Limitations

  • Only the Professional Edition supports the embedded JS SDK.

  • To embed pages that require a logon state, such as an editor page, you must first set up Single Sign-On (SSO) between your Alibaba Cloud account and your system's account. This enables seamless logon and page operations. For more information, see Alibaba Cloud SSO. Cross-domain embedding can be restricted by browser cookie policies. To avoid potential issues, deploy on the same root domain and verify that the logon state and page operations function correctly.

  • Currently, you can only embed certain Quick BI pages, such as the workbench, template marketplace, my dashboards, subscription management, monitoring and alerts, datasets, data entry, Data Management, Data Preparation, dashboards, workbooks, data dashboards, BI portal, ad hoc analysis, and Downloads pages. For more information, see the Routing key list. You can customize the content displayed on these pages and other attributes, such as the destination URL for the back button.

Procedure

In addition to using iframes, Quick BI provides a more developer-friendly way to embed pages using the embedded JS SDK. The SDK allows developers to customize embedding attributes, listen for embedding events, and invoke embedding behaviors as needed. The following example shows how to embed a dashboard editor page.

Note

You cannot configure embedding attributes, events, or behaviors when you use an iframe. These configurations are only supported when you use the embedded JS SDK.

Step 1: Set up the environment

Before you start, you should be familiar with ES2015. This guide assumes you have intermediate knowledge of HTML, CSS, and JavaScript. Before you start development, go to the Node.js official website to download and install the Node.js environment. Install Node.js 20 or a later version. After the installation is complete, run the following command to verify the installation.

node -v

Step 2: Install the npm package

Before you embed Quick BI using the JS SDK, you must install the SDK's npm package. Quick BI provides different npm packages for various development environments. Choose and install the package that matches your environment.

  • For a general JavaScript environment (no framework)

    npm install @quickbi/bi-embed-client
  • For a React framework environment

    npm install @quickbi/bi-embed-client-react
  • For a Vue2 framework environment

    npm install @quickbi/bi-embed-client-vue2
  • For a Vue3 framework environment

    npm install @quickbi/bi-embed-client-vue

Step 3: Develop the embedded page

The procedure varies depending on the development environment.

  • JavaScript environment (no framework): Create an EmbedClient class instance. Use this instance to render the Quick BI dashboard editor page in your host system.

    import { EmbedClient, EmbedRouteKey } from '@quickbi/bi-embed-client';
    
    const embedClient = new EmbedClient({
      src={
        origin: 'xxx',  // The host for accessing Quick BI
        page: EmbedRouteKey.dashboardEdit,  // The EmbedRouteKey for the dashboard editor page
        // The query parameters for accessing the Quick BI dashboard page
        search: {
            workspaceId: 'xxx',  // Workspace ID
            id: 'xxx',  // Work ID
        }
      }
    })
    
    embedClient.render(document.getElementById('container'))
  • React framework environment (recommended): Embed by rendering the EmbedComponent component. This component automatically creates an embedded client instance and handles re-rendering.

    import React from 'react';
    import ReactDOM from 'react-dom';
    import { EmbedComponent, EmbedRouteKey } from '@quickbi/bi-embed-client-react';
    
    const Demo: React.FC = () => {
      return (
        <EmbedComponent
          src={
            origin: 'xxx',  // The host for accessing Quick BI
            page: EmbedRouteKey.dashboardEdit,  // The EmbedRouteKey for the dashboard editor page
            // The query parameters for accessing the Quick BI dashboard page
            search: {
              workspaceId: 'xxx',  // Workspace ID
              id: 'xxx',  // Work ID
            }
          }
        />
      )
    }
    
    ReactDOM.render(<Demo />, document.querySelector('.container'))
  • Vue2 framework environment: Import the EmbedComponent component directly. This component automatically creates an embedded client instance and handles responsive rendering.

    <template>
      <EmbedComponent 
        :src="embedSrc" 
      />
    </template>
    <script lang="ts">
    import Vue from 'vue'
    import {
      EmbedComponent,
      EmbedRouteKey,
    } from '@quickbi/bi-embed-client-vue2'
    
    export default Vue.extend({
      name: 'SDK',
      components: {
        EmbedComponent
      },
      data() {
        return {
           embedSrc: {
            origin: 'xxx',  // The host for accessing Quick BI
            page: EmbedRouteKey.dashboardEdit,  // The EmbedRouteKey for the dashboard editor page
            // The query parameters for accessing the Quick BI dashboard page
            search: {
              workspaceId: 'xxx',  // Workspace ID
              id: 'xxx',  // Work ID
            }
          },
        }
      },
    })
    </script>
  • Vue3 framework environment: Import the EmbedComponent component directly. This component automatically creates an embedded client instance and handles responsive rendering.

    <script setup lang="ts">
    import {
      EmbedRouteKey,
      EmbedComponent,
    } from "@quickbi/bi-embed-client-vue";
    import type { EmbedSrcUnion } from "@quickbi/bi-embed-client-vue";
    import { ref } from "vue";
    
    const embedSrc = ref<EmbedSrcUnion>({
      origin: 'xxx',  // The host for accessing Quick BI
      page: EmbedRouteKey.dashboardEdit,  // The EmbedRouteKey for the dashboard editor page
      // The query parameters for accessing the Quick BI dashboard page
      search: {
        workspaceId: 'xxx',  // Workspace ID
        id: 'xxx',  // Work ID
      }
    });
    
    </script>
    
    <template>
      <EmbedComponent
        :src="embedSrc"
      />
    </template>

References

  • For more information about the embedded client instance and development methods, see Terms and Embedded JS SDK API.

  • For more examples of how to use the embedded JS SDK, see Developer examples.

  • If you encounter issues during development, see the FAQ for troubleshooting information.