Top.Mail.Ru
Configuring a View in YAML
CTRL+K

Configuring a View in YAML

In this article
  • Configuring a View in YAML
  • The metadata Key
  • The dividersHeight Key
  • The autoUpdate Key
  • The widgetsSetting Key
  • The inputs Key
  • The widgets Key
  • The filters Key
  • The actionButtons Key
  • Configuring the View Grid in YAML
  • The layout Key
  • Configuring a Placeholder in YAML
  • The parameters Key

View parameters are defined in several blocks:

The metadata Key

The table below describes keys for defining basic view settings via the metadata key.

KeyTypeDefinition
cornerRadiusnumberCorner radius
maxWidthnumberMaximum view width
If not specified, the view width is unlimited
autoUpdateAuto-update
spacingenumDisplay spacing between widgets in Browse mode
colorenumView background color in Browse mode:
- AUTO — auto
- BASE — solid
apiVersionstringView version
Depends on the system version
dividersHeightHeight of all dividers in the report

The dividersHeight Key

The dividersHeight block defines the height for all dividers in the view.

KeyTypeDefinition
modestring- FIXED — value in pixels
- PERCENT — value in percent (to use Auto, omit the value key)
valuenumberValue

The autoUpdate Key

The autoUpdate block accepts the values listed below.

KeyTypeDefinition
enabledbooleanEnable/disable auto-update
minutesbooleanValue in minutes

The widgetsSetting Key

The widgetsSetting block defines global settings for all widgets in the view.

KeyTypeDefinition
paddingsstringSide paddings
titleSizenumberTitle size
titleColorTitle color:
- AUTO — auto
- BASE — solid
titleWeightenumFont weight:
- NORMAL — normal
- BOLD — bold
textSizenumberText size
filterModeenumFilter mode:
- DEFAULT — default
- SINGLE — single selection
- DISABLED — disabled
ignoreFiltersbooleanIgnore filters
stateNamestringState

The inputs Key

The table below describes keys for defining input values via the inputs key.

KeyTypeDefinition
namestringVariable name
dbDataTypeenumVariable data type:
- STRING — string
- INTEGER — integer
- DATE — date
- DATETIME — date and time
multipleChoicebooleanArray of values in the variable
defaultValuestringDefault value
Defined by formula

The widgets Key

Widgets used in the view are added under the widgets key. Widgets are separated by the - symbol.

Example:

widgets:
  - key: kpi-list
    apiVersion: "16"
    type: KPI_LIST
    settings:
      title: ""
      titleSize: 14
      titleColor:
        mode: AUTO
      titleWeight: NORMAL
      showMarkdown: false
      markdownMeasures: []
      markdownText: ""
      measures:
        - name: Number of Stores
          value:
            mode: FORMULA
            formula: 'link: "Number of Stores"'
          format: NUMBER
          formatting: AUTO
          color:
            mode: AUTO
          dbDataType: Int64
          showName: true
          displayCondition:
            mode: DISABLED
          filters: []
          onClick: []
        - name: Number of Products
          value:
            mode: TEMPLATE
            tableName: product
            columnName: Product
            templateName: countDistinct
          format: NUMBER
          formatting: AUTO
          color:
            mode: AUTO
          formattingTemplate: ""
          dbDataType: Int64
          showName: true
          displayCondition:
            mode: DISABLED
          filters: []
          onClick: []
        - name: Sales Amount
          value:
            mode: TEMPLATE
            tableName: sale
            columnName: Sales Amount
            templateName: sum
          format: NUMBER
          formatting: CUSTOM
          color:
            mode: BASE
            value: "#6636c0"
          formattingTemplate: "#,###[$]"
          dbDataType: Float64
          showName: true
          displayCondition:
            mode: DISABLED
          filters: []
          onClick: []
        - name: Profitability
          value:
            mode: FORMULA
            formula: (sum("sale"."Sales Amount") - sum("sale"."Cost")) / sum("sale"."Sales Amount") * 100
          format: NUMBER
          formatting: x.x[%]
          color:
            mode: BASE
            value: "#ff9f43"
          formattingTemplate: ""
          dbDataType: Float64
          showName: true
          displayCondition:
            mode: DISABLED
          filters: []
          onClick: []
      displaySign: HORIZONTAL
      stateName: null
      filters: []
      sorting: []
      position: TOP
      measuresTextWeight: NORMAL
      measuresTextSize: 30
      alignment: LEFT
      filterMode: DEFAULT
      ignoreFilters: false
      nameSize: 12
      maxRowsName: 1
      itemsAlignment: LEFT
      paddings: 8
      markdownTextSize: 14
    localApiVersion: "2"
  - key: filter (1)
    apiVersion: "16"
    type: FILTER
    settings:
      title: ""
      titleSize: 14
      titleColor:
        mode: AUTO
      titleWeight: NORMAL
      showMarkdown: false
      markdownMeasures: []
      markdownText: ""
      textSize: 12
      dimensionLimit: 50
      displaySign: SELECT
      dimensions:
        - name: Store
          value:
            mode: FORMULA
            formula: '"store"."Store"'
          format: STRING
          formatting: AUTO
          dbDataType: String
      filterMode: DEFAULT
      ignoreFilters: false
      stateName: null
      filters: []
      sorting: []
      paddings: 8
      markdownTextSize: 14

