5

How to change the chartArea background color of gvisAnnotationChart?

I tried this but didn't work (I tried to replicate what I saw in this answer)

gvisAnnotationChart(
...,
options = list(
    ...,
    chart = list(
      backgroundColor = "#D3D3D3"
    )
  )
)
Brani
  • 6,454
  • 15
  • 46
  • 49
  • The answer is in the link you provided: It is not implemented in gvisAnnotationChart(). I am not that familiar with googleVis. Maybe there is a workaround?... – Lucas Apr 01 '22 at 08:38
  • I haven't tested, but could it be because the option is `chartArea.backgroundColor` while you have specified `chart.backgroundColor`? – jpiversen Apr 01 '22 at 08:38

1 Answers1

2

This is using one of the charts in the package demo, with an option for background color designated so you can see how it's documented.

Because the gvisAnnotationChart has side panels, chart area, chart, and other designated panel-type areas, all of which could have different backgrounds, you have to be really specific for this type of chart.

library(googleVis)
data(Stock)

plot(gvisAnnotationChart(Stock, datevar="Date",
                         numvar="Value", idvar="Device",
                         titlevar="Title", annotationvar="Annotation",
                         options=list(
                           displayAnnotations=TRUE,
                               # make it blue
                           chart = "{chartArea:{backgroundColor:'#003b70'}}",
                           legendPosition='newRow',
                           width=600, height=350)))

enter image description here

Kat
  • 15,669
  • 3
  • 18
  • 51
  • Great! Maybe this one too? :-) https://stackoverflow.com/questions/71748472/how-to-change-text-color-in-a-voronoitreemap-legend – Brani Apr 05 '22 at 08:25
  • 1
    I've worked with that question quite a bit. I haven't found anything that's worked so far. There is very little support on that one. There isn't even any widget options built in for options like many other widget-type packages have (i.e., `DT`, `plotly`, etc.). – Kat Apr 06 '22 at 01:26
  • 1
    I figured that linked question out! Woooo hooo! That one took a while. – Kat Apr 06 '22 at 19:47