Forum Discussion
Custom Visualization additional DataViewCategoryColumn
To get data from the second and third columns of Category you should iterate
dataView.categorical.categories.map((category, categoryIndex) => {
// TODO: Write your code here
});
Ignat Vilesov,
Software Engineer
Microsoft Power BI Custom Visuals
Dear Ignat,
Thanks for your reply. I've tried your code and it works when I add more than one column in the same field holder (Category)..
Hoever, I am unable to access the dimension i want to use. I've been able to find it at dataView.categorical.values.grouped() but they lack the right type or idk, but the fact is that when I map it and try to use it in the selectionManager method or I pass it to a valueFormatter, I get a simple array I cannot reference or get the identity object from:
var sliceCount = dataView.categorical.values.grouped();
for(let j=0; j<sliceCount.length; j++){
arcsArray.push(this.formatCategoryValue(sliceCount[j].values[0]["__proto__"].source.groupName, sliceCount[j].values[0]["__proto__"].source.type));
}
Would there be a way to use more than one category? Or may be my dataViewMappings are not correct?
Thanks a lot again for your help.
G.
my full cappabilities file. I'm trying to be able to select by any of the two grouping variables.
{ "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": "Paths"
},
"dataReductionAlgorithm": {
"top": {}
}
},
"values": {
"group": {
"by": "Category",
"select":[
{
"for":{
"in":"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
}
}
}
}
},
"supportsHighlight": true,
"tooltips": {
"supportedTypes": {
"default": true,
"canvas": true
},
"roles": [
"Tooltips"
]
}
}- v-viig8 years agoCommunity Champion
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
- GGimenez8 years agoFrequent Visitor
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