How does one format the data properly for pie chart in Chart.JS

Apologies, I am tearing my hair out trying to figure out how to properly format the data to input into a pie chart Chart.JS element:

In the LABEL formula section, I am using the following:

map(filterByKey(collections[‘c53e963d-a3f8-4105-8192-89c4da37dfca’][‘data’],“portfolio_name”,variables[‘163c7f3a-9848-4d66-b070-7ef43a8d1e53’]),“strategy_name”)

This returns the label array:

["Torray ", “Osterweis”]

In the dataset section, I am using the following formula:

map(filterByKey(collections[‘c53e963d-a3f8-4105-8192-89c4da37dfca’][‘data’],“portfolio_name”,variables[‘163c7f3a-9848-4d66-b070-7ef43a8d1e53’]),“weight”)

This yields the output array:

[0.5,0.3]

But the chart does not show. I tried to read through the Dashboard app example for the pie chart, but did not understand it.

Can anyone please help me fix this?

Thank you,

Michael

Are you using the “advanced” mode in the settings?
The datasets parameter is not an array of values but an array of objects.

If you have a look at the pie documentation you can see an example of datasets like this:

  datasets: [{
    label: 'My First Dataset',
    data: [300, 50, 100],
    backgroundColor: [
      'rgb(255, 99, 132)',
      'rgb(54, 162, 235)',
      'rgb(255, 205, 86)'
    ],
    hoverOffset: 4
  }]```

Dorilama, Thanks! I got it to work.

1 Like