sankey-diagram

Modify networkD3 sankey plot with user-defined colors

别等时光非礼了梦想. 提交于 2019-12-03 07:40:20
I have a sankey plot created in networkD3 package. I would like to modify the colors and transparency of both nodes and links. My data networkD3_data is appended at the end. Question 1: How to modify node colors with user-defined palette? I am not sure how to modify the colors with user-defined palette. It is necessary for me to use the same color palette specific to each node source to keep consistent with other plots I have. Currently I am able to have each source node be a different color and all target nodes to be same color by defining the NodeGroup . The plot below is close to what I

D3 Sankey chart using circle node instead of rectangle node

让人想犯罪 __ 提交于 2019-12-03 03:45:57
I want to use Sankey chart but with circle's instead of rectangles. I am following the example from Mike Bostock . I changed the code there to use circle by setting radius, but how to place the lines connecting nodes around circle. Any clue. Thanks. VividD first of all, I would like to tell you that I liked your idea. I will walk you through several simple steps needed to get a decent Sankey diagram with circles. The final result may not be ideal for your application, but I guess it may be useful for you as starting point. Once you get to know internal and external features of d3 Sankey plugin

how to define nodes and links data frame for sankeyNetwork()

一世执手 提交于 2019-12-02 23:07:59
问题 I have a file with export from source country to target country, the value of the trade is in Before_value dimension. My data is in a data.table with dimensions source and target as character (list of country codes) and beofre_value numeric. I would like to generate a sankey diagram, using sankeyNetwork() from networkd3, with the source countries on the left and the target countries on the right and the flows represented. How do I define the nodes and links data frames properly? I have these

Sankey diagram in javascript

安稳与你 提交于 2019-12-02 20:53:28
I want to draw a Sankey diagram using Javascript. Can anyone provide some direction regarding the algorithms or libraries that are available for this? This is a basic Sankey diagram using raphaeljs function Sankey(x0, y0, height, losses) { var initialcolor = Raphael.getColor(); var start = x0 + 200; var level = y0 + height; var heightunit = height / 100; var remaining = 100 * heightunit; function drawloss(start, level, loss) { var thecolor = Raphael.getColor(); paper.path("M" + (start - 100) + "," + (level - loss) + "L" + start + "," + (level - loss)).attr({stroke: thecolor}); paper.path("M" +

d3 Sankey - Is it possible to affect or decide the placement of nodes?

佐手、 提交于 2019-11-30 20:38:43
I'm working with the Sankey plugin for d3.js. Is there a way to affect the automatic placement of the nodes? If you compare the below 2 images. Automatically generated Sankey Diagram: https://files.secureserver.net/0s3DEU5s3OZtqL After I have manually re-arranged it: https://files.secureserver.net/0sYJF1w7f54wdF You see that the nodes are aligned centered after each other which make it hard to use the diagram until you manually rearrange the nodes. Can I affect this flow somehow - or is it just the way it is? By the way - Is there a way to specify that the text for the nodes should not be

Sankey diagram in R

这一生的挚爱 提交于 2019-11-30 09:07:35
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 results in: My fairly straightforward extension consists of building a diagram with the following

Own colour range for Sankey Diagram with networkD3 package in R

爷,独闯天下 提交于 2019-11-30 05:39:27
问题 I am trying to plot Sankey diagrams using sankeyNetwork() in networkD3 package. sankeyNetwork(Links = Flow_data, Nodes = Nodes_data, Source = "Source_ID", Target = "Target", Value = "value", NodeID = "Nodes_name", width = 1000, height=600, fontsize = 16, nodeWidth = 50, colourScale = "d3.scale.category20c()") The visualization works great but I would like to change the colour range to an individual range. Is there any chance to change the colours of the SankeyNetwork? I need a range of only e

Place text values to right of sankey diagram

℡╲_俬逩灬. 提交于 2019-11-29 10:24:53
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 to have the values displayed to the right of the diagram. library(networkD3) library(data.table) set

Customizing the sankey chart to cater large datasets

隐身守侯 提交于 2019-11-28 14:50:42
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 in modifying the plot dynamically such that I can replicate the code for large number of users and

How to change node and link colors in R googleVis sankey chart

半世苍凉 提交于 2019-11-28 09:26:28
How can node and link colors be changed in R googleVis sankey chart? And link having the same color as its originating node? library(googleVis) datSK <- data.frame(From=c(rep("A",3), rep("B", 3)), To=c(rep(c("X", "Y", "Z"),2)), Weight=c(5,7,6,2,9,4)) Sankey <- gvisSankey(datSK, from="From", to="To", weight="Weight", options=list( sankey="{link: {color: { fill: '#d799ae' } }, node: { color: { fill: '#a61d4c' }, label: { color: '#871b47' } }}")) plot(Sankey) As soon as you have to color links from 2 originated nodes you'll need 2 colors for links. Also you have 5 nodes in total, so you'll need 5