# Change the labels on Pie in Canvas

**URL:** <https://discuss.elastic.co/t/change-the-labels-on-pie-in-canvas/269458>\
**Category:** Kibana\
**Tags:** canvas\
**Created:** [April 7, 2021, 12:03pm UTC](https://discuss.elastic.co/t/change-the-labels-on-pie-in-canvas/269458 "2021-04-07T12:03:32Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![EduardoM](https://avatars.discourse-cdn.com/v4/letter/e/bbe5ce/32.png) [@EduardoM](https://discuss.elastic.co/u/EduardoM)\
**Post date:** [April 7, 2021, 12:03pm UTC](https://discuss.elastic.co/t/change-the-labels-on-pie-in-canvas/269458/1 "2021-04-07T12:03:32Z")

</div>

How can I change the labels on Pie in Cavas.

![image](https://us1.discourse-cdn.com/elastic/original/3X/f/2/f26dbf2b948c326feca8d60d873ef290a468cd46.png)  
and I want to have "car" and "bus" instead of 1 and 2.

I should change this's :  
filters

```
| essql

query="SELECT SUM(Produced) AS Production,typ FROM \"data*\"

WHERE QUERY ('pxp')

AND event = 'ab'

AND typ >0

GROUP BY typ "

| pointseries color="typ" size="Production"

| pie legend=false labels=true

font={font align="center" color="#FFFFFF" family="'Open Sans', Helvetica, Arial, sans-serif" italic=false size=24 underline=false weight="normal"} labels=true hole=0 labelRadius=48 radius=1 tilt=1 seriesStyle={seriesStyle label="1" color="#1785b0"}

seriesStyle={seriesStyle label="2" color="#1ea6dc"}

| render

```

Could anyone help me ? I can not it solve.

---

<div class="post-metadata">

**Author:** ![jportner](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jportner/32/75692_2.png) [@jportner](https://discuss.elastic.co/u/jportner)\
**Post date:** [April 7, 2021, 5:53pm UTC](https://discuss.elastic.co/t/change-the-labels-on-pie-in-canvas/269458/2 "2021-04-07T17:53:47Z")

</div>

These labels are from the "typ" column, right?  
You can try inserting this directly after the `essql` function (before the `pointseries` function):

```auto
| mapColumn name="typ" expression={getCell "typ" | switch {case "1" then="car"} {case "2" then="bus"}}

```

---

<div class="post-metadata">

**Author:** ![EduardoM](https://avatars.discourse-cdn.com/v4/letter/e/bbe5ce/32.png) [@EduardoM](https://discuss.elastic.co/u/EduardoM)\
**Post date:** [April 9, 2021, 7:20am UTC](https://discuss.elastic.co/t/change-the-labels-on-pie-in-canvas/269458/3 "2021-04-09T07:20:03Z")

</div>

Exactly the column "type" has the value 1 and 2. I think that I have done some wrong because it is not working:

```
| filters
| essql
query="SELECT SUM(Produced) AS Production,typ FROM \"data*\"
WHERE QUERY ('pxp')
AND event = 'ab'
AND typ >0
GROUP BY typ "

```

> | mapColumn name="typ" expression={getCell "typ" | switch {case "1" then="car"} {case "2" then="bus"}}

```
| pointseries color="typ" size="Production"
    | pie legend=false labels=true
    font={font align="center" color="#FFFFFF" family="'Open Sans', Helvetica, Arial, sans-serif" italic=false size=24 underline=false weight="normal"} labels=true hole=0 labelRadius=48 radius=1 tilt=1 seriesStyle={seriesStyle label="1" color="#1785b0"} seriesStyle={seriesStyle label="2" color="#1ea6dc"}
| render

```

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/6/f/6fc9111e8c1f3da8adfeebfe162123b91549ec72.png)

---

<div class="post-metadata">

**Author:** ![jportner](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jportner/32/75692_2.png) [@jportner](https://discuss.elastic.co/u/jportner)\
**Post date:** [April 13, 2021, 2:25pm UTC](https://discuss.elastic.co/t/change-the-labels-on-pie-in-canvas/269458/4 "2021-04-13T14:25:11Z")

</div>

I apologize for the dumb question, but after you added the `mapColumn` function, did you click the Run button to re-render?

For reference, here's what I did on my own Kibana instance to test this out. (I'm currently running the latest from source so it might look a bit different than what you see!)

1. From the Home page, install the Logs sample data
2. Navigate to the Canvas app, and open the "[Logs] Web Traffic" workpad
3. Find the existing pie chart for "bytes transferred", resize it to make it larger, and check the "Show labels" switch on the right side:  
 ![image](https://us1.discourse-cdn.com/elastic/original/3X/2/b/2beaa34182551c8e30e1b79c0990b2755591ee0d.png)
4. Open the Expression editor, add a `mapColumn` function, and click the Run button to see the changes:  
 ![image](https://us1.discourse-cdn.com/elastic/original/3X/3/e/3eb9412511d9a49c2cafdf11a3282671cedac705.png)

Can you test with the sample data like that and see if it works for you?

---

<div class="post-metadata">

**Author:** ![EduardoM](https://avatars.discourse-cdn.com/v4/letter/e/bbe5ce/32.png) [@EduardoM](https://discuss.elastic.co/u/EduardoM)\
**Post date:** [April 14, 2021, 8:35am UTC](https://discuss.elastic.co/t/change-the-labels-on-pie-in-canvas/269458/5 "2021-04-14T08:35:12Z")

</div>

Of course, I did it. Thanks to your images, I realized the problem in the code, my column "typ" has 1 and 2 but I write it as follows:

> | switch {case "1" then="Euro"} {case "2" then="Half"}}

but it should be like this :

> | switch {case 1 then="Euro"} {case 2 then="Half"}}

The numbers should be without the quotation marks and for the text have to put the quotation marks. It was the problem, maybe it's a concept so basic where the numbers must be put without quotation marks and the text with them. So, now it's working your advice.  
Thank you very much.

---

<div class="post-metadata">

**Author:** ![jportner](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jportner/32/75692_2.png) [@jportner](https://discuss.elastic.co/u/jportner)\
**Post date:** [April 14, 2021, 1:52pm UTC](https://discuss.elastic.co/t/change-the-labels-on-pie-in-canvas/269458/6 "2021-04-14T13:52:05Z")

</div>

Ah, I didn't consider the difference between numbers and strings. I learned something today too! Glad it was a simple fix.

---

<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:** [May 12, 2021, 1:52pm UTC](https://discuss.elastic.co/t/change-the-labels-on-pie-in-canvas/269458/7 "2021-05-12T13:52:09Z")

</div>

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