d3.js

D3.js animate rotation

…衆ロ難τιáo~ 提交于 2019-12-28 08:39:26
问题 I'm having trouble when I try to correctly execute a rotation animation using the D3.js library. The problem has to do with the point at which I want to rotate the element about. Here is a fiddle I made to show what I mean (in slow motion): http://jsfiddle.net/74mCb/ It seems like the source of the problem lies here: .attr("transform", "rotate(-60, 150,130)"); And then I rotate it like so: .attr("transform", "rotate(40 150,130)"); I would like the butt of the needle to stay in position (to be

d3js Tree square

被刻印的时光 ゝ 提交于 2019-12-28 07:39:29
问题 I would like to use d3.js to build a pedigree tree. All exemples that I found are showcasing organic trees. Are there any exemples out there with a pedigree like style ? 回答1: You could accomplish this using either the cluster or tree layouts. And using a custom path generator to draw orthogonal lines connecting nodes, as in this elbow dendrogram. I guess I was feeling inspired so I gave it a shot: http://bl.ocks.org/2966094 回答2: I recently created some examples of using D3 to draw pedigrees

d3.js Lasso Drawing Polygon Shape Search Tool - on a google map (getting the coordinates/users in a given area) [closed]

為{幸葍}努か 提交于 2019-12-28 06:54:27
问题 Closed . This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 5 years ago . Trying to build a location search app, that displays a google map - on the user drawing on the map it reveals any users that are located within that region. I've also found this example - but it seems clunky/unsmooth - http://jsfiddle.net/pPMqQ/34/ http://jsfiddle.net/4xXQT/156/ var width = 960,

Fit Text into SVG Element (Using D3/JS)

只谈情不闲聊 提交于 2019-12-28 06:01:07
问题 I want to write text inside a rectangle I create as follows: body = d3.select('body') svg = body.append('svg').attr('height', 600).attr('width', 200) rect = svg.append('rect').transition().duration(500).attr('width', 150) .attr('height', 100) .attr('x', 40) .attr('y', 100) .style('fill', 'white') .attr('stroke', 'black') text = svg.append('text').text('This is some information about whatever') .attr('x', 50) .attr('y', 150) .attr('fill', 'black')​ However, as you can see (http://jsfiddle.net

Getting Screen Positions of D3 Nodes After Transform

懵懂的女人 提交于 2019-12-28 05:05:07
问题 I'm trying to get the screen position of a node after the layout has been transformed by d3.behavior.zoom() but I'm not having much luck. How might I go about getting a node's actual position in the window after translating and scaling the layout? mouseOver = function(node) { screenX = magic(node.x); // Need a magic function to transform node screenY = magic(node.y); // positions into screen coordinates. }; Any guidance would be appreciated. EDIT: 'node' above is a force layout node, so it's

Add text label to d3 node in Force directed Graph and resize on hover

懵懂的女人 提交于 2019-12-28 03:40:08
问题 I am trying to add text label to nodes in d3 Force Directed Graph, there seems to be an issue. This is my Fiddle: When I add the node name like this: node.append("text") .attr("class", "word") .attr("dy", ".35em") .text(function(d) { console.log(d.name); return d.name; }); There's no change but the names are getting logged. When i tried using bounding box , the node labels appeared but the nodes are stacked up on the top-left corner of box while the node links are fine.This fiddle is the

Convert JavaScript-generated SVG to a file

允我心安 提交于 2019-12-28 03:39:08
问题 I am using d3.js to visualize some data. I would like to be able to take the SVG code that it generates and store it as a .svg image file (for editing in Inkscape/Illustrator). I have tried simply copying the contents of the svg tag i.e. <svg> <!--snip--> </svg> into a file called image.svg, but this misses out on the color/styling information, which is in two separate CSS files. I'm working with this example. Is there a simple way to do this? 回答1: I think SVG Crowbar may be the best way to

How do I return y coordinate of a path in d3.js?

孤者浪人 提交于 2019-12-28 01:54:05
问题 I have a graph, and I want the line representing the graph to show a circle at the x coordinate when hovering on top of the svg area. This circle should follow the path of the line that represents the curve. The problem is that I don't know how to do this. The code below shows how far I have succeded, and it indeed adds a circle to the document at the right x coordinate. Now, what do I replace the question mark with? svg.on("mousemove", function() { d3.select("path.line") .style("stroke-width

clicking a node in d3 from a button outside the svg

为君一笑 提交于 2019-12-28 01:43:05
问题 I have created a force directed graph using D3 and displayed the id of the nodes in a normal div. I need to highlight the node whose id has been clicked in the div. I have searched the id of the node and using normal javascript tried to click it but it does not work. 回答1: More generally, if the user interacts with element A , how do you select (and then modify) related elements B ? There are many ways of achieving this, but here are three common approaches. Option 1. For one-to-one mappings,

D3.js - Donut charts with multiple rings

*爱你&永不变心* 提交于 2019-12-28 00:58:12
问题 The following example shows a donut chart in D3.js, is it possible to add more than one ring to the chart? var dataset = { apples: [53245, 28479, 19697, 24037, 40245], }; var width = 460, height = 300, radius = Math.min(width, height) / 2; var color = d3.scale.category20(); var pie = d3.layout.pie() .sort(null); var arc = d3.svg.arc() .innerRadius(radius - 100) .outerRadius(radius - 50); var svg = d3.select("body").append("svg") .attr("width", width) .attr("height", height) .append("g") .attr