d3.js

How to find a DOM element by its text content?

房东的猫 提交于 2020-12-31 05:28:33
问题 I try to add new SVG elements to some nodes. For that purpose the nodes the elements are to be added to have to be found by a string contained in there text content, e.g. find any node which has "id0" inside the <text> tag. Here is example of my HTML hierarchy: <pre> <svg> <g> <g> <text> id3 </text> <text> 73% </text> <svg> ... </svg> </g> <g> <svg> ... </svg> </g> <g> <text> id0 </text> <text> 11% </text> <svg> ... </svg> </g> <g> <text> id1 </text> <text> 66% </text> <svg> ... </svg> </g>

D3.js — Ordinal scale (version 3 to version 4)

时光总嘲笑我的痴心妄想 提交于 2020-12-29 09:19:28
问题 I am taking an Udemy's course on D3.js. Unfortunately because of the new version D3.js came out, there aren't any up-to-date tutorials on their new syntax so I am glancing at their API's wiki. That being said, I've been stuck on how to translate this code (version 3). I am learning ordinal scale var data = [ {key: "Glazed", value: 132}, {key: "Jelly", value: 71}, {key: "Holes", value: 337}, {key: "Sprinkles", value: 93}, {key: "Crumb", value: 78}, {key: "Chocolate", value: 43}, {key: "Coconut

svg / d3.js rounded corner on one corner of a rectangle

人走茶凉 提交于 2020-12-27 06:06:17
问题 I know svg has an in built function to do rounded corners, but I need to do rounded corners on only 2 of the four corners. I know I can draw multiple rectangles on top of each other to imitate that, but that seems kind of cheesy. Any way to do it using clipping or any d3.js method? Right now I have a horizontal bar graph that has rects like: rects.enter().append("rect") .attr("x",function(d,i) { return x(0); }) .attr("width",function(d) { return x(d.value) - x(0); }) .attr("height",y

D3js Updating Histogram elements not working (General Update Pattern)

眉间皱痕 提交于 2020-12-26 11:18:31
问题 I am trying to accomplish something similar to what is here : https://www.opportunityatlas.org/. If you proceed further to this link and click on 'Show Distribution' to see the graph and select 'On Screen' and then move the cursor around the map you will see the size of the rectangles changes and also the update patterns works i.e. if a rectangle was already there it moves horizontally to the new value. I have tried doing the same but could not achieve the update part . Could you please point

D3js Updating Histogram elements not working (General Update Pattern)

橙三吉。 提交于 2020-12-26 11:18:20
问题 I am trying to accomplish something similar to what is here : https://www.opportunityatlas.org/. If you proceed further to this link and click on 'Show Distribution' to see the graph and select 'On Screen' and then move the cursor around the map you will see the size of the rectangles changes and also the update patterns works i.e. if a rectangle was already there it moves horizontally to the new value. I have tried doing the same but could not achieve the update part . Could you please point

D3js Updating Histogram elements not working (General Update Pattern)

不羁岁月 提交于 2020-12-26 11:18:09
问题 I am trying to accomplish something similar to what is here : https://www.opportunityatlas.org/. If you proceed further to this link and click on 'Show Distribution' to see the graph and select 'On Screen' and then move the cursor around the map you will see the size of the rectangles changes and also the update patterns works i.e. if a rectangle was already there it moves horizontally to the new value. I have tried doing the same but could not achieve the update part . Could you please point

Why my D3 line graphs shows black areas for each entity?

若如初见. 提交于 2020-12-26 06:40:17
问题 I made a webscraper that gets data about currency transfer rates of different banks and shows that in a D3 line graph over time (each bank has a line, and the rates are per day). A cronjob server-side makes sure the scraping occurs daily. In the front-end, it uses D3.json to get data from this url: http://rateswebscraper.herokuapp.com/rates I made the line graph but instead of a line for every bank, it shows a black area, see screenshot below: Here is my code: /*global d3*/ var margin = { top

Why my D3 line graphs shows black areas for each entity?

一笑奈何 提交于 2020-12-26 06:39:38
问题 I made a webscraper that gets data about currency transfer rates of different banks and shows that in a D3 line graph over time (each bank has a line, and the rates are per day). A cronjob server-side makes sure the scraping occurs daily. In the front-end, it uses D3.json to get data from this url: http://rateswebscraper.herokuapp.com/rates I made the line graph but instead of a line for every bank, it shows a black area, see screenshot below: Here is my code: /*global d3*/ var margin = { top

How to prevent the drag if the user clicks the round in d3.js?

左心房为你撑大大i 提交于 2020-12-15 07:56:07
问题 I have group element it has circle and rect elements. User can drag the group element, so both rect and circle element will move. It is working fine. But I need to prevent the drag if the user clicks on the circle element. JS Fiddle const x = 100; var y = 100; var grid = d3.select("#svg-area"); var g = grid.append("g") .attr("transform", `translate(${x},${y})`) .call(d3.drag() .on("drag", function() { var x1 = d3.event.x - 30; var y1 = d3.event.y - 10; d3.select(this).attr("transform",

How to prevent the drag if the user clicks the round in d3.js?

五迷三道 提交于 2020-12-15 07:56:00
问题 I have group element it has circle and rect elements. User can drag the group element, so both rect and circle element will move. It is working fine. But I need to prevent the drag if the user clicks on the circle element. JS Fiddle const x = 100; var y = 100; var grid = d3.select("#svg-area"); var g = grid.append("g") .attr("transform", `translate(${x},${y})`) .call(d3.drag() .on("drag", function() { var x1 = d3.event.x - 30; var y1 = d3.event.y - 10; d3.select(this).attr("transform",