Multi-select drop-down box

更新时间:
复制 MD 格式

This topic describes the style and configuration items of the multi-select drop-down box widget.

Chart style

The multi-select drop-down box is a control widget. You can use it as a drop-down form in a visualization application. It submits user-selected data to the backend for processing. You can also configure interactions to display the selected content on other widgets.

Configuration panel

  • Search for Configurations: In the right-side panel of Canvas Editor, click the Settings tab, and click Search for Configurations in the upper-right corner. Enter the required configuration item in the search box, and click the search icon to quickly locate the configuration item. Fuzzy match is supported. For more information, see Search for Configurations.
  • Size: indicates the size of a widget, including its pixel width and height. You can click the Proportional resizing icon to proportionally adjust the width and height of a widget. After you click this icon again, you can adjust the width and height as needed.
  • Position: the position of a widget, which is indicated by pixel X and Y coordinates. X-coordinate indicates the pixel distance between the upper-left corner of the widget and the left border of the canvas. Y-coordinate indicates the pixel distance between the upper-left corner of the widget and the upper border of the canvas.
  • Rotation Angle: the angle of a rotation that uses the center point of a widget as the rotation point. The unit is degrees (°). You can use one of the following methods to control the rotation angle of a widget:
    • Directly enter the degrees in the Rotation Angle spin box or click the plus sign (+) or minus sign (-) to increase or decrease the value in the Rotation Angle spin box.
    • Drag the black dot in the Rotation control icon icon.
    • Click the Horizontal flip icon to horizontally flip a widget.
    • Click the Vertical flip icon to vertically flip a widget.
  • Opacity: the opacity of a widget. Valid values: 0 and 1. If this parameter is set to 0, the widget is hidden. If this parameter is set to 1, the widget is completely displayed. Default value: 1.
  • Input Box

    • Default Selection: Sets the default selected items. The values must exist in the value field in the data source. You can separate multiple items with a comma (,).

    • Enhanced Features: Provides the following enhancements for the input box.

      Parameter

      Description

      Drop-down Search

      Turn on this switch to enter custom search content in the input box and filter the data in the drop-down list. Turn off this switch to disable this feature.

      Clear Selection

      Turn on this switch to display the Clear Style configuration item. You can set the size and color of the clear arrow, its margin from the right, and its background color. Turn off this switch to disable the clear selection feature.

      Single-line Display

      Turn on this switch to display all content in a single line. Turn off this switch to allow content to be displayed on multiple lines.

    • Border Style: Configures the style of the input box border.

      Parameter

      Description

      Default

      The line weight, line type, line color, and border radius of the default border.

      Hover

      The line weight, line type, line color, and border radius of the border when you hover the mouse over it.

      Selected

      Triggered when you click the input box border. Sets the border color. We recommend setting the selected color to the hover color with an opacity of 0.2.

    • Content Style: Configures the style of the content in the input box.

      Parameter

      Description

      Text Indent

      The text indent in the input box, in px.

      Background Color

      The background color of the input box. For more information, see Color picker.

      Text Style

      The style of the text entered during a search, the placeholder text, and the text displayed when the drop-down list is empty. This includes the font, weight, size, and color.

      Placeholder Text Content

      The content of the placeholder text when the input box is empty.

      Label Configuration

      • Background Color: The background color of the labels displayed in the input box.

      • Text: The style of the label text in the input box, including font, weight, size, and color.

      • Border: The border weight, type, color, and radius. Border types include Solid line, Dashed line, Dotted line, Double solid line, Groove, Ridge, Inset, and Outset.

      • Padding: The padding on all four sides inside the label.

      • Margin: The margin on all four sides outside the label.

      • Delete: The size and color of the delete icon, and its margin from the right.

    • Arrow Style: Configures the style of the arrow in the input box. You can click the 眼睛图标 icon to show or hide the arrow style settings.

      Parameter

      Description

      Size

      The size of the drop-down arrow.

      Color

      The color of the drop-down arrow.

      Right Margin

      The distance between the drop-down arrow and the right border of the widget, in px.

  • Drop-down Box

    • Height: Configures the height of the drop-down box.

      Parameter

      Description

      List Height

      The total height of the drop-down list, in px.

      Option Height

      The height of each option in the drop-down list, in px.

      Container Top Margin

      The distance from the top of the drop-down container to the multi-select drop-down box, in px.

    • Background: The background color of the drop-down box.

    • Border: Configures the border style of the drop-down box.

      Parameter

      Description

      Weight

      The weight of the drop-down box border line.

      Type

      The line style of the drop-down box border. Options include Solid line, Dashed line, Dotted line, Double solid line, Groove, Ridge, Inset, and Outset.

      Color

      The color of the drop-down box border.

      Border Radius

      The border radius of the drop-down box, in px.

    • Text: Configures the style of the option text in the drop-down box.

      Parameter

      Description

      Font

      The font style of the option text in the drop-down box.

      Weight

      The weight of the option text in the drop-down box.

      Size

      The font size of the option text in the drop-down box.

      Color

      The color of the option text in the drop-down box.

    • Margin: The distance between the content of an option and its four borders, in px.

    • Icon Configuration: Configures the style of the icon to the left of the option text. You can click the 眼睛图标 icon to show or hide the icon configuration.

      Note

      The value of the Icon Configuration setting must match the value of the imgSrc field in the data panel. By default, the sample widget data configures the icon field for only the first data item. To configure icons for other options, you must customize the imgSrc field for the corresponding data items.

      Parameter

      Description

      Width

      The width of the icon.

      Height

      The height of the icon.

      Spacing from Text

      The distance between the icon and the text.

    • Option Hover Style

      Parameter

      Description

      Background

      The background color when you hover the mouse over an option in the drop-down box.

      Text

      The text style when you hover the mouse over an option in the drop-down box. This includes the font, weight, size, and color.

    • Option Selected Style

      Parameter

      Description

      Background

      The background color when you hover the mouse over an option in the drop-down box.

      Text

      The text style when you hover the mouse over an option in the drop-down box. This includes the font, weight, size, and color.

      Check Color

      The color of the checkbox after an item is checked.