The filters Key

Predefined filters can be applied to views. The filters block uses the following keys:

  • name — filter name
  • formula — formula used
  • dbDataType — formula data type
  • format — format
  • filteringMethod — filtering method
  • checkedValues — selected values
  • formValues — for manually entered values (values are specified in the block with numberRangekey)

Example of predefined filters:

filters:
  - dbDataType: UInt64
    format: NUMBER
    formula: '"events"."id"'
    name: id
    formValues:
      numberRange:
        - 100
        - 200
    filteringMethod: NONEMPTY
  - dbDataType: String
    format: STRING
    formula: '"events"."action"'
    name: action
    checkedValues:
      - Client Proposal Approval
      - Full Request Form Entry
    filteringMethod: INCLUDE

The actionButtons Key

Action buttons are added under the actionButtons key. For details on using action buttons, see Views.

KeyTypeDefinition
namestringButton name
buttonTypeenumButton type:
- primary — primary
- primary-outlined — secondary
- link — link
typeenumClick action type: EXECUTE_SCRIPT
Only one action type is allowed
scriptKeystringScript key
parametersScript parameters (optional key)
autoUpdateenumAuto-update:

- NONE — none
- ALL_WIDGETS — all widgets

Configuring the View Grid in YAML

The layout Key

The view structure is a grid of rows and columns — layout. This block uses the rows key to configure and add rows.

The rows Key

The table below lists keys used in this block.

KeyTypeDefinition
columnsColumns
widgetKeystringWidget key to display in the column
Only for WIDGET type
placeholderPlaceholder
Only for PLACEHOLDER type
innerLayoutNested layout
Same structure as layout
Only for INNER_LAYOUT type
Available column content types:
- EMPTY — none (empty column)
- WIDGET — widget
- PLACEHOLDER — placeholder
heightColumn height
widthColumn width
Not applied to DIVIDER column type

The columns Key

The table below lists keys used in this block.

KeyTypeDefinition
modeenumColumn content type
alignmentenumColumn alignment within the row:

- left — left-aligned
- center — centered
- right — right-aligned
- full — full width
The height Key

The height block configures column height.

KeyTypeDefinition
modeenumColumn height calculation mode:
- FIXED — fixed (in pixels)
- PERCENT — dynamic (as percentage of screen height)
valuenumberHeight value
Required in PERCENT mode
The width Key

The width block configures column width.

KeyTypeDefinition
modeenumColumn width calculation mode:
- FRACTION — dynamic (as fraction of view width)
- FIXED — fixed (in pixels)
valuenumberWidth value

Tabs (the tabs Key)

To add tabbed columns to a view, use the tabs block.

