Background:
It is well known that Power BI Desktop supports the Plotly package for R. However, in some cases, if we create a chart in Power BI Desktop using the R package Plotly, we would return the following results (using a scatter plot as an example).
No image was created. The R code didn't result in creation of any visuals. Make sure your R script results in a plot to the R default device.
The reason of this error is that we are using Plotly to create interactive web-based graphics, while the R visual in Power BI is known to support plotting only for default devices.
Solution:
Create a custom R visualization and import it into Power BI Desktop and Service.
npm install -g powerbi-visuals-tools
To confirm it is installed correctly you can run the command: pbiviz
Then you should see the information about Power BI Custom Visual Tools.
cd C:/CustomRvisual
pbiviz new rVisualSample -t rhtml
Note that the dataset used here is "Values", because we need to add fields to the Values pane in PowerBi. The field names assigned to each axis need to be the same as the field names in PowerBI.
For example:
Note: If you cannot save the script.r and pbivis.json files due to access prohibition, please change the user's permission in Properties -> Security of these files.
cd C:/CustomRvisual/rVisualSample
pbiviz package
This command creates a pbiviz file in the dist/ directory of your visual project, and overwrites any previous pbiviz file that might exist. The package contains everything required to import the custom visual into either the Power BI service or a Power BI Desktop report.
Hope this will help you.
Author: Winni Zhang
Reviewer: Kerry Wang & Ula Huang
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.