# cosmos-over-every-tool

> This is a Simple project created and maintained with the **just for fun** philosophy

Latest version **1.0.6** (published 2022-11-15) · CC-BY-NC-4.0 license · 0 weekly downloads

## Install

```sh
npm install cosmos-over-every-tool
pnpm add cosmos-over-every-tool
yarn add cosmos-over-every-tool
bun add cosmos-over-every-tool
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.6 |
| Published | 2022-11-15 |
| First published | 2022-10-11 |
| Weekly downloads | 0 |
| License | CC-BY-NC-4.0 |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 758.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | simCecca |
| Maintainers | simcecca |
| Keywords | graph, webgl, force, simulation, visualization |

## Links

- npm: https://www.npmjs.com/package/cosmos-over-every-tool
- Repository: https://github.com/simCecca/cosmos-over-every-tool
- Homepage: https://github.com/simCecca/cosmos-over-every-tool#readme
- Issues: https://github.com/simCecca/cosmos-over-every-tool/issues
- npm.io page: https://npm.io/package/cosmos-over-every-tool

## Dependencies (3)

- [lodash](https://npm.io/package/lodash.md) ^4.17.21
- [express](https://npm.io/package/express.md) ^4.18.0
- [@cosmograph/cosmos](https://npm.io/package/@cosmograph/cosmos.md) ^1.1.1

## Alternatives

- [d3-force-3d](https://npm.io/package/d3-force-3d.md) — 1.0M weekly downloads
- [ng2-charts](https://npm.io/package/ng2-charts.md) — 486.8K weekly downloads
- [@arcgis/core](https://npm.io/package/@arcgis/core.md) — 257.8K weekly downloads
- [react-sparklines](https://npm.io/package/react-sparklines.md) — 249.3K weekly downloads
- [react-native-gifted-charts](https://npm.io/package/react-native-gifted-charts.md) — 182.3K weekly downloads

## Recent versions

- 1.0.6 (latest) — 2022-11-15
- 1.0.5 — 2022-11-15
- 1.0.4 — 2022-11-01
- 1.0.3 — 2022-10-11
- 1.0.2 — 2022-10-11
- 1.0.1 — 2022-10-11
- 1.0.0 — 2022-10-11

## README

This is a Simple project created and maintained with the **just for fun** philosophy

# cosmos-over-every-tool

This project aims to make available the power of the cosmos library visualization algorithm on any other tool

You can find the repo of this project here
https://github.com/simCecca/cosmos-over-every-tool

And the repo of cosmograph here
https://github.com/cosmograph-org/cosmos

# usage

- Install the library

```
npm install cosmos-over-every-tool
```

- Import it

```
import CosmosAlgorithm from "cosmos-over-every-tool";
```

- Create an instance

```
const cAlgo = new CosmosAlgorithm();
```

- Run the layout

```
cAlgo.runLayout(props: CAProps);

interface CAProps {
  canvas: { width: number; height: number };
  graph: Graph;
  cosmos?: CosmosGraph;
  options?: {
    maxExecutionTime: number;
  };
}
```

The CosmosGraph type is the same type you have in cosmograph, so you can use the whole
cosmos functionalities here

```
type CosmosGraph = GraphConfigInterface<
  { id: string },
  { source: string; target: string }
>;
```

The graph you can draw have to follow this structure

```
interface Graph {
  nodes: Array<{ id: string }>;
  edges: Array<{ source: string; target: string }>;
}
```

In addition to cosmos there is the possibility to set a maximum layout time

# an example

```
import CosmosAlgorithm from "cosmos-over-every-tool";

const cAlgo = new CosmosAlgorithm();

const container = document.querySelector("canvas");

const nodes = [{id: 1}, {id: 2}, {id: 3}, {id: 4}];
const edges = [{source: 1, target: 2}, {source: 1, target: 3}, {source: 1, target: 4}];

// feel free to handle the promise as you want (ex: async-await, then())
const positions = await cAlgo.runLayout({
        cosmos: {
          spaceSize: 8192,
          simulation: {
            linkDistance: 1,
            friction: 0.85,
            linkSpring: 1,
            repulsion: 0.2,
            repulsionTheta: 1,
            gravity: 0.25,
          },
        },
        options: { maxExecutionTime: 1000 },
        canvas: {
          height: container?.height || 1000,
          width: container?.width || 1000,
        },
        graph: { nodes, edges },
      });

// update your positions
```

---
_Source: https://npm.io/package/cosmos-over-every-tool · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
