graph.component.d.ts 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. import { AfterContentChecked, ChangeDetectorRef, ElementRef, EventEmitter, OnChanges, OnDestroy, OnInit, QueryList, SimpleChanges, TemplateRef } from '@angular/core';
  2. import { ReplaySubject } from 'rxjs';
  3. import { NzNoAnimationDirective } from 'ng-zorro-antd/core/no-animation';
  4. import { NzSafeAny } from 'ng-zorro-antd/core/types';
  5. import { NzGraphData } from './data-source/graph-data-source';
  6. import { NzGraph } from './graph';
  7. import { NzGraphNodeComponent } from './graph-node.component';
  8. import { NzGraphZoomDirective } from './graph-zoom.directive';
  9. import { NzGraphDataDef, NzGraphEdge, NzGraphEdgeDef, NzGraphGroupNode, NzGraphLayoutConfig, NzGraphNode, NzGraphNodeDef, NzGraphOption, NzRankDirection } from './interface';
  10. import * as i0 from "@angular/core";
  11. /** Checks whether an object is a data source. */
  12. export declare function isDataSource(value: NzSafeAny): value is NzGraphData;
  13. export declare class NzGraphComponent implements OnInit, OnChanges, AfterContentChecked, OnDestroy, NzGraph {
  14. private cdr;
  15. private elementRef;
  16. listOfNodeElement: QueryList<ElementRef>;
  17. listOfNodeComponent: QueryList<NzGraphNodeComponent>;
  18. nodeTemplate?: TemplateRef<{
  19. $implicit: NzGraphNode;
  20. }>;
  21. groupNodeTemplate?: TemplateRef<{
  22. $implicit: NzGraphGroupNode;
  23. }>;
  24. customGraphEdgeTemplate?: TemplateRef<{
  25. $implicit: NzGraphEdge;
  26. }>;
  27. /**
  28. * Provides a stream containing the latest data array to render.
  29. * Data source can be an observable of NzGraphData, or a NzGraphData to render.
  30. */
  31. nzGraphData: NzGraphData;
  32. nzRankDirection: NzRankDirection;
  33. nzGraphLayoutConfig?: NzGraphLayoutConfig;
  34. nzAutoSize: boolean;
  35. readonly nzGraphInitialized: EventEmitter<NzGraphComponent>;
  36. readonly nzGraphRendered: EventEmitter<NzGraphComponent>;
  37. readonly nzNodeClick: EventEmitter<NzGraphGroupNode | NzGraphNode>;
  38. requestId: number;
  39. transformStyle: string;
  40. graphRenderedSubject$: ReplaySubject<void>;
  41. renderInfo: NzGraphGroupNode;
  42. mapOfNodeAttr: Record<string, NzGraphNodeDef>;
  43. mapOfEdgeAttr: Record<string, NzGraphEdgeDef>;
  44. zoom: number;
  45. readonly typedNodes: (item: unknown) => (NzGraphGroupNode | NzGraphNode)[];
  46. private dataSource?;
  47. private layoutSetting;
  48. /** Data subscription */
  49. private _dataSubscription?;
  50. private destroy$;
  51. edgeTrackByFun: (edge: NzGraphEdge) => string;
  52. subGraphTransform: (node: NzGraphGroupNode) => string;
  53. $asNzGraphEdges: (data: unknown) => NzGraphEdge[];
  54. coreTransform: (node: NzGraphGroupNode) => string;
  55. noAnimation: NzNoAnimationDirective | null;
  56. nzGraphZoom: NzGraphZoomDirective | null;
  57. constructor(cdr: ChangeDetectorRef, elementRef: ElementRef);
  58. ngOnInit(): void;
  59. ngOnChanges(changes: SimpleChanges): void;
  60. ngAfterContentChecked(): void;
  61. ngOnDestroy(): void;
  62. /**
  63. * Move graph to center and scale automatically
  64. */
  65. fitCenter(): void;
  66. /**
  67. * re-Draw graph
  68. *
  69. * @param data
  70. * @param options
  71. * @param needResize
  72. */
  73. drawGraph(data: NzGraphDataDef, options: NzGraphOption, needResize?: boolean): Promise<void>;
  74. /**
  75. * Redraw all nodes
  76. *
  77. * @param animate
  78. */
  79. drawNodes(animate?: boolean): Promise<void>;
  80. private resizeNodeSize;
  81. /**
  82. * Switch to the provided data source by resetting the data and unsubscribing from the current
  83. * render change subscription if one exists. If the data source is null, interpret this by
  84. * clearing the node outlet. Otherwise start listening for new data.
  85. */
  86. private _switchDataSource;
  87. /** Set up a subscription for the data provided by the data source. */
  88. private observeRenderChanges;
  89. /**
  90. * Get renderInfo and prepare some data
  91. *
  92. * @param data
  93. * @param options
  94. * @private
  95. */
  96. private buildGraphInfo;
  97. /**
  98. * Play with animation
  99. *
  100. * @private
  101. */
  102. private makeNodesAnimation;
  103. private parseInfo;
  104. /**
  105. * Merge config with user inputs
  106. *
  107. * @param config
  108. * @private
  109. */
  110. private mergeConfig;
  111. static ɵfac: i0.ɵɵFactoryDeclaration<NzGraphComponent, never>;
  112. static ɵcmp: i0.ɵɵComponentDeclaration<NzGraphComponent, "nz-graph", ["nzGraph"], { "nzGraphData": { "alias": "nzGraphData"; "required": false; }; "nzRankDirection": { "alias": "nzRankDirection"; "required": false; }; "nzGraphLayoutConfig": { "alias": "nzGraphLayoutConfig"; "required": false; }; "nzAutoSize": { "alias": "nzAutoSize"; "required": false; }; }, { "nzGraphInitialized": "nzGraphInitialized"; "nzGraphRendered": "nzGraphRendered"; "nzNodeClick": "nzNodeClick"; }, ["nodeTemplate", "groupNodeTemplate", "customGraphEdgeTemplate"], ["*"], true, never>;
  113. static ngAcceptInputType_nzAutoSize: unknown;
  114. }