0 votes
1 view
in BI by (15.1k points)

I'm having trouble installing d3 typings. I followed Microsoft's instructions at https://github.com/Microsoft/PowerBI-visuals/blob/master/Tutorial/Typings.md as well as what Sachin Patney does in his video at 

.

Running "npm install typings -g" appears to work fine.

Running "typings install --save --global dt~d3" or "typings i dt~d3 -G" both yield this error: "typings ERR! message Attempted to compile "d3" as a global module, but it looks like an external module. You'll need to remove the global option to continue."

If I remove the global option, it adds the typings info in my visual's folder using a "modules" folder in the path instead of a "globals" folder (i.e., MyVisual|typings|modules|d3 instead of MyVisual|typings|globals|d3). Intellisense also doesn't work for d3.

Any idea why I can't install d3 typings globally?

1 Answer

0 votes
by (41.2k points)

The Power BI has released v1.2 of the Custom Visuals SDK. You need to reference d3 v3.5.5 yourself with this version. d3 v4 does not work yet.  For now, you can only use v3.5.5.

Steps for installation:

  • npm i -g typings

  • Add d3 v3.5.5:

npm i [email protected] --save

  • Add d3 typing:

typings install d3=github:DefinitelyTyped/DefinitelyTyped/d3/d3.d.ts#6e2f2280ef16ef277049d0ce8583af167d586c59 --global --save

  • Add files to tsconfig.json:

{

  "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",

    "typings/index.d.ts",

    "node_modules/d3/d3.min.js",

    "src/visual.ts"

  ]

}

Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...