Skip to content
Permalink
Browse files

modernize neovis.js

  • Loading branch information...
thebestnom committed May 24, 2019
1 parent 60b7c4c commit 9444015b4333a3f41029c594aaee1bc7d70895e1
Showing with 7,220 additions and 37,053 deletions.
  1. +7 −0 .babelrc
  2. +7 −0 .eslintignore
  3. +23 −0 .eslintrc.yml
  4. +0 −6 .gitmodules
  5. +323 −0 dist/neovis-without-dependencies.js
  6. +2,253 −36,485 dist/neovis.js
  7. +0 −1 dist/vis.min.css
  8. +7 −7 docs/trolltweets.html
  9. +35 −6 package.json
  10. +59 −59 src/defaults.js
  11. +25 −25 src/events.js
  12. +425 −442 src/neovis.js
  13. +0 −1 vendor/neo4j-javascript-driver
  14. +0 −1 vendor/vis
  15. +35 −20 webpack.config.js
  16. +4,021 −0 yarn.lock
@@ -0,0 +1,7 @@
{
"presets": [["@babel/preset-env", {
"useBuiltIns": "usage",
"corejs": "3"
}]],
"plugins": ["@babel/plugin-proposal-class-properties"]
}
@@ -0,0 +1,7 @@
node_modules
img
examples
doc
dist
test
webpack.config.js
@@ -0,0 +1,23 @@
parser: babel-eslint
env:
browser: true
es6: true
extends: 'eslint:recommended'
globals:
Atomics: readonly
SharedArrayBuffer: readonly
parserOptions:
ecmaVersion: 2018
sourceType: module
rules:
indent:
- error
- tab
quotes:
- error
- single
semi:
- error
- always
no-console:
- error

This file was deleted.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

This file was deleted.

