d3.js

Changing the size of arrow boxes of the sunburst visualization

六月ゝ 毕业季﹏ 提交于 2020-01-04 13:34:31
问题 I am using Kerry Rodden's fork open source d3 and html script for sunburst visualization. https://github.com/mojoaxel/d3-sunburst It works on my data but I have longer labels so it is overlapping in the legend arrows on top left. I am not coming from html/css background so not able to figure out which element in the code needs to be changed to get the right alignment. This is how it looks currently: If you see top left has text overlapping the boxes. I want to elongate the box or reduce the

Same repeatable string values using a band scale

元气小坏坏 提交于 2020-01-04 13:26:27
问题 I'm newbie in D3 and want to draw chart with 6 horizontal bars. My xAxis is scaleLinear with their values. So I want yAxis to be just a list with each bar name. So for yScale I have 6 names - ['Games', 'Apps', 'Games', 'Apps', 'Games', 'Apps'] So when I use this yScale: var params = ['Games', 'Apps', 'Games', 'Apps', 'Games', 'Apps']; var yScale = d3.scaleBand() .domain(params) .range([0, 300]) I see only one 'Games' and one 'Apps' on yAxis How to list all of the params on yAxis and not to

D3.JS - how do I add gridlines to my pie chart

久未见 提交于 2020-01-04 09:36:05
问题 I have extended the pie-chart example at: with pies that vary in radius depending on a percentage. I would like to add gridlines (circles) every 20 percent, but I can't figure out how. here is the updated csv: age,population,percent <5,2704659,67 5-13,4499890,38 14-17,2159981,91 18-24,3853788,49 25-44,14106543,71 45-64,8819342,88 =65,612463,64 and here is the updated code with pie-parts of different radius: <!DOCTYPE html> <meta charset="utf-8"> <style> body { font: 10px sans-serif;

Unexpected value NaN parsing y attribute

北慕城南 提交于 2020-01-04 09:12:10
问题 I am finding the error somewhere here: d3.csv("Sales Export Friendly 2-14-2017.csv", function(data) { var sales = [] sales = data.map(function(d) { return [ +d["BookingID"], +d["Total Paid"] ]; }); var x = d3.scaleBand() .domain(sales.map(function(sale){ return sale.bookingID; })) .range([0, width]) .paddingInner([0.1]) var y = d3.scaleLinear() .range([height, 0]) .domain([0, d3.max(sales.map(function(sale){ return sale['Total Paid']; }))]); I believe it's something to do with the first

Unexpected value NaN parsing y attribute

蹲街弑〆低调 提交于 2020-01-04 09:12:10
问题 I am finding the error somewhere here: d3.csv("Sales Export Friendly 2-14-2017.csv", function(data) { var sales = [] sales = data.map(function(d) { return [ +d["BookingID"], +d["Total Paid"] ]; }); var x = d3.scaleBand() .domain(sales.map(function(sale){ return sale.bookingID; })) .range([0, width]) .paddingInner([0.1]) var y = d3.scaleLinear() .range([height, 0]) .domain([0, d3.max(sales.map(function(sale){ return sale['Total Paid']; }))]); I believe it's something to do with the first

D3 V4 Hierarchical Edge Bundling port from v3

无人久伴 提交于 2020-01-04 06:58:33
问题 I'm struggling to port a graph to V4. here is the one I'm working on: https://bl.ocks.org/mbostock/7607999 I've tried to follow the instructions provided here: d3 v4 Hierarchical Edge Bundling but to no avail. I've gotten the labels to layout correctly but the edge bundles render incorrectly. here's what I have: var diameter = 960, radius = diameter / 2, innerRadius = radius - 120; var cluster = d3.cluster() .size([360, innerRadius]); const line = d3.line() .x(d => d.x) .y(d => d.y) .curve(d3

d3-tip npm module not working with browserify

女生的网名这么多〃 提交于 2020-01-04 06:53:07
问题 First I installed d3-tip with npm install d3-tip v0.6.7 then browserify'd my project without any issues. My js looks like the following var d3 = require("d3"); var d3tip = require("d3-tip"); var tip = d3tip() .attr('class', 'd3-tip') .offset([-10, 0]) .html(function(d) { return "<strong>Hello World:</strong>"; }); The error I get is: TypeError: d3 is undefined in my bundle.js yet I'm using d3 elsewhere in my code without issue which makes me believe the error is in the npm module for d3 tip

D3.js: Transferring the value of one attribute to another attribute, for a specific FDG node?

核能气质少年 提交于 2020-01-04 06:07:09
问题 I'm using a force directed graph that appends circles to each node. As part of the node creation, I first set the radius "r" of each node circle to a default and consistent value (defaultNodeSize = 10). This successfully draws a cluster where all related nodes are the same size. // Append circles to Nodes node.append("circle") .attr("x", function(d) { return d.x; }) .attr("y", function(d) { return d.y; }) .attr("r", function(d) { if (d.id==focalNodeID) { return centerNodeSize; } else { return

Need help coloring in countries from an array, leave rest default color

风流意气都作罢 提交于 2020-01-04 05:46:17
问题 I need some help taking the data from an array I created and then coloring only the countries that exist in the array in color, the rest of the countries that are not in the array I want left as default color. I am using D3 to do all of this, and I am pretty sure I can achieve what I need to via D3, but unsure how. What I want to do, is take the country codes via data2 array, and based on their rank color them in dark red to green. my array: var data2 = [{name:"United Kingdom", country_code:

How to do animation of sequential data with d3.js?

白昼怎懂夜的黑 提交于 2020-01-04 05:33:27
问题 I have a sequential data. Data is an array divided into 30 steps. In the first step I draw initial data. Then I take data from second step, compare it with data from previous step. And make some animation/transition. Now I want to repeat animation for the rest of 28 steps. If I will use code like this var old_data = start_data; for (var i = 0, i < rest_data.length; i++){ var new_data = rest_data[i]; var diff_data = diff(old_data, new_data); var t0 = d3.transition().duration(3000); var