aframe-forcegraph-component
Advanced tools
Comparing version 2.22.0 to 2.22.1
154
index.js
@@ -15,3 +15,3 @@ /* global AFRAME */ | ||
var parseFn = function(prop) { | ||
var parseFn = function (prop) { | ||
var geval = eval; // Avoid using eval directly https://github.com/rollup/rollup/wiki/Troubleshooting#avoiding-eval | ||
@@ -21,11 +21,10 @@ try { | ||
return evalled; | ||
} | ||
catch (e) {} // Can't eval, not a function | ||
} catch (e) {} // Can't eval, not a function | ||
return null; | ||
}; | ||
var parseAccessor = function(prop) { | ||
var parseAccessor = function (prop) { | ||
if (!isNaN(parseFloat(prop))) { return parseFloat(prop); } // parse numbers | ||
if (parseFn(prop)) { return parseFn(prop); } // parse functions | ||
return prop; //strings | ||
return prop; // strings | ||
}; | ||
@@ -38,60 +37,60 @@ | ||
schema: { | ||
jsonUrl: {type: 'string', default: ''}, | ||
nodes: {parse: JSON.parse, default: '[]'}, | ||
links: {parse: JSON.parse, default: '[]'}, | ||
numDimensions: {type: 'number', default: 3}, | ||
dagMode: {type: 'string', default: ''}, | ||
dagLevelDistance: {type: 'number', default: 0}, | ||
nodeRelSize: {type: 'number', default: 4}, // volume per val unit | ||
nodeId: {type: 'string', default: 'id'}, | ||
nodeLabel: {parse: parseAccessor, default: 'name'}, | ||
nodeDesc: {parse: parseAccessor, default: 'desc'}, | ||
nodeVal: {parse: parseAccessor, default: 'val'}, | ||
nodeResolution: {type: 'number', default: 8}, // how many slice segments in the sphere's circumference | ||
nodeVisibility: {parse: parseAccessor, default: true}, | ||
nodeColor: {parse: parseAccessor, default: 'color'}, | ||
nodeAutoColorBy: {parse: parseAccessor, default: ''}, // color nodes with the same field equally | ||
nodeOpacity: {type: 'number', default: 0.75}, | ||
nodeThreeObject: {parse: parseAccessor, default: null}, | ||
nodeThreeObjectExtend: {parse: parseAccessor, default: false}, | ||
linkSource: {type: 'string', default: 'source'}, | ||
linkTarget: {type: 'string', default: 'target'}, | ||
linkLabel: {parse: parseAccessor, default: 'name'}, | ||
linkDesc: {parse: parseAccessor, default: 'desc'}, | ||
linkHoverPrecision: {type: 'number', default: 2}, | ||
linkVisibility: {parse: parseAccessor, default: true}, | ||
linkColor: {parse: parseAccessor, default: 'color'}, | ||
linkAutoColorBy: {parse: parseAccessor, default: ''}, // color links with the same field equally | ||
linkOpacity: {type: 'number', default: 0.2}, | ||
linkWidth: {parse: parseAccessor, default: 0}, | ||
linkResolution: {type: 'number', default: 6}, // how many radial segments in each line cylinder's geometry | ||
linkCurvature: {parse: parseAccessor, default: 0}, | ||
linkCurveRotation: {parse: parseAccessor, default: 0}, | ||
linkMaterial: {parse: parseAccessor, default: null}, | ||
linkThreeObject: {parse: parseAccessor, default: null}, | ||
linkThreeObjectExtend: {parse: parseAccessor, default: false}, | ||
linkPositionUpdate: {parse: parseFn, default: null}, | ||
linkDirectionalArrowLength: {parse: parseAccessor, default: 0}, | ||
linkDirectionalArrowColor: {parse: parseAccessor, default: null}, | ||
linkDirectionalArrowRelPos: {parse: parseAccessor, default: 0.5}, // value between 0<>1 indicating the relative pos along the (exposed) line | ||
linkDirectionalArrowResolution: {type: 'number', default: 8}, // how many slice segments in the arrow's conic circumference | ||
linkDirectionalParticles: {parse: parseAccessor, default: 0}, // animate photons travelling in the link direction | ||
linkDirectionalParticleSpeed: {parse: parseAccessor, default: 0.01}, // in link length ratio per frame | ||
linkDirectionalParticleWidth: {parse: parseAccessor, default: 0.5}, | ||
linkDirectionalParticleColor: {parse: parseAccessor, default: null}, | ||
linkDirectionalParticleResolution: {type: 'number', default: 4}, // how many slice segments in the particle sphere's circumference | ||
onNodeCenterHover: {parse: parseFn, default: function() {}}, | ||
onLinkCenterHover: {parse: parseFn, default: function() {}}, | ||
forceEngine: {type: 'string', default: 'd3'}, // 'd3' or 'ngraph' | ||
d3AlphaDecay: {type: 'number', default: 0.0228}, | ||
d3VelocityDecay: {type: 'number', default: 0.4}, | ||
warmupTicks: {type: 'int', default: 0}, // how many times to tick the force engine at init before starting to render | ||
cooldownTicks: {type: 'int', default: 1e18}, // Simulate infinity (int parser doesn't accept Infinity object) | ||
cooldownTime: {type: 'int', default: 15000}, // ms | ||
onEngineTick: {parse: parseFn, default: function() {}}, | ||
onEngineStop: {parse: parseFn, default: function() {}} | ||
jsonUrl: { type: 'string', default: '' }, | ||
nodes: { parse: JSON.parse, default: '[]' }, | ||
links: { parse: JSON.parse, default: '[]' }, | ||
numDimensions: { type: 'number', default: 3 }, | ||
dagMode: { type: 'string', default: '' }, | ||
dagLevelDistance: { type: 'number', default: 0 }, | ||
nodeRelSize: { type: 'number', default: 4 }, // volume per val unit | ||
nodeId: { type: 'string', default: 'id' }, | ||
nodeLabel: { parse: parseAccessor, default: 'name' }, | ||
nodeDesc: { parse: parseAccessor, default: 'desc' }, | ||
nodeVal: { parse: parseAccessor, default: 'val' }, | ||
nodeResolution: { type: 'number', default: 8 }, // how many slice segments in the sphere's circumference | ||
nodeVisibility: { parse: parseAccessor, default: true }, | ||
nodeColor: { parse: parseAccessor, default: 'color' }, | ||
nodeAutoColorBy: { parse: parseAccessor, default: '' }, // color nodes with the same field equally | ||
nodeOpacity: { type: 'number', default: 0.75 }, | ||
nodeThreeObject: { parse: parseAccessor, default: null }, | ||
nodeThreeObjectExtend: { parse: parseAccessor, default: false }, | ||
linkSource: { type: 'string', default: 'source' }, | ||
linkTarget: { type: 'string', default: 'target' }, | ||
linkLabel: { parse: parseAccessor, default: 'name' }, | ||
linkDesc: { parse: parseAccessor, default: 'desc' }, | ||
linkHoverPrecision: { type: 'number', default: 2 }, | ||
linkVisibility: { parse: parseAccessor, default: true }, | ||
linkColor: { parse: parseAccessor, default: 'color' }, | ||
linkAutoColorBy: { parse: parseAccessor, default: '' }, // color links with the same field equally | ||
linkOpacity: { type: 'number', default: 0.2 }, | ||
linkWidth: { parse: parseAccessor, default: 0 }, | ||
linkResolution: { type: 'number', default: 6 }, // how many radial segments in each line cylinder's geometry | ||
linkCurvature: { parse: parseAccessor, default: 0 }, | ||
linkCurveRotation: { parse: parseAccessor, default: 0 }, | ||
linkMaterial: { parse: parseAccessor, default: null }, | ||
linkThreeObject: { parse: parseAccessor, default: null }, | ||
linkThreeObjectExtend: { parse: parseAccessor, default: false }, | ||
linkPositionUpdate: { parse: parseFn, default: null }, | ||
linkDirectionalArrowLength: { parse: parseAccessor, default: 0 }, | ||
linkDirectionalArrowColor: { parse: parseAccessor, default: null }, | ||
linkDirectionalArrowRelPos: { parse: parseAccessor, default: 0.5 }, // value between 0<>1 indicating the relative pos along the (exposed) line | ||
linkDirectionalArrowResolution: { type: 'number', default: 8 }, // how many slice segments in the arrow's conic circumference | ||
linkDirectionalParticles: { parse: parseAccessor, default: 0 }, // animate photons travelling in the link direction | ||
linkDirectionalParticleSpeed: { parse: parseAccessor, default: 0.01 }, // in link length ratio per frame | ||
linkDirectionalParticleWidth: { parse: parseAccessor, default: 0.5 }, | ||
linkDirectionalParticleColor: { parse: parseAccessor, default: null }, | ||
linkDirectionalParticleResolution: { type: 'number', default: 4 }, // how many slice segments in the particle sphere's circumference | ||
onNodeCenterHover: { parse: parseFn, default: function () {} }, | ||
onLinkCenterHover: { parse: parseFn, default: function () {} }, | ||
forceEngine: { type: 'string', default: 'd3' }, // 'd3' or 'ngraph' | ||
d3AlphaDecay: { type: 'number', default: 0.0228 }, | ||
d3VelocityDecay: { type: 'number', default: 0.4 }, | ||
warmupTicks: { type: 'int', default: 0 }, // how many times to tick the force engine at init before starting to render | ||
cooldownTicks: { type: 'int', default: 1e18 }, // Simulate infinity (int parser doesn't accept Infinity object) | ||
cooldownTime: { type: 'int', default: 15000 }, // ms | ||
onEngineTick: { parse: parseFn, default: function () {} }, | ||
onEngineStop: { parse: parseFn, default: function () {} } | ||
}, | ||
// Bind component methods | ||
d3Force: function() { | ||
d3Force: function () { | ||
if (!this.forceGraph) { | ||
@@ -110,3 +109,3 @@ // Got here before component init -> initialize forceGraph | ||
d3ReheatSimulation: function() { | ||
d3ReheatSimulation: function () { | ||
this.forceGraph && this.forceGraph.d3ReheatSimulation(); | ||
@@ -116,3 +115,3 @@ return this; | ||
refresh: function() { | ||
refresh: function () { | ||
this.forceGraph && this.forceGraph.refresh(); | ||
@@ -156,6 +155,6 @@ return this; | ||
state.cameraObj = cameraEl.object3D.children | ||
.filter(function(child) { return child.type === 'PerspectiveCamera' })[0]; | ||
.filter(function (child) { return child.type === 'PerspectiveCamera'; })[0]; | ||
// On camera switch | ||
this.el.sceneEl.addEventListener('camera-set-active', function(evt) { | ||
this.el.sceneEl.addEventListener('camera-set-active', function (evt) { | ||
// Switch camera reference | ||
@@ -170,9 +169,8 @@ state.cameraObj = evt.detail.cameraEl.components.camera.camera; | ||
this.forceGraph | ||
.onLoading(function() { | ||
.onLoading(function () { | ||
state.infoEl.setAttribute('value', 'Loading...'); // Add loading msg | ||
}) | ||
.onFinishLoading(function() { | ||
.onFinishLoading(function () { | ||
state.infoEl.setAttribute('value', ''); | ||
}); | ||
}, | ||
@@ -188,5 +186,5 @@ | ||
update: function (oldData) { | ||
var comp = this, | ||
elData = this.data, | ||
diff = AFRAME.utils.diff(elData, oldData); | ||
var comp = this; | ||
var elData = this.data; | ||
var diff = AFRAME.utils.diff(elData, oldData); | ||
@@ -242,4 +240,4 @@ var fgProps = [ | ||
fgProps | ||
.filter(function(p) { return p in diff; }) | ||
.forEach(function(p) { comp.forceGraph[p](elData[p] !== '' ? elData[p] : null); }); // Convert blank values into nulls | ||
.filter(function (p) { return p in diff; }) | ||
.forEach(function (p) { comp.forceGraph[p](elData[p] !== '' ? elData[p] : null); }); // Convert blank values into nulls | ||
@@ -254,3 +252,3 @@ if ('nodes' in diff || 'links' in diff) { | ||
tick: function(t, td) { | ||
tick: function (t, td) { | ||
// Update tooltip | ||
@@ -265,8 +263,8 @@ var centerRaycaster = new THREE.Raycaster(); | ||
var intersects = centerRaycaster.intersectObjects(this.forceGraph.children) | ||
.filter(function(o) { // Check only node/link objects | ||
.filter(function (o) { // Check only node/link objects | ||
return ['node', 'link'].indexOf(o.object.__graphObjType) !== -1; | ||
}) | ||
.sort(function(a, b) { // Prioritize nodes over links | ||
.sort(function (a, b) { // Prioritize nodes over links | ||
return isNode(b) - isNode(a); | ||
function isNode(o) { return o.object.__graphObjType === 'node'; } | ||
function isNode (o) { return o.object.__graphObjType === 'node'; } | ||
}); | ||
@@ -292,4 +290,4 @@ | ||
this.state.hoverObj = topObject; | ||
this.state.tooltipEl.setAttribute('value', topObject ? accessorFn(this.data[topObject.__graphObjType + 'Label'])(topObject.__data) || '' : '' ); | ||
this.state.subTooltipEl.setAttribute('value', topObject ? accessorFn(this.data[topObject.__graphObjType + 'Desc'])(topObject.__data) || '' : '' ); | ||
this.state.tooltipEl.setAttribute('value', topObject ? accessorFn(this.data[topObject.__graphObjType + 'Label'])(topObject.__data) || '' : ''); | ||
this.state.subTooltipEl.setAttribute('value', topObject ? accessorFn(this.data[topObject.__graphObjType + 'Desc'])(topObject.__data) || '' : ''); | ||
} | ||
@@ -296,0 +294,0 @@ |
{ | ||
"name": "aframe-forcegraph-component", | ||
"version": "2.22.0", | ||
"version": "2.22.1", | ||
"description": "A 3D Force-Directed Graph component for A-Frame.", | ||
@@ -56,29 +56,29 @@ "main": "index.js", | ||
"devDependencies": { | ||
"@babel/cli": "^7.2.3", | ||
"@babel/core": "^7.3.3", | ||
"@babel/plugin-proposal-class-properties": "^7.0.0", | ||
"@babel/plugin-proposal-decorators": "^7.0.0", | ||
"@babel/plugin-proposal-do-expressions": "^7.0.0", | ||
"@babel/plugin-proposal-export-default-from": "^7.0.0", | ||
"@babel/plugin-proposal-export-namespace-from": "^7.0.0", | ||
"@babel/plugin-proposal-function-bind": "^7.0.0", | ||
"@babel/plugin-proposal-function-sent": "^7.0.0", | ||
"@babel/plugin-proposal-json-strings": "^7.0.0", | ||
"@babel/plugin-proposal-logical-assignment-operators": "^7.0.0", | ||
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.0.0", | ||
"@babel/plugin-proposal-numeric-separator": "^7.0.0", | ||
"@babel/plugin-proposal-optional-chaining": "^7.0.0", | ||
"@babel/plugin-proposal-pipeline-operator": "^7.0.0", | ||
"@babel/plugin-proposal-throw-expressions": "^7.0.0", | ||
"@babel/plugin-syntax-dynamic-import": "^7.0.0", | ||
"@babel/plugin-syntax-import-meta": "^7.0.0", | ||
"@babel/preset-env": "^7.3.1", | ||
"@babel/cli": "^7.7.5", | ||
"@babel/core": "^7.7.5", | ||
"@babel/plugin-proposal-class-properties": "^7.7.4", | ||
"@babel/plugin-proposal-decorators": "^7.7.4", | ||
"@babel/plugin-proposal-do-expressions": "^7.7.4", | ||
"@babel/plugin-proposal-export-default-from": "^7.7.4", | ||
"@babel/plugin-proposal-export-namespace-from": "^7.7.4", | ||
"@babel/plugin-proposal-function-bind": "^7.7.4", | ||
"@babel/plugin-proposal-function-sent": "^7.7.4", | ||
"@babel/plugin-proposal-json-strings": "^7.7.4", | ||
"@babel/plugin-proposal-logical-assignment-operators": "^7.7.4", | ||
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.7.4", | ||
"@babel/plugin-proposal-numeric-separator": "^7.7.4", | ||
"@babel/plugin-proposal-optional-chaining": "^7.7.5", | ||
"@babel/plugin-proposal-pipeline-operator": "^7.7.4", | ||
"@babel/plugin-proposal-throw-expressions": "^7.7.4", | ||
"@babel/plugin-syntax-dynamic-import": "^7.7.4", | ||
"@babel/plugin-syntax-import-meta": "^7.7.4", | ||
"@babel/preset-env": "^7.7.6", | ||
"aframe": "*", | ||
"babel-loader": "^8.0.5", | ||
"babel-preset-minify": "^0.5.0", | ||
"chai": "^3.4.1", | ||
"chai-shallow-deep-equal": "^1.3.0", | ||
"cross-env": "4.0.0", | ||
"ghpages": "^0.0.8", | ||
"karma": "^0.13.15", | ||
"babel-loader": "^8.0.6", | ||
"babel-preset-minify": "^0.5.1", | ||
"chai": "^4.2.0", | ||
"chai-shallow-deep-equal": "^1.4.6", | ||
"cross-env": "6.0.3", | ||
"ghpages": "^0.0.10", | ||
"karma": "^4.4.1", | ||
"karma-browserify": "^4.4.2", | ||
@@ -89,19 +89,19 @@ "karma-chai-shallow-deep-equal": "0.0.4", | ||
"karma-firefox-launcher": "^0.1.7", | ||
"karma-mocha": "^0.2.1", | ||
"karma-mocha-reporter": "^1.1.3", | ||
"karma-sinon-chai": "^1.1.0", | ||
"mocha": "^2.3.4", | ||
"randomcolor": "^0.4.4", | ||
"semistandard": "^8.0.0", | ||
"shelljs": "^0.7.0", | ||
"shx": "^0.2.2", | ||
"sinon": "^1.17.5", | ||
"sinon-chai": "^2.8.0", | ||
"snazzy": "^4.0.0", | ||
"superagent": "^3.8.2", | ||
"karma-mocha": "^1.3.0", | ||
"karma-mocha-reporter": "^2.2.5", | ||
"karma-sinon-chai": "^2.0.2", | ||
"mocha": "^6.2.2", | ||
"randomcolor": "^0.5.4", | ||
"semistandard": "^14.2.0", | ||
"shelljs": "^0.8.3", | ||
"shx": "^0.3.2", | ||
"sinon": "^7.5.0", | ||
"sinon-chai": "^3.3.0", | ||
"snazzy": "^8.0.0", | ||
"superagent": "^5.1.2", | ||
"three": "*", | ||
"webpack": "^4.29.5", | ||
"webpack": "^4.41.2", | ||
"webpack-cli": "*", | ||
"webpack-dev-server": "^3.2.0", | ||
"webpack-sources": "1.0.1" | ||
"webpack-dev-server": "^3.9.0", | ||
"webpack-sources": "1.4.3" | ||
}, | ||
@@ -108,0 +108,0 @@ "semistandard": { |
Sorry, the diff of this file is too big to display
3748957
11698