1.7.1 • Published 6 days ago

ngx-cytoscapejs v1.7.1

Weekly downloads
-
License
MIT
Repository
github
Last release
6 days ago

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, cx2js and cxVizConverter.

ngx-cytoscapejsAngularCytoscape.jsng-add
0.3.x13.x3.xnot supported
1.0.x13.x3.xnot supported
1.1.x13.x3.xnot supported
1.2.x13.x3.xnot supported
1.3.x13.x3.xsupported
1.4.x14.x3.xsupported
1.5.x15.x3.xsupported
1.6.x16.x3.xsupported
1.7.x17.x3.xsupported

Installation

Using the Angular CLI is recommended:

ng add ngx-cytoscapejs

Manual installation

Add dependencies from npm.

npm install --save-dev @types/cytoscape
npm install --save ngx-cytoscapejs

Then 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 {}

Usage

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

NameTypeDefaultDescription
cytoscapeOptionsCytoscapeOptionsYour Cytoscape graph data. You don't have to provide the container property as it will be overwritten with the component's referenced DOM element.
autoFitbooleantrueWhen set to true the graph will be fit every time the browser window is resized.
applyCxBackgroundColorbooleanfalseWhen set to true, the background color specified in the CX1 file will be applied to the visualization.
cxDataanyYour CX graph data. The data is converted using the the converters provided in the cxConverters input.
cxConvertersCxConverter[]cx2js, cxVizConverterAllows 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

NameTypeDescription
coreChangedCoreEmits a Core every time a new core is created.
cxAttributeNameMapChangedCxAttributeNameMapEmits a CxAttributeNameMap every time a graph is converted using cx2js.

Enums

CxConverter

ValueDescription
cx2jsUse cx2js for CX conversion
cxVizConverterUse cxVizConverter for CX conversion

Interfaces

CxConversion

ValueTypeDescription
optionsCytoscapeOptionsThe CytoscapeOptions object resulting from the conversion.
attributeNameMapCxAttributeNameMapThe attribute mapping created when converting the CX graph. This property is optional.
backgroundColorstringThe background color extracted from the CX graph. This property is optional.

CxAttributeNameMap

Properties are unknown as they depend on the converted CX graph.

Getting help

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

Roadmap

  • Unit tests

License

MIT

Credits and references

1.7.1

6 days ago

1.7.0

3 months ago

1.6.0

6 months ago

1.5.0

6 months ago

1.2.0

2 years ago

1.1.0

2 years ago

1.4.0

2 years ago

1.3.0

2 years ago

1.0.0

2 years ago

0.3.1

2 years ago

0.3.0

2 years ago