# Change background color depending on displayed value

**URL:** <https://community.grafana.com/t/change-background-color-depending-on-displayed-value/30911>\
**Category:** Stat Panel\
**Tags:** mysql\
**Created:** [May 26, 2020, 8:25am UTC](https://community.grafana.com/t/change-background-color-depending-on-displayed-value/30911 "2020-05-26T08:25:59Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![wucis](https://avatars.discourse-cdn.com/v4/letter/w/db5fbb/32.png) [@wucis](https://community.grafana.com/u/wucis)\
**Post date:** [May 26, 2020, 8:25am UTC](https://community.grafana.com/t/change-background-color-depending-on-displayed-value/30911/1 "2020-05-26T08:25:59Z")

</div>

I’m using a simple mysql-query and like to change the background color depending on the query result  
The query looks like

```
select mydb.status
from mydb
where 1=1
AND agentid = 11
AND key = 123
```

---

<div class="post-metadata">

**Author:** ![mgrimm](https://avatars.discourse-cdn.com/v4/letter/m/9de053/32.png) [@mgrimm](https://community.grafana.com/u/mgrimm)\
**Post date:** [May 26, 2020, 9:32am UTC](https://community.grafana.com/t/change-background-color-depending-on-displayed-value/30911/2 "2020-05-26T09:32:13Z")

</div>

Hi wucis,

The result from your query would be helpful. Assuming that only a single value returns, this should be a number.  
Then you can select SingleStat as visualization, check Background in the coloring section, enter the thresholds and choose the colors you want.

 ![2020-05-26_11h25_10](https://us1.discourse-cdn.com/grafana/original/2X/a/ad65c19144848506923067ba53fb2255f4067659.png)

---

<div class="post-metadata">

**Author:** ![wucis](https://avatars.discourse-cdn.com/v4/letter/w/db5fbb/32.png) [@wucis](https://community.grafana.com/u/wucis)\
**Post date:** [May 26, 2020, 12:43pm UTC](https://community.grafana.com/t/change-background-color-depending-on-displayed-value/30911/3 "2020-05-26T12:43:03Z")

</div>

mgrimm, thanks for your fast replie(s). I do not have the layout/options which are displayed in your answer. I installed version 7.0.1. (opensource edition) from today and the visualization ‘Stat’ has no such options as ‘Prefix’ , ‘Postfix’ . I miss also the font size tuning options.  
The ‘Stat’ visualization has the option Field | Thresholds where I could implement the changing background color depending on the displayed value.

For the records only: Yes the query returns only a single value in this case.

---

<div class="post-metadata">

**Author:** ![mgrimm](https://avatars.discourse-cdn.com/v4/letter/m/9de053/32.png) [@mgrimm](https://community.grafana.com/u/mgrimm)\
**Post date:** [May 26, 2020, 1:44pm UTC](https://community.grafana.com/t/change-background-color-depending-on-displayed-value/30911/4 "2020-05-26T13:44:48Z")

</div>

Sorry, didnt know you’re using the newest version. But it’almost the same only in a different layout.

 ![2020-05-26_15h42_34](https://us1.discourse-cdn.com/grafana/original/2X/a/af6f4da6d0f1d5c05cde1d272f31c95d921a8ca7.png)

---

<div class="post-metadata">

**Author:** ![wucis](https://avatars.discourse-cdn.com/v4/letter/w/db5fbb/32.png) [@wucis](https://community.grafana.com/u/wucis)\
**Post date:** [May 26, 2020, 3:29pm UTC](https://community.grafana.com/t/change-background-color-depending-on-displayed-value/30911/5 "2020-05-26T15:29:25Z")

</div>

No problem, I’m a grafana-newbie, so I went with the current version 😉  
Can you confirm, that version 7.0 has no options for font size and pre/postfix in the single stat visualization ?

---

<div class="post-metadata">

**Author:** ![hann1](https://avatars.discourse-cdn.com/v4/letter/h/4af34b/32.png) [@hann1](https://community.grafana.com/u/hann1)\
**Post date:** [November 9, 2021, 2:56pm UTC](https://community.grafana.com/t/change-background-color-depending-on-displayed-value/30911/6 "2021-11-09T14:56:01Z")

</div>

Hi @wucis do u know how to use the value that are fetched but not displayed for this situation?
