Interface DataPanelInput Beta
Describes one data slot (input) of a custom widget's data panel.
Each input declares which kind of data item it accepts and how many items can be dropped into it. The custom visualization receives the selected items in dataOptions, keyed by the input name.
The list of inputs also determines how saved widgets are read back. A saved widget stores only the name and the items of each input. When a host loads the widget, it may restore the other properties of an input, such as type, from the input at the same position in the list. As a result, renaming, removing or reordering inputs breaks widgets that were already saved: their items are no longer found, or they are shown with the properties of another input. Changing the type of an input breaks them too: its saved items are still found, but they were chosen for the old type and may not fit the new one.
These changes keep saved widgets working:
- Adding an input at the end of the list, because the existing inputs keep their positions.
- Raising
maxItems, because the items of every saved widget stay within the limit. - Turning on
canColor, because widgets saved without item colors stay valid. Item colors are saved with the widget, so turningcanColoroff leaves saved colors that the data panel no longer offers to edit.
Example
import { DataPanelInput } from '@sisense/sdk-ui';
const inputs: DataPanelInput[] = [
{ name: 'category', displayName: 'Category', type: 'dimension', maxItems: 1 },
{ name: 'value', displayName: 'Value', type: 'measure', minItems: 1 },
];
Properties
canColor
canColor?:
boolean
Whether the items can be colored.
canFormat
canFormat?:
boolean
Whether the items can be formatted.
canSort
canSort?:
boolean
Whether the items can be sorted.
displayName
displayName?:
string
The display name of the input, shown in the data panel.
Do not give an input a display name equal to the name of another input: a host may apply that input's color settings to the wrong input. Registering a plugin logs a warning for it.
Example
'Category'
maxItems
maxItems?:
number
The maximum number of items that can be selected: a whole number of at least 1. Omit for no limit.
Example
5
minItems
minItems?:
number
The minimum number of items that must be selected.
Example
1
name
name:
string
The name of the input, used as the key of the input's items in dataOptions.
A saved widget stores the input's items under this name, and loading the widget reads them back into dataOptions under camelCase(name). A camelCase name, for which camelCase(name) === name (for example breakBy rather than break-by), stays the same after a save and load; any other name is replaced by its camelCase form.
Input names are unique within a widget plugin. Because the name is the key under which the items are passed in dataOptions and stored in a saved widget, two inputs with the same name share one key, and their items cannot be told apart.
Hosts reserve the names filters and color for their own use, so an input whose name has either of them as its camelCase form (for example Filters) is not supported.
Registering a plugin logs a warning for each input name that is not camelCase, is reserved, or has the same camelCase form as the name of an earlier input. The warnings do not stop the plugin from registering.
Example
'category'
type
type:
"dimension"|"measure"
The type of data item the input accepts: a dimension (attribute) or a measure.