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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
jpf5046
Helper I
Helper I

Are there more examples for visual.ts, capabilities.json and R script for custom R Visuals?

I'm trying to develop a custom R powered visual. I'm using the few examples on githib from the Microsoft team as a template. 

 

(I'm using this repo a lot: https://github.com/Microsoft/PowerBI-visuals-clustering-kmeans) 

 

The problem I am running into is the lack of simplicity making the visuals. The examples on Microsoft's github are very complex. I would like to see a custom R visual with a simple line chart, similar to the bar chart walkthrough on Microsoft's github--but for custom R visuals. 

 

I understand the three key files are visual.ts, capabilities.json, and the r script 

 

Is there a simple custom R visual such as a line chart where I can see the visual.ts, capabilities.json, and r script? This would be tremendously helpful. The K means and other examples on Microsoft's github are not helpful because there is a lot of detail in the visual tied to the clustering algorithm, not so much associated with making the visual. 

 

I am native R programmer, I am running into problems at the visual.ts file. Namely finding the interaction bewteen powerbi.extensibility.visual, enumerateObjectInstances, and the R script. 

 

If it is not possible, can Microsoft consider de-encrypting the current R visuals, so we can open up the zip file to see more examples of a working custom R visual? 

 

 

Any direction would be appreciated. 

 

Thank you!

 

5 REPLIES 5
v-viig
Community Champion
Community Champion

Hello @jpf5046

 

You might use these templates as an example to develop a custom R-powered visual:

These templates don't contain a lot of code line. They represent the basic structure of the R-powered visual.

 

Please let us know if you have any questions.

 

Ignat Vilesov,

Software Engineer

 

Microsoft Power BI Custom Visuals

pbicvsupport@microsoft.com

@v-viig thank you for the help. 

 

I'm still having trouble finding the interaction between Power BI fields added and the Rscript. 

 

I was wondering if you could point me in the right direction. 

 

Here is the plot I was to make with my custom visual: 

 

p = plot_ly(mtcars, x = ~wt, y = ~hp, z = ~qsec, color = ~am, colors = c('#BF382A', '#0C4B8E')) %>%
  add_markers() %>%
  layout(scene = list(xaxis = list(title = 'wt'),
                     yaxis = list(title = 'hp'),
                     zaxis = list(title = 'qsec')));

So to do this I did the following:

 

In capabilities.json I changed to this: 

{
  "dataRoles": [
    {
      "displayName": "CAR TYPE",
      "kind": "GroupingOrMeasure",
      "name": "Values"
    },
    {
      "displayName": "wt",
      "kind": "GroupingOrMeasure",
      "name": "Values"
    },
    {
      "displayName": "hp",
      "kind": "GroupingOrMeasure",
      "name": "Values"
    },
    {
      "displayName": "qsec",
      "kind": "GroupingOrMeasure",
      "name": "Values"
    }
  ],
  "dataViewMappings": [
    {
      
      "scriptResult": {
        "dataInput": {
          "table": {
            "rows": {
              "select": [
                {
                  "for": {
                    "in": "Values"
                  }
                }
              ],
              "dataReductionAlgorithm": {
                "top": {}
              }
            }
          }
        },
        "script": {
          "scriptProviderDefault": "R",
          "scriptOutputType": "html",
          "source": {
            "objectName": "rcv_script",
            "propertyName": "source"
          },
          "provider": {
            "objectName": "rcv_script",
            "propertyName": "provider"
          }
        }
      }
    }
  ],
  "objects": {
    "rcv_script": {
      "properties": {
        "provider": {
          "type": {
            "text": true
          }
        },
        "source": {
          "type": {
            "scripting": {
              "source": true
            }
          }
        }
      }
    }
  },
  "suppressDefaultTitle": true
}

 

And then I'm pretty sure I have to change visual.ts but I am unsure of what to change. 

 

Just making the changes above creates a bunch of errors in cmd line as you could guess. 

 

What step did I skip? 

 

Thank you

 

 

@jpf5046

 

Since I'm facing the same problem (binding input data to R script) I'd like to know if you found any solution to this?

 

My first attemts look somehow similar to what you did but without success on my side as well.

 

Any answer will be helpful.

 

Thank you!

v-viig
Community Champion
Community Champion

Hello @Kangaroo,

 

Could you please send an email to pbicvsupport@microsoft.com with issue's details?

We'll include our R developer to resolve this issue.

 

Ignat Vilesov,

Software Engineer

 

Microsoft Power BI Custom Visuals

pbicvsupport@microsoft.com

v-viig
Community Champion
Community Champion

@jpf5046,

 

Could you please collect all data and issues that you have and send it to Power BI Custom Visuals Support <pbicvsupport@microsoft.com>?

We'll contact our R-developer in order to assist you.

 

Ignat Vilesov,

Software Engineer

 

Microsoft Power BI Custom Visuals

pbicvsupport@microsoft.com

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors
Top Kudoed Authors