Socket
Socket
Sign inDemoInstall

visjs-network

Package Overview
Dependencies
6
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 4.24.2 to 4.25.0

examples/basicUsage/index.html

15

examples/exampleUtil.js

@@ -1,3 +0,1 @@

/* eslint-disable */
// prettier-ignore

@@ -23,3 +21,5 @@ // eslint-disable-next-line valid-jsdoc

/* eslint-disable */
function getScaleFreeNetwork(nodeCount) {
/* eslint-enable */
var nodes = []

@@ -40,4 +40,4 @@ var edges = []

if (i == 1) {
var from = i
var to = 0
let from = i
let to = 0
edges.push({

@@ -74,2 +74,3 @@ from: from,

var randomSeed = 764 // Math.round(Math.random()*1000);
// eslint-disable-next-line require-jsdoc
function seededRandom() {

@@ -80,3 +81,5 @@ var x = Math.sin(randomSeed++) * 10000

/* eslint-disable */
function getScaleFreeNetworkSeeded(nodeCount, seed) {
/* eslint-enable */
if (seed) {

@@ -120,4 +123,4 @@ randomSeed = Number(seed)

var from = i
var to = j
let from = i
let to = j
edges.push({

@@ -124,0 +127,0 @@ id: edgesId++,

254

lib/network/dotparser.js

@@ -682,105 +682,18 @@ /**

/**
* Parse a set with attributes,
* for example [label="1.000", shape=solid]
* @return {Object | null} attr
* As explained in [1], graphviz has limitations for combination of
* arrow[head|tail] and dir. If attribute list includes 'dir',
* following cases just be supported.
* 1. both or none + arrowhead, arrowtail
* 2. forward + arrowhead (arrowtail is not affedted)
* 3. back + arrowtail (arrowhead is not affected)
* [1] https://www.graphviz.org/doc/info/attrs.html#h:undir_note
*
* This function is called from parseAttributeList() to parse 'dir'
* attribute with given 'attr_names' and 'attr_list'.
* @param {Object} attr_names Array of attribute names
* @param {Object} attr_list Array of objects of attribute set
* @return {Object} attr_list Updated attr_list
*/
function parseAttributeList() {
function parseDirAttribute(attr_names, attr_list) {
var i
var attr = null
// edge styles of dot and vis
var edgeStyles = {
dashed: true,
solid: false,
dotted: [1, 5]
}
/**
* Define arrow types.
* vis currently supports types defined in 'arrowTypes'.
* Details of arrow shapes are described in
* http://www.graphviz.org/content/arrow-shapes
*/
var arrowTypes = {
dot: 'circle',
box: 'box',
crow: 'crow',
curve: 'curve',
icurve: 'inv_curve',
normal: 'triangle',
inv: 'inv_triangle',
diamond: 'diamond',
tee: 'bar',
vee: 'vee'
}
/**
* 'attr_list' contains attributes for checking if some of them are affected
* later. For instance, both of 'arrowhead' and 'dir' (edge style defined
* in DOT) make changes to 'arrows' attribute in vis.
*/
var attr_list = new Array()
var attr_names = new Array() // used for checking the case.
// parse attributes
while (token === '[') {
getToken()
attr = {}
while (token !== '' && token != ']') {
if (tokenType != TOKENTYPE.IDENTIFIER) {
throw newSyntaxError('Attribute name expected')
}
var name = token
getToken()
if (token != '=') {
throw newSyntaxError('Equal sign = expected')
}
getToken()
if (tokenType != TOKENTYPE.IDENTIFIER) {
throw newSyntaxError('Attribute value expected')
}
var value = token
// convert from dot style to vis
if (name === 'style') {
value = edgeStyles[value]
}
var arrowType
if (name === 'arrowhead') {
arrowType = arrowTypes[value]
name = 'arrows'
value = { to: { enabled: true, type: arrowType } }
}
if (name === 'arrowtail') {
arrowType = arrowTypes[value]
name = 'arrows'
value = { from: { enabled: true, type: arrowType } }
}
attr_list.push({ attr: attr, name: name, value: value })
attr_names.push(name)
getToken()
if (token == ',') {
getToken()
}
}
if (token != ']') {
throw newSyntaxError('Bracket ] expected')
}
getToken()
}
/**
* As explained in [1], graphviz has limitations for combining
* arrow[head|tail] and dir. If the attribute list includes 'dir',
* only following cases are supported:
* 1. both or none + arrowhead, arrowtail
* 2. forward + arrowhead (arrowtail is not affedted)
* 3. back + arrowtail (arrowhead is not affected)
* [1] https://www.graphviz.org/doc/info/attrs.html#h:undir_note
*/
if (attr_names.includes('dir')) {

@@ -802,2 +715,3 @@ var idx = {} // get index of 'arrows' and 'dir'

}
// first, add default arrow shape if it is not assigned to avoid error

@@ -844,2 +758,3 @@ var dir_type = attr_list[idx.dir].value

}
var from_type

@@ -862,2 +777,3 @@ var to_type

attr_list.splice(idx.arrows.from, 1)
// shape of 'to' is assigned and use default to 'from'

@@ -875,2 +791,3 @@ } else if (idx.arrows.to) {

}
// only shape of 'from' is assigned and use default for 'to'

@@ -902,2 +819,3 @@ } else if (idx.arrows.from) {

}
// given shape of 'to', but does not use it

@@ -916,2 +834,3 @@ } else if (idx.arrows.to) {

}
// assign given 'from' shape

@@ -930,2 +849,3 @@ } else if (idx.arrows.from) {

}
attr_list[idx.arrows.from] = {

@@ -948,2 +868,3 @@ attr: attr_list[idx.arrows.from].attr,

}
attr_list[idx_arrow] = {

@@ -967,2 +888,3 @@ attr: attr_list[idx_arrow].attr,

}
// assign given 'to' shape

@@ -980,2 +902,3 @@ } else if (idx.arrows.to) {

}
// given shape of 'from', but does not use it

@@ -995,2 +918,3 @@ } else if (idx.arrows.from) {

}
attr_list[idx.arrows.to] = {

@@ -1000,3 +924,6 @@ attr: attr_list[idx.arrows.to].attr,

value: {
to: { enabled: true, type: attr_list[idx.arrows.to].value.to.type }
to: {
enabled: true,
type: attr_list[idx.arrows.to].value.to.type
}
}

@@ -1007,6 +934,127 @@ }

}
// remove 'dir' attribute no need anymore
attr_list.splice(idx.dir, 1)
}
var nof_attr_list = attr_list.length
return attr_list
}
/**
* Parse a set with attributes,
* for example [label="1.000", shape=solid]
* @return {Object | null} attr
*/
function parseAttributeList() {
var i
var attr = null
// edge styles of dot and vis
var edgeStyles = {
dashed: true,
solid: false,
dotted: [1, 5]
}
/**
* Define arrow types.
* vis currently supports types defined in 'arrowTypes'.
* Details of arrow shapes are described in
* http://www.graphviz.org/content/arrow-shapes
*/
var arrowTypes = {
dot: 'circle',
box: 'box',
crow: 'crow',
curve: 'curve',
icurve: 'inv_curve',
normal: 'triangle',
inv: 'inv_triangle',
diamond: 'diamond',
tee: 'bar',
vee: 'vee'
}
/**
* 'attr_list' contains attributes for checking if some of them are affected
* later. For instance, both of 'arrowhead' and 'dir' (edge style defined
* in DOT) make changes to 'arrows' attribute in vis.
*/
var attr_list = new Array()
var attr_names = new Array() // used for checking the case.
// parse attributes
while (token === '[') {
getToken()
attr = {}
while (token !== '' && token != ']') {
if (tokenType != TOKENTYPE.IDENTIFIER) {
throw newSyntaxError('Attribute name expected')
}
var name = token
getToken()
if (token != '=') {
throw newSyntaxError('Equal sign = expected')
}
getToken()
if (tokenType != TOKENTYPE.IDENTIFIER) {
throw newSyntaxError('Attribute value expected')
}
var value = token
// convert from dot style to vis
if (name === 'style') {
value = edgeStyles[value]
}
var arrowType
if (name === 'arrowhead') {
arrowType = arrowTypes[value]
name = 'arrows'
value = { to: { enabled: true, type: arrowType } }
}
if (name === 'arrowtail') {
arrowType = arrowTypes[value]
name = 'arrows'
value = { from: { enabled: true, type: arrowType } }
}
attr_list.push({ attr: attr, name: name, value: value })
attr_names.push(name)
getToken()
if (token == ',') {
getToken()
}
}
if (token != ']') {
throw newSyntaxError('Bracket ] expected')
}
getToken()
}
attr_list = parseDirAttribute(attr_names, attr_list)
// parse 'penwidth'
var nof_attr_list
if (attr_names.includes('penwidth')) {
var tmp_attr_list = []
nof_attr_list = attr_list.length
for (i = 0; i < nof_attr_list; i++) {
// exclude 'width' from attr_list if 'penwidth' exists
if (attr_list[i].name !== 'width') {
if (attr_list[i].name === 'penwidth') {
attr_list[i].name = 'width'
}
tmp_attr_list.push(attr_list[i])
}
}
attr_list = tmp_attr_list
}
nof_attr_list = attr_list.length
for (i = 0; i < nof_attr_list; i++) {

@@ -1013,0 +1061,0 @@ setValue(attr_list[i].attr, attr_list[i].name, attr_list[i].value)

{
"name": "visjs-network",
"version": "4.24.2",
"version": "4.25.0",
"description": "A dynamic, browser-based network visualization library.",

@@ -5,0 +5,0 @@ "homepage": "http://visjs.org/",

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

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 too big to display

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc