This is a walkthrough on creating custom visuals for Power BI, specifically, R powered custom Visuals. The end product will be similar to the custom visuals found here.
By the end of this tutorial we will have the following Plotly Scatter 3D chart–fully interactive in Power BI as a custom visual.
There are five steps to creating custom visuals in Power BI. This guide will cover all of them. Here is the list of steps:
Easiest part. Use the link above.
pbiviz new Rpoweredcustomvisual - t rhtml
Rpoweredcustomvisual
can be anything the user wants to name the visualcd Rpoweredcustomvisual
npm i powerbi-visuals-utils-dataviewutils
pbiviz start
There you go, your command line should look like this:
Before we move to step 3 Let’s look at what we created in step 2.
RpoweredCustomvisual
It should look exactly like this:
Edit the R script found in the file created in Step Two.
We open up the Rscript and see the following code:
Then we make our R code changes
Let’s copy and paste our plotly code:
p <- Values %>%
plot_ly( x = ~wt, y = ~hp, z = ~qsec, color = ~cyl, colors = c('#BF382A', '#0C4B8E')) %>%
add_markers() %>%
layout(scene = list(xaxis = list(title = 'Weight'),
yaxis = list(title = 'Gross horsepower'),
zaxis = list(title = '1/4 mile time')));
internalSaveWidget(p, 'out.html');
We see the new R code in our Rscript file now. Now we overwrite this new R script and save in our Rpoweredcustomvisual
folder.
After saving the file, we made all the changes neccessary. Let’s package the visual and bring it into Power BI.
pbiviz package
– you might have to type ctrl+c
to terminate listeningThis is your news packaged Power BI custom visual, this is the file you choose in step five.
Rpoweredcustomvisual
folder created in step two, delect the dist
folderSelect your visual
Create data – make sure column names are the same as the R code
Put the custom visual on the Power BI canvas
Drag and drop the data fields into the visual.
Your final visual should look like this: