私はES6を使用して角度jでカスタム棒グラフ指令を書き込もうとしています。私は、c3ライブラリをインストールしました。私はギャルプを実行すると、私はエラーを取得している "c3"は定義されていない - undefです。あなたが直接、それが「友好の角度」ではありませんc3はインストールした場合エラー "c3"が定義されていないno-undef
export class MyDirective {
constructor($interval) {
'ngInject';
this.template = '<div id=chart></div>';
this.restrict = 'E';
this.scope = {}
this.$interval = $interval;
}
compile(tElement) {
tElement.css('position', 'absolute');
}
link(scope, element) {
this.$interval(() => this.chart(), 1000);
}
chart() {
c3.generate({
bindto: '#chart',
data:{
columns: [
['data1', 30, 200, 100, 400, 150, 250],
['data2', 130, 100, 140, 200, 150, 50]
],
type: 'bar'
},
bar: {
width: {
ratio: 0.5 // this makes bar width 50% of length between ticks
}
// or
//width: 100 // this makes bar width 100px
}
});
}
}
です。bower installは適切なファイルをプロジェクトフォルダにのみダウンロードしますが、stiあなたのindex.htmlにスクリプトとcssファイルを含める必要があります。あなたのプロジェクト環境に応じて、これを行うgulpタスクを手助けするかもしれません... – simonberry
gulpタスクにc3.jsとそれに依存するd3.jsファイルが含まれています。 – Sai