"导入“;使用webpack对d3和d3进行云计算

"import"ing d3 and d3-cloud with webpack

本文关键字:d3 云计算 webpack quot 导入 使用      更新时间:2023-10-22

所以,我一直在尝试导入d3和d3cloud(用于单词cloud)进入我的AngularJs(v-1.4)应用程序。我是这样做的——
从"d3"导入d3
从"d3-cloud"导入d3Cloud

当我尝试使用类似d3.layout.cloud()的d3-cloud时,我会得到以下错误

_d2.default.layout.cloud不是函数

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();
}