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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
AF
New Member

Adding a static js script to a custom visualization

Hi,

 

I have followed the instructions on this page: https://github.com/Microsoft/PowerBI-visuals/blob/master/Tutorial/ExternalLibraries.md, i.e.:

 

* Created a folder external in the viz. folder (same level as e.g. src and style).

* Copied my wanted library to this new folder (./external/d3.v4.min.js).

* Added the corresponding line to tsconfig.json, resulting in

{
  "compilerOptions": {
    "allowJs": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "target": "ES5",
    "sourceMap": true,
    "out": "./.tmp/build/visual.js"
  },
  "files": [
    ".api/v1.3.0/PowerBI-visuals.d.ts",
    "src/visual.ts",
    "external/d3.v4.min.js"
  ]
}

However, I still get the compilation error "Cannot find name `d3`".

 

I don't want to use npm or typings (and as I understand from  https://github.com/Microsoft/PowerBI-visuals/blob/master/Tutorial/ExternalLibraries.md that should not be necessary for loading external libraries).

 

What am I missing? Do I have to load it explicitly in src/visual.ts in some way?

 

Thanks!

 

1 ACCEPTED SOLUTION
v-chuncz-msft
Community Support
Community Support

@AF,

 

Based on my test, you could add a let statement as shown below.

let d3 = (<any>window).d3;
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.

View solution in original post

5 REPLIES 5
Anonymous
Not applicable

I want to call the nivo react chart library in the powerbi react visual. I also have seen the documentation. there, they said, you can't call the external js file in the powerbi api 3.0. or above. Any of the way to use react chart library with the latest powerbi library. Thanks

v-chuncz-msft
Community Support
Community Support

@AF,

 

Based on my test, you could add a let statement as shown below.

let d3 = (<any>window).d3;
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.

Thanks, that worked perfectly!

Update (12.27.2017) you now declare external libraries in "externalJS" section of pbiviz.json

Yeah, that's correct.

JavaScript code must be included into externalJS property of pbiviz.json.

 

Ignat Vilesov,

Software Engineer

 

Microsoft Power BI Custom Visuals

[email protected]

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Fabric Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.