jbkunst / highcharter

R wrapper for highcharts
http://jkunst.com/highcharter/
Other
718 stars 147 forks source link

Display issue occurs when creating a Sankey diagram with hchart() and data_to_sankey() functions #737

Closed ISMAILManel closed 2 years ago

ISMAILManel commented 2 years ago

Hello!

I am trying to build a Sankey diagram using the hchart() and data_to_sankey() functions. The group_by executed by the data_to_sankey() function seems to work :

df2<- data.frame(X= c("A","A","B","B", "C"),
                Y= c("B","B","C","D","D"))

data_to_sankey(df2)
data_to_sankey

However, there seems to be a display error when applying the hchart() function :

hchart(data_to_sankey(df2),` "sankey", `name="steps")

hchart

The following output built using d3js is what I should have :

d3js
jbkunst commented 2 years ago

Hi!

library(highcharter)

df2<- data.frame(X= c("A","A", "B","B", "C"),
                 Y= c("B","B", "C","D" ,"D"))

data_to_sankey(df2)

hchart(
  data_to_sankey(df2)[c(1,2,4,3),],
  "sankey",
  name = "steps", 
  nodes = list(
    list(id = "C", offsetVertical = -200)
    )
  )

image