SunburstR图形的Javascript排序

SunburstR图形的Javascript排序,javascript,r,d3.js,sunburst-diagram,Javascript,R,D3.js,Sunburst Diagram,我最近将R中的SunburstR包更新为2.0版本,突然之间,切片排序(按大小、降序、顺时针)不再像以前那样自动进行。有没有R&JS/d3.JS方面的专家来帮我实现一个定制的JS sortFunction或者说如何解决这个问题?出于复制目的: library(jsonlite) library(sunburstR) b = read.csv( file = paste0( "https://gist.githubusercontent.com/rileycrane/", "92

我最近将R中的SunburstR包更新为2.0版本,突然之间,切片排序(按大小、降序、顺时针)不再像以前那样自动进行。有没有R&JS/d3.JS方面的专家来帮我实现一个定制的JS sortFunction或者说如何解决这个问题?出于复制目的:

library(jsonlite)
library(sunburstR)
b = read.csv(
   file = paste0(
   "https://gist.githubusercontent.com/rileycrane/",
   "92a2c36eb932b4f99e51/raw/",
   "a0212b4ca8043af47ec82369aa5f023530279aa3/visit-sequences.csv"
 ),header=FALSE
,stringsAsFactors = FALSE
)

sequence_json <- jsonlite::fromJSON(
  system.file("examples/visit-sequences.json",package="sunburstR"),
  simplifyDataFrame = FALSE
)
sunburst(sequence_json)
谢谢

PS结果:

它过去的样子(注意切片的顺序):

也许按字母顺序排序会有所帮助

作为另一个例子,这里是如何将每个节点从最大计数排序到最小计数

library(sunburstR)

sequence_json <- jsonlite::fromJSON(
  system.file("examples/visit-sequences.json",package="sunburstR"),
  simplifyDataFrame = FALSE
)

sunburst(
  sequence_json,
  sortFunction = htmlwidgets::JS(
    "
function(a,b) {
  // sort by count descending
  //   unlike the other example using data.name, value is at the top level of the object
  return b.value - a.value
}
"    
  )
)
库(sunburstR)

来自创造者本人的惊喜:)非常感谢!事实上,我一直在使用rend2b,它看起来很神奇,但是当我使用“size”作为参数(这也是默认参数)时,valueField似乎不起作用。更正-我现在注意到valueField做了其他事情。我缺少的是在sund2b中对切片进行排序。在
sund2b
上进行排序会有点棘手,但表明它是可以做到的。
library(sunburstR)

sequence_json <- jsonlite::fromJSON(
  system.file("examples/visit-sequences.json",package="sunburstR"),
  simplifyDataFrame = FALSE
)

sunburst(
  sequence_json,
  sortFunction = htmlwidgets::JS(
    "
function(a,b) {
  // sort by count descending
  //   unlike the other example using data.name, value is at the top level of the object
  return b.value - a.value
}
"    
  )
)