Data panel

Field description

Field

Description

title

The title of the pop-up window for each option in the multi-select drop-down box.

value

The actual displayed value for each option in the multi-select drop-down box.

imgSrc

The icon for each option in the multi-select drop-down box. It is displayed only when the Icon Configuration item is enabled in the configuration panel.

Table 1. Parameters
Parameter Description
Controlled Mode If you turn on the switch, data is not requested when a widget is initialized. Data requests are triggered only based on callback IDs or the method configured in Blueprint Editor. If you turn off the switch, data requests are automatically triggered. By default, the switch is turned off.
Auto Data Request After you select the Auto Data Request check box, you can enable dynamic polling, and manually specify the polling interval. If you do not select this check box, data is not automatically requested. You must manually refresh the page to request data or use Blueprint Editor or callback ID events to trigger data requests.
Data Source In the right-side panel of Canvas Editor, click the Data tab. Click Set next to Static Data. In the Configure Datasource panel, select a data source from the Data Source Type drop-down list. Enter code for data query in the code editor, click Preview Data Response to preview the response of the data source, and then view the response. For more information, see Configure asset data.
Data Filter If you select the Data Filter check box, you can convert the data structure, filter data, and perform simple calculations. If you click the plus sign (+) next to Add Filter, you can configure the script for the data filter in the editor that appears. For more information, see Use the data filter.
Data Response Result The response to a data request. If the data source changes, you can click the Refresh icon icon next to Data Response Result to view the data response in real time.

Interaction panel

You can enable interactions for the widget by selecting Enable next to When a drop-down box item is selected. The multi-select drop-down box widget lets you configure interactions to change the content of drop-down items, trigger data requests, or pass callback values to other widgets. By default, the title, value, and imgSrc values from the data source are passed as callback parameters. For more information about the configuration, see Configure a widget callback ID.

