cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Frequent Visitor

Custom Visualization additional DataViewCategoryColumn

Hello,

 

I'm trying to develop a custom visual that replicates an arc chart for every existing category. I've used the code at https://github.com/kiewic/PowerBI-WaffleChart and I'm on the right path:

However, I'm unable to configure a DataViewCategoryColumn for the second level of categories (The slices of the arc chart). 

 

In the current code, I can set up the first categories: 

 

 

 public static converter(dataView: DataView): PieChartViewModel {
            var labelsArray: Array<string> = [];
            var arcsArray: Array<string> = [];
            var Arcs: DataViewCategoryColumn;
            var category0: DataViewCategoryColumn;
            //matrix.columns.root.children
            if (dataView.categorical.categories && dataView.categorical.categories.length > 0) {
                let categories = dataView.categorical.categories;
                category0 = categories[0];
                
                var rowsCount = category0.values.length;
                labelsArray = [];
                arcsArray = [];
                for (let i = 0; i < rowsCount; i++) {
                    let labelPieces: Array<string> = [];
                    for (let j = 0; j < categories.length; j++) {
                        labelPieces.push(this.formatCategoryValue(categories[j].values[i], categories[j].source.type));
                    }
                    labelsArray.push(labelPieces.join("|"));
                }
                var sliceCount = dataView.categorical.values.grouped();
                //.values["0"].__proto__.source.groupName
                for(let j=0; j<sliceCount.length; j++){
                    console.log(sliceCount[j].values[0]["__proto__"].source.groupName);
                    arcsArray.push(this.formatCategoryValue(sliceCount[j].values[0]["__proto__"].source.groupName, sliceCount[j].values[0]["__proto__"].source.type));
                }
           }

 

 

 

However, I'm unable to find a node from which I could set up a similar object for the second dimension of categories. I could create a new array but I believe I need to use the right object type and I'm struggling to do so.

 

Currently, my dataViewMappings look like this:

   cappabilities.json

 

"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":[
                            {
                               "for":{
                                  "in":"Values"
                               }
                            }
                         ], 
                        "dataReductionAlgorithm": {
                            "top": {}
                        }
                    }
                }
            }
        }

Could you please give me a clue?

Thanks a lot in advance!
Guillermo

 

13 REPLIES 13

Helpful resources

Announcements
secondImage

Happy New Year from Power BI

This is a must watch for a message from Power BI!

December Update

Check it Out!

Click here to read more about the December 2020 Updates!

Community Blog

Check it Out!

Click here to read the latest blog and learn more about contributing to the Power BI blog!

Get Ready for Power BI Dev Camp

Get Ready for Power BI Dev Camp

Mark your calendars and join us for our next Power BI Dev Camp!.