Вопрос

Is addControls() compatible with type=pieChart using nPlot()?
The pie chart disappears as soon as I try to add controls.

Im attempting the following:

Sp = c("a", "b", "c", "d") 
A = c(10, 4, 3, 0) 
B = c(3, 5, 22, 4) 
C = c(1, 0 ,10, 8)
df = data.frame(Sp, A, B, C)

p1 <- nPlot(x = "Sp", y ="A" ,
        color = 'Sp', data = df, type = 'pieChart')
p1$addControls('y', 'A', values=c('A','B','C'))
p1

It works perfectly if I use multiBarHorizontalChart instead.

Thank you!

Это было полезно?

Решение

On further investigation, I realized that this is a bug in rCharts, which has been fixed on the dev branch. You can install it using devtools::install_github('ramnathv/rCharts@dev').

So running the code below will produce this chart with controls

library(rCharts)
Sp = c("a", "b", "c", "d") 
A = c(10, 4, 3, 0) 
B = c(3, 5, 22, 4) 
C = c(1, 0 ,10, 8)
df = data.frame(Sp, A, B, C)

p1 <- nPlot(x = "Sp", y ="A" , data = df,
  group = 'Sp', type = 'pieChart'
)
p1$addControls('y', 'A', values=c('A','B','C'))
p1
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top