Custom Widget JSON Reference

The custom widget JSON file specifies the custom widget.

The following sections explain the valid properties of the custom widget JSON. Any other properties present in a custom widget JSON render it invalid.

Root Object

The root object of the custom widget JSON specifies the custom widget. Its JSON properties are:

Property

Required/Optional

Type

Description

id

Required

String

Unique ID of the custom widget, for example, "com.sap.sample.coloredbox"

version

Required

String

Version of the custom widget, for example, "1.0.0"

name

Required

String

Name of the custom widget, for example, "Colored Box"

description

Optional

String

Description of the custom widget, which is used, for example, in tooltips

newInstancePrefix

Required

String

Prefix of a new custom widget instance in a story experience, for example, "ColoredBox"

icon

Optional

String

URL of the custom widget’s icon (16 x 16 pixels).

vendor

Optional

String

Vendor string

eula

Optional

String

End-user license agreement text

license

Optional

String

License text

webcomponents

Required

Array of Webcomponent objects

Web components of the custom widget (see section below)

properties

Required

Properties object

Properties of the custom widget

(see section below)

methods

Required

Methods object

Methods of the custom widget (see section below)

events

Required

Events object

Events of the custom widget (see section below)

imports

Optional

Array of strings

Type libraries used by the custom widget (see chapter Importing Script API Data Types with Type Libraries)

supportsMobile

Optional

Boolean

Indicates whether the custom widget is rendered on mobile devices.

If false, then the custom widget is replaced in a story on a mobile device by a placeholder with a message explaining that the custom widget doesn’t run on a mobile device. See Custom Widgets on Mobile Devices for more information.

Possible values are:
  • true

  • false

supportsExport

Optional

Boolean

Indicates whether the custom widget supports PDF export.

supportsLinkedAnalysisFilterOnSelection

Optional

Boolean

Indicates whether the custom widget supports linked analysis based on Filter on Data Point Selection. In addition, within your Web Component JavaScript file, you need to use Data Binding's linked analysis APIs so that a selected data point from the custom widget can filter other widgets. For more information, refer to Enabling Linked Analysis for Your Custom Widget.

supportsViewportLoading

Optional

Boolean

Indicates whether the custom widget supports viewport loading. For more information, refer to Enabling Viewport Loading for Your Custom Widget.

supportsBookmark

Optional

Boolean

Indicates whether the custom widget supports bookmark. For more information, refer to Configuring Bookmark Support for Your Custom Widget.

supportsLWV

Optional

Boolean

Indicates whether the custom widget can be viewed in Lite Viewer. For more information, refer to Enabling Lite Viewer Support for Your Custom Widget

supportsVisualization

Required

Boolean

Indicates whether the custom widget renders a data visualization (chart, graph).

types

Optional

Types object

Custom types of the custom widget. You can define your own data structures and enumerations here (see section below).

dataBindings

Optional

DataBindings object

Data bindings of the custom widget. You can define your own data bindings with an array of feed objects here (see section below).

Webcomponent Object

A Webcomponent object specifies one web component of a custom widget. Its JSON properties are:

Property

Required/Optional

Type

Description

kind

Required

String

What kind of component this Web Component represents.

Possible values are:
  • "main" (the actual custom widget)

  • "styling" (the Styling Panel of the custom widget)

  • "builder" (the Builder Panel of the custom widget)

tag

Required

String

Unique name of the custom element (its HTML tag name) of this Web Component.

url

Required

String

URL to the Web Component JavaScript file

type

Optional

String

This property can help with the modularization of your JavaScript code.

For more information, see the description of the type attribute with the value module in the Mozilla MDN webdocs on the script element.

integrity

Required

String

String containing the hash value of the Web Component JavaScript file.

The hash value has the format "hashAlgorithm-hashValue", for example, "sha256-ih2Us20RAQ9CaWjbO/LfZPetSX7gTrVlTtbdF6mk4io="

Web browsers support several hash algorithms. For more information, see the Mozilla MDN web docs on Subresource Integrity.

ignoreIntegrity

Optional

Boolean

Indicates whether to ignore the property integrity, for example, during development of a custom widget.

Possible values are:
  • true

  • false

Properties Object

A Properties object specifies the properties of a custom widget. Each JSON property name of a Properties object is the name of a custom widget property. Its value is an object with the following JSON properties:

Properties

Required/Optional

Type

Description

type

Required

String

Type of the custom widget property.

Possible values are, for example:
  • "string"

  • "number"

  • "boolean"

  • "integer"

  • "string[]"

  • "number[]"

  • "boolean[]"

  • "integer[]"

  • You can also use certain script API data types. For more information see section Using Script API Data Types in JavaScript Functions.

  • You can also use simple object types. For more information see section Simple Object Types.

description

Optional

String

Description of the custom widget property

default

Optional

Depending on type

Default value of the custom widget property.

