d3.js-v4

'scale' and 'svg' does not exist in “node_modules/@types/d3/index”

China☆狼群 提交于 2019-12-06 21:47:38
问题 I am trying to create a bar graph using Angular 2 and D3 JS, below are NPM packages I added: "d3": "4.4.0", "d3-tip": "0.7.1", "@types/d3": "^4.3.0", Below typescript file gave error while compiling: import { Component, ElementRef, ViewEncapsulation } from '@angular/core'; import * as d3 from 'd3'; @Component({ selector: 'simple-bar-chart', template: require('./about.component.html'), styles: [require('./about.component.css').toString()] }) export class AboutComponent { constructor(public

d3.js v4 wacky link transition in collapsible tree example

坚强是说给别人听的谎言 提交于 2019-12-04 12:34:05
问题 If you play with the collapsible tree below you'll see that when you get to the end of the tree, and expand and collapse the nodes the lines are doing some wacky stuff and I am no entirely sure what drives the behavior or if my rewriting of enter link description here is completely off base. I went off a flat data structure and used stratify to transform it into a tree layout. The only issue so far is the line transitions...any thoughts? var data = [{ "name": "Hazer 5000", "parent": "CFO",

Constraining map panning with zoom.translateExtent in D3 v4

醉酒当歌 提交于 2019-12-04 04:42:34
I'm trying to display a map of a single state, with zooming and panning constrained to the boundaries of the state. It's mostly working, except for the panning constraint when the state path is scaled to fit a smaller container. I think this comes down to me not understanding what arguments to use for zoom.translateExtent (although I'm very new to this, so it could be something else). Live example on bl.ocks.org, with links to prior art . One notable thing is that I'm using a null projection for d3.geoPath , because I used ogr2ogr to generate a shapefile in projected coordinates for each state

d3.js v4 wacky link transition in collapsible tree example

瘦欲@ 提交于 2019-12-03 08:00:47
If you play with the collapsible tree below you'll see that when you get to the end of the tree, and expand and collapse the nodes the lines are doing some wacky stuff and I am no entirely sure what drives the behavior or if my rewriting of enter link description here is completely off base. I went off a flat data structure and used stratify to transform it into a tree layout. The only issue so far is the line transitions...any thoughts? var data = [{ "name": "Hazer 5000", "parent": "CFO", "img": "https://s3-us-west-2.amazonaws.com/s.cdpn.io/t-342/stephen.jpg" }, { "name": "Employee 1",

d3.js rewriting zoom example in version4

孤人 提交于 2019-12-02 23:16:52
Drag and Drop Example I am trying to rewrite part of this example above to use in my code, specifically this piece: function centerNode(source) { scale = zoomListener.scale(); x = -source.y0; y = -source.x0; x = x * scale + viewerWidth / 2; y = y * scale + viewerHeight / 2; d3.select('g').transition() .duration(duration) .attr("transform", "translate(" + x + "," + y + ")scale(" + scale + ")"); zoomListener.scale(scale); zoomListener.translate([x, y]); } However I am getting stuck since the v4 package has changed quite a bit. I wrote my zoomListener function to be var zoomListener = d3.zoom()

Issue with updating d3 interactive matrix scatterplot to v4

风格不统一 提交于 2019-12-02 10:10:09
问题 I'm trying to improve my skills with D3.js by updating various v3 scripts I'm interested in to v4, but I got stuck while trying to "port" the interactive scatterplot matrix that Mike Bostok posted here: https://bl.ocks.org/mbostock/4063663 While I've ported with no problem the static version of the code (with no brush), when trying to implement the brush in the same fashion as in v3, I have found an issue that seems an actual D3 problem more than being related to my D3 noob-ness: brush seems

Typescript/D3 v4 - Context of this in d3.drag().on(“end”, this.dragended)

断了今生、忘了曾经 提交于 2019-12-01 18:33:16
I am using the D3 library to move an item within a Venn-diagram. When I stop dragging I want to determine the position of the item in the diagram. item.call(d3.drag() .on("start", this.dragstarted) .on("drag", this.dragged) .on("end", this.dragended) ); These are the functions I call when the dragging starts, is going on and ends. dragended(d: TCMemberScenario, i: number) { d3.select(this).classed("active", false); d.calculateRoles(); this.save(); } This is the function that is called when the dragging has ended. I update some things in the diagram and then I want to call the save method. This

Typescript/D3 v4 - Context of this in d3.drag().on(“end”, this.dragended)

痴心易碎 提交于 2019-12-01 17:31:37
问题 I am using the D3 library to move an item within a Venn-diagram. When I stop dragging I want to determine the position of the item in the diagram. item.call(d3.drag() .on("start", this.dragstarted) .on("drag", this.dragged) .on("end", this.dragended) ); These are the functions I call when the dragging starts, is going on and ends. dragended(d: TCMemberScenario, i: number) { d3.select(this).classed("active", false); d.calculateRoles(); this.save(); } This is the function that is called when

Ordinal scale behaviour

微笑、不失礼 提交于 2019-12-01 09:01:27
I would like to create an ordinal scale with one to one correspondence between range and domain. I would expect that values/strings that do not belong to the domain would return nothing. Instead I get the following behaviour: var x = d3.scaleOrdinal().domain(['a', 'b', 'c']).range([10, 20, 30]) x('d') 10 x('e') 20 x('f') 30 Is there any logic behind this behaviour? Maybe I am missing something, but I couldn't find something out there. Gerardo Furtado That's the expected behaviour of an ordinal scale. Actually, D3 scales (quantitative or qualitative) are made in such a way that you can pass

D3.js nesting and rollup at the same time in v4

丶灬走出姿态 提交于 2019-12-01 08:51:41
I have a very similar task as D3.js nesting and rollup at same time and solution provided by @altocumulus for d3.js v3 works perfectly fine for me (tested). However, I am using d3.js v4 across my website and I am having difficulties replicating the same approach with v4 - I am not getting the same results. Perhaps, because I don't understand the sumChildren function. Please feel free to provide a better or different approach on how to restructure the loaded csv file as json with subtotals at every node level using d3.js v4. In my case, I need to have Population at the Country, State and the