Blueprint editor interaction configuration

  1. In Canvas Editor, right-click a widget in the Layer panel and select Add to Blueprint Editor.
  2. Click the Blueprint Editor icon icon in the upper-left corner of the page.
  3. On the blueprint editor page, click the Multi-select drop-down box widget in the Imported Nodes panel. The configuration parameters for the multi-select drop-down box in the blueprint editor are shown in the following figure.

    • Events

      Event

      Description

      On API Description Request Completion

      This event is triggered after data is successfully returned from a data API and processed by a filter. The processed data is passed as a parameter in JSON format. For a data example, see the Data Response section on the Data tab of the widget's configuration panel in the canvas editor.

      When a data request fails

      This event is triggered when a data API request fails, for example, due to network issues or API errors. The error information is processed by a filter and passed as a parameter in JSON format. For a data example, see the Data Response section on the Data tab of the widget's configuration panel in the canvas editor.

      When a drop-down box item is selected

      This event is triggered when a user selects an item from the drop-down box. The data item that corresponds to the selected item is passed as a parameter.

    • Actions

      Action

      Description

      Request API description

      Re-requests data from the server. Data from input data processing nodes or layer nodes is used as parameters. For example, if a multi-select drop-down box has its API data source set to https://api.test and the data passed to the Request API description action is { id: '1'}, the final API request is https://api.test?id=1.

      Import API description

      Processes data according to the component's drawing format, then imports it to redraw the component. This action does not re-request server-side data. For a data example, see the Data Response area on the Data tab in the component's configuration panel in the canvas editor.

      Set selected item

      Sets the value in the current drop-down box.

      Clear selected item

      Clears the selected value in the drop-down box.

      Reset component to default

      Resets the currently selected value to the default value.

      Update component configuration

      Dynamically updates the component's style configuration. To get the configuration data, click Copy Configuration to Clipboard in the component's Configuration panel. Then, in the data processing node on the blueprint editor's configuration page, change the style field values as needed.

      Show

      Shows the component. See the following data example.

      return {
        "animationType": "",
        "animationDuration": 1000,
        "animationEasing": "linear"
      };

      Hide

      Hides the component. See the following data example.

      return {
        "animationType": "",
        "animationDuration": 1000,
        "animationEasing": "linear"
      };

      Toggle visibility

      Toggles the component between shown and hidden. See the following data example.

      return {
        "animationIn": {
          "animationType": "",
          "animationDuration": 1000,
          "animationEasing": "linear"
        },
        "animationOut": {
          "animationType": "",
          "animationDuration": 1000,
          "animationEasing": "linear"
        }
      };

      Move

      Moves the component to a specified position. See the following data example.

      return {
        // Move type. Use 'to' for absolute positioning or 'by' for relative positioning. Default: 'to'.
        "positionType": "to",
        // The target position, specified by x and y coordinates.
        "attr": {
          "x": 0,
          "y": 0
        },
        // Animation settings.
        "animation": {
          "enable": false,
          // Animation duration.
          "animationDuration": 1000,
          // Animation curve. Valid values: linear, easeInOutQuad, or easeInOutExpo.
          "animationEasing": "linear"
        }
      };

Demo