Possible values are one of the following JavaScript types:
  • String, for example, "green"

  • Number, for example, 1

  • Boolean, for example, true

  • An array of string values, for example, ["red", "yellow", "green"]

  • An array of number values, for example, [1, 2, 3]

  • An array of Boolean values, for example, [true, false, true]

Methods Object

A Methods object specifies the script method of a custom widget. Each JSON property name of a Methods object is the name of a custom widget script method. Its value is an object with the following JSON properties:

Properties

Required/Optional

Type

Description

description

Required

String

Description of the script method

parameters

Optional

Array of Parameter objects

Parameters of the script method (see section below). Omit this property if the script method has no parameters.

body

Optional

String

Implementation of the script method expressed in the SAP Analytics Cloud script language.

returnType

Optional

String

Return type of the script method. Omit this property if the script method has no return value.

Parameter Object

A Parameter object specifies one parameter of a script method of a custom widget. Its JSON properties are:

Properties

Required/Optional

Type

Description

name

Required

String

Name of the parameter

type

Required

String

Type of the parameter.

Possible values are, for example:
  • "string"

  • "number"

  • "boolean"

  • "integer"

  • "string[]"

  • "number[]"

  • "boolean[]"

  • "integer[]"

  • You can also use certain script API data types. For more information see chapter Using Script API Data Types in JavaScript Functions .

  • You can also use simple object types. For more information see section Simple Object Types.

description

Optional

String

Description of the parameter

Events Object

An Events object specifies the events of a custom widget. Each JSON property name of an Events object is the name of a custom widget event. Its value is an object with the following JSON properties:

Properties

Required/Optional

Type

Description

descripton

Optional

String

Description of the event

Types Object

A Types object specifies the custom types of a custom widget. Custom types can be either custom data structures or custom enumerations. They can be used as types for properties, arguments and return types of methods inside the custom widget JSON. In the analytic application or optimized story you can use custom types for global variables, script object function arguments and return types.

Each JSON property name of a Types object is the name of a custom type. Its value defines the custom type property, either a custom data structure or a custom enumeration.

To avoid clashes of custom type names, internally each custom type name is made unique by using a qualified custom type name, which contains the custom widget ID. You don’t need to specify the qualified custom type name in the types property section.

For specifying a custom data structure, you can use the following JSON properties:

Property

Required/Optional

Type

Description

description

Optional

String

Description of the data structure

extends

Optional

String

The data structure to extend. You can extend your own custom data structures, but not custom enumerations and simple types (string, number, integer, boolean).

properties

Required

Array of CustomTypeProperty objects

Properties of the data structure (see section CustomTypeProperty).

For specifying a custom enumeration type, you can use the following JSON properties:

Property

Required/Optional

Type

Description

description

Optional

String

Description of the enumeration

extends

Required

String

Possible value:

  • "Enum"

This marks the type as an enumeration.

properties

Required

Array of CustomEnumValue objects

Values of the enumeration (see section CustomEnumValue).

CustomTypeProperty

A CustomTypeProperty object specifies one property of a custom type of a custom widget. Its JSON properties are:

Property

Required/Optional

Type

Description

name

Required

String

Name of the property

description

Optional

String

Description of the type

type

Required

String

The type of the property. This can be a simple type (string, number, integer, boolean), an enumeration, or a type that can be used as an argument type or as an object expression.

mandatory

Optional

Boolean

Defines this property as mandatory. You must specify this property when creating instances of this type.

CustomEnumValue

A CustomEnumValue object specifies one value of a custom enumeration type of a custom widget. Its JSON properties are:

Property

Required/Optional

Type

Description

name

Required

String

Name of the enumeration value

description

Optional

String

Description of the enumeration value

DataBindings Object

You can specify the data binding of your custom widget in the dataBindings property. You can define only one object, and only the first one will be used if you define multiple objects.

The keys of the dataBindings property represent the name of the object.

Property

Required/Optional

Type

Description

feeds

Required

Array of Feed objects

Feeds of DataBindings (see section below)

Also a default Builder panel will be available in design time if you define a DataBindings object in the JSON file. If you've specified your own Builder panel via the Webcomponent object, this automatically generated panel won't be used.

Feed Object

Property

Required/Optional

Type

Description

id

Required

String

Unique ID of the feed

type

Required

String

"dimension" or "mainStructureMember" (also known as measure) as "type". The type defines what you can add to the according feed.

description

Optional

String

Description of the feed

Simple Object Types

In addition to simple types (string, number, integer, boolean), script API data types, custom types and arrays of these types, you can also specify a simple object type using the form Object<type>.

This type represents a JavaScript object with keys of type string and values of type<type>. For example, the type Object<string> represents a JavaScript object with keys of type string and values of type string.

Supported type<type>:
  • simple types (string, number, integer, boolean)

  • custom types

The following example shows how to use an object of type Object<number>, which represents a JavaScript object with keys of type string and values of type number:

Custom Widget JSON
Web Component JavaScript
Sample Analytics Designer or Story Script