user3527451
user3527451

Reputation: 87

Update the axis labels with rChart

I just discovered rChart and googleVis and i want to thank developers for their job. My problem is simple, i want to add a variable label to my axis for nplot? I also want to know if it's possible to add variable like sizevar and colorvar of gvisBubbleChart to nplot ?

Thank you.

library(rCharts)
VehiculeFunction <- function(data, gamme, absciss, ordinate){

  # Aim: Permet de visualiser les données sous la forme de nuages de points 
  #      croisant GMF*Coût,  Ratio K * Ratio Coût ou bien GMF*Ratio en 
  #      choisissant la gamme qu'on désire
  # Input: data.frame avec notamment GAMME, PROJET, PERIMETRE, NITG, GMF.24,
  #        Cout.24 et libele
  # Output: Graphique avec le croisement choisi ainsi que le libellé étiquetté
  #         sur le point qu'on voudra identifier

  if(absciss == "GMF.24"){
    my.data <- data[data$RANG_NITG_PROJET_K %in% c(1, 2, 3),]
  } else if(absciss == "Ratio.K") {
    my.data <- data[data$RANG_NITG_PROJET_C %in% c(1, 2, 3),]
  }
  my.data2 <- my.data[my.data$GAMME == gamme,]
  X <- my.data2[[absciss]] 
  Y <- my.data2[[ordinate]] 
  SIZEVAR <- my.data2$Ratio.K
  df <- data.frame(X,Y,SIZEVAR)

  plot <- nPlot(x = "X", y = "Y", size = "SIZEVAR", data = df, type = "scatterChart")
  plot$xAxis(axisLabel = 'X')
  plot 
}


VehiculeFunction(data.vehicule, gamme = "M1", "GMF.24", "Cout.24")

Upvotes: 0

Views: 122

Answers (1)

Rachel Gallen
Rachel Gallen

Reputation: 28573

Usage:

gvisBubbleChart(data, idvar = "", xvar = "", yvar = "",
                  colorvar = "", sizevar = "",
                  options = list(), chartid)

E.G.

 ## Set color and size
 bubble2 <- gvisBubbleChart(Fruits, idvar="Fruit", xvar="Sales", yvar="Expenses",
                      colorvar="Location", sizevar="Profit",
                      options=list(hAxis='{minValue:75, maxValue:125}'))

SEE http://www.inside-r.org/packages/cran/googleVis/docs/gvisBubbleChart

Upvotes: 1

Related Questions