Displaying Mapped Values in Pie Chart Labels Instead of Original IDs

Hello everyone,

I have set up a table in Retool with two columns: strategy_group and weight. In the strategy_group column, the original data consists of IDs, but I have utilized the mapped value feature within the column settings to display corresponding descriptive names instead of these IDs. Now, I am trying to create a pie chart which reflects the sum of weights, with the value labels displayed as the descriptive names from the strategy_group column.

However, the pie chart currently shows the original ID values (e.g., 1,2,3,4) in the labels instead of the mapped descriptive names. Could someone guide me on how to configure the pie chart to display the mapped values from the strategy_group column as the labels?

Any help would be much appreciated. Thank you in advance!

Best regards,
Fabio

Screenshot 2023-09-22 at 15.21.04

Can you share what the inspect panel contains?

Need more info for the pie chart component... how is it set up?

chat inspect:
Screenshot 2023-09-22 at 15.48.00
Screenshot 2023-09-22 at 15.48.14

table inspect row example:
Screenshot 2023-09-22 at 15.48.52

config:

What does the plotly view look like?

[
  {
    "name": "weight",
    "labels": {{GET_FUNDS.data['strategy_group']}},
    "values": {{GET_FUNDS.data['weight']}},
    "type": "pie",
    "automargin": true,
    "layout": {
      "legend": {
        "xanchor": "left",
        "orientation": "v"
      }
    },
    "marker": {
      "colors": {{(GET_FUNDS.data['strategy_group']).map(v => ['#033663','#247BC7','#55A1E3','#DAECFC'][[...new Set(GET_FUNDS.data['strategy_group'])].indexOf(v)])}}
    }
  }
]

I am not certain but just by adding a chart and using sample data - the formatting is different for labels.....
Screenshot 2023-09-22 at 10.14.58 AM

I can change the plotly code to match, but the same issue remains

[
  {
    "name": "weight",
    "labels": {{formatDataAsObject(table2.data).strategy_group}},
    "values": {{formatDataAsObject(table2.data).weight}},
    "type": "pie",
    "automargin": true,
    "layout": {
      "legend": {
        "xanchor": "left",
        "orientation": "v"
      }
    },
    "marker": {
      "colors": {{(formatDataAsObject(table2.data).strategy_group).map(v => ['#033663','#247BC7','#55A1E3','#DAECFC'][[...new Set(formatDataAsObject(table2.data).strategy_grpup)].indexOf(v)])}}
    }
  }
]

The following
{{formatDataAsObject(table2.data).strategy_group}}

should be
{{formatDataAsObject(table2.data)['strategy_group']}}

same issue - i think the problem is that it passes the value from the underlying table, not the mapped value.

That makes sense so you may have to take the mapped value instead by transforming the data for that column. I will try to get back to this as soon as I can but cannot at the moment

No worries, I restructured the query to join the name rather than mapping it on the table. Thank you for the support!

2 Likes