UNPKG

@antv/g2plot

Version:

G2 Plot, a market of plots built with the Grammar of Graphics'

76 lines (75 loc) 2.35 kB
/** * Create By Bruce Too * On 2019-12-25 */ import { LayerConfig } from '../..'; import Layer from '../../base/layer'; export declare type CloudShape = 'circle' | 'square' | 'cardioid' | 'diamond' | 'triangle' | 'triangle-forward' | 'triangle-backward' | 'triangle-up' | 'triangle-down' | 'pentagon' | 'star'; export declare type Dimension = { x: number; y: number; w: number; h: number; }; export declare type WordCloudData = { word: string; weight: number; id: number; color?: string; }; /** * Inner start function, refresh canvas immediately(no any delay draw all 'cloud' * nearly at same time) with specific id */ export declare type InnerStartFunction = (selected: number) => void; export declare type Active = { shadowColor?: string; shadowBlur?: number; }; export declare type WordStyle = { fontFamily?: string; fontWeight?: string | ((word: string, weight: number) => string); color?: string | ((word: string, weight: number) => string); active?: Active; rotation?: [number, number]; rotationSteps?: number; rotateRatio?: number; fontSize?: [number, number]; gridSize?: number; drawOutOfBound?: boolean; }; export interface WordCloudViewConfig { data: Array<WordCloudData> | Function; maskImage?: string; backgroundColor?: string; wordStyle?: WordStyle; shuffle?: boolean; selected?: number; tooltip?: { visible: boolean; }; shape?: CloudShape | Function; onWordCloudHover?: (item: WordCloudData, dimension: Dimension, evt: MouseEvent, start: InnerStartFunction) => {}; onWordCloudClick?: (item: WordCloudData, dimension: Dimension, evt: MouseEvent) => {}; } interface WordCloudLayerConfig extends WordCloudViewConfig, LayerConfig { } export default class WordCloudLayer extends Layer<WordCloudLayerConfig> { private _targetCanvas; private _toolTips; private readonly _configHoverAction; private readonly _enableToolTips; constructor(props: WordCloudLayerConfig); init(): void; render(): void; private _toolTipsAction; private _initToolTips; private _render; private _handleMaskImage; private _start; private _handleG2PlotConfig; private _startWithMaskImage; private _scaleMaskImageCanvas; private _transformWhite2BlackPixels; } export {};