Ami*_*M S 5 javascript word-cloud d3.js angularjs ecmascript-6
所以,我一直在尝试将d3和d3-cloud(用于词云)导入到我的 AngularJs(v - 1.4) 应用程序中。我这样做是通过 -
import d3 from 'd3'
import d3Cloud from 'd3-cloud'。
当我尝试像d3.layout.cloud()一样使用 d3-cloud 时,我收到以下错误
_d2.default.layout.cloud is not a function
mQu*_*roz -1
import { Component, Input, AfterViewInit } from '@angular/core';
// import and assign libs **
import d3 from 'd3'
import * as cloud from 'd3-cloud'
@Component({
selector: 'word-cloud',
templateUrl: './word-cloud.component.html',
styleUrls: ['./word-cloud.component.scss'],
providers: []
})
export class WordCloudComponent implements AfterViewInit {
constructor() { }
ngAfterViewInit() {
d3.scale.category20();
let layout = cloud()
.size([ width , height ])
.words(data)
.rotate(function () ...)
.spiral('rectangular')
.fontSize(function () ...)
.on("end", function () ...)
.start();
}
Run Code Online (Sandbox Code Playgroud)