# Can't get shape to render with correct color

**URL:** https://discuss.elastic.co/t/cant-get-shape-to-render-with-correct-color/193552
**Category:** Kibana
**Tags:** canvas
**Created:** [August 2, 2019, 2:03pm UTC](https://discuss.elastic.co/t/cant-get-shape-to-render-with-correct-color/193552 "2019-08-02T14:03:31Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![rickardp](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rickardp/32/50905_2.png) [@rickardp](https://discuss.elastic.co/u/rickardp)
#### Post date: [August 2, 2019, 2:03pm UTC](https://discuss.elastic.co/t/cant-get-shape-to-render-with-correct-color/193552/1 "2019-08-02T14:03:32Z")

</div>

Just starting out with Canvas so bear with me 🙂

I am trying to get a box colored based on status, and here's what I have so far

```
filters
| essql 
  query="SELECT
 CASE WHEN LAST(\"kubernetes.pod.status.phase\", \"@timestamp\") = 'failed' THEN 0
      WHEN LAST(\"kubernetes.pod.status.phase\", \"@timestamp\") = 'pending' THEN 1
      ELSE 100 END as status,
 CASE WHEN LAST(\"kubernetes.pod.status.phase\", \"@timestamp\") = 'failed' THEN '#ff0000'
      WHEN LAST(\"kubernetes.pod.status.phase\", \"@timestamp\") = 'pending' THEN '#ffff00'
      ELSE '#00ff00' END as color,
 \"kubernetes.pod.name\" as podname
 FROM \"metricbeat-*\" 
WHERE
 \"kubernetes.app\" = 'proxy'
AND 
  \"kubernetes.pod.status.phase\" IS NOT NULL
GROUP BY
  podname"
| sort | shape "square" fill="{{rows.[0].color}}" border="rgba(255,255,255,0)" borderWidth=0 maintainAspect=false | render

```

I have verified that the query outputs the correct data, an dthe above expression works perfectly when I output the color in a "markdown" text. But the shape box remains black.

I feel like I am missing something fundamental here, but I'm not sure where to even start digging, and I can't find any examples of something similar in the docs.

---

<div class="post-metadata">

### Author: ![lukeelmers](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lukeelmers/32/35230_2.png) [@lukeelmers](https://discuss.elastic.co/u/lukeelmers)
#### Post date: [August 2, 2019, 8:53pm UTC](https://discuss.elastic.co/t/cant-get-shape-to-render-with-correct-color/193552/2 "2019-08-02T20:53:05Z")

</div>

Hi @rickardp,

Assuming the query outputs the correct data, I think the problem lies in the way you are trying to access `{{rows.[0].color}}` in the `fill` argument.

Fill is expecting a hex code, so it won't understand the handlebars template you are trying to give it; it's probably just thinking you provided a malformed color string, and falls back to black.

In order to get the correct hex code, you'll want to use the `getCell` function as a subexpression to pull the cell from the correct place:

```auto
fill={getCell column="color" r=0}

```

This is going to take the `color` value from the first row of results and pass it as the `fill`, which (I think) is what you are trying to do.

Hope this helps!

---

<div class="post-metadata">

### Author: ![rickardp](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rickardp/32/50905_2.png) [@rickardp](https://discuss.elastic.co/u/rickardp)
#### Post date: [August 5, 2019, 7:15am UTC](https://discuss.elastic.co/t/cant-get-shape-to-render-with-correct-color/193552/3 "2019-08-05T07:15:05Z")

</div>

> [@lukeelmers](#):
>
> {getCell column="color" r=0}

That works, thank you! I thought the Handlebars templates worked everywhere in the same way, but apparently not. Still learning as I go along 🙂

---

<div class="post-metadata">

### Author: ![lukeelmers](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lukeelmers/32/35230_2.png) [@lukeelmers](https://discuss.elastic.co/u/lukeelmers)
#### Post date: [August 5, 2019, 3:27pm UTC](https://discuss.elastic.co/t/cant-get-shape-to-render-with-correct-color/193552/4 "2019-08-05T15:27:06Z")

</div>

No problem! Yeah the Handlebars templates are a feature of the Markdown element in Canvas specifically, but they are not a core feature of the expression language.

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [September 2, 2019, 3:27pm UTC](https://discuss.elastic.co/t/cant-get-shape-to-render-with-correct-color/193552/5 "2019-09-02T15:27:09Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
