label above points with rChart Failed with Chinese

2019-08-12 17:40发布

问题:

My problem is just like label above points with rChart

*but my label contains Chinese code, my code is like this:

library(rCharts)
age <- c(1:20)
tall <- seq(0.5, 1.90, length = 20)
name <- rep(c("运营成本由一降为2","游戏进行推广","开始安全运行","无事件","this is"),4)
Encoding(name)<-'UTF-8'
df <- data.frame(age = age, tall = tall,name=name)
n1 <- nPlot(age ~ tall ,data = df, type = "scatterChart")
n1$xAxis(axisLabel = "the age")
n1$yAxis(axisLabel = "the tall", width = 50)
n1$chart(tooltipContent = "#! function(key, x, y, e ){ 
  var d = e.series.values[e.pointIndex];
  return 'x: ' + x + '  y: ' + y + ' name: ' + d.name
} !#")
n1