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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
mikorym
Frequent Visitor

Is there a working example of a custom visual that uses plotly.js?

Hi all,

 

Are there any code repo's that have a working example of a Power BI custom visual that uses the plotly.js library?

 

Ideally, the code should be minimal and should call plotly.js's plot() function instead of manual construction using D3. (In any case, plotly.js is built on D3.) An example of a plotly.js chart is here [1].

 

I could find this [2] example, but it is outdated and I could not get it to work.

 

Note that I am not referring to the R plotly library (which I can get to work correctly for an R custom visual). Instead, I would like to use plotly.js in a typescript custom visual. I can get the pbiviz to compile and export the visual, but when I import it into Power BI, it displays only a blank tile. The only error message that I could manage to produce is (using pbiviz start and Power BI Service):

 

SCRIPT5009: SCRIPT5009: 'module' is not defined

 

However, I am not even sure whether this message is related to Plotly.

 

Any hints would be appreciated.

 

[1] https://plot.ly/javascript/box-plots/

[2] https://github.com/zzeekk/powerbi-plotlyscatterchart

2 REPLIES 2
v-chuncz-msft
Community Support
Community Support

@mikorym,

 

Take a look at the post below.

https://community.powerbi.com/t5/Developer/Include-vis-js-in-custom-visual-causes-error/td-p/340881

Community Support Team _ Sam Zha
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi @v-chuncz-msft,

 

Do you suggest to create a .js file in the src with the following line?

 

var plotly = window.plotly || window.window.plotly;

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.