@@ -44,13 +44,13 @@
"size": "retweets",
"community": "community"
},
"Troll": {
"Troll": {
"caption": "screen_name",
"size": "pagerank",
"community": "community"
}
}
//"sizeCypher": "MATCH (n) WHERE id(n) = {id} MATCH (n)-[r]-() RETURN sum(r.weight) AS c"
//"sizeCypher": "MATCH (n) WHERE id(n) = {id} MATCH (n)-[r]-() RETURN sum(r.weight) AS c"
},
relationships: {
@@ -74,14 +74,14 @@


Cypher query: <textarea rows="4" cols=50 id="cypher"></textarea><br>
<input type="submit" value="Submit" id="reload">
<input type="submit" value="Stabilize" id="stabilize">
<input type="submit" value="Submit" id="reload">
<input type="submit" value="Stabilize" id="stabilize">


</body>

<script>
$("#reload").click(function() {
$("#reload").click(function () {
var cypher = $("#cypher").val();
@@ -95,7 +95,7 @@
});
$("#stabilize").click(function() {
$("#stabilize").click(function () {
viz.stabilize();
})
@@ -3,14 +3,26 @@
"version": "1.0.0",
"description": "Graph visualizations powered by vis.js with data from Neo4j.",
"main": "./dist/neovis.js",
"module": "./dist/neovis-without-dependencies.js",
"directories": {
"doc": "doc",
"example": "examples",
"test": "test"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"build": "webpack"
"eslint": "eslint .",
"prepublishOnly": "npm run build",
"prepublish": "npm run build",
"clean": "rimraf ./dist",
"build": "run-s clean build:prod",
"build-dev": "run-s clean build:dev",
"build:prod": "run-p build:prod:*",
"build:prod:with-dependencies": "cross-env BUILD_WITH_DEPENDENCIES=true webpack --mode=production",
"build:prod:without-dependencies": "webpack --mode=production",
"build:dev": "run-p build:dev:*",
"build:dev:with-dependencies": "cross-env BUILD_WITH_DEPENDENCIES=true webpack --mode=development",
"build:dev:without-dependencies": "webpack --mode=development"
},
"repository": {
"type": "git",
@@ -24,10 +36,27 @@
},
"homepage": "https://github.com/neo4j-contrib/neovis.js#readme",
"devDependencies": {
"css-loader": "^0.28.0",
"file-loader": "^0.11.1",
"style-loader": "^0.16.1",
"url-loader": "^0.5.8",
"webpack": "^2.3.3"
"@babel/cli": "^7.4.4",
"@babel/core": "^7.4.5",
"@babel/plugin-proposal-class-properties": "^7.4.4",
"@babel/preset-env": "^7.4.5",
"babel-loader": "^8.0.6",
"cross-env": "^5.2.0",
"css-loader": "^2.1.1",
"eslint": "^5.16.0",
"file-loader": "^3.0.1",
"npm-run-all": "^4.1.5",
"rimraf": "^2.6.3",
"style-loader": "^0.23.1",
"url-loader": "^1.1.2",
"webpack": "^4.32.2",
"webpack-cli": "^3.3.2"
},
"dependencies": {
"babel-eslint": "^10.0.1",
"core-js": "3",
"neo4j-driver": "^1.7.5",
"regenerator-runtime": "^0.13.2",
"vis": "^4.21.0"
}
}
@@ -1,71 +1,71 @@

const defaults = {
const defaults = {

neo4j: {
initialQuery: `MATCH (n) WHERE exists(n.pagerank)
neo4j: {
initialQuery: `MATCH (n) WHERE exists(n.pagerank)
WITH (n), RAND() AS random
ORDER BY random LIMIT 3000
OPTIONAL MATCH (n)-[r]-(m)
//WITH n,r,m WHERE exists(n.pagerank) AND exists(m.pagerank) AND exists(m.community)
RETURN n, r, m;`,
neo4jUri: "bolt://localhost:7687",
neo4jUser: "neo4j",
neo4jPassword: "neo4j",
encrypted: "ENCRYPTION_OFF",
trust: "TRUST_ALL_CERTIFICATES"
},
neo4jUri: 'bolt://localhost:7687',
neo4jUser: 'neo4j',
neo4jPassword: 'neo4j',
encrypted: 'ENCRYPTION_OFF',
trust: 'TRUST_ALL_CERTIFICATES'
},

visjs: {
interaction: {
hover: true,
hoverConnectedEdges: true,
selectConnectedEdges: false,
// multiselect: true,
multiselect: 'alwaysOn',
zoomView: false,
experimental: { }
},
physics: {
barnesHut: {
damping: 0.1
}
},
nodes: {
mass: 4,
shape: 'neo',
labelHighlightBold: false,
widthConstraint: {
maximum: 40
},
heightConstraint: {
maximum: 40
}
},
edges: {
hoverWidth: 0,
selectionWidth: 0,
smooth: {
type: 'continuous',
roundness: 0.15
},
font: {
size: 9,
strokeWidth: 0,
align: 'top'
},
color: {
inherit: false
},
arrows: {
to: {
enabled: true,
type: 'arrow',
scaleFactor: 0.5
}
}
}
visjs: {
interaction: {
hover: true,
hoverConnectedEdges: true,
selectConnectedEdges: false,
// multiselect: true,
multiselect: 'alwaysOn',
zoomView: false,
experimental: { }
},
physics: {
barnesHut: {
damping: 0.1
}
},
nodes: {
mass: 4,
shape: 'neo',
labelHighlightBold: false,
widthConstraint: {
maximum: 40
},
heightConstraint: {
maximum: 40
}
},
edges: {
hoverWidth: 0,
selectionWidth: 0,
smooth: {
type: 'continuous',
roundness: 0.15
},
font: {
size: 9,
strokeWidth: 0,
align: 'top'
},
color: {
inherit: false
},
arrows: {
to: {
enabled: true,
type: 'arrow',
scaleFactor: 0.5
}
}
}

}
}
};

export { defaults };
@@ -2,37 +2,37 @@ export const CompletionEvent = 'completed';

export class EventController {

constructor() {
this._handlers = {
[CompletionEvent]: [],
};
}
constructor() {
this._handlers = {
[CompletionEvent]: [],
};
}

/**
/**
*
* @param {string} eventType Type of the event to be handled
* @param {callback} handler Handler to manage the event
* @param {string} eventType - Type of the event to be handled
* @param {callback} handler - Handler to manage the event
*/
register(eventType, handler) {
if (this._handlers[eventType] === undefined) {
throw new Error('Unknown event: ' + eventType);
}
register(eventType, handler) {
if (this._handlers[eventType] === undefined) {
throw new Error('Unknown event: ' + eventType);
}

this._handlers[eventType].push(handler);
}
this._handlers[eventType].push(handler);
}

/**
/**
*
* @param {string} eventType Type of the event generated
* @param {dictionary} value Values associated to the event
* @param {string} eventType - Type of the event generated
* @param {object} values - Values associated to the event
*/
generateEvent(eventType, values) {
if (this._handlers[eventType] === undefined) {
throw new Error('Unknown event: ' + eventType);
}
generateEvent(eventType, values) {
if (this._handlers[eventType] === undefined) {
throw new Error('Unknown event: ' + eventType);
}

for (const handler of this._handlers[eventType]) {
handler(values);
}
}
for (const handler of this._handlers[eventType]) {
handler(values);
}
}
}

0 comments on commit 9444015

Please sign in to comment.
You can’t perform that action at this time.