Set bar color via style role in googlevis package for R

45 Views Asked by At

I'm using the GoogleVis Package for R but I'm failing to use a column as data role to change the style of the bar. Currently my dataframe looks like this:

enter image description here

All I wanted to do was to control the bar color via the "style" column. I have tried renaming it to value.style as well as municipio.style but none of these worked. When I create the graph using the googleVis::gvisTimeline() function it just ignores the colors in this column and proccess the graph with the default color schema.

The result I wanted to achieve is this: enter image description here

However I'm currently getting this: enter image description here

I know I can manually adjust this by using the "options" when processing the chart, but for hundred of reasons I would rather do it using the style role column, if possible.

Thanks

1

There are 1 best solutions below

0
Jn Coe On

Just add the style column to the 'barlabel' parameter:

googleVis::gvisTimeline(data=cronograma_final,
                         rowlabel="municipio",
                         barlabel=c("value", "value.style"),
                         start="start", 
                         end="end",
                         options=list(timeline="{groupByRowLabel:true}"))

OBS.: I renamed it to 'value.style'