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

VisualObjectInstanceEnumerationObject formatting pane shows blank displayName

Using API v3.2.0 and have also tried v2.6.0 for this issue.

I'm attempting to use VisualObjectInstanceEnumerationObject to do categorized formatting options similar to the Table visual's Field formatting object. 

fieldFormatting.png

I am succesfully populating the VisualObjectInstanceEnumerationObject object, and am seeing results populated in the formatting pane for each of my containers, which are bound to to categories in a categorical dataview mapping. I can use the dropdown to switch between containers, and the results are bound to the dataview as expected. My issue is that the text of the dropdown for each category is blank for every option. See relevant code below (this is a contrived example but is representative of the issue):

capabilities.json

 

{
    "dataRoles": [
        {
            "displayName": "Category",
            "name": "category",
            "kind": "Grouping"
        },
        {
            "displayName": "Measure",
            "name": "measure",
            "kind": "Measure"
        }
    ],
    "objects": {
        "polygons": {
            "displayName": "Polygons",
            "properties": {
                "polyFill" :{
                    "displayName": "Polygon Color",
                    "type": {
                        "fill": {
                            "solid": {
                                "color": true
                            }
                        }
                    }
                }
            }
        }
    }
    "dataViewMappings": [
        {
            "categorical": {
                "categories": {
                    "for": {
                        "in": "category"
                    },
                },
                "values": {
                    "select": [
                        {
                            "bind": {
                                "to": "measure"
                            }
                        }
                    ]
                }
            }
        }
    ]
}

 

dataview conversion

 

    public convert(): dataPoint[]{
        const categorical = this._options.dataViews[0].categorical;

        const categories: DataViewCategoryColumn[] = categorical.categories;
        const values: DataViewValueColumns = categorical.values;

        const category = categories[dataRoleHelper.getCategoryIndexOfRole(categories, 'category')];
        const value = values.find(d => dataRoleHelper.hasRoleInValueColumn(d, 'measure'));

        const data: dataPoint[] = [];
        const scaleColor = d3.scaleOrdinal(d3.schemeSet3);
        
        for (let i = 0; i < category.values.length; i++){
            data.push({
                xValue : <number>category.values[i],
                yValue: <number>value.values[i],
                selectionId: this.host.createSelectionIdBuilder().withCategory(category, i).createSelectionId(),
                color: scaleColor(i.toString())
            });
        }

        return data;
    }

 

enumerateObjectInstances

 

    public enumerateObjectInstances(options: EnumerateVisualObjectInstancesOptions): VisualObjectInstance[] | VisualObjectInstanceEnumerationObject {
        let instances: VisualObjectInstance[] | VisualObjectInstanceEnumerationObject =
            (<VisualObjectInstanceEnumerationObject>VisualSettings.enumerateObjectInstances(this.settings, options)).instances || [];

        switch (options.objectName) {
            case 'polygons': {
                if (this.visualData) {
                    instances = {
                        containers: this.visualData.map(d => { return { displayName: `${d.xValue}, ${d.yValue}` } }),
                        instances: this.visualData.map((d, i) => {
                            return {
                                containerIdx: i,
                                objectName: "polygons",
                                displayName: `${d.xValue}, ${d.yValue}`,
                                properties: {
                                    polyFill: { solid: { color: d.color } }
                                },
                                selector: d.selectionId.getSelector()
                            }
                        })
                    };
                }
                break;
            }
        }

        return instances;
    }

 

blankDisplayName.png

The type of displayName is:

 

    export type DisplayNameGetter = ((resourceProvider: IStringResourceProvider) => string) | string;

 

I've tried to set the value of displayName to a function that takes an IStringResourceProvider and return my chosen container name as a string. I have also tried to use the get(id: string) method of IStringResourceProvider, passing in the chosen string name as the id. If there is a significance of the id parameter of the get method, then I've been unable to determine it.

I debugged the execution of the Table visual and can see that it simply passes the displayName of the container as a string as I appear to be doing. Not sure what the difference is (maybe different API for first party visuals?).

tableVisualDisplayName.png

 @v-viig @v-evelk @jamesdales 

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Super User II
Super User II

Re: VisualObjectInstanceEnumerationObject formatting pane shows blank displayName

Hi @john_m_dixon,

Your approach is correct, but unfortunately containers don't work properly for custom visuals. It's somewhat frustrating, particularly as the MS-produced ones seem to work (although they have the same issue if you build them locally). I recently asked the team on its status and it's still outstanding.

Regards,

Daniel





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

2 REPLIES 2
Highlighted
Super User II
Super User II

Re: VisualObjectInstanceEnumerationObject formatting pane shows blank displayName

Hi @john_m_dixon,

Your approach is correct, but unfortunately containers don't work properly for custom visuals. It's somewhat frustrating, particularly as the MS-produced ones seem to work (although they have the same issue if you build them locally). I recently asked the team on its status and it's still outstanding.

Regards,

Daniel





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

Highlighted
Frequent Visitor

Re: VisualObjectInstanceEnumerationObject formatting pane shows blank displayName

Thanks @dm-p, I got the same feedback from Microsoft, but hadn't been able to find the github issue you mentioned. It's a little puzzling that pbiviz scaffolds this interface into all new projects if it isn't usable by the api flagged for custom visuals and isn't ready for prime time.

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

Upcoming Events

Experience what’s next for Power BI

See the latest Power BI innovations, updates, and demos from the Microsoft Business Applications Launch Event.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

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!.

Top Kudoed Authors