Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

aframe-forcegraph-component

Package Overview
Dependencies
Maintainers
1
Versions
113
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

aframe-forcegraph-component - npm Package Compare versions

Comparing version 1.0.0 to 1.1.0

_config.yml

50

index.js

@@ -8,3 +8,3 @@ /* global AFRAME */

// Extend d3 with force-3d functionality
const d3 = require('lodash').assign(require('d3'), require('d3-force-3d'));
var d3 = require('lodash').assign(require('d3'), require('d3-force-3d'));

@@ -61,3 +61,3 @@ // Include line-component

update: function (oldData) {
const comp = this,
var comp = this,
elData = this.data,

@@ -68,13 +68,15 @@ diff = AFRAME.utils.diff(elData, oldData);

// (Re-)load data
d3.json(elData.jsonUrl, json => {
d3.json(elData.jsonUrl, function(json) {
// Color brewer paired set
const colors = ['#a6cee3','#1f78b4','#b2df8a','#33a02c','#fb9a99','#e31a1c','#fdbf6f','#ff7f00','#cab2d6','#6a3d9a','#ffff99','#b15928'];
var colors = ['#a6cee3','#1f78b4','#b2df8a','#33a02c','#fb9a99','#e31a1c','#fdbf6f','#ff7f00','#cab2d6','#6a3d9a','#ffff99','#b15928'];
// add color
json.nodes.filter(node => !node[elData.colorField]).forEach(node => {
node[elData.colorField] = parseInt(colors[node[elData.autoColorBy] % colors.length].slice(1), 16);
});
json.nodes
.filter(function(node) { return !node[elData.colorField] })
.forEach(function(node) {
node[elData.colorField] = parseInt(colors[node[elData.autoColorBy] % colors.length].slice(1), 16);
});
// add links id
json.links.forEach(link => {
json.links.forEach(function(link) {
link.source = link[elData.linkSourceField];

@@ -93,5 +95,5 @@ link.target = link[elData.linkTargetField];

// Add children entities
const d3El = d3.select(this.el);
let d3Nodes = d3El.selectAll('a-sphere.node')
.data(elData.nodes, d => d[elData.idField]);
var d3El = d3.select(this.el);
var d3Nodes = d3El.selectAll('a-sphere.node')
.data(elData.nodes, function(d) { return d[elData.idField] });

@@ -106,9 +108,9 @@ d3Nodes.exit().remove();

.attr('segments-height', 8)
.attr('radius', d => Math.cbrt(d[elData.valField] || 1) * elData.nodeRelSize)
.attr('color', d => '#' + (d[elData.colorField] || 0xffffaa).toString(16))
.attr('radius', function(d) { return Math.cbrt(d[elData.valField] || 1) * elData.nodeRelSize })
.attr('color', function(d) {return '#' + (d[elData.colorField] || 0xffffaa).toString(16) })
.attr('opacity', 0.75)
.on('mouseenter', d => {
.on('mouseenter', function(d) {
elData.tooltipEl.attr('value', d[elData.nameField] || '');
})
.on('mouseleave', () => {
.on('mouseleave', function() {
elData.tooltipEl.attr('value', '');

@@ -118,4 +120,4 @@ })

let d3Links = d3El.selectAll('a-entity.link')
.data(elData.links, d => d.id);
var d3Links = d3El.selectAll('a-entity.link')
.data(elData.links, function(d) { return d.id });

@@ -128,3 +130,3 @@ d3Links.exit().remove();

.classed('link', true)
.attr('line', `color: #f0f0f0; opacity: ${elData.lineOpacity}`)
.attr('line', 'color: #f0f0f0; opacity: ' + elData.lineOpacity)
);

@@ -138,9 +140,9 @@

.force('link')
.id(d => d[elData.idField])
.id(function(d) { return d[elData.idField] })
.links(elData.links);
for (let i=0; i<elData.warmupTicks; i++) { elData.forceLayout.tick(); } // Initial ticks before starting to render
for (var i=0; i<elData.warmupTicks; i++) { elData.forceLayout.tick(); } // Initial ticks before starting to render
let cntTicks = 0;
const startTickTime = new Date();
var cntTicks = 0;
var startTickTime = new Date();
elData.forceLayout.on('tick', layoutTick).restart();

@@ -156,8 +158,8 @@

// Update nodes position
d3Nodes.attr('position', d => `${d.x} ${d.y || 0} ${d.z || 0}`);
d3Nodes.attr('position', function(d) { return [d.x, d.y || 0, d.z || 0].join(' ') });
//Update links position
d3Links.attr('line', d => `start: ${d.source.x} ${d.source.y || 0} ${d.source.z || 0}; end: ${d.target.x} ${d.target.y || 0} ${d.target.z || 0}`);
d3Links.attr('line', function(d) { return ['start:', d.source.x, d.source.y || 0, d.source.z || 0, ';', 'end:', d.target.x, d.target.y || 0, d.target.z || 0].join(' ') });
}
}
});
{
"name": "aframe-forcegraph-component",
"version": "1.0.0",
"version": "1.1.0",
"description": "A 3D Force-Directed Graph component for A-Frame.",

@@ -9,3 +9,3 @@ "main": "index.js",

"dev": "budo index.js:dist/aframe-forcegraph-component.min.js --port 7000 --live --open",
"dist": "webpack index.js dist/aframe-forcegraph-component.js && webpack index.js dist/aframe-forcegraph-component.min.js",
"dist": "webpack index.js dist/aframe-forcegraph-component.js && webpack -p index.js dist/aframe-forcegraph-component.min.js",
"lint": "semistandard -v | snazzy",

@@ -83,7 +83,3 @@ "prepublish": "npm run dist",

]
},
"publishConfig": {
"registry": "https://registry.npmjs.org/"
}
}

Sorry, the diff of this file is not supported yet

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

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