Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
7 years ago
Solved

Custom Visual, when I add table binding, the custom formatting disappears.

I use API 2.3.0

 

I created table bind
{
    "dataRoles": [
        {
            "displayName": "Category",
            "name": "Category",
            "kind": "GroupingOrMeasure"
        },
        {
            "displayName": "Value1",
            "name": "Value1",
            "kind": "GroupingOrMeasure"
        },
        {
            "displayName": "Value2",
            "name": "Value2",
            "kind": "GroupingOrMeasure"
        }
    ],
    "objects": {
        "category": {
            "displayName": "Category ",
            "properties": {
                "show": {
                    "displayName": "Turn on/off",
                    "type": {
                        "bool": true
                    }
                },    
                "fontColor": {
                    "displayName": "Font Color",
                    "description": "Select font color",
                    "type": {
                        "fill": {
                            "solid": {
                                "color": true
                            }
                        }
                    }
                }
            }
        }       
    },
    "dataViewMappings": [
        {
            "table": {
                "rows": {
                    "select": [
                        {
                            "for": {
                                "in": "Category"
                            }
                        },                
                        {
                            "for": {
                                "in": "Value1"
                            }
                        },
                        {
                            "for": {
                                "in": "Value2"
                            }
                        }
                    ],
                    "dataReductionAlgorithm": {
                        "sample": {
                            "count": 2000
                        }
                    }
                }
            }
        }
    ]
}
 When I add custom visual to the board, I see custom formatting. But when select some field, custom formatting disappears.
The general format is always available.
 
When I bind via category, everything works correctly. But I need to work with table now.
 
Function enumerateObjectInstances has default code
 const settings: VisualSettings = this.visualSettings || 
                                         VisualSettings.getDefault() as VisualSettings;
        var visualObjects: VisualObjectInstanceEnumerationObject = <VisualObjectInstanceEnumerationObject> VisualSettings.enumerateObjectInstances(settings, options);
        return visualObjects;
 In update method I add 
let dataView = options.dataViews[0] || {} as powerbi.DataView;
this.visualSettings = VisualSettings.parse<VisualSettings>(dataView);
 
 
What I miss?
Also what is the best way to parse data bind?
I have noticed that sometimes metadata.object is not displayed, why?
 
 

6 Replies