You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi I am using Sankey Diagram and it works perfectly in my local. However, when I tried to print it to Rmarkdown, it did not work at all. I have followed @ramnathv 's other post in including the options in the chunk and print in the end. This trick works well for all other RCharts but not for Sankey Diagram. The related piece of code is showing as below and in this example, only p2 showed up not p1
````{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE)
library(rCharts)
library(knitr)
```
```{r set-options, echo=FALSE, cache=FALSE}
options(RCHART_WIDTH = 1000, RCHART_HEIGHT = 400)
```
```{r, echo = FALSE, results = 'asis'}
load("/home/user/R/df_sankey_example.rda")
sankeyPlot_fct=function(df){
sankeyPlot <- rCharts$new()
sankeyPlot$setLib('/home/user/rcharts_d3_sankey/')
sankeyPlot$setTemplate(
afterScript = "
<script>
// to be specific in case you have more than one chart
d3.selectAll('#{{ chartId }} svg path.link')
.style('stroke', function(d){
//here we will use the source color
//if you want target then sub target for source
//or if you want something other than gray
//supply a constant
//or use a categorical scale or gradient
return d.source.color;
})
//note no changes were made to opacity
//to do uncomment below but will affect mouseover
//so will need to define mouseover and mouseout
//happy to show how to do this also
.style('stroke-opacity', .7)
</script>
")
sankeyPlot$set(
data = df,
nodeWidth = 25,
nodePadding = 10,
layout = 32,
width = 1800,
height = 900
)
sankeyPlot
}
Hi I am using Sankey Diagram and it works perfectly in my local. However, when I tried to print it to Rmarkdown, it did not work at all. I have followed @ramnathv 's other post in including the options in the chunk and
print
in the end. This trick works well for all other RCharts but not for Sankey Diagram. The related piece of code is showing as below and in this example, onlyp2
showed up notp1
The text was updated successfully, but these errors were encountered: