kpi properties
This API is reliable and breaking changes are unlikely.
kpi()
These are the properties used by Qlik Sense kpi objects.
Version history
Version state | Details |
---|---|
Introduced | 2.2 |
Properties
showTitles
Type: Boolean
Show title for the visualization.
Default: true.
showDetails
Type: Boolean
Sets if visualization details should be shown.
Default: false
title
Type: String | qStringExpression
Visualization title shown if "showTitles": true.
subtitle
Type: String | qStringExpression
Visualization subtitle shown if "showTitles": true.
footnote
Type: String | qStringExpression
Visualization footnote shown if "showTitles": true.
disableNavMenu
Type: Boolean
Disables the hover menu in the visualization.
Default: false
qHyperCubeDef
Type: Object
The hypercube definition used by most visualizations.
A subset of the properties available in the qHyperCubeDef is presented here. For complete documentation of all available properties, see Engine API: HyperCubeDef.
Properties
qDimension
Type: Array
Description: Extends NxDimension, see Engine API: NxDimension.
Additional properties
-
qDef
Type: Object
Description: Extends NxInlineDimensionDef, see Engine API: NxInlineDimensionDef.
qDef properties Name Type Description autoSort Boolean Set to automatically sort the dimension.
Default: true
cId String ID used by the client. Must be unique within the current chart. othersLabel StringExpressionContainer String expression container. -
qAttributeDimensions
Type: Array
Description: Extends NxAttrDimDef, see Engine API: NxAttrDimDef.
id
Type: String
One of:
- colorByAlternative: colors the chart using different dimensions. Can be used together with color.mode="byDimension" for attribute dimensions.
- colorByExpression: used together with color.mode="byExpression".
qMeasures
Type: Array
Description: Extends NxMeasure, see Engine API: NxMeasure.
Additional properties:
-
qDef
Type: Object
Description Extends NxInlineMeasureDef, see Engine API: NxInlineMeasureDef.
Additional properties:
-
autoSort
Type: Boolean
Description: Set to automatically sort the measure. Default: true.
-
cId
Type: String
Description: ID used by the client. Must be unique within the current chart.
-
isCustomFormatted
Type: Boolean
Description: Set to true to toggle off the default client formatting.
-
numFormatFromTemplate
Type: Boolean
Description: When enabled, the number format to use can be selected from multiple predefined formats based on the desired type: number or date. Default: true.
-
conditionalColoring
Type: Object
Description: Coloring settings.
- useConditionalColoring
Type: Boolean
Description: Set if the object should use conditions to color the object.
Default: false
- singleColor
Type: Integer
Description: Deprecated. Use paletteSingleColor instead. Set to reference a color in the color palette.
Default: 3
- paletteSingleColor
Type: Integer
Color information structure. Holds actual color and index in palette.
paletteSingleColor properties Name Type Description index Integer Index in the palette.
The default Qlik Sense color palette:
- -1: set to use custom color that is not in the palette.
- 0: No color
- 1: White, HEX: #ffffff
- 2: Light green, HEX: #46c646
- 3: Green, HEX: #276e27
- 4: Light blue, HEX: #b6d7ea
- 5: Blue, HEX: #7db8da
- 6: Dark blue, HEX: #4477aa
- 7: Purple, HEX: #8e477d
- 8: Yellow, HEX: #ffcf02
- 9: Orange, HEX: #f8981d
- 10: Red, HEX: #f93f17
- 11: Brown, HEX: #633d0c
- 12: Light gray, HEX: #b0afae
- 13: Gray, HEX: #7b7a78
- 14: Dark gray, HEX: #545352
- 15: Black, HEX: #000000
Default: 6
color String Color as HEX string.
Mandatory if "index": "-1".
- segments
Type: Object
Segment settings.
segments properties Name Type Description limits Array Color gradient limitations.
- value:
Type: ValueExpressionContainer
Description: Value expression container. - gradient:
Type: Boolean
Description: Set to use gradient between segments.
paletteColors Object Replaces segment colors and provides ability to set custom colors. Overrides segment.colors when set.
- color:
Type: String
Description: Color as hex string (mandatory if index: -1) - index:
Type: Integer
Description: Index in palette. Default: 6 - icon:
Type: String
Description: Name of icon.
colors String Color value for individual segment.
- color:
Type: Integer
Color of segment. Default: 3- icon:
Type: String
Description: Name of icon. - icon:
- value:
- useConditionalColoring
-
measureAxis
Type: Object
Set the limits for the range.
measureAxis properties Name Type Description min ValueExpressionContainer Set the min value for the range. max ValueExpressionContainer Set the max value for the range.
-
-
qAttributeExpressions
Type: Array
Description: Extends NxAttrExprDef, see Engine API: NxAttrExprDef.
-
id
Type: String
Description: If set to `\"bullet-target\"` the expression will be interpreted as the target for the specific measure. If set to `\"bullet-segment\"` the expression will be interpreted as a segment limit.
-
qLayoutExclude
Type: Object
customErrorMessage
Type: Object
Set to define custom error messages.
-
calcCondition
Type: String
Description: Deprecated. Use qCalcCondition.qMsg instead. Set to customize the calculation condition unfilled message.
style
Type: Object
Description: Set background to a color .
- background
useColorExpression
Type: Boolean
Description: Defines if a color expression is used.
Default: false
color
Type: Object
Description: Set to specify color.
Index: -1
Color: null
colorExpression
Type: String
Description: An expression string that defines the color.
Default: ''
showMeasureTitle
Type: Boolean
Sets if the main title of the first measure should be displayed.
Default: true
textAlign
Type: String
Aligns the text in the KPI object. Can be one of:
- left
- center
- right
Default: center
layoutBehavior
Type: String
Sets the layout mode for the font in the KPI object. Can be one of:
- Fixed. The font size is always the same. The font size is independent of the box size and the length of the KPI text. Overflows with (…) if the text is too long.
- Fluid. The font size adapts to the size of the box. Overflows with (…) if the text is too long. Information noteMake the KPI boxes the same size to keep the same font size.
- Responsive. Text always fits. The font size adapts to the size of the box and the length of text.
fontSize
Type: String
Sets the font size of the main value. Can be one of:
- S (small)
- M (medium)
- L (large)
Default: M
useLink
Type: Boolean
Set if the KPI will link to another sheet when clicked.
Default: false
sheetLink
Type: String
The sheet id (as a string) of the sheet to link to if "useLink": true.
openUrlInNewTab
Type: Boolean
Sets if the KPI opens in another tab when clicked. If false, it will only redirect from the current page.
Default: true
color
Type: Object
Controls if colors encoded in master items should be used.
Name | Type | Description |
---|---|---|
useBaseColors | String |
Use colors encoded in master items. One of:
Default: measure |
Example using Visualization API
In this example we create a basic KPI, containing a single measure. Measure titles are displayed in the visualization by default.
app.visualization.create(
'kpi',
[
{
"qDef": {
"qLabel": "GIR %",
"qDef": "Avg(GIR)",
"qNumFormat": {
"qType": "F",
"qnDec": 2,
"qUseThou": 0,
"qFmt": "0.0%",
"qDec": ".",
"qThou": ","
}
}
}
],
{
"showTitles": false,
"showMeasureTitle": true,
"textAlign": "center",
"fontSize": "L"
}
).then(function(vis){
vis.show("QV01");
});