Events association and triggers
You can customize how each part of your widget can interact with the whole Data App. Widgets can be used as an argument for a function and initialize its execution. For example, when the value of a widget is changed, the function will be executed.
This can be done in a very simple way. Just define a Python function in your code and connect it to a Widget. For each widget, you’ll find the bind function. Bind allows you to connect the result of a function to a Widget, so when the function is executed, the result of the function will show in the selected widget.
Bind allows passing arguments to the inside function. These arguments could be widgets, which means that the value of the widget will be used in the function. Each time a widget is used as an argument and its value changes, the function inside the bind will be executed. Shapelets platform will be listening to those widgets and trigger the function when needed.
Additionally, you can specify other widgets that do not form a part of the function arguments to trigger the execution. You can also mute widgets used as arguments so only their value is used, but a change in their value won’t trigger the execution.
The function bind is available to set these changes between widgets and associate events between them. Essentially, what happens behind the scenes is that once the bind function is activated, the event is analyzed by our platform to make sure the return value will match the associated widget. The Data App API will alert us if something doesn’t look right but don’t worry, we will take care of this for you to avoid registering a dysfunctional Data App.
In addition, widgets can be connected. You can use widgets as attributes of other widgets. For example, you could have a selector widget as a line chart widget title. Therefore, every time the value of the selector widget changes, the title of the line chart will change too. Everything interacts within the Shapelets Data Apps!