52f199f0ef11ab306a8d3fca98ffa3dd6ccbfd7469e2422d92200a108f9703aa1519f0b28cd3ae5dc7f75f386bd936ea18bf701514852acd2be23b0217a7fa 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /**
  2. * @file The layout algorithm of node-link tree diagrams. Here we using Reingold-Tilford algorithm to drawing
  3. * the tree.
  4. */
  5. import * as layout from '../../util/layout.js';
  6. import { TreeNode } from '../../data/Tree.js';
  7. import TreeSeriesModel from './TreeSeries.js';
  8. import ExtensionAPI from '../../core/ExtensionAPI.js';
  9. interface HierNode {
  10. defaultAncestor: TreeLayoutNode;
  11. ancestor: TreeLayoutNode;
  12. prelim: number;
  13. modifier: number;
  14. change: number;
  15. shift: number;
  16. i: number;
  17. thread: TreeLayoutNode;
  18. }
  19. export interface TreeLayoutNode extends TreeNode {
  20. parentNode: TreeLayoutNode;
  21. hierNode: HierNode;
  22. children: TreeLayoutNode[];
  23. }
  24. /**
  25. * Initialize all computational message for following algorithm.
  26. */
  27. export declare function init(inRoot: TreeNode): void;
  28. /**
  29. * The implementation of this function was originally copied from "d3.js"
  30. * <https://github.com/d3/d3-hierarchy/blob/4c1f038f2725d6eae2e49b61d01456400694bac4/src/tree.js>
  31. * with some modifications made for this program.
  32. * See the license statement at the head of this file.
  33. *
  34. * Computes a preliminary x coordinate for node. Before that, this function is
  35. * applied recursively to the children of node, as well as the function
  36. * apportion(). After spacing out the children by calling executeShifts(), the
  37. * node is placed to the midpoint of its outermost children.
  38. */
  39. export declare function firstWalk(node: TreeLayoutNode, separation: SeparationFunc): void;
  40. /**
  41. * The implementation of this function was originally copied from "d3.js"
  42. * <https://github.com/d3/d3-hierarchy/blob/4c1f038f2725d6eae2e49b61d01456400694bac4/src/tree.js>
  43. * with some modifications made for this program.
  44. * See the license statement at the head of this file.
  45. *
  46. * Computes all real x-coordinates by summing up the modifiers recursively.
  47. */
  48. export declare function secondWalk(node: TreeLayoutNode): void;
  49. export declare function separation(cb?: SeparationFunc): SeparationFunc;
  50. /**
  51. * Transform the common coordinate to radial coordinate.
  52. */
  53. export declare function radialCoordinate(rad: number, r: number): {
  54. x: number;
  55. y: number;
  56. };
  57. /**
  58. * Get the layout position of the whole view.
  59. */
  60. export declare function getViewRect(seriesModel: TreeSeriesModel, api: ExtensionAPI): layout.LayoutRect;
  61. interface SeparationFunc {
  62. (node1: TreeLayoutNode, node2: TreeLayoutNode): number;
  63. }
  64. export {};