This demo shows how to use the multi-select feature of the multi-select drop-down box to dynamically display a choropleth layer of city areas on a basic map.

  1. Log on to the DataV console.

  2. Select a visualization application and click Edit to go to the canvas editor page.

  3. Add the Multi-select drop-down box widget and the Basic Flat Map widget to the canvas.

  4. Click the multi-select drop-down box, go to the Data panel, and modify the static data.

    [
      {
        "title": "Beijing",
        "value": "Beijing",
        "lng": 116.40632076,
        "lat": 39.89450291,
        "isDefaultShow": true,
        "adcode": "110000",
        "colorField": 1200,
        "textureShapeField": "A",
        "textureColorField": 1200,
        "info": "Beijing City"
      },
      {
        "title": "Shanghai",
        "value": "Shanghai",
        "lng": 121.47299061,
        "lat": 31.22716135,
        "adcode": "310000",
        "colorField": 1200,
        "textureShapeField": "B",
        "textureColorField": 150,
        "info": "Shanghai City"
      },
      {
        "title": "Guangdong",
        "value": "Guangdong",
        "lng": 113.2571588,
        "lat": 23.09843572,
        "adcode": "440000",
        "colorField": 1200,
        "textureShapeField": "B",
        "textureColorField": 200,
        "info": "Guangdong Province"
      },
      {
        "title": "Shenzhen",
        "value": "Shenzhen",
        "lng": 114.05894426,
        "lat": 22.54231542,
        "adcode": "440300",
        "colorField": 1200,
        "textureShapeField": "B",
        "textureColorField": 700,
        "info": "Shenzhen City"
      },
      {
        "title": "Tianjin",
        "value": "Tianjin",
        "lng": 117.19545325,
        "lat": 39.07749431,
        "adcode": "120000",
        "colorField": 1200,
        "textureShapeField": "B",
        "textureColorField": 1500,
        "info": "Tianjin City"
      },
      {
        "title": "Chongqing",
        "value": "Chongqing",
        "lng": 106.54702949,
        "lat": 29.53667791,
        "adcode": "500000",
        "colorField": 1200,
        "textureShapeField": "B",
        "textureColorField": 800,
        "info": "Chongqing City"
      },
      {
        "title": "Jiangsu",
        "value": "Jiangsu",
        "lng": 118.7892579,
        "lat": 32.04676609,
        "adcode": "320000",
        "colorField": 1200,
        "textureShapeField": "B",
        "textureColorField": 100,
        "info": "Jiangsu Province"
      },
      {
        "title": "Sichuan",
        "value": "Sichuan",
        "lng": 104.04941941,
        "lat": 30.5477514,
        "adcode": "510000",
        "colorField": 1200,
        "textureShapeField": "B",
        "textureColorField": 1200,
        "info": "Sichuan Province"
      },
      {
        "title": "Hubei",
        "value": "Hubei",
        "lng": 114.30359243,
        "lat": 30.57913598,
        "adcode": "420000",
        "colorField": 1200,
        "textureShapeField": "B",
        "textureColorField": 400,
        "info": "Hubei Province"
      },
      {
        "title": "Shaanxi",
        "value": "Shaanxi",
        "lng": 108.92574006,
        "lat": 34.30156022,
        "adcode": "610000",
        "colorField": 1200,
        "textureShapeField": "B",
        "textureColorField": 600,
        "info": "Shaanxi Province"
      },
      {
        "title": "Qinghai",
        "value": "Qinghai",
        "lng": 101.78380219,
        "lat": 36.58760494,
        "adcode": "630000",
        "colorField": 1200,
        "textureShapeField": "B",
        "textureColorField": 200,
        "info": "Qinghai Province"
      }
    ]
  5. Right-click a component and import the multi-select drop-down box, basic map, and choropleth layer into the blueprint editor.

  6. Connect the widgets.

  7. Configure the processing method for the serial data processing node.

    • Set the display position

      return {
        zoom: 8,//Set the map zoom level
        lng: data[data.length - 1].lng,//Display the longitude of the last city
        lat: data[data.length - 1].lat,//Display the latitude of the last city
        duration: 0.25//Set the map response interval
      }
    • Set the target choropleth layer

      let list = [];
      for (let item of data) {
        let obj = {
          adcode: item.adcode,
          name: item.name,
          colorField: item.colorField,
          textureShapeField: item.textureShapeField,
          textureColorField: item.textureColorField,
          info: item.info
        }
        list.push(obj);
      }
      return list;
  8. Click the image icon in the upper-right corner of the page to preview the results.