npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ngx-cytoscapejs

v1.7.1

Published

Cytoscape.js Angular Wrapper

Downloads

478

Readme

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-cytoscapejs | Angular | Cytoscape.js | ng-add | | --------------- | ------- | ------------ | ------------- | | 0.3.x | 13.x | 3.x | not supported | | 1.0.x | 13.x | 3.x | not supported | | 1.1.x | 13.x | 3.x | not supported | | 1.2.x | 13.x | 3.x | not supported | | 1.3.x | 13.x | 3.x | supported | | 1.4.x | 14.x | 3.x | supported | | 1.5.x | 15.x | 3.x | supported | | 1.6.x | 16.x | 3.x | supported | | 1.7.x | 17.x | 3.x | supported |

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

| 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. |

Outputs

| 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. |

Enums

CxConverter

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

Interfaces

CxConversion

| 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. |

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