本文介绍了更改rCharts Sankey图上的字体大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用以下代码使用rCharts创建Sankey图.我希望增加打印在Sankey图上的文本的字体大小.我找不到手册来说明如何执行此操作.有想法吗?

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

推荐答案

基于这个答案,您可以添加脚本来自定义您的情节.要更改文本大小,您可以添加:

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>
")

这篇关于更改rCharts Sankey图上的字体大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-15 01:42