cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
robjensen Helper I
Helper I

Cannot import multiple r-script sources in RHTML visual

I'm unable to import multiple r-script source files in RHTML visuals.  Power BI and R seem to import the first file referenced, but any subsequent source(./r_files/foo.r) calls appear to be ignored.  This behavior is not getting repeated in RStudio using the same instance of R.  Any guidance would be appreciated.

 

Steps to reproduce:

1) Create new visual using the RHTML template and create a new .r file in the r_files directory:

 

> pbiviz new sampleRHTMLVisual -t rhtml
> cd sampleRHTMLVisual
> echo $null >> .\r_files\test.r

2) Flesh out required information in pbiviz.json:

 

 

visual:description
visual:supportUrl
visual:author:name
visual:author:email

3) Insert the following code as the first line in script.r:

 

 

source('./r_files/test.r')

4) Compile and load the visual:

 

> pbiviz package

5) Observe the error message:

Can't display this visual.
R script error.
Error in libraryRequiredInstall("ggplot2"): could not find function "libraryRequireInstall"
Execution halted

PBI_error.png

 

2 ACCEPTED SOLUTIONS

Accepted Solutions
Microsoft v-evelk
Microsoft

Re: Cannot import multiple r-script sources in RHTML visual

Hello,

 

It is an issue in the template, we will fix it soon.

To fix it for you now, please, change NodeListOf by HTMLCollectionOf type. It should help.

 

Kind Regards,

 

Evgenii Elkin,
Software Engineer
Microsoft Power BI Custom Visuals
pbicvsupport@microsoft.com

View solution in original post

robjensen Helper I
Helper I

Re: Cannot import multiple r-script sources in RHTML visual

Confirmed. Changing the following seems to fix the issue:

 

./src/visual.ts

148let headList: NodeListOf = el.getElementsByTagName("head");>let headList: HTMLCollectionOf = el.getElementsByTagName("head");
160let bodyList: NodeListOf = el.getElementsByTagName("body");>let bodyList: HTMLCollectionOf = el.getElementsByTagName("body");

View solution in original post

7 REPLIES 7
Microsoft v-evelk
Microsoft

Re: Cannot import multiple r-script sources in RHTML visual

Hello,

 

It looks like you try to create new project with non-webpack version of tools and it is probably required to set this file in tsconfig.json ('files' section).

I tried to build by your instruction with the latest version of powerbi-visuals-tools and everything looks OK.

To install the latest version of tools please run in a console the following command:

npm install -g powerbi-visuals-tools@latest

Kind Regards,

Evgenii Elkin,
Software Engineer
Microsoft Power BI Custom Visuals
pbicvsupport@microsoft.com

robjensen Helper I
Helper I

Re: Cannot import multiple r-script sources in RHTML visual

Following the same set of instructions after installing the latest powerbi-visuals-tools package has two new errors during compilation.

 

Additionally, the same error occurs when simply running the following 3 steps:

 

 

> pbiviz new sampleRHTMLVisual -t rhtml
> cd .\sampleRHTMLVisual\
> pbiviz package

 

 

> pbiviz package
info Building visual...
info Start preparing plugin template
info Finish preparing plugin template
Error parsing bundle asset "C:\Users\foobar\sampleRHTMLVisual\.tmp\drop\visual.js": no such file
No bundles were parsed. Analyzer will show only original module sizes from stats file.
Webpack Bundle Analyzer saved report to C:\Users\foobar\sampleRHTMLVisual\webpack.statistics.prod.html
ERROR Failed to compile with 2 errors 3:21:44 PM
error in C:\Users\foobar\sampleRHTMLVisual\src\visual.ts
[tsl] ERROR in C:\Users\foobar\sampleRHTMLVisual\src\visual.ts(148,17) TS2741: Property 'forEach' is missing in type 'HTMLCollectionOf<HTMLHeadElement>' but required in type 'NodeListOf<HTMLHeadElement>'.
error in C:\Users\foobar\sampleRHTMLVisual\src\visual.ts
[tsl] ERROR in C:\Users\foobar\sampleRHTMLVisual\src\visual.ts(160,13) TS2741: Property 'forEach' is missing in type 'HTMLCollectionOf<HTMLBodyElement>' but required in type 'NodeListOf<HTMLBodyElement>'. error Package wasn't created. 2 errors found

 

Microsoft v-evelk
Microsoft

Re: Cannot import multiple r-script sources in RHTML visual

Is it possible to share a link to your repo that I could analyze it?

You could send it to pbicvsupport@microsoft.com 

 

Kind Regards,

 

Evgenii Elkin,
Software Engineer
Microsoft Power BI Custom Visuals
pbicvsupport@microsoft.com

Microsoft v-evelk
Microsoft

Re: Cannot import multiple r-script sources in RHTML visual

Hello,

 

It is an issue in the template, we will fix it soon.

To fix it for you now, please, change NodeListOf by HTMLCollectionOf type. It should help.

 

Kind Regards,

 

Evgenii Elkin,
Software Engineer
Microsoft Power BI Custom Visuals
pbicvsupport@microsoft.com

