Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
Hi,
I'm currently working on Power BI Custom Visual and struggle with Visual objects and properties data binding for Series (withSeries) data. Basically, goal is to bind Data Color Selector for dynamic series/groups in my stacked-barchart like visual. I looked in multiple public git repos of Microsoft's visual, where such binding is done, but none of the scenario is fitting mine simple approach. The issue I am facing is that after enumerating object instances with my Serie Selection IDs, nothing is pushed to DataView (DataViewObjects are not added). I tried my approach with Categorical and Measure selections, it worked well - objects property was binded to DataView (withCategory and withMeasure). Maybe you will be able to help me, or advice how to proceed. Thanks a lot! Below codes:
Current state I am working on:
# Preparation of Series data points with Selection IDs
let categorical: DataViewCategorical = dataView.categorical;
let categories: DataViewCategoryColumn = categorical.categories[0];
let series: DataViewValueColumns = categorical.values;
let values: DataViewValueColumnGroup[] = categorical.values.grouped();
this.waterfallSeries = [];
for (let i = 0; i < values.length; i++) {
const element = values[i];
let serieSelectionId = this.host.createSelectionIdBuilder()
.withSeries(series, element)
.createSelectionId();
this.waterfallSeries.push({
serie: <string>element.name,
serieSelectionId: serieSelectionId,
color: ''
})
}
# Objects enumeration
public enumerateObjectInstances(options: EnumerateVisualObjectInstancesOptions): VisualObjectInstance[] | VisualObjectInstanceEnumerationObject {
let objectName = options.objectName;
let objectEnumeration: VisualObjectInstance[] = [];
switch (objectName) {
case 'colorSelector':
for (let serie of this.waterfallSeries) {
objectEnumeration.push({
objectName: objectName,
displayName: serie.serie,
properties: {
fill: {
solid: {
color: serie.color
}
}
},
selector: serie.serieSelectionId.getSelector()
});
}
break;
}
return objectEnumeration;
}
# Capabilities (I have 2 groupings and 1 measure -> groupped category)
{
"dataRoles": [
{
"displayName": "Category",
"name": "category",
"kind": "Grouping"
},
{
"displayName": "Legend",
"name": "legend",
"kind": "Grouping"
},
{
"displayName": "Y-Axis",
"name": "measure",
"kind": "Measure"
}
],
"objects": {
"dataPoint": {
"displayName": "Data colors",
"properties": {
"defaultColor": {
"displayName": "Default color",
"type": {
"fill": {
"solid": {
"color": true
}
}
}
},
"showAllDataPoints": {
"displayName": "Show all",
"type": {
"bool": true
}
},
"fill": {
"displayName": "Fill",
"type": {
"fill": {
"solid": {
"color": true
}
}
}
},
"fillRule": {
"displayName": "Color saturation",
"type": {
"fill": {}
}
},
"fontSize": {
"displayName": "Text Size",
"type": {
"formatting": {
"fontSize": true
}
}
}
}
},
"colorSelector": {
"displayName": "Data Colors",
"properties": {
"fill": {
"displayName": "Color",
"type": {
"fill": {
"solid": {
"color": true
}
}
}
}
}
}
},
"dataViewMappings": [
{
"categorical": {
"categories": {
"for": {
"in": "category"
},
"dataReductionAlgorithm": {
"top": {}
}
},
"values": {
"group": {
"by": "legend",
"select": [
{
"bind": {
"to": "measure"
}
}
]
}
}
}
}
],
"sorting": {
"default": {
}
}
}
# Output
Visual pane is being fulfilled by the series. After selecting random color, nothing is happening to the DataView - unfortunately, objects are not binded to DataView's metadata
As mentioned in intro paragraph, when I used Categories selectors in enumerateObjectInstances after enumrating objects in my DataView metadata (for categories) objects property is being added (array of object instances for each category)
Below code how I generated Category selection IDs:
let categorySelectionId = this.host.createSelectionIdBuilder()
.withCategory(categories, i)
.createSelectionId();
Any ideas what I'm doing wrong or how should I proceed? Thanks in advance!
Best Regards
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
| User | Count |
|---|---|
| 3 | |
| 3 | |
| 2 | |
| 2 | |
| 1 |
| User | Count |
|---|---|
| 4 | |
| 4 | |
| 4 | |
| 3 | |
| 3 |