# observable plot background color

**URL:** <https://talk.observablehq.com/t/observable-plot-background-color/7021>\
**Category:** Help\
**Created:** [September 9, 2022, 1:51pm UTC](https://talk.observablehq.com/t/observable-plot-background-color/7021 "2022-09-09T13:51:06Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jchrist](https://avatars.discourse-cdn.com/v4/letter/j/858c86/32.png) [@jchrist](https://talk.observablehq.com/u/jchrist)\
**Post date:** [September 9, 2022, 1:51pm UTC](https://talk.observablehq.com/t/observable-plot-background-color/7021/1 "2022-09-09T13:51:06Z")

</div>

I have build a chart with observalble plot with a dark background: [https://observablehq.com/embed/b148b6e87a01be8f?cells=chart%2Cviewof+contcheck%2Cviewof+years%2Cviewof+wert%2Clabel%2Ctitle%2Cviewof+toggleanzeige%2Cviewof+togglepop%2Ccredits%2CmyStyles](https://observablehq.com/embed/b148b6e87a01be8f?cells=chart%2Cviewof+contcheck%2Cviewof+years%2Cviewof+wert%2Clabel%2Ctitle%2Cviewof+toggleanzeige%2Cviewof+togglepop%2Ccredits%2CmyStyles)

Unfortunately there is a small area on the right where the background is not filled with that colour. I don´t know why. Here is the notebook where everything looks right: [Emissionen (dark) / RND / Observable](https://observablehq.com/@rnd/emissionen-dark?oetm_referrer=&oetm_route=%2Fd%2Fb148b6e87a01be8f)

This is the code:

```
    style: {
      backgroundColor: '#293845',
      color: '#ffffff',
    },

```

---

<div class="post-metadata">

**Author:** ![mootari](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/mootari/32/581_2.png) [@mootari](https://talk.observablehq.com/u/mootari)\
**Post date:** [September 9, 2022, 2:29pm UTC](https://talk.observablehq.com/t/observable-plot-background-color/7021/2 "2022-09-09T14:29:13Z")

</div>

Hi @jchrist! Unfortunately this is a problem with how Observable’s Standard Library computes `width`:

- Your external stylesheet changes `document.body.clientWidth`, but only _after_ the initial value for `width` has been computed.
- Then, because loading your styles does not trigger a “resize” event, the Plot chart will still use the stale `width` value.

If you resize the window manually you’ll see the chart expand.

---

<div class="post-metadata">

**Author:** ![Fil](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/fil/32/207_2.png) [@Fil](https://talk.observablehq.com/u/Fil)\
**Post date:** [September 9, 2022, 2:32pm UTC](https://talk.observablehq.com/t/observable-plot-background-color/7021/3 "2022-09-09T14:32:54Z")

</div>

As a complement, here’s a change that seems to fix this notebook, at least for me (testing with Chrome—for some reason the bug doesn’t show up on Safari):

```auto
  Plot.plot({
    width: (width, document.body.clientWidth),

```

---

<div class="post-metadata">

**Author:** ![jchrist](https://avatars.discourse-cdn.com/v4/letter/j/858c86/32.png) [@jchrist](https://talk.observablehq.com/u/jchrist)\
**Post date:** [September 9, 2022, 2:42pm UTC](https://talk.observablehq.com/t/observable-plot-background-color/7021/4 "2022-09-09T14:42:28Z")

</div>

that does the trick, thank you for helping me!
