1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93
   | import { Component, OnInit } from '@angular/core';
  import cytoscape from 'cytoscape'; import klay from 'cytoscape-klay';
  @Component({   selector: 'app-root',   templateUrl: './app.component.html',   styleUrls: ['./app.component.scss'], }) export class AppComponent implements OnInit {   
 
    constructor() {}
    
 
    ngOnInit(): void {     cytoscape.use(klay);
      const cy = cytoscape({       container: document.getElementById('cy'), 
        elements: [                  { data: { id: 'step1', name: 'step1' } },         { data: { id: 'step2', name: 'step2' } },         { data: { id: 'step3', name: 'step3' } },         { data: { id: 'step4', name: 'step4' } },                  { data: { id: '1', source: 'step1', target: 'step2' } },         { data: { id: '2', source: 'step1', target: 'step3' } },         { data: { id: '3', source: 'step2', target: 'step4' } },         { data: { id: '4', source: 'step3', target: 'step4' } },       ],
        style: [                  {           selector: 'node',           style: {             content: 'data(name)',             shape: 'rectangle',             'text-wrap': 'wrap',             'text-halign': 'center',             'text-valign': 'center',             'background-color': '#6FB1FC',             width: '40px',             height: '40px',             color: 'black',             'font-size': '10px',           },         },         {           selector: 'edge',           style: {             'curve-style': 'bezier',             'line-color': '#000000',             'target-arrow-shape': 'triangle',             'target-arrow-fill': 'filled',             'target-arrow-color': '#000000',             width: '1px',             'line-style': 'solid',             opacity: 0.666,           },         },       ],       layout: {         name: 'klay',       },     });
      const options = {       name: 'klay',       nodeDimensionsIncludeLabels: true,       klay: {         borderSpacing: 100,         fixedAlignment: 'BALANCED',         edgeRouting: 'POLYLINE',         edgeSpacingFactor: 10,         inLayerSpacingFactor: 2.0,         layoutHierarchy: true,         linearSegmentsDeflectionDampening: 3.0,         spacing: 30,         mergeEdges: false,       },     };
      cy.layout(options).run();   } }
  |