Action interface configuration

更新时间:
复制 MD 格式

If a block needs to expose an interface that other widgets can call, you must create an action interface. For example, if an external widget needs to control the color of a Vertical Capsule Column Chart widget within a block, you can create an Update Style action to use in the blueprint editor of a visualization application. This topic describes how to configure action interfaces for a block.

In the block editor, click the 动作图标 icon in the upper-right corner. On the Action Settings tab, you can perform the following operations.

Switch modes

At the top of the dialog box, you can switch the action mode. The options are View Mode and Code Mode.

Mode Description
View Mode In view mode, you can see the style of the sample action and customize the action content based on the sample style without writing code.
Sample action panel in view mode
视图模式下的动作面板示例
Code Mode In code mode, you can write custom code for your required action based on the sample action code. This lets you add or configure action content.
Sample action panel in code mode
代码模式下的动作面板示例
Note For more information about the code specifications for configuring action interfaces, see Widget development specifications.

Configure the action interface

On the Action Settings tab, a sample action is provided by default. You can customize its content.动作接口示例

Operation Description
Expand the action details list Click the 下拉图标 icon to the right of the sample action to open the detailed configuration list for the current action.
Edit basic action information Each action contains multiple parameters. You can edit the basic information parameters of an action.
  • Name: The name of the action.
  • Display Name: The name of the action that is displayed externally. After you confirm the change to the display name, press Enter. The result immediately appears in the configuration panel.
  • Description: The description of the action.
  • Data Type: Select a data type for the action. The options are Object, Array, Any, and None.
Delete an action Click the 删除图标 icon to the right of the action to delete the current action.
Add an action Click Add Data Interface on the Action Settings tab to add a new action to the configuration area below.
Note You can add or edit multiple actions for the block interface.

Configure action fields

In the action configuration panel, two sample action fields are added by default. You can customize these fields.动作字段示例

Operation Description
Edit basic field information Each action field contains multiple parameters. You can edit the field parameters.
  • Field Name: Enter the English name of the action field. The field name must consist of English characters and serves as the key when passing parameters.
  • Chinese Name: Enter the Chinese display name for the field. The Chinese name must be within 10 characters and is used to explain the meaning of the field.
  • Description: Enter a detailed description for the field. The description must be within 25 characters.
  • Type: Select a type for the field. The options are String, Number, Object, Array, Boolean value, and Binary.
  • Default Value: Enter the default value for the field. This is optional.
  • Optional: Select whether the field is required. The options are Required and Optional. This is optional.
Add a field Click the 新增按键 icon to the right of a field row and select Add Sibling to add a new field row.
Adjust field positions After adding multiple field rows to the data interface, click the 调整位置图标 icon on the far left of a field row and drag the row to adjust its vertical order among other rows.
Delete a field Click the 删除字段图标 icon to the right of a field row to delete the field.
Note After deleting all fields in the list, click Add Field in the field list to quickly add a new field row.
添加字段

View and use action interfaces in a visualization application

After you configure an action interface in the block editor, you can use the block in a visualization application and view its interface information in the blueprint editor. The following steps describe how to view and use the interface in a visualization application.

  1. In the block editor, preview and test the configured action interface. After the test is successful, publish the block. For more information, see Preview a block and Publish a block.测试修改动作参数样式
  2. Switch to the My Visualizations page in the console. Hover over a visualization application and click Edit to open the canvas editor.
  3. Click the 资产列表 icon to expand the All Assets list. Select the Blocks module to view the list of published blocks.
  4. Click the desired block to add it to the canvas editor.
  5. Select the block on the canvas, right-click it, and then select Export to Blueprint Editor.
  6. Switch to the blueprint editor. Drag the block node to the blueprint editor canvas to view the event and action interface information for the block. In the blueprint editor, the block's event and action interfaces can be called by other widgets by connecting lines and configuring logic nodes. For more information, see Introduction.区块动作信息面板

Preview action configurations in real time

On the Action Settings tab, the left area of the dialog box is for customizing action configurations, and the right area provides a real-time preview. The action parameters that you configure on the left are displayed in the preview area on the right in real time, which makes it easy to view the configured content.预览动作区域示例