GithubHelp home page GithubHelp logo

rcharts_d3_sankey's People

Contributors

timelyportfolio avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

rcharts_d3_sankey's Issues

Manipulate 'columns' in a sankey plot

Below is a sankey plot I created using this wonderful library.

screen shot 2014-09-29 at 11 36 38 pm

I wonder whether it is possible to manipulate the 'column' each item appears. For example, I wish to put "lak12_old" and "lak12_new" in a same column. Is that doable through this library? Thanks!

Problems with rounding Number

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?

Freezing chart

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

invalid input found on input connection

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 (?).

Error in yaml.load(paste(readLines(input), collapse = "\n"), ...)

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)

Note:

ramnathv/rCharts#515

get source from original example

this is a JSON, so will need to translate

this is complicated and unnecessary but feel I need to replicate

for completeness

expect most data to come straight from R

in form of source, target, value

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
)

convert to data.frame so souce and target can be character and value numeric

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

now we finally have the data in the form we need

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.

How to customize tooltips and color in Sankey plot

Hi Timelyportfolio,

I have two questions:

  1. I would like to add custom tool tips for the mouse-over within Sankey plot (links between nodes), is there a way to do this
  2. I have subset of nodes from the same group evolved across time, and they share common pre-fix in their names. Is it possible to color the nodes the same color according to the pre-fix so that it's very easy to follow the change across time.

Thanks in advance

issue 1 - sankey plot - not working properly (probably) if 3 levels and many items in 3 level

foo
Hi,

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)
screen shot 2013-08-22 at 12 32 35 am

Thank you in advance.

Best regards
robert

Cropped plots using the sankeyPlot function

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:

rplot

help: sankey Diagram

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"

Links Label

HI is there any ways to put label, not a tool tips, (e.g. values) in particular links?

http/https issues

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.

Should the plot display in RStudio?

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.