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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
benadriaensen
New Member

linking (or packaging) huge GEOJSON file in a R Html Custom Visual

I have been testing with R and geographical data and would like to incorporate the technology in a custom visual. For my requirements, I link to an online geojson file that contains the cantonal boundaries of Switzerland.

Locally, the custom visual works, but as soon as i publish to the service, the URL of the JSON file cannot be found. I have read the docs and understand that the native PBI R visual runs in a sandbox mode that does not allow internet links, but it is unclear whether this also accounts or the custom visual. My questions are the following:

 

-could I possibly open a port with the pbiviz SDK code?

-could I access the geojson file with JS and then refer to it with the r script?

-could I package the raw file in the power bi visual?

 

Looking forward to your inputs

1 ACCEPTED SOLUTION
dm-p
Super User
Super User

Hi @benadriaensen,

You can load files over HTTP(S), provided that the destination endpoint has no CORS restrictions and allows all origins to request access (i.e. Access-Control-Allow-Origin: *), as custom visuals are sandboxed iframes with no domain.
Accessing via JS might be possible with R visuals. It can be done in TypeScript visuals by adding/setting resolveJsonModule: true in tsconfig.json and importing the file as if it were a module. This ensures that the JSON is packaged with the visual and can be referenced through code. However, as R visuals are wrapped with just enough TypeScript to bootsrap them, I'm not sure if this will work (and I don't know R well enough to help here).

If R permits it, another option is to encode the JSON as base64 and load it 'over HTTP' using a data URL within your request. This will effectively be the same as packaging the JSON inside the visual and is the way we sometimes need to handle assets in certified visuals if they cannot be compiled through TypeScript.

Hopefully some of this may help. Good luck!

Daniel





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!


My course: Introduction to Developing Power BI Visuals


On how to ask a technical question, if you really want an answer (courtesy of SQLBI)




View solution in original post

3 REPLIES 3
ysk
Frequent Visitor

Hi @benadriaensen ,

 

I am trying to achieve a similar kind of thing with a custom R visual and a geojson file. Can you kindly share what approach worked for you?

Thank you.

 

Best Regards,

Yusra

dm-p
Super User
Super User

Hi @benadriaensen,

You can load files over HTTP(S), provided that the destination endpoint has no CORS restrictions and allows all origins to request access (i.e. Access-Control-Allow-Origin: *), as custom visuals are sandboxed iframes with no domain.
Accessing via JS might be possible with R visuals. It can be done in TypeScript visuals by adding/setting resolveJsonModule: true in tsconfig.json and importing the file as if it were a module. This ensures that the JSON is packaged with the visual and can be referenced through code. However, as R visuals are wrapped with just enough TypeScript to bootsrap them, I'm not sure if this will work (and I don't know R well enough to help here).

If R permits it, another option is to encode the JSON as base64 and load it 'over HTTP' using a data URL within your request. This will effectively be the same as packaging the JSON inside the visual and is the way we sometimes need to handle assets in certified visuals if they cannot be compiled through TypeScript.

Hopefully some of this may help. Good luck!

Daniel





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!


My course: Introduction to Developing Power BI Visuals


On how to ask a technical question, if you really want an answer (courtesy of SQLBI)




lbendlin
Super User
Super User

Does it have to be an R visual?  Would Azure Maps or Shape Maps visuals work too?

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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