2017-07-26 7 views
0

私はカスタムガントライブラリを持っています。これはd3に基づいています。それは通常のjavascriptで書かれています。今度はそれを私のAngular 2 Appに追加したいと思います。私はそれがあるため、輸出や定義ファイルの誤った使用法のだと思います角2の定義ファイル

__WEBPACK_IMPORTED_MODULE_4_d3__.gantt is not a function 

:私は出回っNPM経由D3をインストールし、node_modulesにタイプのファイルだけでなく、ガントチャートを追加しましたが、私は、次のエラーメッセージが表示されます。しかし、私はそれをどのように解決するか分かりません。

node_modules/D3/index.js:

export {version} from "./build/package"; 
export * from "d3-array"; 
. 
. 
. 
export * from "d3-gantt"; 

node_modules/D3-ガント/ index.js:

export default gantt; 

function gantt() 
{ 
    // a lot of code 
    return gantt 
} 

node_modules/@types/d3/index.d.ts:

export as namespace d3; 
export * from 'd3-array'; 
. 
. 
. 
export * from 'd3-gantt'; 

node_modules/@types/d3-gantt/index.d.ts:

export function gantt(): any; 

のsrc /アプリ/ AppComponent.ts

buildGantt(){ 
... 
import * as d3 from 'd3' 
d3.gantt().taskTypes(taskNames).taskStatus(taskStatus).selector('#d3Chart') //here i get the error 
... 
} 
+0

は、私は同様の問題は、あなたはそれを解決したのか? – David

+0

@David私が思い出したように私のソリューションを投稿します – Florian

答えて

0
  • はindex.dを追加する通常のコード以外にあり
  • にappディレクトリに
  • 場所あなたのD3-ガントフォルダをjavascriptのフォルダを追加します行と.TS:あなたのapp.components.tsでexport function gantt(): any;
  • import { gantt } from "./javascript/d3-gantt";
  • セットを追加

tsconfig.jsonでは私のために、このように働いた

関連する問題