d3.js

How to read in CSV with d3 v4?

你离开我真会死。 提交于 2019-12-29 05:22:08
问题 I'm just having a little trouble understanding the documentation for CSV Parse with D3. I currently have: d3.parse("data.csv",function(data){ salesData = data; }); But I keep on getting the error: Uncaught TypeError: d3.parse is not a function What is this supposed to look like? I'm just a little confused, and the only examples that I could find was something like this. I also tried something like: d3.dsv.parse("data.csv",function(data){ salesData = data; }); and got: Uncaught TypeError:

d3.js Sankey diagram: rectangles fill color

对着背影说爱祢 提交于 2019-12-29 04:24:31
问题 So I am playing around with the d3.js Sankey diagram. In this example (pictured above) color is defined using var color = d3.scale.category20(); For each node there is a rectangle, and that rectangle is filled by altering the style: .style("fill", function(d) { return d.color = color(d.name.replace(/ .*/, "")); }) I'm looking for suggestions on using custom colors. If I wanted to use only say 6 colors, but have the node rectangle colors chosen based on a value in the .json file. For example,

Live drawing of a line in D3.js [closed]

隐身守侯 提交于 2019-12-29 03:33:12
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 6 years ago . I'm just started with D3.js, and I want to create something like what we do in Paint to draw a line. The steps are should be the same: - Click on a point on the screen - Drag to the destination to create a line. What I'm having troubles now is when you drag your mouse to the destination, the line should move

D3, nested appends, and data flow

人盡茶涼 提交于 2019-12-29 02:45:10
问题 I'm in the process of finally learning D3, and I stumbled upon a problem that I haven't been able to find an answer to. I'm not certain if my question is because I'm not thinking idiomatically with the library, or if it is because of a procedure that I am currently unaware of. I should also mention that I've only started doing web-related things in June, so I'm fairly new to javascript. Say that we're building a tool that gives a user a list of foods with respective images. And lets add on

How to dynamically display a multiline text in D3.js?

ぐ巨炮叔叔 提交于 2019-12-28 22:13:33
问题 I need to display a multiline text in a SVG:Text using D3.js. The sample data looks as follows and I want to display "all" the "titles" under a single node for every author and not as an individual node in a force directional layout. Sample data { {"author":"Author1", "group":"fiction", "books" : [ {"title":"Book Title1", "rating":3}, {"title":"Book Title2", "rating":4} ]}, {"author":"Author2", "group":"non-fiction", "books" : [ {"title":"Book Title3", "rating":3}, ]} } SVG:text takes only

How to dynamically display a multiline text in D3.js?

元气小坏坏 提交于 2019-12-28 22:12:51
问题 I need to display a multiline text in a SVG:Text using D3.js. The sample data looks as follows and I want to display "all" the "titles" under a single node for every author and not as an individual node in a force directional layout. Sample data { {"author":"Author1", "group":"fiction", "books" : [ {"title":"Book Title1", "rating":3}, {"title":"Book Title2", "rating":4} ]}, {"author":"Author2", "group":"non-fiction", "books" : [ {"title":"Book Title3", "rating":3}, ]} } SVG:text takes only

SVG marker-mid on specific point on path

浪子不回头ぞ 提交于 2019-12-28 16:06:44
问题 I got some code that generates pathes on canvas. the path objects looks similar to this : <path class="link" d="M450,215.L265,236L225,236" style="stroke-width: 1;"></path> and on view (a,b,c letters are just for explaining the problem): My problem is that I want to draw some arrow (marker) on the middle of the line, between "a" to "b", but when I create a marker and do a marker-mid attribute, its generates on b point. I've tried to do some point between a and b, but then marker-mid did the

How to disable legend in nvd3 or limit it's size

本小妞迷上赌 提交于 2019-12-28 14:22:10
问题 I'm using nvd3 and have a few charts where the legend is much to large. E.g. a scatter/bubble with 15 groups and the group names are long. The legend is so large that it leaves almost no room for the chart itself. Is there a way to remove the legend or toggle the legend or limit the height/width it is taking up? Any example would be great. Also, is there a way to have the bubble show a descriptive string? Right now when you stand on top of a bubble it highlights the x/y coordinates. I also

How to select parent element of current element in d3.js

和自甴很熟 提交于 2019-12-28 11:50:08
问题 I want to access the parent element of current element Here is the structure of HTML svg g id=invisibleG g circle g circle g circle Basically I want to add text inside the circles when I hover over them. So I want something like this on hover of any particular circle svg g id=invisibleG g circle --> radius is increased and text presented inside that text g circle g circle On hover I can select current element through d3.select(this),How can I get root element(g in my case)? 回答1: You can use

d3 csv data loading

牧云@^-^@ 提交于 2019-12-28 10:06:09
问题 I am trying to adapt a simple scatterplot program in D3 to accept a CSV file. When I use the data in the file it works just fine, but when I try to load the CSV file it simply won't work. Is there something simple I am missing? The contents of the CSV file "datatest.csv" are the same as the dataset in the code. I have checked that the browser is loading the data, and it seems to all be there. I figure I'm simply missing a step. <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8">