Forum Discussion
R Custom Visual - Setting colours for each value in a field/column
Hi Anonymous,
I've set up a visual project with your files and sample data, and everything seems to be running okay.
The challenge now is having unpacked how the R visuals work vs. TypeScript, the approach used for these visuals doesn't seem to work in the same way as for R (to my knowledge).
Usually, you have full access to the dataRoles in the dataView when the visual renders, and you use this information to build your list for the properties pane, using enumerateObjectInstances to push them in. When using R, the whole result of the execution is provided as the scriptResult, e.g.:
The above dataView is from the developer visual for the R project. For TypeScript visuals, you'd get data in the metadata object and whichever dataViewMapping you were using, e.g. table.
I've decoded the payloadBase64 and this is essentially the JavaScript and HTML to render the visual, post-processing with R. What this looks like is we can add simple properties to the pane but any data-bound ones come with a separate challenge; there doesn't seem to be suitable hook in a similar place to the TypeScript workflow and I was hoping that there might be, so I apologise if I got your hopes up.
I'll yield the floor to someone else, but it might be better to get in touch with the custom visuals team directly to see if they can definitively comfirm your question - you can email them at [email protected]
I'd be keen to hear if anyone else can solve this, or if the team have any advice on how it can be managed in the R visuals.
Regards,
Daniel
Hi again Daniel,
Thanks very much for having a look at it - I appreciate the time you spent trying to get it working. It looks like I'm not going mad after all and can't set colours the way I wanted to be able to (unless the visuals team has some insight on how to do it). I may just end up doing something simple like passing in a colour theme based on some enumerated values (which is a bit too much like hard-coding for my taste).
I'll post any information I can gather here in case someone else runs into the same issue.
Thanks again.
Frank
- Anonymous7 years agoNot applicable
There doesn't appear to be a way to pass dynamic/data driven properties through to R according to the PBI visuals team. Their recommendation was to implement the visual in TypeScript.