I've discovered a workaround for achieving this task. Although not the recommended Typescript approach, I managed to do it using the fallback JS method. Here is the step-by-step guide:
import
the d3 library as usual, but assign an alias to it: import * as D3 from 'd3';
(Take note: Capital D for D3)
declare
d3 once more so you can utilize it for WordCloud: declare let d3: any;
- Utilize
D3
for all tasks related to the main d3 library and d3
specifically for word cloud generation.
The typings for d3-cloud don't appear to be functioning correctly. Therefore, resorting to declare
seems to be the only viable option at the moment.
Complete Code:
word-cloud.component.ts:
Updated implementation goes here...
word-cloud.component.html:
<ng-content></ng-content>
word-cloud.component.scss:
.word-cloud {
Updated styles go here...
}