View solution in original post

robjensen Helper I
Helper I

Re: Cannot import multiple r-script sources in RHTML visual

Confirmed. Changing the following seems to fix the issue:

 

./src/visual.ts

148let headList: NodeListOf = el.getElementsByTagName("head");>let headList: HTMLCollectionOf = el.getElementsByTagName("head");
160let bodyList: NodeListOf = el.getElementsByTagName("body");>let bodyList: HTMLCollectionOf = el.getElementsByTagName("body");

View solution in original post

idajh
Regular Visitor

Re: Cannot import multiple r-script sources in RHTML visual

When I try to do as robjensen does here 


@robjensen wrote:

Confirmed. Changing the following seems to fix the issue:

 

./src/visual.ts

148let headList: NodeListOf = el.getElementsByTagName("head");>let headList: HTMLCollectionOf = el.getElementsByTagName("head");
160let bodyList: NodeListOf = el.getElementsByTagName("body");>let bodyList: HTMLCollectionOf = el.getElementsByTagName("body");

I get the following error:

C:\sampleRHTMLVisual>pbiviz package
info Building visual...
info Start preparing plugin template
info Finish preparing plugin template
Error parsing bundle asset "C:\sampleRHTMLVisual\.tmp\drop\visual.js": no such file

No bundles were parsed. Analyzer will show only original module sizes from stats file.

Webpack Bundle Analyzer saved report to C:\sampleRHTMLVisual\webpack.statistics.prod.html


ERROR Failed to compile with 2 errors 12:11:45 PM

error in C:\sampleRHTMLVisual\src\visual.ts

[tsl] ERROR in C:\sampleRHTMLVisual\src\visual.ts(148,27)
TS2314: Generic type 'HTMLCollectionOf<T>' requires 1 type argument(s).

error in C:\sampleRHTMLVisual\src\visual.ts

[tsl] ERROR in C:\sampleRHTMLVisual\src\visual.ts(160,23)
TS2314: Generic type 'HTMLCollectionOf<T>' requires 1 type argument(s).

 

 

Any suggestions?

 

Highlighted
robjensen Helper I
Helper I

Re: Cannot import multiple r-script sources in RHTML visual


@idajh wrote:

When I try to do as robjensen does here 


@robjensen wrote:

Confirmed. Changing the following seems to fix the issue:

 

./src/visual.ts

148let headList: NodeListOf = el.getElementsByTagName("head");>let headList: HTMLCollectionOf = el.getElementsByTagName("head");
160let bodyList: NodeListOf = el.getElementsByTagName("body");>let bodyList: HTMLCollectionOf = el.getElementsByTagName("body");

I get the following error:

C:\sampleRHTMLVisual>pbiviz package
info Building visual...
info Start preparing plugin template
info Finish preparing plugin template
Error parsing bundle asset "C:\sampleRHTMLVisual\.tmp\drop\visual.js": no such file

No bundles were parsed. Analyzer will show only original module sizes from stats file.

Webpack Bundle Analyzer saved report to C:\sampleRHTMLVisual\webpack.statistics.prod.html


ERROR Failed to compile with 2 errors 12:11:45 PM

error in C:\sampleRHTMLVisual\src\visual.ts

[tsl] ERROR in C:\sampleRHTMLVisual\src\visual.ts(148,27)
TS2314: Generic type 'HTMLCollectionOf<T>' requires 1 type argument(s).

error in C:\sampleRHTMLVisual\src\visual.ts

[tsl] ERROR in C:\sampleRHTMLVisual\src\visual.ts(160,23)
TS2314: Generic type 'HTMLCollectionOf<T>' requires 1 type argument(s).

 

 

Any suggestions?


What is your complete line of code in row 148?  The table in this webpage wrapped each line of text into two rows, but they should just be one row each in visual.ts

 

Row 148 should read:

let headList: HTMLCollectionOf<HTMLHeadElement> = el.getElementsByTagName("head");

 

Row 160 should read:

let bodyList: HTMLCollectionOf<HTMLBodyElement> = el.getElementsByTagName("body");

Helpful resources

Announcements
New Ranks Launched March 24th!

New Ranks Launched March 24th!

The time has come: We are finally able to share more details on the brand-new ranks coming to the Power BI Community!

‘Better Together’ Contest Finalists Announced!

‘Better Together’ Contest Finalists Announced!

Congrats to the finalists of our ‘Better Together’-themed T-shirt design contest! Click for the top entries.

Arun 'Triple A' Event Video, Q&A, and Slides

Arun 'Triple A' Event Video, Q&A, and Slides

Missed the Arun 'Triple A' event or want to revisit it? We've got you covered! Check out the video, Q&A, and slides now.

Join THE global Microsoft Power Platform event series.

Join THE global Power Platform event series.

Attend for two days of expert-led learning and innovation on topics like AI and Analytics, powered by Dynamic Communities.

Community Summit North America

Community Summit North America

Innovate, Collaborate, Grow. The top training and networking event across the globe for Microsoft Business Applications

Top Solution Authors