UNPKG

echarts

Version:

Apache ECharts is a powerful, interactive charting and data visualization library for browser

58 lines (57 loc) 2.1 kB
/** * @file The layout algorithm of node-link tree diagrams. Here we using Reingold-Tilford algorithm to drawing * the tree. */ import { TreeNode } from '../../data/Tree.js'; interface HierNode { defaultAncestor: TreeLayoutNode; ancestor: TreeLayoutNode; prelim: number; modifier: number; change: number; shift: number; i: number; thread: TreeLayoutNode; } export interface TreeLayoutNode extends TreeNode { parentNode: TreeLayoutNode; hierNode: HierNode; children: TreeLayoutNode[]; } /** * Initialize all computational message for following algorithm. */ export declare function init(inRoot: TreeNode): void; /** * The implementation of this function was originally copied from "d3.js" * <https://github.com/d3/d3-hierarchy/blob/4c1f038f2725d6eae2e49b61d01456400694bac4/src/tree.js> * with some modifications made for this program. * See the license statement at the head of this file. * * Computes a preliminary x coordinate for node. Before that, this function is * applied recursively to the children of node, as well as the function * apportion(). After spacing out the children by calling executeShifts(), the * node is placed to the midpoint of its outermost children. */ export declare function firstWalk(node: TreeLayoutNode, separation: SeparationFunc): void; /** * The implementation of this function was originally copied from "d3.js" * <https://github.com/d3/d3-hierarchy/blob/4c1f038f2725d6eae2e49b61d01456400694bac4/src/tree.js> * with some modifications made for this program. * See the license statement at the head of this file. * * Computes all real x-coordinates by summing up the modifiers recursively. */ export declare function secondWalk(node: TreeLayoutNode): void; export declare function separation(cb?: SeparationFunc): SeparationFunc; /** * Transform the common coordinate to radial coordinate. */ export declare function radialCoordinate(rad: number, r: number): { x: number; y: number; }; interface SeparationFunc { (node1: TreeLayoutNode, node2: TreeLayoutNode): number; } export {};