r - Changing legend label in googleVis charts -


how change default legend labels in googlevis chart?

what have tried

i see there labelinlegend setting, , can hardcode options see below:

  library(data.table)   library(googlevis)    test.dt  <- data.table(day = c(1,2,3), value = c(0.8,1.2,1.2),                           price = c(1,1.1,1.2), name = c("a","a","a"))     # set chart options in hamfisted hardcoded way   testop <- list(series = "[{labelinlegend: 'a price'},                             {labelinlegend: 'a value'}]",                  legend = chart.op$op.legend)    testplotdatay <-  c("price", "value")    plot(gvislinechart(test.dt,                       xvar = "day",                      yvar = testplotdatay,                      options = testop)) 

to get: googlelinechartlegend

but how make work in parameterised way?

do still need send in json string googlevis as old answer suggests, or there easier way? example, googlevis supports data roles (for annotationtext, scope).

the task

i looking add name in front of numeric fields plotted distinguish when more 1 company selected e.g. price, b price in legend.

mylabels <- paste(unique(test.dt$name), testplotdatay)  # i.e. "a price" "a value"  

i have tried send googlevis no luck:

testop <- list(labelinlegend  = mylabels) 

or

testop <- list(series.labelinlegend  = mylabels) 

what more seasoned googlevis users do?

and, if have use tojson() parameterize right syntax?

edit: googlevis 0.5.9, r 3.1.3


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

jquery - javascript onscroll fade same class but with different div -