Help Center/ Data Lake Visualization/ Developer Guide/ Custom Component Development
Updated on 2022-02-22 GMT+08:00

Custom Component Development

Environment Preparation

Go to the Node.js official website and download and install a Node.js version suitable for your operating system. Node.js supports the Windows, macOS, and Linux operating systems.

Installing Developer Tools

  1. Log in to the DLV management console. On the Control Center > Components page, click Download Developer Tools in the upper right corner of the page to download the developer tool package named dlv-cli-x.x.x, where x.x.x indicates the tool version.
  2. Decompress the dlv-cli-x.x.x package to the local host. Open the command prompt window in Windows or open the CLI terminal in Linux or Mac. Run the cd command to go to the dlv-cli-x.x.x directory, and run the npm i command to install dependency packages, and then run the npm link command to install the dlv-cli developer tool.
  3. After the installation is successful, run the dlv command to view information about the current developer tool.
    Figure 1 Running the dlv command
    Table 1 Description of developer tool commands

    Command

    Description

    dlv init

    Quickly initialize component templates.

    dlv start

    Start component packages to preview components.

    dlv package

    Package components.

Generating Component Packages

A component package is a custom component template provided by DLV. You can develop components based on the custom template.

Create a directory, for example, newCom, go to the directory, and run the dlv init command to create a component, as shown in Figure 2. Enter the information about the new component as prompted.

Do not run the dlv init command in the directory of developer tool dlv-cli-x.x.x. Otherwise, the developer tool cannot be used properly.

Figure 2 dlv init
Table 2 Component messages

Message

Description

Please select a language...

Use ↑ and ↓ to select a language.

Please set the component name...

Set a component name, which consists of 1 to 32 characters, including letters, digits, and underscores (_), and must start with a letter or underscore (_). Unless otherwise specified, the names in this document comply with the naming rules.

Please set the component alias...

Set a component alias, which consist of 1 to 32 characters, including Chinese, letters, and special characters. .

Please set the component version number...

Set a component version number. The default version number is 1.0.0.

Please describe the component...

Describe a component.

If the corresponding template file is generated in the new directory, the component package is successfully generated.

├──node_modules # npm dependency package

├──gui.json # Component configuration

├──index.js # Component entry

├──index.less # Component style

└──package.json # npm module description

Developing Components

After a component package is generated, you can customize components based on the generated template. For details, see Component Development Guide.

Previewing Components

Go to the component directory and run the dlv start command to preview a component. If the command output shows that the service is started, the Chrome browser is automatically launched and navigates to the component preview page.

The preview page consists of the central canvas area and the toolbar on the right. The details are as follows:

  • Central canvas area

    The central canvas area displays components and allows you to observe component changes in real time.

    All configurations and data modifications made on the toolbar on the right are displayed on the components of the central canvas in real time.

    The black frame of a component indicates the container size of the component. The black frame can be scaled in each direction to test the scaling performance of the component.

  • Toolbar

    The toolbar on the right consists of the pattern, data, and interaction panels.

Table 3 Panel description

Panel

Description

Pattern

The Pattern panel provides configuration items for components. After you set the configuration items, the corresponding configurations take effect on the components immediately.

Data

The Data panel provides data API configuration items for components. Once the data on the Data panel is changed, the changes are made on the components accordingly.

Interaction

The Interaction panel describes the component interaction.

Publishing Components

Go to the component directory and run the dlv package command. A tar.gz package named in the format of component name-version number is generated outside the component directory. Upload the package to a component package on the Components page of the DLV management console to publish the package.