This is a template repo for a new TypeScript-based Power BI custom visual and hopefully saves a bit of time when setting up a new one from scratch.
This repo is set up for v2.6.1 of the powerbi-visuals-api and will also install version 3.1 of the powerbi-visuals-tools SDK as a local dependency.
When we instantiate a custom visual using pbiviz new, the first thing I do is remove a whole bunch of stuff and set up some things I typically need each time:
- Set up a new git repo and add the SDK-specific files to the
.gitignorefile. - Remove the boilerplate code that the template leaves in there.
- Remove boilerplate
objectsfromcapabilities.jsonas we typically don't need them. - Add packages for code linting, with suggested rules for certification. I can then run
npm run lintto check my code is formatted consistently. - Add powerbi-visuals-utils-formattingutils package so that we can do localisation.
- Add sample localisation keys to
capabilities.json. - Create
stringResources/en_US/resources.resjsonwith these keys, so that we can validateen_USlocalisation when we package (not currently supported in the developer visual).
- Add sample localisation keys to
- Fill out the
pbiviz.jsonwith some defaults so that I can runpbiviz packagewithout it erroring about missing fields. - Add rendering events handling, so that we're doing the right thing if we want to work towards certification.
Once you create a new repo from this template (or pull down an update), you need to do the following:
- Run
npm ito ensure that all dependent node modules are pulled down and up-to-date. - If you have the correct version of
powerbi-visuals-toolsinstalled globally, then the certificate will be reused, otherwise: - If this is the first time using the version of the SDK/API then you'll need to generate and install your certificate with
pbiviz --install-cert. - Update
pbiviz.json(see below).
pbiviz.json contains the metadata for your custom visual. I have included enough details to allow the visual to package into a .pbiviz file without an error being thrown, but you should put your own mark on this.
- Update the
visualobject values:- Change
nameto match the desired internal name of your visual. - Change
displayNameto the name you wish to see in the visual palette. - Change
guidto something unique.- The
guidis used by the marketplace to uniquely identify your visual, so if this happens to match then you might have problems when packaging/loading. - Something that combines the same value as what you add to
name, plus a 32 character hexadecimal string matches what the SDK tool does, but you can do whatever you like here to guarantee uniqueness.
- The
- Change
versionto your desired number. - Change
descriptionto what you want to see when you right-click the visual and select About. - Change
supportUrlto the site that you wish to see when you right-click the visual and select About. Note that this is required for packaging but doesn't necessarily have to be a legitimate site.
- Change
- Update the
authorobject values:- Change
nameto the person or company who authors the visual. - Change
emailto a suitable address.
- Change