dm-p / powerbi-visuals-html-content

Visualise column or measure values as HTML in your Power BI reports. Intended as a spiritual successor to the OG HTML Viewer custom visual, with some extra stuff thrown in.
MIT License
82 stars 19 forks source link

Support for pyodide [ENHANCEMENT] #90

Open franktoffel opened 11 months ago

franktoffel commented 11 months ago

Pyodide is the leading package to bring Python to web-browser without the need of a backend.

https://pyodide.org/en/stable/index.html

I wasn't able to complete the minimum examples in PowerBI html_python_js.xlsx

I wonder if this will be possible (not sure if JavaScript libraries can be imported).

dm-p commented 11 months ago

We don't support importing of external JavaScript, for two main reasons:

  1. The custom visual sandbox makes this inconsistent due to some CDNs needing to allow access from any domain (as custom visuals have the origin removed and this often results in CORS errors). This is further documented lower down on the page linked above.
  2. There's no real capability for debugging JS within the visual. Power BI doesn't offer a console, and it suppresses some JS operations, like alert(), and it would be tremendous amount of effort to implement IDE/console-like functionality to help creators debug anything they try.

It looks like Pyodide uses WebAssembly, so if it could even be loaded to the visual, there may be further issues here with the sandboxing that may prevent it from running (although this is untested; I haven't come across any custom visuals that successfully use WebAssembly so there would likely be significant R&D here to explore whether this is even possible).

Typically, anything that relies heavily on a specific JS package (or a number of them) would be better done as a proper custom visual, as you would get much more control over the dataset, DOM and the workflow than a generic visual such as this one might do.