@graphty/layout 1.2.6 → 1.2.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +55 -5
  2. package/package.json +3 -3
package/README.md CHANGED
@@ -4,9 +4,9 @@
4
4
  [![Coverage Status](https://coveralls.io/repos/github/graphty-org/layout/badge.svg?branch=main)](https://coveralls.io/github/graphty-org/layout?branch=main)
5
5
  [![npm version](https://badge.fury.io/js/%40graphty%2Flayout.svg)](https://badge.fury.io/js/%40graphty%2Flayout)
6
6
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
7
- [![GitHub Pages](https://img.shields.io/badge/demo-github%20pages-blue)](https://graphty-org.github.io/layout/)
7
+ [![GitHub Pages](https://img.shields.io/badge/demo-github%20pages-blue)](https://graphty-org.github.io/layout/examples/index.html)
8
8
 
9
- **[View Interactive Examples →](https://graphty-org.github.io/layout/index.html)**
9
+ **[View Interactive Examples →](https://graphty-org.github.io/layout/examples/index.html)**
10
10
 
11
11
  Layout is a TypeScript library for positioning nodes in graphs. It's a TypeScript port of the [layout algorithms](https://networkx.org/documentation/stable/reference/drawing.html) from the Python [NetworkX](https://networkx.org/documentation/stable/) library.
12
12
 
@@ -51,6 +51,12 @@ Additionally, the library includes:
51
51
  - **combineLayouts** - Blend multiple layout algorithms
52
52
  - **interpolateLayouts** - Smooth animation between layouts
53
53
 
54
+ ## Installation
55
+
56
+ ```bash
57
+ npm install @graphty/layout
58
+ ```
59
+
54
60
  ## How to Use
55
61
 
56
62
  Import the library in your TypeScript/JavaScript project:
@@ -91,7 +97,7 @@ import {
91
97
  layoutQuality,
92
98
  combineLayouts,
93
99
  interpolateLayouts
94
- } from './layout.js'
100
+ } from '@graphty/layout'
95
101
  ```
96
102
 
97
103
  ## Quick Start
@@ -476,12 +482,30 @@ if (detected) {
476
482
  }
477
483
  ```
478
484
 
485
+ ## 3D Support
486
+
487
+ All layout algorithms support 3D positioning by setting the `dim` parameter to 3:
488
+
489
+ ```typescript
490
+ // Any layout algorithm in 3D
491
+ const positions3D = springLayout(graph, null, null, null, 50, 1, [0, 0, 0], 3)
492
+ // Returns: { node1: [x, y, z], node2: [x, y, z], ... }
493
+
494
+ // ForceAtlas2 in 3D
495
+ const fa3D = forceatlas2Layout(graph, null, 100, 1, 2, 1, false, false, null, null, null, false, false, 42, 3)
496
+
497
+ // Circular layout in 3D (creates a sphere)
498
+ const circular3D = circularLayout(graph, 1, [0, 0, 0], 3)
499
+ ```
500
+
501
+ When using 3D layouts, positions will have three coordinates `[x, y, z]` instead of two.
502
+
479
503
  ## Common Parameters
480
504
 
481
505
  Most layout functions share these parameters:
482
506
 
483
507
  - **scale** (number): Scale factor for positions (default: 1)
484
- - **center** (number[]): Center coordinates around which to center the layout (default: [0, 0])
508
+ - **center** (number[]): Center coordinates around which to center the layout (default: [0, 0] for 2D, [0, 0, 0] for 3D)
485
509
  - **dim** (number): Layout dimension - 2D or 3D (default: 2)
486
510
  - **seed** (number): Seed for random generation (for reproducible layouts)
487
511
 
@@ -722,7 +746,26 @@ const positions = forceatlas2Layout(
722
746
  true, // dissuadeHubs: good for scale-free
723
747
  false, // linlog: logarithmic attraction
724
748
  42, // seed
725
- 2 // dim
749
+ 2 // dim: 2 for 2D, 3 for 3D
750
+ )
751
+
752
+ // 3D layout example
753
+ const positions3D = forceatlas2Layout(
754
+ graph,
755
+ null,
756
+ 100,
757
+ 1.0,
758
+ 2.0,
759
+ 1.0,
760
+ false,
761
+ false,
762
+ null,
763
+ null,
764
+ null,
765
+ false,
766
+ false,
767
+ 42,
768
+ 3 // 3D mode - returns [x, y, z] coordinates
726
769
  )
727
770
  ```
728
771
 
@@ -1098,6 +1141,13 @@ To deploy to GitHub Pages, see `gh-pages/DEPLOY.md` after building.
1098
1141
  4. **Build for production** with `npm run build:all`
1099
1142
  5. **Deploy examples** with `npm run build:gh-pages`
1100
1143
 
1144
+ ## Recent Updates
1145
+
1146
+ ### Version 1.2.7 (Latest)
1147
+ - **Fixed**: ForceAtlas2 now correctly returns numeric Z coordinates in 3D mode (previously returned NaN)
1148
+ - **Fixed**: NPM package now uses the correct bundled entry point (`dist/layout.js`)
1149
+ - **Added**: Full 3D support documentation and examples
1150
+
1101
1151
  ## Contributing
1102
1152
 
1103
1153
  This project is a TypeScript port of the NetworkX Python library. For contributions and issues, visit the [GitHub repository](https://github.com/graphty-org/layout).
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@graphty/layout",
3
- "version": "1.2.6",
3
+ "version": "1.2.7",
4
4
  "description": "graph layout algorithms based on networkx",
5
5
  "author": "Adam Powers <apowers@ato.ms>",
6
- "main": "dist/src/index.js",
6
+ "main": "dist/layout.js",
7
7
  "type": "module",
8
8
  "exports": {
9
9
  ".": {
10
- "import": "./dist/src/index.js",
10
+ "import": "./dist/layout.js",
11
11
  "types": "./dist/src/index.d.ts"
12
12
  }
13
13
  },