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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
callum
Helper II
Helper II

How come d3 doesn't need explicitly defining but other libraries do?

I use three JS libraries in my visual; d3, lodash and one called tinycolor.

 

d3 just "works", in that I just install d3 and its relevant @types package, add it to the external_js section of pbiviz.json, and can then start using its features in my visual.

 

The other two, on the other hand, need to be explicitly defined in my visual.ts file after doing the above. I don't know if there's a more elegant method than the one here but that's the one that works for me. So I have the following in visual.ts:

 

 

let _ = (<any>window)._;
let tinycolor = (<any>window).tinycolor;

If I remove one of these lines then the TypeScript fails to compile because it "Cannot find name '_'" (and equivalent for tinycolor), yet d3 works just fine without it.

 

 

I hope I explained the situation well enough. I'm just curious what the reason behind this discrepancy is?

1 ACCEPTED SOLUTION
v-viig
Community Champion
Community Champion

Power BI applies a special workaround to define d3 and jQuery at the global context.

Other libraries are out of support at least for now. In other words, you should define other libraries manually.

 

Ignat Vilesov,

Software Engineer

 

Microsoft Power BI Custom Visuals

pbicvsupport@microsoft.com

View solution in original post

2 REPLIES 2
v-viig
Community Champion
Community Champion

Power BI applies a special workaround to define d3 and jQuery at the global context.

Other libraries are out of support at least for now. In other words, you should define other libraries manually.

 

Ignat Vilesov,

Software Engineer

 

Microsoft Power BI Custom Visuals

pbicvsupport@microsoft.com

v-chuncz-msft
Community Support
Community Support

@callum,

 

Additional type definitions (d.ts files) are installed.

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.

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.