The switch widget toggles between on and off states and can interact with other widgets to control content visibility.
Widget overview
The switch is a control widget that mimics a physical switch. Click it to toggle between on and off states. You can configure interactions with other widgets to control content visibility or present different states.
Scenarios
Use the switch in visualization applications to show or hide specific content by defining its on or off state. For example, use a switch to enable or disable sound, or to show or hide sidebar configurations.
Demonstration
-
Static switch

-
Interaction scenario

Prerequisites
-
Create a data dashboard. You can use a template, use a blank canvas, or use AI to generate one.
-
Your business data is prepared. For more information, see Data Source.
Add a switch widget
-
Access the DataV console.
-
On the Workbench page, in the Data Dashboards area, hover over the target dashboard and click Edit. The canvas editor opens.
-
In the navigation pane on the left, add the Switch widget to the canvas.

You can also use the global search to add components.
Connect to business data
After you add the widget, connect it to your business data. Click the switch widget, and then on the Data Source tab in the right-side panel, configure the data.
-
The following table describes the data fields accepted by the switch widget.
Field
Description
onValueThe value returned when the switch is turned on. The default value is 1.
offValueThe value returned when the switch is turned off. The default value is 0.
stateThe on or off state of the switch. This parameter can only be set to the value of
onValueoroffValue. The default value is 0 or 1. 0 indicates that the switch is off, and 1 indicates that the switch is on.The following shows the data structure and effect of an example switch.
// Turn the switch on [ { "onValue": 1, "offValue": 0, "state": 1 } ] // Turn the switch off [ { "onValue": 1, "offValue": 0, "state": 0 } ]
-
This section describes the core configuration items for the data source.
Configuration
Description
Select Data Source
Supports various data types, such as CSV files, APIs, and different databases. For more information, see Supported data source types. Edit data fields in a visual table or in code.
Configure Filter (Optional)
Customize filter code to transform, filter, display, and perform simple calculations on data. For more information, see Manage data filters.
Configure Data Mapping
Map fields from the selected data source to the widget's fields. This enables real-time data matching. Click the
icon to configure field styles.View Response Result
Displays the data connected to the widget in real time. When the widget's data source changes, this section shows the latest data.
-
Click the data response result to view the data field code.
-
Click View Example to see the array type and sample code that the data source accepts. You can write your fields based on the example.
Other data request configurations:
-
Disable Loading State: If you check this box, the widget's initial loading content does not appear when the widget updates or when you preview the data dashboard.
-
Controlled Mode: If you check this box, the widget does not request data when it initializes. Data requests can only be started by the blueprint editor or by global variable events.
-
Auto Update Request: If you check this box, the platform polls for data updates at the interval you set. If you do not check this box, you must refresh the page manually or use the blueprint editor or global variable events to trigger data updates.
-
Configure the switch widget
Click the switch widget. In the right-side panel, configure its basic styles, advanced settings such as global variables and interaction events, and Blueprint interactions.
Style configuration
On the Style panel, configure the default state, background color, and border style of the switch.
You can also click the
icon and search by keyword to quickly locate a specific configuration item. The search feature supports fuzzy matching. For more information, see Search for configuration items.
The following table describes the configuration items.
|
Configuration Item |
Description |
Example |
|
Global Settings |
Defines the widget's position, transparency, and interaction passthrough in the data dashboard.
|
|
|
Basic Styles |
Configure styles for the switch, including its default selected state, background color, and border properties such as line style, color, thickness, and border radius. The following section provides more details:
|
|
|
Switch Handle Configuration |
Specifies the color, border style, width, height, and vertical offset of the switch handle. |
|
Advanced Configuration
Define interactions between the switch and other widgets. The following table describes the configuration items.
|
Configuration Item |
Description |
Illustration |
|
Interaction Events |
Define interaction behaviors with other widgets to enable filter interactions. Click the |
|
|
Associate Global Variables |
Associate global parameters to pass values between widgets for interaction. Click the When the switch state changes, a data request is triggered and the configured value in the Data Source panel is returned. When the switch is on, the |
Blueprint interaction
Use the Blueprint editor to define interaction relationships and behavior logic between widgets by connecting them visually.
Procedure
-
On the canvas editor page, click the
icon on the left side of the top menu bar to open the Blueprint editor. -
In the layer node list, hover over the switch widget and click the
icon to add the widget to the main canvas. -
Connect the widgets to configure the Blueprint interaction effects as needed.
The following figure shows an example.

icon to configure field styles.



icon to define interaction events and actions.
icon to enable the instruction and associate the required
icon on the left side of the top menu bar to open the Blueprint editor.
icon to add the widget to the main canvas.
icon next to an event or action to view detailed parameter descriptions.