Capabilities and properties of Power BI visuals
Every visual has a capabilities.json file that describes the visual to the host. The capabilities.json file tells the host what kind of data the visual accepts, what customizable attributes to put on the properties pane, and other information needed to create the visual. All properties in the capabilities.json file are optional.
The capabilities.json file has the following format:
{
"dataRoles": [ ... ],
"dataViewMappings": [ ... ],
"objects": { ... },
"supportsHighlight": true|false,
"advancedEditModeSupport": 0|1|2,
"sorting": { ... }
...
}
When you create a new visual, the default capabilities.json file includes the following root objects:
The above objects are the ones needed for data-binding. They can be edited as necessary for your visual.
The following additional root objects can be added as needed:
- tooltips
- supportsHighlight
- sorting
- drilldown
- expandCollapse
- supportsKeyboardFocus
- supportsSynchronizingFilterState
- advancedEditModeSupport
- supportsLandingPage
- supportsEmptyDataView
- supportsMultiVisualSelection
- subtotals
You can find all these objects and their parameters in the capabilities.json schema
data roles: define the data fields that your visual expects
To define fields that can be bound to data, you use dataRoles. dataRoles is an array of DataViewRole objects, which defines all the required properties. The dataRoles objects are the fields that appear on the Properties pane.
The user drags data fields into them to bind data the data fields to the objects.
DataRole properties
DataRoles are defined by the following properties:
- name: The internal name of this data field (must be unique).
- displayName: The name displayed to the user in the Properties pane.
- kind: The kind of field:
Grouping: Set of discrete values that are used to group measure fields.Measure: Single numeric values.GroupingOrMeasure: Values that can be used as either a grouping or a measure.
- description: A short text description of the field (optional).
- requiredTypes: The required type of data for this data role. Values that don't match are set to null (optional).
- preferredTypes: The preferred type of data for this data role (optional).
Valid data types for requiredTypes and preferredTypes
- bool: A boolean value
- integer: An integer value
- numeric: A numeric value
- text: A text value
- geography: A geographic data
dataRoles example
"dataRoles": [
{
"displayName": "My Category Data",
"name": "myCategory",
"kind": "Grouping",
"requiredTypes": [
{
"text": true
},
{
"numeric": true
},
{
"integer": true
}
],
"preferredTypes": [
{
"text": true
}
]
},
{
"displayName": "My Measure Data",
"name": "myMeasure",
"kind": "Measure",
"requiredTypes": [
{
"integer": true
},
{
"numeric": true
}
],
"preferredTypes": [
{
"integer": true
}
]
}
]
...
}
The preceding data roles would create the fields that are displayed in the following image:

dataViewMappings: how you want the data mapped
The dataViewMappings objects describe how the data roles relate to each other and allow you to specify conditional requirements for the displaying data views.
Most visuals provide a single mapping, but you can provide multiple dataViewMappings. Each valid mapping produces a data view.
"dataViewMappings": [
{
"conditions": [ ... ],
"categorical": { ... },
"table": { ... },
"single": { ... },
"matrix": { ... }
}
]
For more information, see Understand data view mapping in Power BI visuals.
objects: define property pane options
Objects describe customizable properties that are associated with the visual. The objects defined in this section are the objects that appear in the Format pane. Each object can have multiple properties, and each property has a type that's associated with it.
"objects": {
"myCustomObject": {
"displayName": "My Object Name",
"properties": { ... }
}
}
For more information, see Objects and properties of Power BI visuals.
Next steps
Povratne informacije
Pošalјite i prikažite povratne informacije za