d3 add text to circle

Here is an example showing some text in circles with data from a json file: http://bl.ocks.org/4474971. Which gives the following: The main idea behind this is to encapsulate the text and the circle in the same “div” as you would do in html to have the logo and the name of the company in the … Read more

Highlight selected node, its links, and its children in a D3 force directed graph

The error is because you are selecting the data objects (d.source and d.target) rather than the DOM elements associated with those data objects. You’ve got the line highlighting working, but I would probably combine your code into a single iteration, like this: link.style(“opacity”, function(o) { return o.source === d || o.target === d ? 1 … Read more

Convert a directory structure in the filesystem to JSON with Node.js

Here’s a sketch. Error handling is left as an exercise for the reader. var fs = require(‘fs’), path = require(‘path’) function dirTree(filename) { var stats = fs.lstatSync(filename), info = { path: filename, name: path.basename(filename) }; if (stats.isDirectory()) { info.type = “folder”; info.children = fs.readdirSync(filename).map(function(child) { return dirTree(filename + “https://stackoverflow.com/” + child); }); } else { … Read more

Fix Node Position in D3 Force Directed Layout

Set d.fixed on the desired nodes to true, and initialize d.x and d.y to the desired position. These nodes will then still be part of the simulation, and you can use the normal display code (e.g., setting a transform attribute); however, because they are marked as fixed, they can only be moved by dragging and … Read more

Understanding how D3.js binds data to nodes

When you write: ….data(someArray).enter().append(‘foo’); D3 creates a bunch of <foo> elements, one for each entry in the array. More importantly, it also associates the data for each entry in the array with that DOM element, as a __data__ property. Try this: var data = [ {msg:”Hello”,cats:42}, {msg:”World”,cats:17} ]; d3.select(“body”).selectAll(“q”).data(data).enter().append(“q”); console.log( document.querySelector(‘q’).__data__ ); What you will … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)