Angular 13+ Cytoscape.js Wrapper

Overview

ngx-cytoscapejs

Documentation · Demo

This library is a wrapper for Cytoscape.js to be used from any Angular 13+ application.

  • Rendering of Cytoscape.js and CX graphs
  • Automatic rerendering on graph data changes
  • Automatic graph size adjustment on window resize

Table of contents

Dependencies

ngx-cytoscapejs depends on Angular, Cytoscape.js, lodash, cx2js and cxVizConverter.

ngx-cytoscapejs Angular Cytoscape.js lodash cx2js cxVizConverter
0.3.0 13.x.x 3.x.x 4.x.x 0.6.x 0.1.x

Installation

npm install --save ngx-cytoscapejs

Usage

Import the CytoscapejsModule and add it to your module:

import { NgModule } from '@angular/core';
import { CytoscapejsModule } from 'ngx-cytoscapejs';

@NgModule({
  declarations: [...],
  imports: [CytoscapejsModule],
  providers: [...],
  bootstrap: [...],
})
export class AppModule {}

Add the cytoscapejs directive to your component's HTML:

<cytoscapejs
  [cytoscapeOptions]="cytoscapeOptions"
  [autoFit]="autoFit"
  (coreChanged)="coreChanged($event)"
></cytoscapejs>

Configure the directive in your component:

import { Core, CytoscapeOptions } from 'cytoscape';
import { CxConverter } from 'ngx-cytoscapejs';

export class AppComponent {
  cytoscapeOptions: CytoscapeOptions = {...};

  autoFit: boolean = true;

  coreChanged(core: Core): void {
    // do something with the core
  }
}

The component will take up 100% of the parent's height and width.

API

For a graph to render you have to provide either cytoscapeOptions or cxData. The remaining inputs are optional.

Inputs

Name Type Default Description
cytoscapeOptions CytoscapeOptions Your Cytoscape graph data. You don't have to provide the container property as it will be overwritten with the component's referenced DOM element.
autoFit boolean true When set to true the graph will be fit every time the browser window is resized.
cxData any Your CX graph data. The data is converted using the the converters provided in the cxConverters input.
cxConverters CxConverter[] [cx2js, cxVizConverter] Allows customizing the converters used by the library to convert the CX data. The library tries to convert the input data in the given order and renders the first successful conversion result.

Outputs

Name Type Description
coreChanged Core Emits a Core every time a new core is created.

Enums

CxConverter

Value Description
cx2js Use cx2js for CX conversion
cxVizConverter Use cxVizConverter for CX conversion

Getting help

If you have questions, concerns, bug reports, etc., please file an issue in this repository's Issue Tracker.

Roadmap

  • Unit tests
  • Angular CLI schematics

License

MIT

Credits and references

Comments
  • Access to attributeNameMap

    Access to attributeNameMap

    Hello kind sir,

    Problem

    I am using your library when rendering CX networks. The node and edge properties can be read from the core without any problems. I am however having issues with cytoscape.js selectors, since the CX converter changes their property names (they append _u1, _u2 etc to distinguish properties I guess).

    Steps to reproduce

    The changes in network property names can be validated via this tool: https://frankkramer-lab.github.io/NDExEdit.

    • Load this sample network via UUID: 5820d988-68d5-11e7-961c-0ac135e8bacf
    • Select some nodes in the network
    • Check the table of selected nodes for the property names

    The respective section in the converter: https://github.com/cytoscape/cx2js/blob/master/src/cx_to_js.js#L418

    Favored solution

    As far as I know, the correct property names, that can be used to make selections on the core, are stored in the attributeNameMap, the CX converter uses during conversion. If you could extend the library to add another Output() containing this attributeNameMap, that would be awesome.

    Project

    • Angular 13.3.4
    • Node: 16.15.0
    • NgRx 13.1.0
    • ngx-cytoscapejs 1.0.0
    enhancement 
    opened by SherlockMones 2
  • Storing core immutably triggers endless loop

    Storing core immutably triggers endless loop

    Problem

    Loading network data from NDEx and storing the CX in my network.state.

    As soon as the library is done with rendering, I store the received Cytoscapejs core in the network.state. Since I'm working immutable, I update my state as such:

    
      on(renderNetworkSuccess, (state: NetworkState, { core }): NetworkState => ({ ...state, core }))
    
    

    The new reference re-triggers the rendering resulting in an endless loop that kills the app.

    I tried moving the core into a separate state (graph.state), which would be fine for my use case, but it still triggers the update for all states (graph.state and network.state), which leads to the same problem. (See code from graph.state below)

    
      on(renderNetworkSuccess, (state: GraphState, {core}): GraphState => ({...state, core})),
    
    

    Steps to reproduce

    • Create a simple project with NgRx
    • one state holding the network data
    • store the resulting core in the same state
    • watch your browser suffer

    Favored solution

    I would need persistent access to the core for further actions on the graph. Storing that in any of my states is mandatory for me. Maybe add an option to skip re-rendering the network with sort of a debounce time? Alternatively a separate input.

    Project

    • Angular 13.3.4
    • Node: 16.15.0
    • NgRx 13.1.0
    • ngx-cytoscapejs 1.0.0
    wontfix 
    opened by SherlockMones 1
  • Add GitHub Topics to increase visibility

    Add GitHub Topics to increase visibility

    • https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/classifying-your-repository-with-topics
    • https://github.com/topics
    documentation good first issue 
    opened by muellerdo 1
  • React to autoFit's input change

    React to autoFit's input change

    Right now, toggeling the autoFit flag will resize and reposition the graph only on window resize. It would be brilliant, if on toggeling the autoFit (input changes to true), the graph would fit once, without the need for the window resize.

    enhancement good first issue 
    opened by SherlockMones 1
  • Apply background color based on CX

    Apply background color based on CX

    Hello :)

    Problem

    The CX2JS converter generates a backgroundColor, that could be applied to the canvas you're rendering the graph in (that's not a problem per se, but would be a nice feature).

    You'll find the respective line of code here.

    Steps to reproduce

    A sample network that has a background color is 5820d988-68d5-11e7-961c-0ac135e8bacf (you can take a look at it here ). When using your library to render this network, the background stays white.

    Favored solution

    It would be great, if you could expand the @Inputs to allow users to toggle application of the background color.

    Project

    Angular 13.3.4 Node: 16.15.0 NgRx 13.1.0 ngx-cytoscapejs 1.0.0

    opened by SherlockMones 0
