This topic demonstrates how to use the global variable feature through four examples.
Prerequisites
Ensure you are in the canvas editor.
Example 1: Implement query by date
Add widgets to the canvas.
In the canvas editor, click Search at the top, enter General Title and Time Picker, and add them to the canvas.
Click to add widgets to the canvas.
Set static global variables.
In the canvas editor, select the Global Variables tab on the left side.
Click New Variable, name it
date, describe it asdate value, and set its initial value to2023-07-19.
Configure the data source for the General Title widget.
Select the General Title widget and navigate to the Data Source tab.
Set the data source type to database and select an existing data source. Then, input the following SQL statement in the SQL input box.
NoteNote: Use a colon to introduce the global variable. For more information, see the referenced document.
Observe the data return results and the General Title widget's display, which should now show the initial value set for the global variable.

Configure the Time Picker widget for interaction.
Select the Time Picker widget and go to the Advanced tab.
Enable the interaction occurrence switch and link it to the
datevariable under the time field.
NoteThis configuration ensures that any time selection updates the date value.
Preview the configuration.
Click Preview in the upper right corner of the canvas editor to test the settings.
NoteThe preview page initially displays the default value of the global variable, followed by the Time Picker's default value. Changing the time will update the General Title to reflect the selected time value.
Set dynamic global variables.
Return to the canvas editor and change the global variable date's source to Data Source Request.
Select the created data source and input the query code to fetch the current time in the SQL window.
select cast(curDate() as char) as dateAdd a filter to import the date value into the General Title.
return data[0].date;Examine the input and output values of the filter.

Observe the General Title widget, which now displays the dynamically obtained time value.

Preview the dynamic results.
Click Preview in the upper right corner of the canvas editor to test the dynamic settings.
NoteThe preview page initially displays the dynamically obtained time value of the global variable. Changing the time will synchronize the General Title to show the selected time value.
Example 2: Implement data distribution
Add widgets to the canvas.
In the canvas editor, click Search at the top, enter General Title and Number Ticker Board, and add them to the canvas.
Click to add widgets to the canvas.
Set static global variables.
On the left side of the canvas editor, select the Global Variables tab.
Click on New Variable, assign the name
xto it, and specify the initial value.[ { "text": "text", "number": 123 } ]
Configure blueprint interaction.
Click the
icon in the upper left corner to access the blueprint editor.Drag the layer and global variable nodes onto the main canvas of the blueprint.
Select Logic Node and add two serial data processing nodes.
Connect the nodes as shown.

Define the processing methods for the serial data processing nodes.
For the Number Ticker Board:
return [{ value: data[0].number }]For the General Title:
return [{ value: data[0].text }]
Preview the configuration.
Click Preview in the upper right corner of the canvas editor to test the settings.

Example 3: Implement dynamic data summation
Add widgets to the canvas.
In the canvas editor, click Search at the top, enter Number Ticker Board, and add it to the canvas.
Click to add widgets to the canvas.
Set static global variables.
On the left side of the canvas editor, select the Global Variables tab.
Click New Variable and create two global variables named
yandz, with initial values of123and234respectively.
Configure blueprint interaction.
Click the
icon in the upper left corner to access the blueprint editor.Drag the layer and global variable nodes onto the main canvas of the blueprint.
Select Logic Node and add two serial data processing nodes.
Connect the nodes as shown.

Define the processing methods for the serial data processing nodes.
For Node 1:
return [{ value: data + getCallbackValue( "z") }]For Node 2:
return [{ value: data + getLocalValue( "y") }]
Preview the configuration.
Click Preview in the upper right corner of the canvas editor to test the settings.

Set dynamic global variables.
Change the source of the global variable y to Data Source Request and select a dynamic data source such as an API or database.
Configure blueprint interaction.
Select Logic Node and add a Timer.
Activate the Loop switch and set the timer node's delay to 3 seconds.

Connect the nodes as illustrated.

Preview the dynamic results.
Click Preview in the upper right corner of the canvas editor to validate the results. The Number Ticker Board will update every three seconds, demonstrating dynamic data summation.
Example 4: Implement data screening
Add widgets to the canvas.
In the canvas editor, click Search at the top, enter Tab List and Line Chart, and add them to the canvas.
Click to add the Tab List and Line Chart widgets to the canvas.
Select the Tab List widget and navigate to the Data Source tab.
Alter the static data.
[ { "id": 1, "content": "All" }, { "id": 2, "content": "Type A" }, { "id": 3, "content": "Type B" } ]
Set static global variables.
Select the Line Chart widget, navigate to the Data Source tab, and copy the full static data.
In the canvas editor, select the Global Variables tab on the left side.
Click New Variable, create a global variable named
data, and set its initial value to the copied full data from the Line Chart.
Configure blueprint interaction.
Click the
icon in the upper left corner to access the blueprint editor.Drag the layer node onto the main canvas of the blueprint.
Select Logic Node and add a serial data processing node.
Connect the nodes as shown.

Define the processing method for the serial data processing node.
let result = getCallbackValue("data") // Get global variable data return result.filter(i => { if (data.content == "All") { return result; // If the content of the tab list is "All", return all data } else { return i.colorField == data.content; // If the content of the tab list is "Type A" or "Type B", return only the corresponding data } });
Preview the configuration.
Click Preview in the upper right corner of the canvas editor to test the settings. The preview will demonstrate the data screening functionality in action.
