Change the chartArea background color of gvisAnnotationChart
Asked Answered
F

1

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"
    )
  )
)
Footwork answered 1/4, 2022 at 6:52 Comment(2)
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?...Vaporization
I haven't tested, but could it be because the option is chartArea.backgroundColor while you have specified chart.backgroundColor?Kershner
L
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

Lurid answered 4/4, 2022 at 14:53 Comment(3)
Great! Maybe this one too? :-) #71748972Footwork
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.).Lurid
I figured that linked question out! Woooo hooo! That one took a while.Lurid

© 2022 - 2024 — McMap. All rights reserved.