import * as i0 from '@angular/core'; import { OnChanges, ElementRef, EventEmitter, SimpleChanges } from '@angular/core'; interface IWord { value: string; weight: number; exportColor: string; } type IWordWithFontSize = T & { fontSize: number; truncatedValue: string; }; type IWordWithPosition = T & IWordWithFontSize & { canvasX: number; canvasY: number; x: number; y: number; width: number; height: number; }; interface IWordCloudConfig { debugMode: boolean; fontFamily: string; fontWeight: string; minFontSize: number; maxFontSize: number; paddingX: number; paddingY: number; maxCharCount: number; resizeTolerance: number; } declare class WordCloudComponent implements OnChanges { private _elRef; private _renderer; private _cdRef; private _document; elRef: ElementRef; words: T[]; options: Partial; wordsPositioned: EventEmitter[]>; private _truncatedWordsWithFontSize; private _positionedWords; private _canvas; private _ctx; private _centerPoint; /** * Controls how many points are generated on the spiral. Should be kept between 0 and 1. Lower values generate more * points on the spiral but it can take a lot longer to position the words. If updating this value to <= 0.3, consider * all the places where this is used and for each one the amount of words in the cloud. It could also be a good idea to * make this value configurable by allowing it to be specified in the `options` input */ private _spiralResolution; config: IWordCloudConfig; ngOnChanges(changes: SimpleChanges): void; /** * Exports the canvas to a PNG image and returns the base64-encoded PNG data * * @returns A string containing the base64-encoded PNG data of the canvas */ exportCanvas(): string; downloadCanvas(filename: string): void; onResize(): void; private _init; /** * Calculates the font size for each word based on its weight and the range of weights in the list of words * * @param words List of words with their respective weights * @returns A new list of words sorted by weight (largest to smallest) with their respective font sizes */ private _getTruncatedWordsWithFontSize; private _drawCanvas; /** * This method is responsible for positioning the words onto a canvas by iterating through each word, finding a suitable location for * it using a spiral algorithm, and checking if the word's bounding box intersects with any existing bounding boxes */ private _positionWords; private _truncateWord; private _drawWord; private _setFontDetails; private _isIntersecting; /** * Calculate the font size for a given word weight based on the minimum and maximum weights and the minimum and maximum font sizes * defined in the word cloud configuration object */ private _getFontSize; /** * @description This method is used to place a point on a spiral based on the input n. It calculates the coordinates of the * point on the spiral using the spiral helper function and returns an object of type IPoint. The spiral is defined using a combination * of trigonometric functions and aspects such as factor, aspectRatio, and angle. * * @returns An object of type `IPoint` with `x` and `y` properties */ private _placeOnSpiral; private _isOutsideCanvas; /** * Retrieve the word cloud configuration object by merging default values with any options passed to this component instance */ private _getConfig; private _drawSprial; /** * Determine the amount of overflow for the words that have been placed outside the canvas, calculate the scaling factor for repositioning these * words back inside the canvas, and update and return the placed words with the scaling factor applied */ private _scalePositionedWords; private _isFontLoaded; static ɵfac: i0.ɵɵFactoryDeclaration, never>; static ɵcmp: i0.ɵɵComponentDeclaration, "nw-word-cloud", never, { "words": { "alias": "words"; "required": false; }; "options": { "alias": "options"; "required": false; }; }, { "wordsPositioned": "wordsPositioned"; }, never, ["*"], true, never>; } declare class WordComponent implements OnChanges { word: IWordWithPosition; translate: string; fontSize: number; lineHeight: number; width: number; ngOnChanges(changes: SimpleChanges): void; static ɵfac: i0.ɵɵFactoryDeclaration, never>; static ɵcmp: i0.ɵɵComponentDeclaration, "nw-word", never, { "word": { "alias": "word"; "required": false; }; }, {}, never, never, true, never>; } /** * Export cooperating directives * https://v17.angular.io/guide/standalone-components#standalone-components-for-library-authors */ declare const WORD_CLOUD_COMPONENTS: readonly [typeof WordCloudComponent, typeof WordComponent]; export { WORD_CLOUD_COMPONENTS, WordCloudComponent, WordComponent }; export type { IWord, IWordCloudConfig, IWordWithPosition };