Change the labels on Pie in Canvas

How can I change the labels on Pie in Cavas.

image
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.

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

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

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

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:
  4. Open the Expression editor, add a mapColumn function, and click the Run button to see the changes:

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

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.

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