2013-10-08 61 views
5

我目前使用rCharts包中的nPlot,以及如何向y軸添加$符號?rChart nPlot - 更新yAxis標籤

我想我需要類似n1$yAxis(labels = ...)但我不認爲nPlot支持這個?

test <- data.frame(object = c("A", "B"), price = c(111333, 876176)) 
test$Test <- "TEST" 
n1 <- nPlot(price~Test, group = "object", data = test, type = "multiBarChart") 

此外,它看起來像NPLOT被四捨五入至5個顯著數字(最初以爲是四捨五入到最接近的10),在那裏顯示全值的方法嗎?

感謝,

+0

你想要一個美元符號到y軸標題嗎? – Michele

+1

我剛推出了一個修復'rCharts'的'dev'分支。它在轉換爲json時使用13位數字,並且可以使用'options('rcharts.digits')'進行控制。 – Ramnath

+0

@Michele我想添加美元符號到y軸標籤,例如類似scale_y_continuous(「價格」,標籤=美元)從秤包 – MKa

回答

7

我張貼我的評論作爲一個完整的解決方案,因此,它是爲別人尋找更容易。

require(rCharts) # install the latest from the dev branch 
test <- data.frame(object = c("A", "B"), price = c(111333, 876176)) 
test$Test <- "TEST" 
n1 <- nPlot(price~Test, group = "object", data = test, type = "multiBarChart") 
n1$yAxis(tickFormat = "#! function(d) {return '$' + d} !#") 
+0

感謝拉姆納特,這增加了美元符號,但擺脫了','1,000分隔符。如何在同一時間添加$和分隔符? – MKa

+3

嘗試 n1 $ yAxis(tickFormat =「#!function(d){return'$'+ d3.format(',。2f')(d)}!」# – timelyportfolio

+0

@timelyportfolio完美運作!謝謝! – MKa