d3.js

extend x and y axis length in scatterplot, d3js

爷,独闯天下 提交于 2021-02-05 07:06:15
问题 I am trying to extend the x and y axis length and add the arrow at the end. Here is my code and plunker. I need x axis to extend beyond 4.6 and y-axis beyond "AS" and add an arrow at the end. Kindly help. https://plnkr.co/edit/tA6oyKQCCmhNadbARR89?p=preview var margin = {top: 20, right: 20, bottom: 20, left: 40}, width = 420 - margin.left - margin.right, height = 500 - margin.top - margin.bottom; var x = d3.scale.linear() .range([0, width]); var y = d3.scale.ordinal().rangePoints([height, 0])

reverse how vertical bar chart is drawn

拥有回忆 提交于 2021-02-05 07:05:23
问题 How can I reverse how my vertical bar is drawn? I want it to be drawn from the bottom to the top. It is important to maintain the right representation of the dataset https://jsfiddle.net/adai183/ztsh1ptx/ var dataset = [ 10, 80, 5, 5]; //Create SVG element var svg = d3.select("body") .append("svg") .attr("width", w) .attr("height", h); svg.selectAll("rect") .data(dataset) .enter() .append("rect") .attr("fill", "rgb(250, 128, 114)") .attr("x", function(d, i) { return i * (w / dataset.length);

reverse how vertical bar chart is drawn

若如初见. 提交于 2021-02-05 07:04:50
问题 How can I reverse how my vertical bar is drawn? I want it to be drawn from the bottom to the top. It is important to maintain the right representation of the dataset https://jsfiddle.net/adai183/ztsh1ptx/ var dataset = [ 10, 80, 5, 5]; //Create SVG element var svg = d3.select("body") .append("svg") .attr("width", w) .attr("height", h); svg.selectAll("rect") .data(dataset) .enter() .append("rect") .attr("fill", "rgb(250, 128, 114)") .attr("x", function(d, i) { return i * (w / dataset.length);

Create artificial zoom transform event

白昼怎懂夜的黑 提交于 2021-02-05 05:49:12
问题 I have a timeline in D3 with a highly modified drag/scroll pan/zoom. The zoom callbacks use the d3.event.transform objects generated by the zoom behavior. I need to add a programmatic zoom that uses my existing callbacks. I have tried and tried to do this without doing so, but I haven't gotten it to work and it would be radically easier and faster to reuse the existing structure. So the input is a new domain, i.e. [new Date(1800,0), new Date(2000,0)] , and the output should be a new d3.event

D3.js的v5版本入门教程(第十二章)—— D3.js中各种精美的图形

假如想象 提交于 2021-02-05 03:06:04
D3.js的v5版本入门教程(第十二章) D3中提供了各种制作常见图形的函数,在d3的v3版本中叫布局,通过d3.layout.xxx,来新建,但是到了v5,新建一个d3中基本的图形的方式变了(我也并不知道是不是还叫布局,我觉得也可以这么叫,反正布局指的也是一个绘图函数) 下面是d3中一些常见的部分图形 bubble —— 泡泡图 packing —— 打包图 bundling —— 捆图 force —— 力导向图 chord —— 弦图 pie——饼状图 tree——树状图 中国地图 我们利用下面的四章,分布讲解饼状图、力导向图、树状图和中国地图 ———————————————— 版权声明:本文为CSDN博主「数星星等天明」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。 原文链接:https://blog.csdn.net/qq_34414916/article/details/80035926 来源: oschina 链接: https://my.oschina.net/u/4300698/blog/3382530

d3.js V3 force directed graph and unlinked nodes

吃可爱长大的小学妹 提交于 2021-02-04 21:47:29
问题 I'm doing my first data visualization project. It's more for practice, and to learn d3.js as data visualization interests me. My first project is making a force directed graph. The data set is the 50 states linked to their bordering states. The source is the state, the target is the bordering state(s). Hawaii and Alaska have no bordering States. If I leave the target State blank in the csv file, they attach to each other with a middle node that is an empty string. If I make their targets

d3.js V3 force directed graph and unlinked nodes

余生颓废 提交于 2021-02-04 21:43:39
问题 I'm doing my first data visualization project. It's more for practice, and to learn d3.js as data visualization interests me. My first project is making a force directed graph. The data set is the 50 states linked to their bordering states. The source is the state, the target is the bordering state(s). Hawaii and Alaska have no bordering States. If I leave the target State blank in the csv file, they attach to each other with a middle node that is an empty string. If I make their targets

radial gradients for multiple arcs in d3

。_饼干妹妹 提交于 2021-02-04 21:19:30
问题 I have the following arc diagram: I would like to add a gradient to each of the individual arcs, that flows from the outer radius to the inner radius of each individual arc. I am guessing that I will need to create an individual gradient for each arc? let radius = 100; for(let i = 0; i < 5; i ++) { let grad = defs.append('radialGradient') .attr('id', 'mygrad' + i) .attr('gradientUnits', 'userSpaceOnUse') .attr('cx', '0') .attr('cy', '0') .attr('r', radius) grad.append('stop') .attr('offset',

radial gradients for multiple arcs in d3

 ̄綄美尐妖づ 提交于 2021-02-04 21:16:58
问题 I have the following arc diagram: I would like to add a gradient to each of the individual arcs, that flows from the outer radius to the inner radius of each individual arc. I am guessing that I will need to create an individual gradient for each arc? let radius = 100; for(let i = 0; i < 5; i ++) { let grad = defs.append('radialGradient') .attr('id', 'mygrad' + i) .attr('gradientUnits', 'userSpaceOnUse') .attr('cx', '0') .attr('cy', '0') .attr('r', radius) grad.append('stop') .attr('offset',

D3 Mouse Move on Two Graphs at once

血红的双手。 提交于 2021-02-04 18:49:57
问题 How can I capture the mouse over events of two graphs at once. I need to do something like shown in the image below: Can anyone guide me as to how should I approach this ?. So far I was able to get the simple mouseover working for a single graph. 回答1: I'm the author of function-plot which is able to dispatch events to multiple graphs one of them being mouseover , for example var width = 300 var height = 180 var a = functionPlot({ target: '#a', height: height, width: width, data: [{ fn: 'x^2'