timelyportfolio / rcharts_d3_sankey Goto Github PK
View Code? Open in Web Editor NEWrCharts implementation of d3 sankey plugin
rCharts implementation of d3 sankey plugin
Hi,
first i have to thank you for your genius work.
My problem is, that the Numbers that i specify in the Inputfile are rounded somewhere in the code.
for example: source = a, target = b, value=2055858,29
shows in the sankey as 2,055,900.00
how can i disable this rounding?
Hi,
I was trying to create a 3 layer sankey with 3 connections from each node .
Most of the time it is showing the following error "A script on this page may be busy, or it may have stopped responding. You can stop the script now, or you can continue to see if the script will complete.
Script: http://127.0.0.1:5754/rCharts_d3_sankey-gh-pages/js/sankey.js:120"
Any way to resolve it
Jagan
Hi,
I am started using rCharts Sankey plots. And it really suits my needs. However, I have many problems. Because sometimes it works, sometimes doesn't.
So, firstly I would like to ask how should I correctly specify library path with setLib(). I have cloned this repo to my local and set it:
sankeyPlot$setLib('C:/Users/adomasb/Documents/GitHub/rCharts_d3_sankey/libraries/widgets/d3_sankey')
but I still get error:
> sankeyPlot Warning message: In readLines(file, warn = warn, ...) : invalid input found on input connection 'C:\Users\adomasb\Documents\GitHub\rCharts_d3_sankey\libraries\widgets\d3_sankey/layouts/chart.html'
The only thing I get in Viewer is question mark (?).
After downloading the files and adjusting the paths in the way I think is necessary, I get the following error message:
Error in yaml.load(paste(readLines(input), collapse = "\n"), ...) :
Scanner error: mapping values are not allowed in this context
Is it something obvious that I can fix?
My current code follows.
-.-.-.-.-.-
require(rCharts)
require(rjson)
links <- matrix(unlist(
rjson::fromJSON(
# file = "http://bost.ocks.org/mike/sankey/energy.json"
file = "input/energy.json"
)$links
),ncol = 3, byrow = TRUE)
nodes <- unlist(
rjson::fromJSON(
# file = "http://bost.ocks.org/mike/sankey/energy.json"
file = "input/energy.json"
)$nodes
)
links <- data.frame(links)
colnames(links) <- c("source", "target", "value")
links$source <- sapply(links$source, FUN = function(x) {return(as.character(nodes[x+1]))}) #x+1 since js starts at 0
links$target <- sapply(links$target, FUN = function(x) {return(nodes[x+1])}) #x+1 since js starts at 0
sankeyPlot <- rCharts$new()
sankeyPlot$setLib('d3_sankey')
sankeyPlot$setTemplate(script = "d3_sankey/layouts/chart.html")
sankeyPlot$set(
data = links,
nodeWidth = 15,
nodePadding = 10,
layout = 32,
width = 960,
height = 500,
units = "TWh",
title = "Sankey Diagram"
)
sankeyPlot
-.-.-.-.-.-
I downloaded the contents of this folder in a "d3_sankey" directory in the working dir, and also downloaded the json data file, as an additional earlier simplification.
Any suggestions?
Thanks.
Hi Timelyportfolio,
I have two questions:
Thanks in advance
My data.frame:
str(bbb)
'data.frame': 1116 obs. of 3 variables:
$ source: chr "SVC_GTS" "SVC_TWR" "SVC_TWR" "SVC_GTS" ...
$ target: chr "AMS_GTS_SAS600" "AMS_TWR_SAS600" "DS5K_TWR_FC300" "DS5K_GTS_FC300" ...
$ value : num 0.99 1 0.84 1 0.97 0.97 0.08 0.06 0.44 0.44 ...
I do :
library(rCharts)
library(lattice)
sankeyPlot <- rCharts$new()
sankeyPlot$setLib('../rCharts_d3_sankey')
sankeyPlot$setTemplate(script = "../rCharts_d3_sankey/layouts/chart.html")
require(devtools)
install_github('rCharts', 'ramnathv')
sankeyPlot$set(
data = bbb,
nodeWidth = 15,
nodePadding = 10,
layout = 32,
width = 750,
height = 500,
labelFormat = ".1%"
)
sankeyPlot
Picture and data.frame bbb attached to post ( change foo.PNG to foo.ZIP)
Thank you in advance.
Best regards
robert
Hi. I am trying to plot some sankey diagrams. However when I generate the plot (on Rstudio) I get a cropped version, which I can't retrieve the targets that fall bellow the plot area limit.
I already tried to change the dimensions but nothing seam to work.
Thank you so much!
here is the piece of code that I have:
sankeyPlot=function(df)
{
sankeyPlot <- rCharts$new()
#--------
#setwd("...\rCharts\rCharts_d3_sankey-gh-pages")
sankeyPlot$setLib('http://timelyportfolio.github.io/rCharts_d3_sankey/')
#sankeyPlot$setTemplate(script = "...\rCharts\rCharts_d3_sankey-gh-pages\layouts\chart.html")
#---------
sankeyPlot$set(
data = df,
nodeWidth = 15,
nodePadding = 10,
layout = 32,
width = 750,
height = 400,
units = "TWh",
labelFormat = ".1%"
)
sankeyPlot
}
and here is what I get as file:
rCharts is powerful package!!
when i use rCharts to plot the sankey Diagram, i wonder how to plot the diagrams described as follow:
โA -> B ->C
A ->C -> A"
HI is there any ways to put label, not a tool tips, (e.g. values) in particular links?
The template uses fixed http
protocol for loading resources that can raise issues when loading the original page via https
, e.g. in Chrome:
Mixed Content: The page at 'https://psychemedia.github.io/parlihacks/sankeyFlow.html' was loaded over HTTPS, but requested an insecure stylesheet 'http://timelyportfolio.github.io/rCharts_d3_sankey/css/sankey.css'. This request has been blocked; the content must be served over HTTPS.
about:srcdoc:1
Mixed Content: The page at 'https://psychemedia.github.io/parlihacks/sankeyFlow.html' was loaded over HTTPS, but requested an insecure script 'http://d3js.org/d3.v3.min.js'. This request has been blocked; the content must be served over HTTPS.
about:srcdoc:1
Mixed Content: The page at 'https://psychemedia.github.io/parlihacks/sankeyFlow.html' was loaded over HTTPS, but requested an insecure script 'http://timelyportfolio.github.io/rCharts_d3_sankey/js/sankey.js'. This request has been blocked; the content must be served over HTTPS.
Mixed Content: The page at 'https://psychemedia.github.io/parlihacks/sankeyFlow.html' was loaded over HTTPS, but requested an insecure stylesheet 'http://timelyportfolio.github.io/rCharts_d3_sankey/css/sankey.css'. This request has been blocked; the content must be served over HTTPS.
I following the steps and everything is looking good until I try the print step and then I see only HTML instead of the plot. Can this technique be used inside RStudio?
sankeyPlot$print(chartId = 'sankey1')
libraries/widgets/d3_sankey/layouts/chart.html
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.