Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
Anthony_W
Helper I
Helper I

Custom R Interactive Visual - How to setup parameters

I am trying to develop several custom power bi visuals using R and Plotly. Previously I have not had any problem in developing ‘basic’ visuals, but would like to extend the visuals to include

  • labelling of the incoming data g. X Values column, Y Values Column, Data Points Colour etc. and
  • the selection of parameters e.g. Colour Gradient, Axis Title font sizes, point size, transparency etc..

1 Basic custom R/Plotly visual

I start a custom visual with the following steps

  1. Type the following command into CMD window: pbiviz new TestVisual -t rhtml
  2. Update blank fields in ‘pbiviz.json’ that must have values
  3. Update ‘script.R’ with the R Script to generate the required visual
  4. Type the following command into CMD window to compile the package: pbiviz package

The visual is then compiled, I can add it to the Power BI report and it works fine.

2 Custom R/Plotly visual with data assignments

I start off with test custom visual as noted above and modify the capabilities.json file. I update the dataRoles and dataviewmappings sections to include 3 parameters: Xvalues, YValues and ColourValues.

The visual is then compiled (using pbiviz package in the command prompt)., I can add it to the Power BI report and it works fine.

3 Custom R/Plotly visual with data assignments and parameters

I am struggling to implement parameters within the customised visual. I have looked at Microsoft’s tutorial located at the following link.

https://microsoft.github.io/PowerBI-visuals/tutorials/funnel-plot-from-r-script-to-r-custom-visual/o...

According to the tutorial, I just have to change the capabilities.json file, the settings.ts file and the R script to identify whether a parameter value exists and assign a default value if required.

I have attempted to do that but can’t get the parameters working probably. Has anyone succeeded in getting the parameters working for a dynamic R custom visual? Or can share a link to a detailed tutorial that works?

 

Thanks.

 

5 REPLIES 5

Thanks for the links Amitchandak.

 

Unfortunately the links don't help with my problem.

 

Cheers,

 

 

 

Hi @Anthony_W ,

Please find the following links, hope they can help you.

https://radacad.com/create-custom-visual-with-r-and-json-part3

https://www.youtube.com/watch?v=NMXlWu_oeyA

 

Best Regards

Rena

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Thanks for the links yinginr,

 

I am working through the Radacad example. I downloaded the example visual data and managed to compile the custom.

 

I did receive an initial error during compilation stating a 'Globalize' package was not available. The error gave instructions for how to install the package - npm install --save globalize. Once the package is installed, the custom visual compiled OK.

 

I added the visual to a power bi report, but now receive the following R related error:

Error in strsplit(names(values), "\\.") : non-character argument
Calls: %>% -> eval -> eval -> style -> strsplit
Execution halted

 

I tried to find to find the strsplit function in the R code in the custom visual files, but haven't found. I suspect it is in one of the packages. I am still investigating the location of the error...

 

Hi @Anthony_W ,

Which sample you are using? Please try the solution in the following link and check if it works after you find the related "package".

https://www.rdocumentation.org/packages/base/versions/3.6.2/topics/strsplit

 

Best Regards

Rena

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.

Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.