Key concepts

Updated at:

This topic describes the key concepts of Quick BI custom components.

Custom component

In Quick BI, a custom component is an object withbootstrap,mount,unmount, andupdate properties that implements the component's logic. For more information, see lifecycle.

Example

// This is a custom component
const CustomComponent = {
    bootstrap: (props) => {},
  mount: (props) => {},
  unmount: (props) => {},
  update: (props) => {},
}
Note

In most cases, you do not need to manage the custom component lifecycle yourself. Thebi-open-sdk andbi-open-react-sdk provide thecreateBIComponent function to easily create a custom component.

Component meta information

Component meta information is an object that contains properties such aspropsSchema. This object allows you to customize features such as the data panel, style panel, and advanced panel for a Quick BI custom component. For more information, see component meta information.

Example

const meta = {
    propsSchema: {
      dataSchema: {
        schema: {}
    },
    styleSchema: {
        schema: {}
    },
  }
}

Project structure

The recommended way to create a Quick BI custom component is to use thecreate-qbi-app command to generate a seed project. Run thenpm init qbi-app <project name> command to create the project. For more information, see Quick start.

  • File directory

    The generated seed project has the following directory structure:

    ├── build                # Build output directory
    ├── node_modules         # Project dependencies
    ├── public               # Entry point for local debugging
    │    └──index.html
    ├── src                  # Source code
    │    ├──index.tsx        # Component entry point
    │    ├──index.scss       # Component style file
    │    └──meta.ts          # Component property configuration (data, styles, data-to-view mappings).
    ├── .eslintrc            # Configuration file for the ESLint plugin
    ├── config-overrides.js  # webpack configuration file
    ├── package.json         # Dependency management
    ├── README.md            # Project README file
    └── tsconfig.json        # TypeScript configuration file
  • Related commands

    • npm run start: Starts local debugging.

    • npm run build: Builds the project.

    • npm run pack: Packages the build output into a Quick BI development package. This command runsnpm run build by default before packaging.

  • src directory

    This directory contains the custom component's source code:

    • meta.ts: component meta information, used to configure the data panel and style panel.

    • index.tsx: The custom component.

    • index.scss: The style file for the custom component.

  • public directory

    This directory contains the HTML template and mock data for thedevserver.

  • build directory

    This directory contains the build output and the packaged result.

    Runningnpm run build generates the following modules:

    File name

    Module type

    Module name

    main.js

    umd

    BIComponent

    meta.js

    umd

    BIComponentMeta

    main.css

    -

    -

    Note

    To ensure correct build output, do not modify thewebpack configuration.

Custom component status

Quick BI custom components have two status categories: running status and visibility status.

Running status

The running status describes a component's lifecycle from creation to deletion. The states vary depending on the component's development mode. You can manage the running status of a component on thecustom component management page at Open Platform > Custom Components.

Online editing

  • pending release - The component is newly registered, or it was modified after publishing, but the changes have not been synced to the production environment.

  • published - The component is running in the production environment.

image.png

Professional mode

  • in development - The component is registered but no development package has been uploaded.

  • pending release - A development package has been uploaded, or the component has been modified after being published but the changes have not been synced to the production environment.

  • published - The component is running in the production environment.

image.png

Register a component

Click Register Component, fill in the required information, and then click OK.

After successful registration, the component's card appears on the page.

image

The development mode dictates the development process and cannot be changed later. Choose the mode that best suits your needs.

  • Online editing: Allows you to edit and debug directly on the page. This mode is simpler and more convenient. For more information, see Mode 1: Online editing.

  • Professional mode: Uses the SDK for local debugging and is ideal for developing complex components. For more information, see Mode 2: Professional mode.

image

Debug a component

In the component list, click the Debug button on the component card.

image

The debug component dialog box opens.

image.png

In online editing mode, there are three debugging environments:

  • Online Development Environment - You can edit the component's source code online. Other configurations use the settings from the pending release package.

  • Staging Environment - All component resources and configurations are loaded from the pending release package.

  • Production Environment - All component resources and configurations are loaded from the published package.

In professional mode, there are three debugging environments:

  • Local Development Environment - Component resources are loaded from the local server, while other configurations are loaded from the pending release package.

  • Staging Environment - All component resources and configurations are loaded from the pending release package.

  • Production Environment - All component resources and configurations are loaded from the published package.

In the debug component dialog box, select the Debug Scope, workspace, and the corresponding dashboard, and click Go to Debug to open the dashboard.

Online editing

In online editing mode, the component's icon appears in the materials panel. A code editor appears at the bottom of the page. You can select a file from the src directory on the left to edit it. After modifying the code, click the Run button to run the code in real time.

image.png

You can close the code editor panel manually. To reopen it, click the drop-down menu in the upper-right corner of the custom component card and select Edit Custom Component.

image.png

Note

Note:

  • In debug mode, the custom component always appears in the materials panel, ignoring its visibility status.

  • In debug mode, you can save the dashboard, but you cannot publish it.

After you finish developing the component in online editing mode, click the Save button to save the custom component code. The component's status changes to pending release.

image.png

Professional mode

In professional mode, go to the dashboard page and click Add Chart -> Custom. The component's icon appears. Drag it onto the dashboard, configure its data panel, and fetch data. After you modify the code locally, refresh the page to debug your changes.

image.png

Note

Note:

  • In professional mode, ensure that the local component server is running.

  • In debug mode, the custom component always appears in the materials panel, ignoring its visibility status.

  • In debug mode, you can save the dashboard, but you cannot publish it.

After you finish developing the component in professional mode, package the component and upload it on the Open Platform > Custom Components page.

image

Click the Modify button. The component information dialog box opens.

image.png

After you modify the information, click the OK button. The component's status changes to pending release.

You can generate the package by running yarn run pack in the seed project.

Publish a component

When a component has a pending release status, the Publish button on its card is enabled.

image

Click the Publish button. The component change details are displayed, with modified properties highlighted in red.

image

If you are in online editing mode, click View Code Comparison to see the specific code changes.

image.png

Click Confirm Publish to publish the component to the production environment. Its status changes to published.

Delete a component

In the component list, click Delete on a component card to delete the custom component.

image

After deletion:

  • The custom component cannot be added to new dashboards.

  • Existing charts that use the component can no longer render it and instead display the message "The chart meta information is abnormal or has been deleted".

image.png

Visibility status

The visibility status determines if a custom component is displayed in the chart selection list on a dashboard. It has two states:

  • Hidden: In the hidden state, the custom component is not displayed under Add Chart > Custom on the dashboard editing page. You cannot switch chart types to it, but existing charts that use this component are unaffected.

  • Visible: In the visible state, the custom component is displayed under Add Chart > Custom on the dashboard editing page, and you can switch other charts to this component type.

Note

Note:

  • Changing the component's visibility status does not change its running status to pending release. The change takes effect in the production environment immediately.

  • In development mode, the component is always visible.

On the Open Platform > Custom Components page, click the Hide or Show button to change the component's visibility status.

image

This change determines whether the entry point for the component is visible on the dashboard.

image