sankeyNetwork
기능으로 생성 된 html 위젯을 수정하기 위해 고군분투하고 있습니다.
여기 에 값 을 반환 하도록 SD
함수의 출력 이라고 가정합니다 . 다음 벡터입니다.SankeyDiagram()
dput(SD)
colorJS
> colorJS
[1] "d3.scaleOrdinal([\" #1f77b4\", \"#aec7e8\", \"#ff7f0e\", \"#ffbb78\", \"#008800\", \"#ff9900\", \"#aaaaaa\", \"#ffcc33\", \"#548235\", \"#00CC00\", \"#203864\", \"#315597\", \"##5A82CA\", \"#3399ff\", \"#33ccff\", \"#999999\", \"#9467bd\", \"#c5b0d5\", \"#8c564b\", \"#c49c94\", \"#e377c2\", \"#f7b6d2\", \"#7f7f7f\", \"#c7c7c7\", \"#bcbd22\", \"#dbdb8d\", \"#17becf\", \"#9edae5\", \"#1f77b4\", \"#aec7e8\", \"#ff7f0e\", \"#ffbb78\", \"#008800 \"])"
sankeyNetwork를 만들려면 다음을 수행합니다.
sankey <- sankeyNetwork(SD$links,SD$nodes,Source = 'source', Target = 'target', Value = 'value',
NodeID = 'name', sinksRight = FALSE, fontSize = 21, fontFamily = "Verdana", LinkGroup = 'group', NodeGroup = 'group', colourScale =colorJS, nodeWidth = 20, nodePadding = 20 , iterations=0 , margin = list(top=-250, right=-700, left=-400, bottom=150))
# add title and text
sankey <- htmlwidgets::prependContent(sankey, htmltools::tags$h1(paste0('Country Group: ', country,'; Year: ',sYear0[y] )))
sankey <- htmlwidgets::prependContent(sankey, htmltools::tags$h2('Gases', 'Sectors', 'Stages', 'Categories') )
나는 위젯의 콘텐츠 (Gases, Sectors, Stages, CAtegoroes)가 일종의 x- 축과 같은 그림에서 와 같이 다이어그램의 단계와 수직으로 정렬되도록하고 싶습니다.
이것은 htmlwidgets (또는 다른 트릭)로 달성 할 수 있습니까? 도와 주셔서 감사합니다
다음을 사용하여 해결했습니다.
htmlwidgets::prependContent(sankey, htmltools::includeMarkdown("group.txt"))
여기서 'group.txt'는
공백을 생성하기 위해 여러 번 반복 되는 문자열을 포함합니다 .
우아한 솔루션은 아니지만 작업을 수행합니다.
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다