Interactive Charts using R and Power BI: Create Custom Visual Part 3



In the last two posts (Part 1 and 2), I have explained the main process of creating the R custom Visual Packages in Power BI. there are some parts that still need improvement which I will do in next posts. In this post, I am going to show different R charts that can be used in power BI and when we should used them for what type of data, these are Facet jitter chart, Pie chart, Polar Scatter Chart, Multiple Box Plot, and Column Width Chart. I follow the same process I did in Post 1 and Post 2. I just change the R scripts  and will explain how to use these graphs

1-Jitter Chart

This chart has been used to show all data points. Also, it shows three variables in at the same time: two numeric variable for x and y axis and one factor variable with different colours. In the below picture you will see that I created a custom visual that shows the speed of the car in the city in x axis, the car’s speed in high way in Y axis and the number of cylinders as factor variable in chart legend.



also there is a possibility to show 4 or 5 variable at the same time. One for x axis, y axis, the colour shade that should be factor, two factor variable for Facet and different tiles. in the below GIF you see that I show the speed of car in city and highway in x and y axises, also I put the year in to z variable. Moreover, for different tiles I need two variables one for year and another factor variable for Fl of cars. this custom visual get constant 5 variables as x,y,z,w, and v. I have a post on this chart before see



The code for generating the chart has been shown below


2-Pie Chart

Pie chart able to shows the composition of data. In the below example, I have shown how to show the composition of the car’s speed in highway as a continues variable with grouping them based on FL of the car. this chart shows the labels inside the pie chart (in power bi it shows outside)



The code for generating the chart has been shown below


3-Polar Scatter Chart

this chart has been used to show two numeric variable, which one of the should have wider range for instance from 0 to 365 or 177 to -177 also another variable should be a limited range for instance from 0 to 10 or from 0 to 1. we need another factor variable to show the colour. in the below gif, you will see we have a variable that range from 0 to 1 and the other one from 0 to 270. also we have a factor variable that shows the lines in graph in different colours.



The code for generating the chart has been shown below


4-Box Plot

It always important to have a holistic perspective regarding the minimum, maximum, middle, outliers of our data in one picture.
One of the chart that helps us to have a perspective regard these values in “Box Plot” in R. I have already a post on this concepts and how to have it see :

Visualizing numeric variables in Power BI – boxplots -Part 1


here I have shown how to make them more interactive via Plotly , having more plots in one chart regarding a factor variable.



The code for generating the chart has been shown below

5- Column Width Chart

for comparison purpose most of the charts can be available in Power BI Visualization, just two of them are not :Variable Width Column Chart and table with table embedded chart (I will show it next post hopefully)  . This chart help us to do compare two variable in a bar chart. we have height and width of the bar chart. in normal bar chart the bar width are same size the process of creating this chart has been explained in post :

Here am going to create a custom visual to show how to have them. the dataset that I have has information about the car speed in city and highway plus the number of cylinder and their type of drive (four wheel drive, rear drive or front drive).

to do that first in power BI I create two separate dataset that has been group by :1- number of cylinder and 2- type of drive.




Leila Etaati on LinkedinLeila Etaati on TwitterLeila Etaati on Youtube
Leila Etaati
Trainer, Consultant, Mentor
Leila is the first Microsoft AI MVP in New Zealand and Australia, She has Ph.D. in Information System from the University Of Auckland. She is the Co-director and data scientist in RADACAD Company with more than 100 clients in around the world. She is the co-organizer of Microsoft Business Intelligence and Power BI Use group (meetup) in Auckland with more than 1200 members, She is the co-organizer of three main conferences in Auckland: SQL Saturday Auckland (2015 till now) with more than 400 registrations, Difinity (2017 till now) with more than 200 registrations and Global AI Bootcamp 2018. She is a Data Scientist, BI Consultant, Trainer, and Speaker. She is a well-known International Speakers to many conferences such as Microsoft ignite, SQL pass, Data Platform Summit, SQL Saturday, Power BI world Tour and so forth in Europe, USA, Asia, Australia, and New Zealand. She has over ten years’ experience working with databases and software systems. She was involved in many large-scale projects for big-sized companies. She also AI and Data Platform Microsoft MVP. Leila is an active Technical Microsoft AI blogger for RADACAD.

3 thoughts on “Interactive Charts using R and Power BI: Create Custom Visual Part 3

Leave a Reply

%d bloggers like this: