Forum Discussion
Custom Visualization additional DataViewCategoryColumn
Are you talking about Category? You can add select into categories instead.
Please also remove group by statement and use select instead.
"select": [{
"for": {
"in": "Values"
}
},
{
"for": {
"in": "Category"
}
}
],
Ignat Vilesov,
Software Engineer
Microsoft Power BI Custom Visuals
hello Ignat,
Thanks for your help. I've been following up on your hint and somehow I understand that I may have a design flaw, so I was hoping you could help me review it and define the right approach.
I have a series of groups (field Category) for which I want to evaluate the distribution of the total sum of values(field Values) grouped by path (field Paths) for every category. (The pie slices/Arcs)
I need to be able to configure the color of the pie slices so they can be picked through the color Palette.
But I also need to have a 3rd measure (Field Measure) to be shown in the middle of the pie chart, that depends from the field "Category" independently of "Paths" and "Values". It is usually a % hence I cannot aggregate randomly as sometimes will not be a dynamic DAX measure. (I'm OK forcing it to be though)
Before I was using unable to configure the color palette for the chart slice groups but everything else was working:
{
"dataRoles": [{
"displayName": "Category Data",
"name": "Category",
"kind": "Grouping"
},
{
"displayName": "Paths",
"name": "Paths",
"kind": "Grouping",
"description": "The value used to customize the shape of the data points",
"requiredTypes": [{
"text": true
}]
},
{
"displayName": "Values",
"name": "Values",
"kind": "Measure",
"requiredTypes": [{
"numeric": true
}, {
"integer": true
}]
},
{
"displayName": "Measure",
"name": "measure",
"kind": "Measure",
"requiredTypes": [{
"numeric": true
}, {
"integer": false
}]
},
{
"displayName": "Measure Color",
"name": "measureColor",
"kind": "Measure",
"requiredTypes": [{
"numeric": true
}, {
"integer": false
}]
}
],
"dataViewMappings": [{
"conditions": [{
"Category": {
"min": 0,
"max": 3
},
"Paths": {
"min": 0,
"max": 1
},
"Values": {
"min": 0,
"max": 1
},
"Measure": {
"min": 0,
"max": 1
}
}],
"categorical": {
"categories": {
"for": {
"in": "Category"
},
"dataReductionAlgorithm": {
"top": {}
}
},
"values": {
"group": {
"by": "Paths",
"select": [{
"bind": {
"to": "Values"
}
}],
"dataReductionAlgorithm": {
"top": {}
}
}
}
}
},
{
"conditions": [{
"Category": {
"min": 0,
"max": 3
},
"Paths": {
"min": 0,
"max": 1
},
"Values": {
"min": 0,
"max": 1
},
"Measure": {
"min": 0,
"max": 1
}
}],
"categorical": {
"categories": {
"for": {
"in": "Category"
},
"dataReductionAlgorithm": {
"top": {}
}
},
"values": {
"select": [{
"bind": {
"to": "measure"
}
},
{
"bind": {
"to": "measureColor"
}
}
]
}
}
}
],
"objects": {
"colorSelector": {
"displayName": "Data Colors",
"properties": {
"fill": {
"displayName": "Color",
"type": {
"fill": {
"solid": {
"color": true
}
}
}
}
}
},
"generalView": {
"displayName": "General View",
"properties": {
"opacity": {
"displayName": "Bars Opacity",
"type": {
"integer": true
}
},
"showHelpLink": {
"displayName": "Show Help Button",
"type": {
"bool": true
}
}
}
},
"fontFamily": {
"displayName": "Font",
"properties": {
"MarkerShape": {
"displayName": "Marker shape",
"type": {
"enumeration": [{
"displayName": "Default",
"description": "helvetica, arial, sans-serif",
"value": "helvetica, arial, sans-serif"
},
{
"displayName": "Arial",
"value": "Arial"
},
{
"displayName": "Arial Black",
"value": "\"Arial Black\""
}
]
}
}
}
}
},
"tooltips": {
"supportedTypes": {
"default": true,
"canvas": true
},
"roles": [
"Tooltips"
]
}
}Now after raising the question here, I've been working to build something different that I think would allow me to create selectors for the slices, but I cannot see how I can get the measure for the "Category" field.
{
"dataRoles": [{
"displayName": "Category Data",
"name": "Category",
"kind": "Grouping"
},
{
"displayName": "Paths",
"name": "Paths",
"kind": "Grouping",
"description": "The value used to customize the shape of the data points",
"requiredTypes": [{
"text": true
}]
},
{
"displayName": "Values",
"name": "Values",
"kind": "Measure",
"requiredTypes": [{
"numeric": true
}, {
"integer": true
}]
},
{
"displayName": "Measure",
"name": "measure",
"kind": "Measure",
"requiredTypes": [{
"numeric": true
}, {
"integer": false
}]
},
{
"displayName": "Measure Color",
"name": "measureColor",
"kind": "Measure",
"requiredTypes": [{
"numeric": true
}, {
"integer": false
}]
}
],
"dataViewMappings": [{
"conditions": [{
"Category": {
"min": 0,
"max": 3
},
"Paths": {
"min": 0,
"max": 1
},
"Values": {
"min": 0,
"max": 1
},
"Measure": {
"min": 0,
"max": 1
}
}],
"categorical": {
"categories": {
"for": {
"in": "Category"
},
"dataReductionAlgorithm": {
"top": {}
}
},
"values": {
"select": [{
"for": {
"in": "Values"
}},{
"bind": {
"to": "Paths"
}},{
"bind": {
"to": "measure"
}
},
{
"bind": {
"to": "measureColor"
}
}
],
"dataReductionAlgorithm": {
"top": {}
}
}
}
}
],
"objects": {
"colorSelector": {
"displayName": "Data Colors",
"properties": {
"fill": {
"displayName": "Color",
"type": {
"fill": {
"solid": {
"color": true
}
}
}
}
}
},
"generalView": {
"displayName": "General View",
"properties": {
"opacity": {
"displayName": "Bars Opacity",
"type": {
"integer": true
}
},
"showHelpLink": {
"displayName": "Show Help Button",
"type": {
"bool": true
}
}
}
},
"fontFamily": {
"displayName": "Font",
"properties": {
"MarkerShape": {
"displayName": "Marker shape",
"type": {
"enumeration": [{
"displayName": "Default",
"description": "helvetica, arial, sans-serif",
"value": "helvetica, arial, sans-serif"
},
{
"displayName": "Arial",
"value": "Arial"
},
{
"displayName": "Arial Black",
"value": "\"Arial Black\""
}
]
}
}
}
}
},
"tooltips": {
"supportedTypes": {
"default": true,
"canvas": true
},
"roles": [
"Tooltips"
]
}
}
Is it possible to group all the independent combinations of category-path in a single colorPalette setting and at the same time have a measure dependent on the category field?
Some help will be REALLY appreciated.
Thanks a lot in advance,
G.
- v-viig8 years agoCommunity Champion
You wanted to specify a color for each segment of each pie. Is that correct?
Ignat Vilesov,
Software Engineer
Microsoft Power BI Custom Visuals
- GGimenez8 years agoFrequent Visitor
Yes, that's it. But the arc segment colors must be the same for all the pies, as they represent the same across pies.
- GGimenez8 years agoFrequent Visitor
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; }