New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@antv/layout

Package Overview
Dependencies
Maintainers
34
Versions
161
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@antv/layout - npm Package Compare versions

Comparing version 0.1.7-beta.1 to 0.1.7-beta.2

35

es/layout/dagre.js

@@ -39,3 +39,3 @@ /**

ranksep: 50,
controlPoints: false // 是否保留布局连线的控制点
controlPoints: false,
};

@@ -52,3 +52,6 @@ }

const edges = self.edges || [];
const g = new dagre.graphlib.Graph();
const g = new dagre.graphlib.Graph({
multigraph: true,
compound: true,
});
let nodeSizeFunc;

@@ -80,3 +83,4 @@ if (!nodeSize) {

g.setGraph(self);
nodes.forEach(node => {
const comboMap = {};
nodes.forEach((node) => {
const size = nodeSizeFunc(node);

@@ -88,7 +92,14 @@ const verti = vertisep(node);

g.setNode(node.id, { width, height });
if (this.sortByCombo && node.comboId) {
if (!comboMap[node.comboId]) {
comboMap[node.comboId] = true;
g.setNode(node.comboId, {});
}
g.setParent(node.id, node.comboId);
}
});
edges.forEach(edge => {
edges.forEach((edge) => {
// dagrejs Wiki https://github.com/dagrejs/dagre/wiki#configuring-the-layout
g.setEdge(edge.source, edge.target, {
weight: edge.weight || 1
weight: edge.weight || 1,
});

@@ -100,3 +111,5 @@ });

coord = g.node(node);
const i = nodes.findIndex(it => it.id === node);
const i = nodes.findIndex((it) => it.id === node);
if (!nodes[i])
return;
nodes[i].x = coord.x;

@@ -107,3 +120,3 @@ nodes[i].y = coord.y;

coord = g.edge(edge);
const i = edges.findIndex(it => it.source === edge.v && it.target === edge.w);
const i = edges.findIndex((it) => it.source === edge.v && it.target === edge.w);
if (self.controlPoints && edges[i].type !== "loop") {

@@ -120,3 +133,3 @@ edges[i].controlPoints = coord.points.slice(1, coord.points.length - 1);

nodes,
edges
edges,
};

@@ -128,3 +141,3 @@ }

const levels = {};
nodes.forEach(node => {
nodes.forEach((node) => {
if (!levels[node.y])

@@ -134,3 +147,3 @@ levels[node.y] = { y: node.y, nodes: [] };

});
Object.keys(levels).forEach(key => {
Object.keys(levels).forEach((key) => {
const levelNodes = levels[key].nodes;

@@ -147,3 +160,3 @@ const nodesNum = levelNodes.length;

});
Object.keys(comboCenters).forEach(ckey => {
Object.keys(comboCenters).forEach((ckey) => {
comboCenters[ckey].x /= comboCenters[ckey].count;

@@ -150,0 +163,0 @@ comboCenters[ckey].y /= comboCenters[ckey].count;

@@ -7,2 +7,3 @@ export interface Node {

y: number;
comboId?: string;
}

@@ -9,0 +10,0 @@ export interface Edge {

@@ -60,3 +60,3 @@ "use strict";

ranksep: 50,
controlPoints: false // 是否保留布局连线的控制点
controlPoints: false,
};

@@ -68,2 +68,3 @@ };

DagreLayout.prototype.execute = function () {
var _this = this;
var self = this;

@@ -74,3 +75,6 @@ var nodes = self.nodes, nodeSize = self.nodeSize, rankdir = self.rankdir;

var edges = self.edges || [];
var g = new dagre_1.default.graphlib.Graph();
var g = new dagre_1.default.graphlib.Graph({
multigraph: true,
compound: true,
});
var nodeSizeFunc;

@@ -102,2 +106,3 @@ if (!nodeSize) {

g.setGraph(self);
var comboMap = {};
nodes.forEach(function (node) {

@@ -110,2 +115,9 @@ var size = nodeSizeFunc(node);

g.setNode(node.id, { width: width, height: height });
if (_this.sortByCombo && node.comboId) {
if (!comboMap[node.comboId]) {
comboMap[node.comboId] = true;
g.setNode(node.comboId, {});
}
g.setParent(node.id, node.comboId);
}
});

@@ -115,3 +127,3 @@ edges.forEach(function (edge) {

g.setEdge(edge.source, edge.target, {
weight: edge.weight || 1
weight: edge.weight || 1,
});

@@ -124,2 +136,4 @@ });

var i = nodes.findIndex(function (it) { return it.id === node; });
if (!nodes[i])
return;
nodes[i].x = coord.x;

@@ -142,3 +156,3 @@ nodes[i].y = coord.y;

nodes: nodes,
edges: edges
edges: edges,
};

@@ -145,0 +159,0 @@ };

@@ -7,2 +7,3 @@ export interface Node {

y: number;
comboId?: string;
}

@@ -9,0 +10,0 @@ export interface Edge {

{
"name": "@antv/layout",
"version": "0.1.7-beta.1",
"version": "0.1.7-beta.2",
"description": "graph layout algorithm",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc