Giter Club home page Giter Club logo

chorddiag's Introduction

Create a D3 Chord Diagram

The chorddiag package allows to create interactive chord diagrams using the JavaScript visualization library D3 (http://d3js.org) from within R using the htmlwidgets interfacing framework.. Chord diagrams show directed relationships among a group of entities. The chord diagram layout is explained in detail here: https://github.com/mbostock/d3/wiki/Chord-Layout.

To quote the explanation found there:

Consider a hypothetical population of people with different hair colors: black, blonde, brown and red. Each person in this population has a preferred hair color for a dating partner; of the 29,630 (hypothetical) people with black hair, 40% (11,975) prefer partners with the same hair color. This preference is asymmetric: for example, only 10% of people with blonde hair prefer black hair, while 20% of people with black hair prefer blonde hair. A chord diagram visualizes these relationships by drawing quadratic Bézier curves between arcs. The source and target arcs represents two mirrored subsets of the total population, such as the number of people with black hair that prefer blonde hair, and the number of people with blonde hair that prefer black hair.

To create a chord diagram for this example, we need the preferences in matrix format:

m <- matrix(c(11975,  5871, 8916, 2868,
              1951, 10048, 2060, 6171,
              8010, 16145, 8090, 8045,
              1013,   990,  940, 6907),
            byrow = TRUE,
            nrow = 4, ncol = 4)
haircolors <- c("black", "blonde", "brown", "red")
dimnames(m) <- list(have = haircolors,
                    prefer = haircolors)
m
#>         prefer
#> have     black blonde brown  red
#>   black  11975   5871  8916 2868
#>   blonde  1951  10048  2060 6171
#>   brown   8010  16145  8090 8045
#>   red     1013    990   940 6907

Then, the chorddiag function creates the chord diagram:

library(chorddiag)
groupColors <- c("#000000", "#FFDD89", "#957244", "#F26223")
chorddiag(m, groupColors = groupColors, groupnamePadding = 20)

Directional chord diagram for the hair dataset

This diagram will be interactive when generated by the function. Interactive here means chord fading and tooltip popups on certain mouse over events. E.g. if the mouse pointer hovers over the chord connecting the "blonde" and "red" groups, a tooltip is displayed giving the numbers for the chord, and all other chords fade away.

Directional chord diagram for the hair dataset

The package's code is based on http://bl.ocks.org/mbostock/4062006, with modifications for fading behaviour and addition of tooltips.

The default chord diagram type is directional but chord diagrams can also be a useful visualization of relationships between two categories of groups, i.e. contingency tables. In this package, this type of chord diagram is called bipartite (because there are only chords between categories but not within categories). Here is an example for the Titanic dataset, depicting how many passengers from the different classes and from the crew survived or died when the ship sunk:

Bipartite chord diagram for the Titanic dataset

See the vignette for more information.

Updating to the latest version of chorddiag

You can track (and contribute to) development of chorddiag at https://github.com/mattflor/chorddiag. To install it, run the following command (this requires the devtools package):

devtools::install_github("mattflor/chorddiag")

If this fails to install the package vignette, try devtools::install_github("mattflor/chorddiag", build_vignettes = TRUE).

chorddiag's People

Contributors

edwindj avatar eliztang avatar mattflor 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  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar

chorddiag's Issues

Figure resolution

Hi Matt,

I find the figure is in low resolution. Is it possible to export high resolution figure for publication, e.g. in PDF format?

Thanks

how to rotate group labels and save 3d form

Hi!
please guide me
same question like
its possible to rotate group labels: and ##how to save as 3d form ##
this is my script
`library(chorddiag)

data<- read.csv("C:/Users/Hp/Desktop/final chord diagram 16 s.csv", sep=",", header = T, row=1)

my.data <-as.matrix(data)

row.names(my.data) <- c("HL", "HR", "ML", "MR", "LL", "LR", "RL", "RR")

colnames(my.data) <- c("Alphaproteobacteria", "Betaproteobacteria", "Gammaproteobacteria",
"Actinobacteria", "Firmicutes", "Bacteroidetes",
"Others")

groupColors <- c("orange", "maroon","cyan", "salmon","sienna1", "skyblue", "gold", "pink","chocolate", "red", "grey", "green","brown", "blue", "purple")

chorddiag(my.data,type = "bipartite", showTicks = T,tickInterval = 5 ,groupColors = groupColors ,
groupnameFontsize = 15,grop_ ,groupnamePadding = 20, margin = 100
Rplot05
)
`
Rplot05

thanks in advance

creating a matrix

Unfortunately, I do not understand how could create a matrix for my data. There separated in 2 json files. The first one describe the circle labeling, color and size

[
  {
    "color": "#996600", 
    "id": "chr03", 
    "len": 35020413, 
    "label": "chr03"
  }, 
  {
    "color": "#666600", 
    "id": "tig00007144", 
    "len": 40868, 
    "label": "tig00007144"
  }, 
  {
    "color": "#666600", 
    "id": "tig00026480", 
    "len": 95961, 
    "label": "tig00026480"
  },
...
]

On the other hand, the second file describes the relationship between each label in the chord chart.

[
  {
    "source": {
      "start": 30824, 
      "end": 23113, 
      "id": "tig00007144"
    }, 
    "target": {
      "start": 33203431, 
      "end": 33211142, 
      "id": "chr03"
    }
  }, 
  {
    "source": {
      "start": 48387, 
      "end": 1, 
      "id": "tig00026480"
    }, 
    "target": {
      "start": 35010628, 
      "end": 34962190, 
      "id": "chr03"
    }
  }, 
...
]

How do I convert the above relationship file to a proper matrix?

Thank you in advance.

Action when clicking Group

Hi,

Bravo!!!Great package!!! Keep up the good work. Would it be possible to add an action when a group/node is clicked? The total for a group is already displayed upon hover and the groups linking to it are highlighted. To make it even better, it would be great to allow an action to analyse these links via a click action.

Correct me if I am wrong but currently there is only an action when the arc/link is clicked with the indices stored in d.source.index and d.target.index.

Cheers

Exporting

Thanks for the wonderful package!

Is there a way to save a plot made with the function chorddiag as pdf or anything at high resolution?

Thanks!

chorddiag plots are not visible when using dynamically generated tabs

I want to dynamically generate tabs, and each tab plot the corddiag plot

library(igraph)
library(tidygraph)
library(chorddiag)

m <- matrix(c(11975,  5871, 8916, 2868,
               1951, 10048, 2060, 6171,
               8010, 16145, 8090, 8045,
               1013,   990,  940, 6907),
               byrow = TRUE,
               nrow = 4, ncol = 4)
groupnames <- c("black", "blonde", "brown", "red")
row.names(m) <- groupnames
colnames(m) <- groupnames
## First learned languages {.tabset .tabset-fade .tabset-pills}

```{r echo=FALSE, fig.height=6, fig.width=6, warning=FALSE, results='asis'}
for (i in 1:3) {
  cat("###", paste("Tab ",i), '{-}',  '\n\n')
  print(chorddiag(m))
  cat( '\n\n')
}

everything works pretty well in Rmarkdown window, but when I knot I can't generate plots. I also tried to use htmltools::tagList as it did worked for plotly library, it does create a space but no plots show up

I also get an error :/chunk_output/42CC8C6564F105CC/4A1ED7C7/c3rny570vwpsr/000029.html?viewer_pane=1&capabilities=1 not found

Adding another dimension of data?

A really wonderful and helpful package, thanks!

I've followed the examples, reviewed the documentation, and generated plots using my own data, so I think feature I'm asking about is unsupported by please let me know if I'm mistaken.

I'd like to know if there is any way to relate one of the parameters like colors/line thickness/font color/ etc. to another dimension of data. Currently, my bipartite matrix edge thickness is directly tied to the values of the corresponding matrix - and this is beautiful. But I'd like to add another dimension - let's say by scaling the colors.

So Imagine I have a separate matrix (matrix2) which has the exact same row/col names as my original matrix, but different values. Is there a way that I could make the edge colors something like a heatmap? So the final plot would have the edge thickness corresponding to the first matrix, and the edge colors corresponding to second matrix.

Thanks!

Background colour

Hi,
I want to ask is it possible to change backround colour of the chord diagram.
Now it is white but I want to make backgound transperant.

Thank you!

Extended groupNames Control?

Great package! Any way to get additional control over how group names are displayed? For example, wrapping a name onto two lines at a given point, or indeed manually placing a name over two lines? Thanks!

background fill

Hi Matt,

I'm having trouble finding documentation on editing the circle's background fill to white. Would you be able to point me in the right direction?

Thanks for your time,
Diana

How can i put more intense colors to strong relations and light colors to the weak ones?

First of all congratulations for this R package! it is really awesome and has soooo many applications!

I create a big chord diagram that represents the correlation matrix between many metrics i get from Prometheus monitoring framework. An example of this chord diagram can be seen below:
chordexample

I know that via the groupColors attribure i can control the color of the groups. But i want to be able to define the color of the matrix cells as well. For example metric28 has a very high correlation with metric 108 (89.03%) as seen below:
chordexample1

I would like to put more intense colors to strong relations and light colors to the weak ones.
I have created the necessary vector but i need a placeholder to put it at the chord diagram. As seen at the above pallete, only 4 relations are in deep blue....so actually i am only interested in them.

colourstest

Hope the issue description is well explained!
Thank you very much for you time!

Updating to v4

It looks like d3v4 is fast becoming standard. Are we open to upgrading this repo to reflect this, to prevent the inevitable conflicts that will arise from using v3 (one already exists with networkd3)

Using my own colours

Hi Matt,

I am wondering if it is possible to change the colours to a self-defined palette and not to some predefined palette.
My main issue is that I wish to create a chord diagram of 53 nodes so I would like to have 53 different colours.

Thank you in advance,
Julia

Long labels cut off

I am running into a problem where labels are being cut off on the plot. Specifically the labels coming from the top and bottom of the chord diagram. I have tried increasing margins and decreasing font size, but this only helps so much. Any recommendations I can try to fix this?

Thanks, and really easy package to work with!

Adjacency matrix shape

Hi, thanks for a great package! Wondering if it is possible to relax the m:m constraint on the adjacency matrix to allow for missing observations to avoid having to display an NA (unknown in this case) section on the diagram?

chord

Plot not displaying

The chord diagram plot is not displaying in R studio Viewer. I tried updating R and R studio to the most recent versions but it hasn't fixed the issue. Any advise?

How to edit the toolip?

Is there a way to edit what is shown in toolip in R: I just want to have a toolip showing A>B information ( with no B<A)


m <- matrix(c(11975,  5871, 8916, 2868,
               1951, 10048, 2060, 6171,
               8010, 16145, 8090, 8045,
               1013,   990,  940, 6907),
               byrow = TRUE,
               nrow =2, ncol = 2)
groupnames <- c("A", "B")
row.names(m) <- groupnames
colnames(m) <- groupnames
chorddiag(m)

Can't see the relationships

Hello there,
EDIT: seems like NA values stops the graph from working. Substituting them with 0 did the trick.
I'm turning this into a suggestion: a simple warning regarding the NAs could save people time

I have a square matrix which is like this:

            risposto
autore       Ananas Canis Ficus Lutra Mustela Phasianus Pieris Psylocybe Ramphastos Rana Ursus Vitis
  Ananas          3     2    16    12      28         7      4        20         27   21     7     9
  Canis           6    NA     2    NA       4         1     NA         7          4    7    NA    NA
  Ficus          NA     1     1    NA       5        NA      1         8          7    4     3     1
  Lutra          17     2    10     4       8         6      3        36         19   29     3    NA
  Mustela        24     7    11     9       5         3     NA        21         43   25     6    14
  Phasianus      14    NA     3     6       7         5      2         5         11    8     3     4
  Pieris          6    NA     6     4       1         1      2         7         11   15     3     5
  Psylocybe      28     8    30    20      40         7      8         2         63   42    22    19
  Ramphastos     79    12    49    34      65        16     14        84         23   85    26    36
  Rana           29    16    20    25      31        10      6        41         79    2    12    19
  Ursus          10     2     9     5      13         2     NA        17         25   19     4    10
  Vitis          35    NA     6     6      26         3      9        32         52   26    18     4

And I created the groupcolors

groupColors <- c("#000000", "#FFDD89", "#957244", "#F26223", "#e4704b", "#90eb96", "#472c86", "#c3f729", "#004d8e", "#6d9db0", "#71b1e4", "#516afe")

Problem is, when I run the code:

p <- chorddiag(RepliedToMatrix, groupColors = groupColors, groupnamePadding = 20)
p

All I see is the circle without the relationships (I attach the image). I don't have troubles with using the example with the hair color, I have it working just fine.

Have no clue of why this is happening, any idea?

Is it possible to add additional labels on the chord diagram?

Hi Matt,

I was wondering would chorddiag currently able to add additonal "labels" to the link in the chord diagram?

For example, in the first example here, if the size of the links represent the number of students, is it possible to add additional texts that would be displayed when you hover around the links? An example is adding the name of the teachers for each class/section as well as the time so that when you however around the links, not only it will show you the number of students but also the teacher's name and time of the class.

Thanks!
Aaron

Install's error

Hello Matt:

This is my situation, i can't install the package and i leave you the error code:

Downloading GitHub repo mattflor/chorddiag@master
These packages have more recent versions available.
It is recommended to update all of them.
Which would you like to update?

1: All
2: CRAN packages only
3: None
4: rlang (0.4.5 -> 0.4.6) [CRAN]

Enter one or more numbers, or an empty line to skip updates: (i leave empty)

WARNING: Rtools is required to build R packages, but is not currently installed.

Please download and install Rtools custom from http://cran.r-project.org/bin/windows/Rtools/.
√ checking for file 'C:\Users\AppData\Local\Temp\RtmpGwmiu1\remotes224470786d\mattflor-chorddiag-86b1652/DESCRIPTION' (767ms)

  • preparing 'chorddiag':
    √ checking DESCRIPTION meta-information ...

  • installing the package to build vignettes (340ms)
    E creating vignettes (9s)
    --- re-building 'chorddiagram-vignette.Rmd' using rmarkdown
    Quitting from lines 70-72 (chorddiagram-vignette.Rmd)
    Error: processing vignette 'chorddiagram-vignette.Rmd' failed with diagnostics:
    there is no package called 'pander'
    --- failed re-building 'chorddiagram-vignette.Rmd'

    SUMMARY: processing the following file failed:
    'chorddiagram-vignette.Rmd'

    Error: Vignette re-building failed.
    Ejecución interrumpida
    Error: Failed to install 'chorddiag' from GitHub:
    System command 'Rcmd.exe' failed, exit status: 1, stdout + stderr (last 10 lines):
    E> Quitting from lines 70-72 (chorddiagram-vignette.Rmd)
    E> Error: processing vignette 'chorddiagram-vignette.Rmd' failed with diagnostics:
    E> there is no package called 'pander'
    E> --- failed re-building 'chorddiagram-vignette.Rmd'
    E>
    E> SUMMARY: processing the following file failed:
    E> 'chorddiagram-vignette.Rmd'
    E>
    E> Error: Vignette re-building failed.
    E> Ejecución interrumpida

I hope you can help me please!

See you

Title feature

Hello,

This is a great package! Thanks for making it. Is it possible for you to either create a feature for a title or a legend? If not, could you provide me with means to how add a title or a legend?

Thanks!
-Tom

rotate the whole diagram

m <- matrix(c(11975,  5871, 8916, 2868,
              1951, 10048, 2060, 6171,
              8010, 16145, 8090, 8045,
              1013,   990,  940, 6907),
            byrow = TRUE,
            nrow = 4, ncol = 4)
haircolors <- c("black", "blonde", "brown", "red")
dimnames(m) <- list(have = haircolors,
                    prefer = haircolors)
library(chorddiag)
groupColors <- c("#000000", "#FFDD89", "#957244", "#F26223")
chorddiag(m, groupColors = groupColors, groupnamePadding = 20)

Is it possible to rotate the entire plot, so that, for instance, the category black started at 90 degrees but maybe 180?

Feature : manual chord's tooltip

Hi!

I've created a chord diagram to explore chemicals associations in different samples using your package (great job, btw). I would like to display different informations on tooltips :

1 - When mouse is over a group section (I mean : not a chord) : a list of others chemicals found with the one selected with their % of association.
2 - When mouse is over a chord : just a line with % of associations and how many samples contain simultaneously the two considered chemicals.

Actually, it seems not possible to have different informations in group popup and in chord popup... Is there a way to achieve it?

Regards.

renderChorddiag showing blank page in Shiny

I was testing chorrdiag in a Shiny application. While there was no problem creating chorrdiag with chorrdiag function. I was getting blank page when trying to render the plot in shiny. The example I used is

library(shiny)
library(chorddiag)
library(htmlwidgets)

ui <- shinyUI(fluidPage(
  titlePanel("Hair Color Preferences"),
  
  sidebarLayout(
    
    sidebarPanel(
      sliderInput("margin", "Margin",  min = 0, max = 200, value = 100),
      sliderInput("groupnamePadding", "Group Name Padding",  min = 0, max = 100, value = 30),
      checkboxInput("showTicks", "Show Ticks", value = TRUE)
    ),
    
    mainPanel(
      chorddiagOutput('chorddiag')
    )
  )
))

server <- function(input, output){
  m <- matrix(c(11975,  5871, 8916, 2868,
                1951, 10048, 2060, 6171,
                8010, 16145, 8090, 8045,
                1013,   990,  940, 6907),
              byrow = TRUE,
              nrow = 4, ncol = 4)
  groupNames <- c("black", "blonde", "brown", "red")
  groupColors <- c("#000000", "#FFDD89", "#957244", "#F26223")
  
  row.names(m) <- groupNames
  colnames(m) <- groupNames
  
  shinyServer(function(input, output) {
    output$chorddiag <- renderChorddiag(
      chorddiag(m,
                groupColors = groupColors,
                groupnamePadding = input$groupnamePadding,
                showTicks = input$showTicks,
                margin = input$margin
      ))})
  
  
}

shinyApp(ui = ui, server = server)

My session information is

R version 4.2.2 (2022-10-31 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 22621)

Matrix products: default

locale:
[1] LC_COLLATE=English_Canada.utf8  LC_CTYPE=English_Canada.utf8    LC_MONETARY=English_Canada.utf8 LC_NUMERIC=C                   
[5] LC_TIME=English_Canada.utf8    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] htmlwidgets_1.6.2 chorddiag_0.1.3   shiny_1.7.3      

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.9       digest_0.6.30    later_1.3.0      mime_0.12        R6_2.5.1         jsonlite_1.8.3   lifecycle_1.0.3  xtable_1.8-4    
 [9] magrittr_2.0.3   cachem_1.0.6     rlang_1.1.0      cli_3.4.1        rstudioapi_0.14  promises_1.2.0.1 jquerylib_0.1.4  bslib_0.4.1     
[17] ellipsis_0.3.2   tools_4.2.2      yaml_2.3.6       httpuv_1.6.6     fastmap_1.1.0    compiler_4.2.2   memoise_2.0.1    htmltools_0.5.5 
[25] sass_0.4.2

I am wondering if this issue is caused by package versions.

Control color of edges

Is it possible to control the color of the nodes and the chords? I wish to specify which node will get what color and which chord will get what color

Different patterns for arches (links)

Hi I have below coding for chord diagram and 2 different type of data (i.e., positive and negative ones). I used the dash pointed line for negative ones (just line around of each arches) but I want to know that how I can define different pattern for inside of each arch (link) instead of dash pointed line around them. Thanks in advance.
library(statnet)
library(circlize)
library(readxl)
data1 <- read_excel("C:
Goal Negative.xlsx
Goal posetive.xlsx
Rplot10
\SDGs\My File GM\Final Nvivo & Excel\R program\Goal negative.xlsx", col_names = FALSE)
my.data1 <- as.matrix(x =data1, nrow = 5, ncol = 5)
rownames(my.data1) <- c("SDG2","SDG6","SDG8","SDG13","SDG15")#named by yourself
colnames(my.data1) <- c("SDG2","SDG6","SDG8","SDG13","SDG15")#named by yourself
data2 <- read_excel("C:\Users\rbandari\OneDrive - Deakin University\SDGs\My File GM\Final Nvivo & Excel\R program\Goal posetive.xlsx", col_names = FALSE)
my.data2 <- as.matrix(x =data2, nrow = 5, ncol = 5)
rownames(my.data2) <- c("SDG2","SDG6","SDG8","SDG13","SDG15")#named by yourself
colnames(my.data2) <- c("SDG2","SDG6","SDG8","SDG13","SDG15")#named by yourself

mat=rbind(my.data1,my.data2)
rownames(mat) <- c("SDG2","SDG6","SDG8","SDG13","SDG15","SDG2","SDG6","SDG8","SDG13","SDG15")#named by yourself
colnames(mat) <- c("SDG2","SDG6","SDG8","SDG13","SDG15")#named by yourself
grid.col[c("SDG2","SDG6","SDG8","SDG13","SDG15")] = c(rgb(red = 221, green = 166, blue = 58, max=255),rgb(red = 38, green = 189, blue = 226, max=255), rgb(red = 162, green = 25, blue = 66, max=255), rgb(red = 63, green = 126, blue = 68, max=255), rgb(red = 86, green = 192, blue = 43, max=255))

lwd_mat = matrix(1, nrow = nrow(mat), ncol = ncol(mat))
rownames(lwd_mat) <- c("SDG2","SDG6","SDG8","SDG13","SDG15","SDG2","SDG6","SDG8","SDG13","SDG15")#named by yourself
colnames(lwd_mat) <- c("SDG2","SDG6","SDG8","SDG13","SDG15")#named by yourself
lwd_mat[mat < 0] = 2
border_mat = matrix(NA, nrow = nrow(mat), ncol = ncol(mat))
rownames(border_mat) <- c("SDG2","SDG6","SDG8","SDG13","SDG15","SDG2","SDG6","SDG8","SDG13","SDG15")#named by yourself
colnames(border_mat) <- c("SDG2","SDG6","SDG8","SDG13","SDG15")#named by yourself
border_mat[mat < 0] = "red"
lty_mat =matrix(1, nrow = nrow(mat), ncol = ncol(mat))
rownames(lty_mat) <- c("SDG2","SDG6","SDG8","SDG13","SDG15","SDG2","SDG6","SDG8","SDG13","SDG15")#named by yourself
colnames(lty_mat) <- c("SDG2","SDG6","SDG8","SDG13","SDG15")#named by yourself
lty_mat[mat < 0] = 3

chordDiagram(mat, grid.col = grid.col, link.lwd = lwd_mat, link.lty =lty_mat, link.border = border_mat,
transparency = 0.25, annotationTrack = "grid", preAllocateTracks = list(track.height = max(strwidth(unlist(dimnames(my.data))))))
circos.track(track.index = 1, panel.fun = function(x, y) {
circos.text(CELL_META$xcenter, CELL_META$ylim[1], CELL_META$sector.index,
facing = "outside", niceFacing = TRUE, adj = c(0.4, 1))
}, bg.border = NA) # here set bg.border to NA is important

circos.clear()

Integration with opencpu

Hi,
I am trying to create an opencpu app that would display the chordiagram created using chorddiag. Is there any way to do this. For static plots if I return print(plot1), it is working fine, but not for htmlwidgets objects.

Any help on this would be great.

Freeze interactive plot in Shiny

Hi!

thanks for your package!
Is there a way to freeze the diagram on a mouse click in Shiny (only the chords appearance, not the chords tooltips)?

Thanks!

M

cran

Hi Matt, any plans to put this on CRAN? Thanks!

How to add another layer for a group over the chord segments?

Hi,

I love this example. This perhaps is the simplest way of creating a circle plot. I have a migration data very similar to https://gjabel.wordpress.com/2014/03/28/circular-migration-flow-plots-in-r/, and I am trying to add a group over the countries. For example, I want to group China, Thailand, Malaysia, Indonesia, Philippines into a group by continent (Asia in this case). How do I do that? I came across this example on stack, but my data can not be fit into an adjacency matrix. It is a square matrix with regions and countries separated commas (Names in rows and columns will be similar to \Asia,India\Asia,Philippines\ etc.). Please help!

Thank you!

Regards,
KD

Color options for semi-large N (N=38)?

Hi all,

Awesome package and was able to get it off the ground with little issue! Props to Matt and the other contributors.

I have a quick of question I (hope) is straightforward.

I've managed to get the chorddiag() running (see code on my repo: https://github.com/jefferycsauer/gic_chord_diag). However, I'm struggling to understand how colors work on the diagram. I have 38 countries total, so I would like to color each country uniquely. When I attempt to pass a random selection of colors through the diagram, it does nothing (for example, groupColors = rainbow(38)). What am I doing wrong? Do I have to many groups?

chord diagramm available to others

hello
i have made a chord diagram which displays perfectly.
how can I show the diagram on the internet for everybody to look at.
what do I have to do to export the files for viewing the diagram on a website.
thanx

Font size of shiny app changes

Hi,
thank you for your package.
When I use it within a shiny app, the fontsize of the other elements is changing (decreasing).
Do you have any idea why?

Thanks

image

conditional display of tooltip?

Hi

I find this package quite handy.

Sometimes there is no value from right to left and, in this case, it might be better not to show. Specifically the tooltip shows the following when right to left is 0.

# original
A -> B: 2.15%
B -> A: 0%

If the line 86 of chorddiag.js is modified as following, the second line is not shown as following.

#86 of chorddiag.js
return dir1 + (vji > 0 ? "</br>" + dir2 : "");

# modified
A -> B: 2.15%

I wonder if an option to hide tooltip entry when value is 0 may be good.

Thanks.

Regards
Jaehyeon

Issue when using chorddiag with collapsibleTree

Hi,

Thank you for your package. I have an issue, though, while using the chorddiag and the collapsibleTree packages in the same shiny app.
Here is a minimal example. The chord Diagram will not draw, except if I comment out the line collapsibleTreeOutput("tree"). Note that the two graphs use D3.js

Could you have a look?
Thank you.
R.

library(shiny)
library(chorddiag)
library(collapsibleTree)


# Server logic
ui <-   fluidPage(
  h5("The graph should be here"),
  chorddiagOutput("chordDiagram"),
  h5("The graph should be here"),
# The chord diagram is drawn only if I comment out the following line
  collapsibleTreeOutput("tree"),
  hr()
  
)

server <- function(input, output) {
  output$chordDiagram <- renderChorddiag({  

    m <- matrix(c(11975,  5871, 8916, 2868,
                  1951, 10048, 2060, 6171,
                  8010, 16145, 8090, 8045,
                  1013,   990,  940, 6907),
                byrow = TRUE,
                nrow = 4, ncol = 4)
    groupnames <- c("black", "blonde", "brown", "red")
    row.names(m) <- groupnames
    colnames(m) <- groupnames
    chorddiag(m)
    
  })
  
  output$tree <- renderCollapsibleTree(
    collapsibleTree(warpbreaks, c("wool", "tension"))
  )
  
}


shinyApp(ui, server)

Note: I use
‘collapsibleTree’ version 0.1.7
‘shiny’ version 1.1.0
‘chorddiag’ version 0.1.2
R version 3.5.0

Creating square matrix from data.frame

Hello there, I know this isn't a problem particularly related to chorddiag, but maybe you can implement some function or give me some tips concerning my problem.

I was aggregating data with dplyr::group_by resulting in an output of a 16x18 data.frame object.

qdmatrix = group_by(mobility_data, destination_activity, source_activity) %>% summarise(count = n()) %>% reshape2::acast(formula = destination_activity~source_activity, drop=FALSE, fill=0)

Activities can have names of a predefined set of factors e.g. "home", "work" ...
But the aggregation does not lead to a square matrix, because in the data set there was never a source_activity "church", but there was a destination_activity "church".

For chorddiag I need to supply a square matrix,

Error in chorddiag::chorddiag(qdmatrix) : 'data' must be a square matrix.

but I have no clue how to fill in missing rows or columns, is there a function for such a purpose?

Regards

Setting tick interval leads to tick label error

If I leave the tick options alone, everything looks OK, but if I modify your README example to include the tickInterval option, the tick labels default to 25,000. I don't see a tickLabelInterval option, but it seems like the behavior just needs to match the tickInterval. Great package by the way!

m <- matrix(c(11975,  5871, 8916, 2868,
              1951, 10048, 2060, 6171,
              8010, 16145, 8090, 8045,
              1013,   990,  940, 6907),
            byrow = TRUE,
            nrow = 4, ncol = 4)
haircolors <- c("black", "blonde", "brown", "red")
dimnames(m) <- list(have = haircolors,
                    prefer = haircolors)

library(chorddiag)
groupColors <- c("#000000", "#FFDD89", "#957244", "#F26223")
chorddiag(m, groupColors = groupColors, groupnamePadding = 20, tickInterval = 5000)

image

Removing numbers from tooltips

Hello! Thank you for this fantastic package. Is it possible to altogether remove the values/quantities displayed on the tooltip but keep the labels/names?

Thanks!

Fixing arc lengths

Is there a way to fix the arc lengths, meaning removing the proportionality between size of the arc and importance of the flow?

Label ordel

Hello!

Is there anyway I can reoder the labels?
I noticed their appear in an alphabetical form, but for my case it would make more sense
if the labels could be arranged in a specific way.

Thanks in advance.

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.