Quantcast
Channel: Developer topics
Viewing all articles
Browse latest Browse all 17890

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

$
0
0

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?


Viewing all articles
Browse latest Browse all 17890

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>