2

I'm using the following code to create a Sankey Diagram using rCharts. I wish to increase the font size of the text printed on the Sankey Diagram. I can't find a manual to show me how to do this. Thoughts?

rm(list = ls())
require(reshape)
require(rCharts)
require(rjson)
target <- c('TMF', 'TMF', 'TMF','Evaporation','Mill Reclaim','Void Losses','Seepage')
source <- c('Precipitation & Run Off','Slurry','Other','TMF','TMF','TMF','TMF')
value <- c(638,1610,755,118,1430,466,2)
x <- data.frame(target,source,value)
sankeyPlot <- rCharts$new()
sankeyPlot$set(
data = x,
nodeWidth = 10,
nodePadding = 10,
layout = 32,
width = 1100,
height = 675,
units = "cubic metres",
title = "Sankey Diagram"
)
sankeyPlot$setLib('http://timelyportfolio.github.io/rCharts_d3_sankey')
sankeyPlot
VividD
  • 10,456
  • 6
  • 64
  • 111
Reuben Mathew
  • 598
  • 4
  • 22

2 Answers2

4

Based on this answer you can add scripts to customize your plots. To change the text-size, you could add:

sankeyPlot$setTemplate(
        afterScript = "
<script>
d3.selectAll('#{{ chartId }} svg text')
  .style('font-size', '55')
</script>
")
Community
  • 1
  • 1
NicE
  • 21,165
  • 3
  • 51
  • 68
  • Didn't work for me 'as is'; I needed to add `'px'` to the size to get it working. – MBR Aug 17 '15 at 16:08
1

I was able to change the font size after creating the sankey diagram by setting the fontSize option:

#create sankey diagram
p<-sankeyNetwork(...)

#the default font size    
> p$x$options$fontSize
    [1] 7

#set desired font size
p$x$options$fontSize<-10