d3.js

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

风流意气都作罢 提交于 2020-12-15 07:55:20
问题 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",

d3 zoom pan to specific region of line graph

余生长醉 提交于 2020-12-15 07:17:27
问题 I see a lot of tutorials and resources for zooming and panning based on click events, but I have a line graph that I want the user to be able to zoom into based on clicking buttons which align with certain data ranges. [Specifically: the graph is initiated using all data, but when the user clicks on either 1, 2, or 3 use some effect that shows they're "zooming" into a subset of the graph] I tried using a transform in the code below but it looks a little wonky. I think I want something closer

Cannot use attr with an object in D3 v4

北战南征 提交于 2020-12-15 06:50:40
问题 I've been trying to convert a nice D3 chart example ( https://jsfiddle.net/thudfactor/HdwTH/ ) to an Angular2 component with the new D3 v4. I do however get a "cannot read property text of null" exception with the following code: var textLabels = labelGroups.append("text").attr({ x: function (d, i) { var centroid = pied_arc.centroid(d); var midAngle = Math.atan2(centroid[1], centroid[0]); var x = Math.cos(midAngle) * cDim.labelRadius; var sign = (x > 0) ? 1 : -1 var labelX = x + (5 * sign)

d3.js change circle radius on mouse events [duplicate]

巧了我就是萌 提交于 2020-12-15 06:20:37
问题 This question already has an answer here : Cannot use attr with an object in D3 v4 (1 answer) Closed 3 months ago . I have circles that I've drawn in d3.js v5. I'm getting the mouse over events as expected, and I can log stuff to the console and everything looks right. The only part that isn't working is when I try and set the radius to be larger. The radius size isn't changing. function handleMouseOver(d, i) { console.log("over ", d, i); console.log("this", this) d3.select(this).attr({ r: 8

dc.js: Bar chart on subset of data

混江龙づ霸主 提交于 2020-12-13 12:15:11
问题 I have data in format [ { "date": dt1, "action": "T", "isRequest": "", "delay": 0 }, { "date": dt1, "action": "C1", "isRequest": "R", "delay": 10 }, { "date": dt1, "action": "T", "isRequest": "", "delay": 0 }, { "date": dt1, "action": "C2", "isRequest": "R", "delay": 20 }, { "date": dt1, "action": "T", "isRequest": "", "delay": 0 }, ... ] Main bar chart is about counts (1 line in array), all delays chart is about delay distribution (attribute delay) Filtering by date main graph, changes data

How to implement the html variables for a graphic from d3.js

北战南征 提交于 2020-12-13 03:46:43
问题 I would like to do a donut-chart in d3.js. Basically the idea would be to write 3 inputs and it should be displayed this way: Unfortunatelly I cannot make it, I am not sure about how to implement the variables fuel, fuel 2 and fuel 3 in the javascript code, I am not sure wether it has to be indicated in the html code or in the javascript code. Thanks in advance. <meta charset="utf-8"> <!-- Load d3.js --> <script src="https://d3js.org/d3.v4.js"></script> <div> <input type="number" id="fuel"

How to interact JQuery slider with d3 vertical lines for every data point

隐身守侯 提交于 2020-12-13 03:20:56
问题 I am trying to create an interactive slider zooming and filtering into a data range using vertical line from each data point selected. I am not sure how to draw every vertical lines on each data point so the slider can zoom and filter vertical lines on this data range. Currently, I can draw circles on every data point and one vertical line (see attached output graph), but would like to draw vertical lines on top of those circles or just for each data point if d3 has some way to do it. I am

How to interact JQuery slider with d3 vertical lines for every data point

梦想的初衷 提交于 2020-12-13 03:20:25
问题 I am trying to create an interactive slider zooming and filtering into a data range using vertical line from each data point selected. I am not sure how to draw every vertical lines on each data point so the slider can zoom and filter vertical lines on this data range. Currently, I can draw circles on every data point and one vertical line (see attached output graph), but would like to draw vertical lines on top of those circles or just for each data point if d3 has some way to do it. I am

how to show D3.js HTML graph in Github

北战南征 提交于 2020-12-13 03:09:58
问题 I tried to let d3.js graph can show in github.But failed.Does it have any methods to solve this problem. I had pushed d3 html graph into github.Because it didn't render,so I could not see the plot. 回答1: You could try using GitHub Pages to turn your repository into a website. Then the javascript will actually run. 来源: https://stackoverflow.com/questions/25903179/how-to-show-d3-js-html-graph-in-github

how to show D3.js HTML graph in Github

人盡茶涼 提交于 2020-12-13 03:08:46
问题 I tried to let d3.js graph can show in github.But failed.Does it have any methods to solve this problem. I had pushed d3 html graph into github.Because it didn't render,so I could not see the plot. 回答1: You could try using GitHub Pages to turn your repository into a website. Then the javascript will actually run. 来源: https://stackoverflow.com/questions/25903179/how-to-show-d3-js-html-graph-in-github