KeyTypeDefinition
labelstringTab label
displayConditionDisplay condition
innerLayoutNested layout

Available column component types:
EMPTY — empty column
WIDGET — widget
PLACEHOLDER — placeholder
likeViewBackgroundbooleanView-like background

Available only if view spacing is disabled in Browse mode
alignmentenumAlignment:

Options:
left — left-aligned
center — centered
right — right-aligned
textSizenumberFont size
displayOneTabbooleanDisplay single tab in view

Example of tabs usage:

layout:
  rows:
    - columns:
        - mode: TABS
          tabs:
            - label: Tab (1)
              displayCondition:
                mode: DISABLED
              innerLayout:
                rows:
                  - columns:
                      - mode: EMPTY
                        width:
                          mode: FRACTION
                          value: 1
            - label: Tab (2)
              displayCondition:
                mode: DISABLED
              innerLayout:
                rows:
                  - columns:
                      - mode: EMPTY
                        width:
                          mode: FRACTION
                          value: 1
          width:
            mode: FRACTION
            value: 1
    - columns:
        - mode: EMPTY
          width:
            mode: FRACTION
            value: 1

Example of a widget in a tab:

layout:
  rows:
    - columns:
        - mode: WIDGET
          widgetKey: barchart-140c3362
          width:
            mode: FRACTION
            value: 1
    - columns:
        - mode: EMPTY
          width:
            mode: FRACTION
            value: 1

Example of a placeholder in a tab:

layout:
  rows:
    - columns:
        - mode: PLACEHOLDER
          placeholder:
            name: Placeholder
            mode: EXISTED_VIEW
            viewKey: view-140c3362
          width:
            mode: FRACTION
            value: 1
    - columns:
        - mode: EMPTY
          width:
            mode: FRACTION
            value: 1

Example of nested layout:

layout:
  rows:
    - columns:
        - mode: INNER_LAYOUT
          innerLayout:
            rows:
              - columns:
                  - mode: EMPTY
                    width:
                      mode: FRACTION
                      value: 1
              - columns:
                  - mode: EMPTY
                    width:
                      mode: FRACTION
                      value: 1
          width:
            mode: FRACTION
            value: 1

Display Condition

To define a tab display condition, use the displayCondition block.

KeyTypeDefinition
modeenumDisplay mode:

DISABLED — always
VARIABLE — by variable
FORMULA — by formula
variableNamestringVariable name (only for VARIABLE mode)
variableValuestringVariable value (only for VARIABLE mode)
formulastringFormula (only for FORMULA mode)

Example of widget display by variable:

displayCondition:
  mode: VARIABLE
  variableName: variable_1
  variableValue: "value_1"

Example of widget display by formula:

displayCondition:
  mode: FORMULA
  formula: if(quantile(0.75)("p1"."TTCR") > 10, true, false)

Configuring a Placeholder in YAML

To add a placeholder to a view, use the placeholder block after the mode: PLACEHOLDER key-value pair. Example:

layout:
  rows:
    - columns:
        - mode: PLACEHOLDER
          placeholder:
            # Additional key-value pairs

The tables below list keys available for placeholder configuration.

KeyTypeDefinition
namestringUnique placeholder name
modeenumMode:
- EMPTY — none (empty)
- EXISTED_VIEW — existing view
- GENERATED_BY_SCRIPT — script-generated view
viewKeystringView key to display in the column
Only for EXISTED_VIEW mode
scriptKeystringScript key
Only for GENERATED_BY_SCRIPT mode
parametersScript parameters
Only for GENERATED_BY_SCRIPT mode

The parameters Key

The parameters block configures parameters for a script-generated view.

KeyTypeDefinition
namestringParameter name
sourceVariablestringVariable name
inputMethodenumInput method:
- VARIABLE — variable
- AGGREGATION — set by aggregation
considerFiltersbooleanConsider Filters switch:
- true — enabled
- false — disabled

Was the article helpful?

Yes
No
Previous
YAML Editor
We use cookies to improve our website for you.