Forum Discussion

allaboutdata's avatar
allaboutdata
Advocate II
10 years ago

DataViewMapping in capabilities, specifying 3 different categorical mappings

Hi All,

 

So i've setup my custom visual to have 3 dataviews in its capabilities. It seems though that its just duplicating the first categorical data view for the other 2. Anyone got any ideas?

 

In the visual playground where i control the data view mapping inputted the visual renders correctly. So i'm assuming it has to do with how the service is mapping the inputs to the mappings below.

 

dataViewMappings: [
            {
                categorical: {
                    categories: {
                        for: { in: 'A' },
                        dataReductionAlgorithm: { top: {} }
                    },
                    values: {
                        group: {
                            by: 'B',
                            select: [{ for: { in: 'Values' } }],
                            dataReductionAlgorithm: { top: {} }
                        }
                    },
                    rowCount: { preferred: { min: 2 }, supported: { min: 0 } }
                },
            },
            {
                categorical: {
                    categories: {
                        for: { in: 'ACategory' },
                        dataReductionAlgorithm: { top: {} }
                    },
                    values: {
                        group: {
                            by: 'A',
                            select: [{ for: { in: 'Values' } }],
                            dataReductionAlgorithm: { top: {} }
                        }
                    },
                    rowCount: { preferred: { min: 2 }, supported: { min: 0 } }
                },
            },
            {
                categorical: {
                    categories: {
                        for: { in: 'BCategory' },
                        dataReductionAlgorithm: { top: {} }
                    },
                    values: {
                        group: {
                            by: 'B',
                            select: [{ for: { in: 'Values' } }],
                            dataReductionAlgorithm: { top: {} }
                        }
                    },
                    rowCount: { preferred: { min: 2 }, supported: { min: 0 } }
                },
            }
        ]

 

 

5 Replies

  • deldersveld's avatar
    deldersveld
    Resident Rockstar

    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' } }]
                }
            },
        }
    }],

    • allaboutdata's avatar
      allaboutdata
      Advocate 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.

      • deldersveld's avatar
        deldersveld
        Resident 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.