This library is a wrapper for Cytoscape.js to be used from any Angular 13+ application.
ngx-cytoscapejs depends on Angular, Cytoscape.js, cx2js and cxVizConverter.
ngx-cytoscapejs | Angular | Cytoscape.js | ng-add |
---|---|---|---|
0.3.x | 13.x | 3.x | :x: |
1.0.x | 13.x | 3.x | :x: |
1.1.x | 13.x | 3.x | :x: |
1.2.x | 13.x | 3.x | :x: |
1.3.x | 13.x | 3.x | :heavy_check_mark: |
1.4.x | 14.x | 3.x | :heavy_check_mark: |
1.5.x | 15.x | 3.x | :heavy_check_mark: |
1.6.x | 16.x | 3.x | :heavy_check_mark: |
1.7.x | 17.x | 3.x | :heavy_check_mark: |
1.8.x | 18.x | 3.x | :x: |
Add dependencies from npm:
npm install --save ngx-cytoscapejs
Then import the CytoscapejsComponent into your component:
import { CytoscapejsComponent } from 'ngx-cytoscapejs';
@Component({
selector: 'app-root',
standalone: true,
imports: [CytoscapejsComponent],
templateUrl: './app.component.html',
styleUrl: './app.component.scss',
})
export class AppComponent {}
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.
For a graph to render you have to provide either cytoscapeOptions
or cxData
. The remaining inputs are optional.
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. |
applyCxBackgroundColor |
boolean | false | When set to true, the background color specified in the CX1 file will be applied to the visualization. |
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. |
Name | Type | Description |
---|---|---|
coreChanged |
Core | Emits a Core every time a new core is created. |
cxAttributeNameMapChanged |
CxAttributeNameMap | Emits a CxAttributeNameMap every time a graph is converted using cx2js. |
Value | Description |
---|---|
cx2js | Use cx2js for CX conversion |
cxVizConverter | Use cxVizConverter for CX conversion |
Value | Type | Description |
---|---|---|
options | CytoscapeOptions | The CytoscapeOptions object resulting from the conversion. |
attributeNameMap | CxAttributeNameMap | The attribute mapping created when converting the CX graph. This property is optional. |
backgroundColor | string | The background color extracted from the CX graph. This property is optional. |
Properties are unknown as they depend on the converted CX graph.
If you have questions, concerns, bug reports, etc., please file an issue in this repository's Issue Tracker.