This article helps you understand what are the important aspects of using R and TypeScript as the language choice for developing Microsoft PowerBI Custom Visuals. If you are planning for writting a Custom visual it is always better to know beforehand pros and cons of using R vs TypeScript.
R vs TypeScript for Microsoft PowerBI custom visual development

1. Community Support

Though PowerBI supports R for custom visual development, but Microsoft's hosted sample tutorials and documentation (https://github.com/microsoft/PowerBI-visuals) are provided in TypeScript only and not much help, guidelines or documentation provided for R.

Performance of a Machine Learning model is judged based on prediction it makes. If we ask the model to predict output or dependent variable for a data which is already in training data, then we are more likely to close to accurate prediction. Even various forums internal and external to Microsoft mainly discuss about TypeScript usage while writing Custom Visuals.

2. Ease of Development

If you are comfortable with R and the requirement for Custom Visual is quite simple, one is suggested to use R. It is quite simple to use and no additional knowledge is needed. You will be adding list of data options in capabilities.json which is same for R and TypeScript implementation.

While if you are planning to use TypeScript for writing Custom Visuals, you need to learn D3 library also. TypeScript uses D3 for Custom Visual development. So, learning will be more for TypeScript/D3 as compared with R.

3. Inconsistencies in Power BI Desktop vs Online Publishing

Here is the list of R packages and their versions supported in PowerBI(https://docs.microsoft.com/en-us/power-bi/service-r-packages-support). It is frequently found that many packages and quite commonly their latest versions are not supported in PowerBI. Hence, it is always better to check this list before using any package/version.

Also, sometimes there are incosistencies found between package support between Power BI Desktop Version and Online Version. Because of which, it can occur that your Custom Visual with R can render correctly in PowerBI desktop but not while published online.

For example, scatterpolar as one of the type in plotly for "add_traces" is supported in PowerBI Desktop Version, while it is not supported in Online version. Hence, if you wish to publish your visual online, you will face an issue something like this which states the list of all the types supported which doesn't contain scatterpolar.

scatterpolar not supported in online PowerBI version

Such inconsistences often wastes lots of time and energy and limits the scope of implementation of Custom Visuals with R.

Hence, it is always advised to keep checking the Visual in both Desktop and Online version during development. Such is not the case with TypeScript.

4. Inability for introduce in click event listener or make a visual interactive

Currently(as of July 2019) PowerBI doesn't support shiny package in R. Shiny is primarily being used to make a chart interactive, for example a click event listener for clicking a section of pie chart or a bar of bar chart. If your custom visual will have such requirement, where you wish to take some actions like drill-down or filtering based of click. Then, please don't go for R.
However, it is easily doable with TypeScript with D3.

5. Toolkit features

With R using plotly or ggplot packages you will get rich set of toolkit like zooming, panning, snipping etc. Such toolkit is not possible in TypeScript/D3 where you have to design everything in explicit manner.

Inbuit Toolkit that comes with Plotly library

6. Speed and Performance

If your custom visuals is quite simple and not requiring thousands of rows of data crunching, then both R and TypeScript will have similar performance experience, However, it is observed that R based custom visuals are slower when compared to TypeScript. Reason being, R first prepares a html output of the visual and then fit it PowerBI.
However, TypeScript with D3 renders the visuals directly to PowerBI dashboard.

Conclusion

With the above points it is clear that if you are equally good in R vs TypeScript with D3, then obvious choice tilt towards TypeScript. But if your requirement with Custom Visuals is simple and non-interactive, then R is better for faster writing and inbuilt toolkit.


Thank you for reading it all along. Hope you liked this article!!


About the author

Prakash snippetnuggets

Prakash

You can contact him at [email protected]