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
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
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.