Comments (4)
I guess that's something you can figure out yourself. It's just javascript :)
from neo4j-3d-force-graph.
Thanks a lot,
I'm really just wrapping his amazing work. I think you saw the example for "text as nodes".
I saw you already raised an issue with him.
If you look at his code example I guess the easiest is to draw a background circle on the canvas instead of a rect here:
https://github.com/vasturiano/force-graph/blob/master/example/text-nodes/index.html#L26
from neo4j-3d-force-graph.
Please let me know how it goes.
from neo4j-3d-force-graph.
I just quickly took his demo and changed it a bit:
Looks like this now:
<head>
<style> body { margin: 0; } </style>
<script src="//unpkg.com/force-graph"></script>
<!--<script src="../../dist/force-graph.js"></script>-->
<script src="//unpkg.com/d3-quadtree"></script>
<script src="//unpkg.com/d3-force"></script>
</head>
<body>
<div id="graph"></div>
<script>
fetch('../datasets/miserables.json').then(res => res.json()).then(data => {
const Graph = ForceGraph()
(document.getElementById('graph'))
.graphData(data)
.d3Force('collide', d3.forceCollide(50))
.nodeId('id')
.nodeAutoColorBy('group')
.nodeCanvasObject((node, ctx, globalScale) => {
const label = node.id;
const fontSize = 12/globalScale;
ctx.font = `${fontSize}px Sans-Serif`;
const textWidth = ctx.measureText(label).width;
const bckgDimensions = [textWidth, fontSize].map(n => n + fontSize * 0.2); // some padding
ctx.fillStyle = node.color; // 'rgba(255, 255, 255, 0.8)';
ctx.beginPath();
const radius = Math.max(bckgDimensions[0],bckgDimensions[1])/2 + 2;
ctx.arc(node.x, node.y, radius, 0, 2 * Math.PI);
ctx.globalAlpha = 0.3;
ctx.fill();
ctx.stroke();
ctx.globalAlpha = 1;
// ctx.fillRect(node.x - bckgDimensions[0] / 2, node.y - bckgDimensions[1] / 2, ...bckgDimensions);
ctx.textAlign = 'center';
ctx.textBaseline = 'middle';
ctx.fillStyle = node.color;
ctx.fillText(label, node.x, node.y);
});
});
</script>
</body>
from neo4j-3d-force-graph.
Related Issues (9)
- not showing any nodes when using with my neo4j HOT 5
- onClick "reload" button won't rerender the graph into the newly* edited query
- Regarding Relationship Captions HOT 1
- particles, color, incremental, index
- Render from database without reload HOT 1
- sample cannot open HOT 5
- Color of nodes HOT 2
- Hi, there, when I apply it to my laptop localhost, it failed. HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from neo4j-3d-force-graph.