sankey-diagram

d3 Sankey - Highlight all connected paths from start to end

戏子无情 提交于 2019-12-18 15:55:51
问题 I'm trying to highlight all the connected links and links of their target nodes till the end of the layout. The first level of highlighting can be easily achieved as follows - On node click, call highlight_paths(1) ; function highlight_paths(stroke_opacity) { return function(d,i){ d.sourceLinks.forEach(function(srcLnk){ d3.select("#link"+srcLnk.id).style("stroke-opacity", stroke_opacity); }); d.targetLinks.forEach(function(srcLnk){ d3.select("#link"+srcLnk.id).style("stroke-opacity", stroke

Sankey diagram in R

痴心易碎 提交于 2019-12-18 13:28:21
问题 Attempting to make a fairly generic Sankey diagram with the help of R's networkD3 package. Just for reference--here's the example from the package's manual library(networkD3) library(jsonlite) library(magrittr) energy <- "https://cdn.rawgit.com/christophergandrud/networkD3/master/JSONdata/energy.json" %>% fromJSON sankeyNetwork(Links = energy$links, Nodes = energy$nodes, Source = "source", Target = "target", Value = "value", NodeID = "name", units = "TWh", fontSize = 12, nodeWidth = 30) which

Place text values to right of sankey diagram

微笑、不失礼 提交于 2019-12-18 05:53:31
问题 Is there a trick to placing text on a sankey diagram rendered using networkD3? I would like to have the values of the endpoints be displayed as text to the right of their boxes. I realize that hovering over the boxes displays the value, but as the boxes get smaller it would be much easier in many cases to portray the information if the values were always visible on the side. Here is an example; I was able to kinda hack it by adding the values as part of the labels, but it would be much better

Customizing the sankey chart to cater large datasets

社会主义新天地 提交于 2019-12-17 21:25:24
问题 kindly run the script below, I have created a Sankey chart in R and plotly using data from "patients" dataset of the bupaR library. Please see the snapshot for reference. The issue I am facing is that, this custom plot has been built by declaring and building each and every relationship between users("r1","r2",etc.) and activities("Registration","X-Ray, etc). If I have a large number of users and activities, it will become a very tedious task to declare each and every relation. Please help me

Sankey Diagrams in R?

断了今生、忘了曾经 提交于 2019-12-17 02:54:30
问题 I am trying to visualize my data flow with a Sankey Diagram in R. I found this blog post linking to an R script that produces a Sankey Diagram, unfortunately it's quite raw and somewhat limited (see below for sample code and data). Does anyone know of other scripts—or maybe even a package—that is more developed? My end goal is to visualize both data flow and percentages by relative size of diagram components, like in these examples of Sankey Diagrams. I posted a somewhat similar question on

Group alluvia in the R alluvial diagram

浪子不回头ぞ 提交于 2019-12-14 01:21:46
问题 In the alluvial package, is it possible to combine those alluvia that have the same source and target nodes? For example the two dark alluvia in the image below, that both go through AB and 3. Edit: Here is an example using the Titanic dataset, which shows the same behaviour: # Titanic data tit <- as.data.frame(Titanic) tit3d <- aggregate( Freq ~ Class + Sex + Survived, data=tit, sum) ord <- list(NULL, with(tit3d, order(Sex, Survived)), NULL) alluvial(tit3d[,1:3], freq=tit3d$Freq, alpha=1, xw

D3 sankey diagram - enforce node position

◇◆丶佛笑我妖孽 提交于 2019-12-13 06:59:24
问题 Using the D3 Sankey plugin, I'm updating a Sankey diagram with new values (on changing the data, passing new values for the nodes and links -- keeping all of them consistent). Is there functionality like d3.treemap's sticky to maintain node and link orders on the page? If not, is there an approach to building this? var sankey = d3.sankey() .nodeWidth(15) .nodePadding(10) .size([width, height]); .sticky(true) I'm following the pattern here: http://bost.ocks.org/mike/sankey/ 回答1: No, there isn

Connecting two Sankey diagrams in matplotlib

别等时光非礼了梦想. 提交于 2019-12-13 00:16:42
问题 I'm trying to represent a country's gas balance using matplotlib. The idea is that there are three sources of imported gas which I want to plot using one Sankey and connect it to another Sankey which has other sources of gas (production, gas storages) and gas consumers as outflows. I tried it many times but I cannot connect two graphs together . Each of the graphs separately plots as designed. But as soon as I add "prior=0, connect=(3,0)" which supposedly connects two graphs together

Adding additional label value when clicked on Sankey Chart lines in R shiny

允我心安 提交于 2019-12-12 21:25:43
问题 The following R shiny script creates a sankey chart as in the snapshot below. My requirement is that when I click on any link between the nodes on left and right i.e. "a1" and "a2", I want the total sum of corresponding "a3" to be present in the label. For Illustration, "A" in a1 and "E" in a2 together have value 50 and 32. So, I want to see 82 in the label when clicked on link, please help and thanks. Similary for all other a1,a2 pairs. Some tweak is needed in the list() function in server

Increasing d3 SVG container size

匆匆过客 提交于 2019-12-12 18:08:06
问题 I am trying to increase the size of my SVG container dynamically so that it fits all the data. There is a fiddle which explains the dynamic increase of the SVG: http://jsfiddle.net/CKW5q/ However, the same concept doesn't work for a bi-directional sankey chart(d3). Following is the function called to expand the parentnode: function expand(node) { node.state = "expanded"; node.children.forEach(function (child) { child.state = "collapsed"; child._parent = this; child.parent = null;