Typings for d3-cloud

前端 未结 2 1658
有刺的猬
有刺的猬 2021-01-13 04:06

I want to use d3-cloud to generate a word cloud in my Angular2 app. However, I\'m not able to find the right typings to install. I tried this but when I tried to import it i

2条回答
  •  鱼传尺愫
    2021-01-13 04:59

    I worked it out by following below steps -

    1. Import d3-cloud npm package --> npm i d3-cloud
    2. Import typings of d3-cloud --> npm i @types/d3-cloud --save-dev
    3. Now below in the sample component.ts imports and code -

    import * as d3 from "d3";
    import * as d3Cloud from "d3-cloud";
    
    wordCloud(): void {
        let svg: any = d3.select("svg")
            .attr("width", 850)
            .attr("height", 350);
        d3Cloud().size([800, 300])
            .words(wordList)
    }
    

提交回复
热议问题