React Embedded AnalyticsCustom Widgets Form Setup

Custom widgets can use the built-in Studio form builder to edit their data and format settings.

The example above adds a Special Config section to the setup tab, with an input to control the font size of the value in the custom widget.

The form is provided via the form property of the widget definition.

Function
Form configuration using typed form builder.

Form Setup Copy Link

The ID of each form item is a dot delimited path of the corresponding property within the widget config.

interface CustomWidgetStyle {
    valueFontSize?: number;
}

interface CustomWidgetDef {
    type: 'customWidget';
    dataMapping: {
        value: AgWidgetFieldReference[];
    };
    format?: AgWidgetDataFormat<CustomWidgetStyle>;
}

For the above definition, the corresponding input ID for the valueFontSize property would be format.style.valueFontSize.

Form Helpers Copy Link

The form callback provides some helper functions to create form elements for the default properties (e.g. data mapping, titles, etc.).

const widgetDefinition = {
    // ...
    form: (params) => {
        return params.createDefaults({
            dataMappingItems: [
                {
                    key: 'value',
                    label: 'Value',
                },
            ],
        });
    },
}
createDefaultsCopy Link
Function
Create the default tab group with a setup and format tab. Setup tab contains:
  • Widget section
  • Data mapping section (if data mapping exists)
  • Cross filter section
  • CSV export item
  • Format tab contains:
  • Titles section
  • createWidgetSectionCopy Link
    Function
    Creates a section containing the widget type selector.
    createDataMappingCopy Link
    Function
    Create the data mapping item. Either a section if multiple data mapping fields, or a single fieldset or field item.
    createCrossFilterSectionCopy Link
    Function
    Creates a section containing the cross filter input. supportsCrossHighlight true if this widget supports cross highlight and therefore should show the cross highlight options
    createTitleGroupCopy Link
    Function
    Creates the title group.
    createSubtitleGroupCopy Link
    Function
    Creates the subtitle group.
    createCaptionGroupCopy Link
    Function
    Creates the caption group.
    createTitleSectionCopy Link
    Function
    Creates the title section containing the title, subtitle and caption group.

    Form Grouping Items Copy Link

    The following form items allow for grouping/structuring the form items (e.g. they have children).

    ItemInterfaceDescription
    Tab GroupAgWidgetFormTabGroup / AgFormTabGroupA group of tab items. E.g. the top-level Setup / Format tab group in the edit panel for the default widgets.
    TabAgWidgetFormTab / AgFormTabA child tab of a tab group item. E.g. the Setup tab in the edit panel for the default widgets.
    SectionAgWidgetFormSection / AgFormSectionA top-level collection of items. E.g. the Titles section in the edit panel for the default widgets.
    GroupAgWidgetFormGroup / AgFormGroupA lower-level collection of items (with an optional toggle). E.g. the Title group in the edit panel for the default widgets.

    Form Input Items Copy Link

    ItemInterfaceDescription
    SelectAgWidgetFormSelect / AgFormSelectA select input item.
    CheckboxAgWidgetFormCheckbox / AgFormCheckboxA checkbox input item.
    ToggleAgWidgetFormToggle / AgFormToggleA toggle input item.
    Text InputAgWidgetFormTextField / AgFormTextFieldA text input item.
    Text AreaAgWidgetFormTextArea / AgFormTextAreaA text area input item.
    Number InputAgWidgetFormNumber / AgFormNumberA number input item.
    Optional Number InputAgWidgetFormOptionalNumber / AgFormOptionalNumberA number input item that allows optional values.
    Color InputAgWidgetFormColor / AgFormColorA color picker input item.
    Widget Type SelectorAgWidgetFormWidgetType (widget form only)A select input that allows changing the widget type.
    Field Selection InputAgWidgetFormField (widget form only)An input for selecting a field (supporting drag and drop).
    Fieldset Selection InputAgWidgetFormFieldSet (widget form only)An input for selecting multiple fields (supporting drag and drop).
    Grouped Typography InputAgWidgetFormTypography (widget form only)A group of elements for configuring typography.