Owner
Remo Griesbaum
Remo Griesbaum
Sam4Sc - a migration assistant for Angular to SCAM (Single Angular Component Modules) and Standalone Components

Sam4Sc - a migration assistant for Angular to SCAM (Single Angular Component Modules) and Standalone Components

Rainer Hahnekamp 7 Nov 16, 2022
Clarity Angular is a scalable, accessible, customizable, open-source design system built for Angular.

Getting Started Clarity Angular is published as two npm packages: Contains the static styles for building HTML components. Contains the Angular compon

VMware Clarity 145 Dec 29, 2022
An example application that uses file-based routing with Angular, Analog, Vite with the Angular Router

Angular, Vite, and File-based routes This is an example application that uses Angular, Analog, and Vite for file-based routing. Routes are places in t

Brandon 9 Sep 25, 2022
Monorepo for all the tooling related to using ESLint with Angular

Angular ESLint Monorepo for all the tooling which enables ESLint to lint Angular projects

angular-eslint 1.4k Dec 29, 2022
Reactive Extensions for Angular

RxAngular offers a comprehensive toolset for handling fully reactive Angular applications with the main focus on runtime performance and template rendering.

RxAngular 1.5k Jan 5, 2023
Semantic UI Angular Integrations

Semantic-UI-Angular Semantic-UI-Angular is a pure AngularJS 1.x set of directives for Semantic-UI components. We are considering Angular 2 support in

Semantic Org 561 Dec 28, 2022
The code for a set of Angular 6+ components for the PatternFly project.

The code for a set of Angular 6+ components for the PatternFly project. Note that the release/3.x branch supports Angular 4 and 5.

PatternFly 87 Nov 15, 2022
Angular 11 & Bootstrap 5 & Material Design 2.0 UI KIT

MDB 5 Angular Angular 12 & Bootstrap 5 & Material Design 2.0 UI KIT >> Get Started in 4 steps >> MDBAngular 5 Demo 500+ material UI components Super s

MDBootstrap 1.1k Dec 30, 2022
Component infrastructure and Material Design components for Angular

Official components for Angular The Angular team builds and maintains both common UI components and tools to help you build your own custom components

Angular 23.2k Jan 3, 2023
Angular UI Component Library based on Ant Design

NG-ZORRO An enterprise-class Angular UI component library based on Ant Design. English | 简体中文 ✨ Features An enterprise-class UI design system for Angu

NG-ZORRO 8.3k Jan 6, 2023
Angular 2 building blocks :package: based on Semantic UI

Angular2 & Semantic UI Angular2 - Semantic UI Live demo ng-semantic.herokuapp.com Angular 2 Semantic UI version: 2.2.2 Installation npm install ng-sem

Vlado Tesanovic 995 Dec 23, 2022
Native Angular components & directives for Lightning Design System

ng-lightning This library contains native Angular components and directives written from scratch in TypeScript using the Lightning Design System CSS f

null 910 Dec 8, 2022
Native AngularJS (Angular) directives for Bootstrap

Native AngularJS (Angular) directives for Bootstrap. Smaller footprint (20kB gzipped), no 3rd party JS dependencies (jQuery, bootstrap JS) required. Please read the README.md file before submitting an issue!

AngularUI 14.4k Jan 3, 2023
NG Bootstrap - Angular powered Bootstrap widgets

NG Bootstrap - Angular powered Bootstrap widgets Angular widgets built from the ground up using only Bootstrap 4 CSS with APIs designed for the Angula

ng-bootstrap 8k Dec 24, 2022
🚀 Style and Component Library for Angular

ngx-ui Component & Style Library for Angular by Swimlane. Installing npm i @swimlane/ngx-ui --S Install the project's peer depencencies (moment, codem

Swimlane 654 Dec 24, 2022
Lightweight, Material Design inspired go to top button. No dependencies. Pure Angular!

Angular ScrollTop Button Lightweight, Material Design inspired button for scroll-to-top of the page. No dependencies. Pure Angular! ✓ Angular 13, Ivy

BART! 19 Dec 18, 2022
The best way to quickly integrate Bootstrap 5 Bootstrap 4 or Bootstrap 3 Components with Angular

ngx-bootstrap The best way to quickly integrate Bootstrap 5 Bootstrap 4 or Bootstrap 3 Components with Angular Links Documentation Release Notes Slack

Valor Software 5.4k Jan 8, 2023
Customizable Angular UI Library based on Eva Design System

Nebular Documentation | Stackblitz Template | UI Bakery - Angular UI Builder | Angular templates Nebular is a customizable Angular 10 UI Library with

Akveo 7.7k Dec 31, 2022
A set of UI components for use with Angular 2 and Bootstrap 4.

#Fuel-UI A set of UI components for use with Angular 2 and Bootstrap 4. See Fuel-UI homepage for live demo and documentation. ##Dependencies Node Gulp

Fuel Interactive 302 Jul 4, 2022