d3.js

D3: use d3.max to get containing object?

纵饮孤独 提交于 2020-01-24 11:34:04
问题 I have the following data, an array of objects: var data = [ { x: 0, y0: 0, y: 100 }, { x: 1, y0: 0, y: 150 }, { x: 2, y0: 50, y: 100 }, { x: 3, y0: 50, y: 150 } ] I'd like to find the object with the biggest discrepancy between y and y0 , using D3. I can do this to get the biggest difference: var max_val = d3.max(data, function(d) { return d.y - d.y0;} ); It returns 150. But what I don't know how to do is get the containing object, and learn that the corresponding value of x is 1. Any ideas?

How to fill an image inside my svg circles in d3.js

家住魔仙堡 提交于 2020-01-24 09:48:05
问题 This is my piece of code filling circles in my svg. var svgContainer = d3.select("body").append("svg") .attr("width", 1000) .attr("height", 1000); var circles = svgContainer.selectAll("circle") .data(nodes) .enter() .append("circle"); var circleAttributes = circles .attr("cx", function (d) { return d.x_axis; }) .attr("cy", function (d) { return d.y_axis; }) .attr("r", function (d) { return d.radius; }) .attr('fill', 'green') But instead of filling green color inside my circles, I want to fill

SVG clip-path works in Chrome, but not in Firefox or Safari

♀尐吖头ヾ 提交于 2020-01-24 09:13:42
问题 I'm drawing a rather complex line chart with D3. It uses brushing for zooming into the data (used http://bl.ocks.org/mbostock/1667367 as inspiration). While it works perfectly fine in Chrome, the chart-line ignores the borders specified with clip-path (see the attached picture) in Firefox and Safari, and I have no idea why. CSS: clip-path: url(#mainChartClip); JS: // Clip = borders the canvas for zoom svg.append('defs') .append('clipPath') .attr('id', 'mainChartClip') .append('rect') .attr(

d3 GeoJSON geoCircle ellipse equivalent

元气小坏坏 提交于 2020-01-24 09:13:24
问题 The title pretty much says it all. I'm looking for a convenient way to generate a geoJSON polygon defining an ellipse similar to d3-geo's d3.geoCircle()(); I want to use this GeoJSON ellipse with d3-geo. To clarify with and example, Cesium has this capability with a simple function allowing you to create an ellipse like so: var ellipse = new Cesium.EllipseGeometry({ center : Cesium.Cartesian3.fromDegrees(-75.59777, 40.03883), semiMajorAxis : 500000.0, semiMinorAxis : 300000.0, rotation :

Ho do I capture ctrl + click on MacOS with d3js

只谈情不闲聊 提交于 2020-01-24 09:12:05
问题 I got a report that my script which should trigger on ctrl + click does not work on Mac. Like shown in "Determine if Shift key is pressed during mousedown event" we can determine if modifier keys are pressed during a mouse click testing d3.event.shiftKey , d3.event.ctrlKey etc. The shift detection works everywhere but ctrl does not seem to work on MacOS. d3.select(window).on("click", function() { if (d3.event.ctrlKey) { alert("Mouse + Ctrl pressed"); } }); <script src="https://cdnjs

d3.js, click action to another URL encoding with array of variables of sunburst

[亡魂溺海] 提交于 2020-01-24 07:29:27
问题 I made sequences sunburst visualization and want to add a link to each path. I read similar question d3.js, click to link to another URL encoded with variables and could make a link based on variable of specific path. (See the code below) This Code could generate url suck like "http://somelink.com/link.php?id1=CurrentNode". However, I want to generate url such like "http://somelink.com/link.php?id1=CurrentNode&id2=ParentNode" using hierarchy information. I do not know very much about

d3.js, click action to another URL encoding with array of variables of sunburst

徘徊边缘 提交于 2020-01-24 07:29:11
问题 I made sequences sunburst visualization and want to add a link to each path. I read similar question d3.js, click to link to another URL encoded with variables and could make a link based on variable of specific path. (See the code below) This Code could generate url suck like "http://somelink.com/link.php?id1=CurrentNode". However, I want to generate url such like "http://somelink.com/link.php?id1=CurrentNode&id2=ParentNode" using hierarchy information. I do not know very much about

d3.js, click action to another URL encoding with array of variables of sunburst

一个人想着一个人 提交于 2020-01-24 07:29:04
问题 I made sequences sunburst visualization and want to add a link to each path. I read similar question d3.js, click to link to another URL encoded with variables and could make a link based on variable of specific path. (See the code below) This Code could generate url suck like "http://somelink.com/link.php?id1=CurrentNode". However, I want to generate url such like "http://somelink.com/link.php?id1=CurrentNode&id2=ParentNode" using hierarchy information. I do not know very much about

d3 (v4) tree layout and typescript: Property 'x' does not exist on type 'HierarchyNode<IOrgChartNode>'

房东的猫 提交于 2020-01-24 06:26:45
问题 I am trying to use proper ts types while using a d3.hierarchy root with a tree layout, e.g.: interface MyCustomGraphType { id: string; children?: MyCustomGraphType[] } let treeData: MyCustomGraphType = {/*...*/}; let root = d3.hierarchy(treeData); let layout = d3.tree().size([500,500])(root); let nodes = layout.descendants(); // BIND DATA (Node) let node = this.nodesGroup.selectAll('g.node') .data(nodes, d => d.data.person.email); // <--- compile-time error // ^^^ Property 'data' does not

Change size of bubble in Scatter Plot for c3.js

馋奶兔 提交于 2020-01-24 03:05:30
问题 I have a scatter plot charge where i want to change the size of the dots to make them look like bubble. Can someone show me how to change size of the bubble? Here is my code: var chart = c3.generate({ data: { xs: { IBM: 'ibm_x', Microsoft: 'microsoft_x', }, columns: [ ["ibm_x", 3.5, 3.0, 3.2, 3.1, 3.6, 3.9, 3.4, 3.4, 2.9, 3.1, 3.7, 3.4, 3.0, 3.0, 4.0, 4.4, 3.9, 3.5, 3.8, 3.8, 3.4, 3.7, 3.6, 3.3, 3.4, 3.0, 3.4, 3.5, 3.4, 3.2, 3.1, 3.4, 4.1, 4.2, 3.1, 3.2, 3.5, 3.6, 3.0, 3.4, 3.5, 2.3, 3.2, 3.5