d3.js

How can I detect the intersection of lines on a D3 geo globe?

戏子无情 提交于 2020-01-14 03:20:09
问题 I've been playing around with several d3 globes: Rotating globe Rotating orthographic Morphing map projections And I've put this together: Great circle graph My goal is to show that this graph can be 3 colored. The problem I'm having is that the method of drawing lines involves using the orthographic projection of "LineString" paths. In the globe I linked above, my "great circles" are coded in this way: // poles svg.append("path") .datum({type: "LineString", coordinates: [[0, -180], [0, -90],

Change the color of the legend text in forceNetwork for networkD3

老子叫甜甜 提交于 2020-01-14 03:04:14
问题 Using forceNetwork from the networkD3 R package, how can I change the color of the text in the legend to white? My Code: library(networkD3) forceNetwork(Links = subLinkList, Nodes = subNodes, Source = "root", Target = "children", Value = "linkValue", NodeID = "nodeName", Nodesize = "nodeSize", Group = "nodeGroup", colourScale = JS(colorScale), charge = -500, opacity = 1, opacityNoHover = 1, fontSize = 25, fontFamily = "Calibri", linkDistance = JS('function(){d3.select("body").style(

How can I run a javascript as a node.js script without the DOM?

非 Y 不嫁゛ 提交于 2020-01-14 02:44:34
问题 https://github.com/jasondavies/d3-cloud is a word cloud in javascript using D3 library. This is an interactive demo. The demo used the d3-cloud script to generate an SVG in the HTML. I would like to use this on the server side and get node.js to generate me an SVG file and save it to the disk whenever I update my data instead of loading the D3 library to the browser and rendering it there. Is there a way to do this? Can I use libraries that seem to rely on the HTML DOM without the DOM? I am

How to get quantile of object array

爷,独闯天下 提交于 2020-01-14 01:49:18
问题 I have an object array, called dataArray , where one object is like this: { id, x, y } now I want to have the lower quantile of this array by using d3. I thought about something like this: quartile = d3.quantile(dataArray, 0.25, function(d) {return d.y}) but unfortunately there is no accessor option for this method. How can I get the quantile of a property from an object array ? Thanks in advance 回答1: I found the solution to my problem. I need to get an array of only a certain property of an

How to get quantile of object array

别来无恙 提交于 2020-01-14 01:49:12
问题 I have an object array, called dataArray , where one object is like this: { id, x, y } now I want to have the lower quantile of this array by using d3. I thought about something like this: quartile = d3.quantile(dataArray, 0.25, function(d) {return d.y}) but unfortunately there is no accessor option for this method. How can I get the quantile of a property from an object array ? Thanks in advance 回答1: I found the solution to my problem. I need to get an array of only a certain property of an

How to get quantile of object array

房东的猫 提交于 2020-01-14 01:49:10
问题 I have an object array, called dataArray , where one object is like this: { id, x, y } now I want to have the lower quantile of this array by using d3. I thought about something like this: quartile = d3.quantile(dataArray, 0.25, function(d) {return d.y}) but unfortunately there is no accessor option for this method. How can I get the quantile of a property from an object array ? Thanks in advance 回答1: I found the solution to my problem. I need to get an array of only a certain property of an

Can we add event listeners to “Vega-Lite” specification?

夙愿已清 提交于 2020-01-13 19:52:11
问题 I am new to Vega and Vega-Lite. I am creating a simple bar chart using Vega-Lite but I am not able to add any event listeners e.g. "hover". I want to hover a bar and change the color of the bar. 回答1: If you're using Vega-Embed, it returns a promise with a reference to the view which allows you to use addEventListener - explained in the docs here. Here is an example: const width = 600 const color = blue embed(element, { $schema: 'https://vega.github.io/schema/vega-lite/3.0.0-rc6.json', data: {

Trying to link object and text when dragging in v4

泄露秘密 提交于 2020-01-13 19:18:25
问题 I have been trying to learn enough about d3.drag to integrate it into a sankey diagram for v4 similar to this example. The start point was Mikes circle dragging example here which I tried to integrate with the object+text drag implementation here. Tragically I can't quite work out how to grab the 'g' element using d3.drag. There have been several iterations over the past few days, but I think the closest I have come is the example below which will only grab a specific rectangle for dragging

Y axis labels are cut off on D3 plot

六月ゝ 毕业季﹏ 提交于 2020-01-13 18:10:11
问题 I have this multi-line plot with D3: But as you can see, the beginning of the y-axis labels are cut off - anybody know how I can properly display the full label? And if you have any advice on how to rotate the x-axis labels by 90 degrees, that would help too. Here is the complete code which generates the plot: <!DOCTYPE html> <html lang='en'> <head> <link href='http://getbootstrap.com/dist/css/bootstrap.min.css' rel='stylesheet'> <link href='http://getbootstrap.com/examples/justified-nav

What is the different between d3.max() vs. math.max() in d3.js?

家住魔仙堡 提交于 2020-01-13 17:05:53
问题 I'm trying to understand the code from http://bl.ocks.org/d3noob/e34791a32a54e015f57d I don't get the part where the code trying to scale the data below : // Scale the range of the data x.domain(d3.extent(data, function(d) { return d.date; })); y0.domain([0, d3.max(data, function(d) { return Math.max(d.close); })]); y1.domain([0, d3.max(data, function(d) { return Math.max(d.open); })]); Why would we have to use d3.max and also need Math.max within the return statement ? shouldn't d3.max(data,