Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
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
Check out the July 2025 Power BI update to learn about new features.
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
User | Count |
---|---|
6 | |
6 | |
3 | |
2 | |
2 |
User | Count |
---|---|
6 | |
5 | |
4 | |
4 | |
3 |