Configure plugins to work with actions
Workbooks support actions that use plugins in two ways:
- Plugins as trigger elements: You can use a plugin to trigger an action in a workbook element. For example, a plugin can be used to trigger an action that updates a workbook control or chart.
- Plugins as target elements: You can create an action that enables a workbook element to trigger effects within a plugin. For example, an action like selecting a table cell can filter a plugin visualization.
This document covers how to edit your plugin code to work with workbook actions.
For more information on plugins as trigger elements, see Action triggers in Intro to actions. For more information on plugins as target elements, see Create actions that modify plugins.
Prerequisites
- You must create a base plugin. See Getting Started for instructions.
- Ensure you have a Dev Playground set up. See Using the development playground for setup instructions.
Configure plugins to use as trigger elements
To use a plugin to trigger an action in a workbook element, make the following changes to your plugin code. For more information on the functions used, refer to the README in the Sigma plugins repository.
- Call
useEditorPanelConfig()
to create a list of configuration objects.useEditorPanelConfig()
expects a list of configuration objects of the following types:type : string
, the field type, which must be'action-trigger'
if you are using a plugin as a trigger elementname : string
, the name of the action trigger you are defining
- Access the configuration objects defined in
useEditorPanelConfig()
with theuseConfig()
function. - To return a function that calls the action configured within Sigma, call the
useActionTrigger()
function with the name of the configuration object defined inuseEditorPanelConfig()
. For example, if the name of your config object is'ExampleAction'
, calluseActionTrigger(config.ExampleAction)
. - Program your desired action. The action must call the function returned by
useActionTrigger()
. For example, you could configure a UI button in your workbook that allows your stored function from step 3 to be called upon clicking. - Save and refresh your plugin. Your plugin is now compatible with actions in Sigma.
- In your workbook, set up your desired action sequence. For more information on what effects can be triggered and how to create these actions, see Action effects in Intro to actions.
Configure plugins to use as target elements
To create an action that enables a workbook element to trigger effects within a plugin, you will first need to make the following changes to your plugin code. For more information on the functions used, refer to the README in the Sigma plugins repository.
- Call
useEditorPanelConfig()
to create a list of configuration objects.useEditorPanelConfig()
expects a list of configuration objects of the following types:type : string
, the field type, which must be'action-effect'
if you are using an element to trigger plugin effectsname : string
, the name of the action effect you are defining
- Access the configuration objects defined in
useEditorPanelConfig()
with theuseConfig()
function. - Create a function that, when called, results in your desired effect in the plugin.
- Call
useActionEffect()
.useActionEffect()
takes in a configuration object (defined inuseEditorPanelConfig()
) and a function (the function you created that results in your desired plugin effect). Note thatuseActionEffect()
does not return anything. - Save and refresh your plugin. Your plugin is now compatible with actions in Sigma.
- In your workbook, create the element you want to use to trigger an effect in your plugin.
- Configure your desired action sequence. See Create actions that modify plugins.
Updated about 1 month ago