Forum Discussion
Custom Visualization additional DataViewCategoryColumn
Now I'm able to edit and store the color picked, but it changes the color for all the other columns of the object:
var metadataColumns2: DataViewMetadataColumn[] = this.dataView.metadata.columns.filter(function(d) {
if (d.groupName){
return true
} })
and in the enumerateObjects function:
case 'stackColorsFormatting':
for (let barDataPoint of metadataColumns2) {
var col = this.getArcColor(barDataPoint.objects, objectName, "fill", null);
objectEnumeration.push({
objectName: objectName,
displayName: barDataPoint.groupName.toString(),
properties: {
fill: {
solid: {
color: col.solid.color
}
}
},
selector: { metadata: barDataPoint.queryName }
});
}
break;
And the getArcColor function:
public getArcColor<T>(objects: DataViewObject, objectName: string, propertyName: string, defaultValue: T): T {
if (objects) {
let object = objects[objectName];
if (object) {
let property: T = <T>object[propertyName];
if (property !== undefined) {
return property;
}
}
}
return defaultValue;
}
Not sure if I understood you well. Have you resolved the issue?
Ignat Vilesov,
Software Engineer
Microsoft Power BI Custom Visuals
- v-viig8 years agoCommunity Champion
You should use group-by Category to group values. In such case you will be able to generate a proper SelectionId.
"values": { "group": { "by": "Paths", "select":[Please have a look at this example.
Ignat Vilesov,
Software Engineer
Microsoft Power BI Custom Visuals
- GGimenez8 years agoFrequent Visitor
No, i'm still stuck.
Here is how it looks now:
https://gist.github.com/sineline/f4f4074919777079d59cbf7551bc1d47
- GGimenez8 years agoFrequent Visitor
I believe this is how I've got it right now, with the group by (See gist in previous post).
With it I get the right values, but I want to enumerate and set colors per group (Which are the pie slices).
Can I build the selectors the same way when enumerating the different series? (For the pie slices coloring)
For the moment, I've been playing with this function.. but i dont know if I'm in the right path:
case "stackColorsFormatting": var metadataColumns2: DataViewMetadataColumn[] = this.dataView.metadata.columns.filter( function(d) { if (d.groupName) { return true; } } ); for (let barDataPoint of metadataColumns2) { console.log("create selection id?"); objectEnumeration.push({ objectName: objectName, displayName: barDataPoint.groupName.toString(), properties: { fill:this.getArcColor<object>(barDataPoint.objects,objectName,"fill",null) }, selector: { id: this.host.createSelectionIdBuilder().withSeries( this.dataView.categorical.values,this.dataView.categorical.values[0] ).createSelectionId().getKey() } }); } break; - v-viig8 years agoCommunity Champion
GGimenez Could you please share source code to make some changes?
You can send code to [email protected].
Ignat Vilesov,
Software Engineer
Microsoft Power BI Custom Visuals