d3.js

Getting a better performance on repeatedly method on d3 line generator

天大地大妈咪最大 提交于 2019-12-25 10:31:02
问题 I've been struggling the past few days to optimize performance on a D3. I'm using a line generator on the SVG and would like to calculate only one time the function used in the x and y . For example: d3.line().curve(d3.curveLinear) .x(function(d){ return Math.sqrt(d) } .y(function(d){ return Math.sqrt(d) + 2) I I would like to save the result of Math.sqrt(d) and compute only one time. Does anyone have any suggestions? 回答1: You could store the result in your first function, and use it in the

adding class names to arcs from data in d3.layout.pie()

独自空忆成欢 提交于 2019-12-25 10:01:31
问题 I'm creating a pie chart from a JSON file. I wonder if there is a way I can take some names from the JSON file and assign them as class names of the arcs created by d3.layout.pie(). Here is an example I created: http://blockbuilder.org/jinlong25/532d889e01d02cef2d24 Essentially, I want to do something like the last line of code below: var data = [ { 'name': 'apple', 'value': 250 }, { 'name': 'banana', 'value': 100 }, { 'name': 'orange', 'value': 150 } ]; var arcs = svg.selectAll('g.arc')

Why are the .selectAll() D3-created circles in my SVG said to be 1 element using .length?

依然范特西╮ 提交于 2019-12-25 09:59:45
问题 I suspect that the answer lies somewhere between my ignorance of what kind of object I'm actually working and the inner darkness of D3 and/or SVG. I can see 30 circles on the screen. So I go in the console like this. var circles = d3.select("#svg1").selectAll("circle"); >undefined circles; >[Array[30]]... circles.length; >1 I know I'm targeting the right elements because executing .remove() on the set clears them from the screen. But what's up with the count? 回答1: var circles = d3.select("

Why are the .selectAll() D3-created circles in my SVG said to be 1 element using .length?

时间秒杀一切 提交于 2019-12-25 09:58:51
问题 I suspect that the answer lies somewhere between my ignorance of what kind of object I'm actually working and the inner darkness of D3 and/or SVG. I can see 30 circles on the screen. So I go in the console like this. var circles = d3.select("#svg1").selectAll("circle"); >undefined circles; >[Array[30]]... circles.length; >1 I know I'm targeting the right elements because executing .remove() on the set clears them from the screen. But what's up with the count? 回答1: var circles = d3.select("

d3 ordering column rule based on JSON response

对着背影说爱祢 提交于 2019-12-25 09:43:47
问题 I have this d3 function that generates a table based on my data's JSON output function tabulate(data, columns) { $("body").css("padding-top", "10px") var table = d3.select('#response').append('table').attr('class', 'table table-bordered table-hover') var thead = table.append('thead') var tbody = table.append('tbody'); thead.append("tr") .selectAll("th") .data(columns).enter() .append("th") .text(function(column) { return column; }); var rows = tbody.selectAll('tr') .data(data) .enter()

How to drag the nodes in US Map created using D3

穿精又带淫゛_ 提交于 2019-12-25 09:27:43
问题 I have created a US Network Map and Now I am trying to give the drag option to the nodes because in some case the nodes have the same longitude and latitude because of this we can't differentiate the nodes, but I am unable to give that option. I have created a js fiddle for this.Kindly have a look on it and please provide me some solution. https://jsfiddle.net/AmitSah/po9vvm1x/ var svg = d3.select("svg"), width = +svg.attr("width"), height = +svg.attr("height"), radius = 10; /*svg.call(d3

Disable resize of brush on range chart from focus charts (dc.js, d3.js) - Solved

二次信任 提交于 2019-12-25 09:26:59
问题 Please note - there is a solution for part of this problem by Gordon Woodhull in Disable brush on range chart before selecting a scale from the dropdown/on page load(dc.js,d3.js) In addition,there is a partial solution at the end this question. Furthermore there are two fiddles: 1) https://jsfiddle.net/dani2011/4dsjjdan/1/ 2) https://jsfiddle.net/dani2011/uzg48yk7/1/ (with partial solution) Need to disable resize of the brush on range chart (timeSlider) by dragging the line within the focus

D3/JS mapping a JSON data callback

故事扮演 提交于 2019-12-25 09:26:09
问题 I have seen many examples with d3.csv() callback mappings such as: var data = raw_data.map(function(d) { return variable1 : +d.variable1, variable2 : +d.variable2 }); However I'm trying to figure out how to use map.() for a JSON callback. The reason being is I have a attribute d: expected number, "MaNn", "NaNz" error. This error if I'm not mistaken, is often associated with data being parsed as a string. The JSON looks to be in numbers/floats, but just in case D3 is parsing my data as strings

D3 nesting and object traversal

和自甴很熟 提交于 2019-12-25 09:14:36
问题 i have a json as shared below and I am trying to nest the data prior to visualization. I wish to plot under gov and non-gov how every vendor is distributed for high and low projects so trying to create a json object like [{v1: {Gov: {high:3, low:2}, {Non-Gov: {high:12, low:1}}}, {v2:{Gov: {high:3, low:2}, {Non-Gov: {high:12, low:1}}}, ...] I am able to nest the data but unable to get the respective counts. Any guidance is appreciated. Apologies if the question construct is vague. [ { "vendor"

Resize the SVGs according to windows size

99封情书 提交于 2019-12-25 08:57:31
问题 Here's how's the D3.js look currently What I want to achieve is that, when I resize the windows four tables inside needs resize accordingly. No new tables are added. Currently it just keep adding new tables inside. How to correct this behavior? The content of 1.json [ [[1,3,3,5,6,7],[3,5,8,3,2,6],[9,0,6,3,6,3],[3,4,4,5,6,8],[3,4,5,2,1,8]], [[1,3,3,5,6,7],[3,5,8,3,2,6],[9,0,6,3,6,3],[3,4,4,5,6,8],[3,4,5,2,1,8]], [[1,3,3,5,6,7],[3,5,8,3,2,6],[9,0,6,3,6,3],[3,4,4,5,6,8],[3,4,5,2,1,8]], [[1,3,3,5