Forum Discussion
DataViewMapping in capabilities, specifying 3 different categorical mappings
dataViewMappings correspond to the dataRoles. What does your dataRoles section look like?
You can only map once, so having three is not correct. Something like this may get you closer. Note how the roles match the mappings. The best way to learn is to find a chart that behaves the way that you want and start from that example. If you log the dataview to the console, you can experiment and see how changes you make to capabilities affect the dataview.
dataRoles: [
{
name: "A",
kind: VisualDataRoleKind.Grouping,
displayName: "A"
},
{
name: "B",
kind: VisualDataRoleKind.Grouping,
displayName: "B"
},
{
name: "Values",
kind: VisualDataRoleKind.Measure,
displayName: "Values"
}
],
dataViewMappings: [{
categorical: {
categories: {
for: { in: "A" }
},
values: {
group: {
by: "B",
select: [{ bind: { to: 'Values' } }]
}
},
}
}],
- allaboutdata10 years agoAdvocate II
Hey Deldversveld,
Do you know for certain that you can only map once? Can you further iterate on that. Or are you saying that per data role you can only allocate to one datamapping?
If you take a look at the combo chart in the visualisation playground it has multiple dataviewmappings assosciated to it.
dataViewMappings: [ { conditions: [ { 'Category': { max: 1 }, 'Series': { max: 0 } }, { 'Category': { max: 1 }, 'Series': { min: 1, max: 1 }, 'Y': { max: 1 } }, ], categorical: { categories: { for: { in: 'Category' }, dataReductionAlgorithm: { top: {} } }, values: { group: { by: 'Series', select: [ { for: { in: 'Y' } } ], dataReductionAlgorithm: { top: {} } } }, rowCount: { preferred: { min: 2 }, supported: { min: 0 } } } }, { conditions: [ { 'Category': { max: 1 }, 'Series': { max: 0 }, 'Y2': { min: 1 } }, { 'Category': { max: 1 }, 'Series': { min: 1, max: 1 }, 'Y': { max: 1 }, 'Y2': { min: 1 } }, ], categorical: { categories: { for: { in: 'Category' }, dataReductionAlgorithm: { top: {} } }, values: { select: [ { for: { in: 'Y2' } } ], dataReductionAlgorithm: { top: {} } }, rowCount: { preferred: { min: 2 }, supported: { min: 0 } } }, } ],thoughts?
I was thinking a long your lines until i saw the combo chart. I have my base visualisation working with the single data view mapping.
This is really to activate category colouring but with two groupings and a single measure. As opposed to a combo chart which is one grouping i.e. axis and two measures.
- deldersveld10 years agoResident Rockstar
You're right! I had not looked at the capabilities for combo chart. No suggestions on a solution, but I'll try to look into it later tonight.
- allaboutdata10 years agoAdvocate II
yeah cool okay, keen to see if you can find the way to do it.
Knocking my head over it, you should be able to do it if the combo chart works that way.