/** * cytoscape-overlays * https://github.com/sgratzl/cytoscape.js-overlays * * Copyright (c) 2020-2022 Samuel Gratzl */ import cy from 'cytoscape'; import { ICanvasLayerOptions, INodeCanvasLayerOption, ICanvasLayer } from 'cytoscape-layers'; import { BoxplotStatsOptions, IBoxPlot } from '@sgratzl/boxplots'; import { SymbolType } from 'd3-shape'; type OverlayPosition = 'top' | 'bottom' | 'right' | 'left' | 'right' | 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right'; interface IDimension { position: OverlayPosition; width: number; height: number; } interface IVisualization { init?: (nodes: cy.NodeCollection) => void; (ctx: CanvasRenderingContext2D, node: cy.NodeSingular, dim: IDimension): void; defaultWidth?: number; defaultHeight?: number; defaultPosition?: OverlayPosition; } declare type IAttrAccessor = string | ((v: cy.NodeSingular) => T | null); declare type IScale = [number, number] | ((v: number) => number); declare type INodeFunction = T | ((v: cy.NodeSingular) => T); interface IBarOptions { /** * the domain scale to use to map to the 0...1 scale * in the array version a value of NaN indicate to automatically derive it from the data * @default [0, NaN] */ scale: IScale; /** * background color of the bar * @default '#cccccc' */ backgroundColor: INodeFunction; /** * border color to frame the bar * @default '#a0a0a0' */ borderColor: INodeFunction; } /** * renders a horizontal or vertical bar * @param attr the accessor to the value of the node * @param options additional customization options */ declare function renderBar(attr: IAttrAccessor, options?: Partial): IVisualization; interface IBoxplotOptions extends BoxplotStatsOptions, IBarOptions { /** * pixel radius when rendering outliers * @default 2 */ outlierRadius: number; /** * color for rendering outliers */ outlierBackgroundColor: INodeFunction; /** * pixel radius when rendering items * @default 0 */ itemRadius: number; /** * color for rendering items */ itemBackgroundColor: INodeFunction; /** * padding for a smaller boxplot box * @default 1 */ boxPadding: number; } declare function renderBoxplot(attr: IAttrAccessor, options?: Partial): IVisualization; interface IHist { bins: readonly number[]; } interface IHistogramOptions { scale: [number, number]; maxBin: number; backgroundColor: INodeFunction; borderColor: INodeFunction; barPadding: number; } declare function renderHistogram(attr: IAttrAccessor, options?: Partial): IVisualization; interface ISparkLineOptions { scale: IScale; backgroundColor: INodeFunction; lineColor: INodeFunction; borderColor: INodeFunction; padding: number; } declare function renderSparkLine(attr: IAttrAccessor, options?: Partial): IVisualization; interface IBinarySparkLineOptions { scale: IScale; centerValue: number; aboveBackgroundColor: INodeFunction; belowBackgroundColor: INodeFunction; aboveLineColor: INodeFunction; belowLineColor: INodeFunction; centerValueColor: INodeFunction; borderColor: INodeFunction; padding: number; } declare function renderBinarySparkLine(attr: IAttrAccessor, options?: Partial): IVisualization; declare const symbols: { circle: SymbolType; cross: SymbolType; diamond: SymbolType; square: SymbolType; star: SymbolType; triangle: SymbolType; wye: SymbolType; }; interface ITextSymbol { text: string; font?: string; } interface ISymbolOptions { symbol: INodeFunction; color: INodeFunction; } declare function renderSymbol(options?: Partial): IVisualization; interface IOverlayVisualization { position?: OverlayPosition; width?: number; height?: number; vis: IVisualization; } interface IOverlayPluginOptions extends ICanvasLayerOptions, INodeCanvasLayerOption { layer: ICanvasLayer; backgroundColor: string; padding: number; } declare function overlays(this: cy.Core, definitions: readonly (IOverlayVisualization | IVisualization)[], options?: Partial): { remove(): void; }; declare function register(cytoscape: (type: 'core' | 'collection' | 'layout', name: string, extension: any) => void): void; declare namespace cytoscape { type Ext2 = (cytoscape: (type: 'core' | 'collection' | 'layout', name: string, extension: any) => void) => void; function use(module: Ext2): void; interface Core { overlays: typeof overlays; } } export { cytoscape, register as default, overlays, renderBar, renderBinarySparkLine, renderBoxplot, renderHistogram, renderSparkLine, renderSymbol }; export type { IAttrAccessor, IBarOptions, IBinarySparkLineOptions, IBoxplotOptions, IDimension, IHist, IHistogramOptions, INodeFunction, IOverlayPluginOptions, IOverlayVisualization, IScale, ISparkLineOptions, ISymbolOptions, ITextSymbol, IVisualization, OverlayPosition }; //# sourceMappingURL=index.d.ts.map