powerbipbiviz

Power BI Custom Visual - Visual Tab Not Visible in Formatting Pane


Posting in the hope it saves someone else hours of frustration!

I am developing a power bi custom visual and want to have a number of properties in the format pane as per the below image.
https://learn.microsoft.com/en-au/power-bi/developer/visuals/format-pane-general enter image description here

I got everything working and had a fairly complex visual with >1000 lines of code. Then I decided to do a significant refactor to "cleanup" the code (I made the mistake of doing this in one fairly large chunk, so lots of changes made, with only one check-in).

After doing the refactor, I noticed that the Visual tab in the Formatting pane was not visible. (Note I haven't provided my full implementation as the problem ended up being very simple as per the following answer. Refer to the attached Microsoft link for full details of the implementation)


Solution

  • I spent several hours retracing my refactoring steps trying to find my error and I checked everything in the capabilities.json, settings.ts and visual.ts files.

    However, for me, the very simple answer was that I had deleted the implementation of the getFormattingModel() method on the visual class, because the method "was not used" in my code and appeared to be redundant.

    Once I found that and restored the implementation, the Visual tab reappeared. Makes me yearn for C# that would presumably have given a compile time error that an interface was not implemented!

        public getFormattingModel(): powerbi.visuals.FormattingModel {
      return this.formattingSettingsService.buildFormattingModel(this.formattingSettings);
    

    }

    I know that there are multiple other causes that can result in the tab not being displayed, but this was the one that tripped me up.