2015-05-23 25 views
2

我使用以下代碼使用rCharts創建Sankey圖。我希望增加在Sankey圖上打印的文字的字體大小。我找不到一本手冊來告訴我如何做到這一點。思考?更改rCharts上的字體大小Sankey圖

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 

回答

4

根據this answer您可以添加腳本來自定義您的圖。要更改文字大小,您可以添加:

sankeyPlot$setTemplate(
     afterScript = " 
<script> 
d3.selectAll('#{{ chartId }} svg text') 
    .style('font-size', '55') 
</script> 
") 
+0

奇妙!非常感謝! –

+0

沒有爲我工作'原樣';我需要添加''px''來使其工作。 – MBR