d3.js

stacking transforms in D3

旧街凉风 提交于 2020-01-02 05:32:07
问题 I have an SVG element with a transform already applied to it (this could be a single translate, or a combination of multiple transforms). I'm trying to apply additional transform to it. Problem is that this transform could be applied repeatedly and needs to stack with the existing transform state (so appending additional transforms to the end is not practical). Looking through d3 API, I didn't notice anything that lets me apply a relative transform (although I must admit, I'm not that

Hide some graphic elements, c3js, without unloading data

烈酒焚心 提交于 2020-01-02 04:46:13
问题 Is it possible to hide certain lines, bars and other graphic elements from a c3js chart, without unloading or hiding data? I wish to keep that data in the tooltip but hide some graphic elements. Hover over one bar and see data for other hidden bars. I know about the hide method - chart.hide(['data2', 'data3']); - but this also deletes the data from the tooltip. My question is not discussed in the documentation it seems. A similar issue in November was not solved. I don't have any code right

d3.js: Zoom on click event

房东的猫 提交于 2020-01-02 04:36:10
问题 I was trying to get same behavior Wil Linssen's implementation but on d3.js version 4. I am quite confused with zoom api in version 4. The changes that I made in the original implementation is: zoom.translate() replaced with d3.zoomTransform(selection.node()) and appropriate points added instead: svg.attr("transform", "translate(" + t.x + "," + t.y + ")" + "scale(" + t.k + ")" ); This one: zoom .scale(iScale(t)) .translate(iTranslate(t)); replaced to var foo = iTranslate(t); zoom. translateBy

D3 update on node removal always remove the last entry in SVG DOM

被刻印的时光 ゝ 提交于 2020-01-02 04:31:06
问题 I'm seeing a weird behaviour in my D3 application and after hours of trying to figure out what's happening I hope someone can point me at the thing I obviously do wrong. I have simplified the app down to be very simple and still exhibit the problem. As you'll see it's derived from all the great D3 examples out there. The simple scenario I have an issue with is: select a node (by clicking on it) and, upon hitting the delete key remove said node along with all related links and labels of both

Force Directed Graph Error, “Cannot Read Property 'Push' of Undefined”

馋奶兔 提交于 2020-01-02 04:10:13
问题 I am new to coding and recently began using d3 to generate a force directed graph. I successfully generated a four node graph when using the links to derive the nodes. However, when I explicitly list the nodes I receive the error "Uncaught TypeError: Cannot read property 'push' of undefined (d3.v3.min.js)". I have studied responses to the following two similar questions but have been unable to resolve this issue using the answers. I attempted to remove as many of the non-relevant features as

SVG circles don't get repositioned when zooming leaflet map

扶醉桌前 提交于 2020-01-02 03:27:08
问题 I'm using d3 to add svg circles on leaflet map. My fiddle is here http://jsfiddle.net/nextstopsun/C3U8g/ I've added a reset() function to map viewreset event to calculate transformation for svg g element containing all circles. This function is called on map viewreset event. svg.attr("width", topRight[0] - bottomLeft[0]) .attr("height", bottomLeft[1] - topRight[1]) .style("margin-left", bottomLeft[0] + "px") .style("margin-top", topRight[1] + "px"); g.attr("transform", "translate(" +

Adding a specific tick to a D3.js axis

£可爱£侵袭症+ 提交于 2020-01-02 03:01:06
问题 I've created an axis with d3.svg.axis and a time scale and am happy with the ticks produced by the tick generator. However, I would like to ensure that a particular value is always marked. So for example the if the generator produces the following dates 2000-1-1, 2001-1-1, 2002-1-1, 2003-1-1 I might want to make the axis show 2000-1-1, 2000-7-21 , 2001-1-1, 2002-1-1, 2003-1-1 How do i get an array of the ticks made by the tick generator so that I can add my value and pass it into the

How do I specify domain in d3.scale.ordinal() ?

青春壹個敷衍的年華 提交于 2020-01-02 02:43:08
问题 var W = 100; var H = 200; var data = [{v:4}, {v:8}, {v:15}, {v:16}, {v:23}, {v:42}]; var x = d3.scale.linear().domain([0, max_x]).range([0, W]); var y = d3.scale.ordinal().domain([0, 1, 2, 3, 4, 5]).rangeBands([0, H]); How do I automatically enumerate the domain of data without typing it out e.g., 0, 1, 2, 3 I have tried domain(data) , and domain([0, data.length]) , but I need all the values in between. 回答1: If you want the domain of the ordinal scale to be the indexes of your data, then use

dc datatable without grouping the rows

£可爱£侵袭症+ 提交于 2020-01-02 02:43:07
问题 Is it possible to have a dc data table without showing the data in groups? I just want to show all the data across all groups! My code is as follows: dc.dataTable(".dc-data-table") .dimension(dateDimension) .group(function (d) { return '' }) .size(10) // (optional) max number of records to be shown, :default = 25 .columns([ function (d) { return getFormattedDate(d.dd); }, function (d) { return d.referredfor; }, function (d) { return numberFormat(d.cost); }, function (d) { return d.gender; } ]

d3.js: vertical alignment of text in a donut chart

女生的网名这么多〃 提交于 2020-01-01 22:03:08
问题 I've got a simple donut chart in d3.js, which will only be used to compare 2 or 3 items. http://jsfiddle.net/Ltqu2/ I want to combine the legend and values as text in the center of the chart. In the current implementation, the text alignment is ok for 3 items, but for 2 items it doesn't adjust. The alignment is somewhat hard coded: var l = svg.selectAll('.legend') .data(data) .enter().append('g') .attr('class', 'legend'); l.append('text') .attr('x', 0) .attr('y', function(d, i) { return i *