Hello, I'm having trouble with the `<PieChart>` co...
# gooddata-ui
c
Hello, I'm having trouble with the
<PieChart>
component's
sortBy
prop. I've set the sort order in GD to alphabetical Z->A, but the legend and chart continue to be sorted by largest to smallest. I am passing the visualizationObjects response values (
data.attributes.content.sorts
) directly into the prop. Another odd thing: when I change it to smallest to largest, the colors of the pie chart change, but the legend names/order do not (note: it looks as expected in the GD UI, but not using the PieChart component in our app). I am using 9.0.1 for all @gooddata libs... any ideas?
👀 1
Hi @Radek Novacek, any news on this?
r
Hello there @Cayce Collins, unless you're using GD.CN (since that one has version dependencies), would it be possible for you to upgrade and re-test? Many thanks 🙂
c
Hi @Radek Novacek, we are using GD CN 2.3.2 in this case. Is there a known issue with this? Right now it is not possible for our company to update this environment to 2.4.
I checked with an older version of the UI SDK (8.11 and 8.12) as well as the latest (9.2), but I'm still seeing the same behavior. Could we schedule a call to investigate this a bit more? We are a paying customer.
pinging @David Ramirez and @Isadora Betancourt as well (per my manager's suggestion)
r
Hi @Cayce Collins, let me reach out to you via private messages 🙂
c
adding additional context for others in this thread and pinging @Phanindra, @rohit mathur, and @John Richardson In our app, we are doing the following: 1. Fetch all insights for a specific workspace using
tigerFactory
(via
workspace().insights().getInsights()
) 2. For each insight (when we need to render it), we extract the measures, views, and segments from the insight's buckets 3. Determine the chart type (from the
visualizationObjects
endpoint response) and use corresponding component (in this case
<PieChart>
) 4. Pass the props to the component as such:
Copy code
// Note: `insightData` is this insight's data object from `getInsights` sdk response

<PieChart
  measures={measures} // measures from bucket.items
  viewBy={views[0]} // view/attribute/trend from bucket.items
  filters={chartFilters}
  config={chartConfig} // insightData.insight.properties.controls
  sortBy={insightData?.insight?.sorts}
/>
For others who may run into this issue in the future... Per Radek's response in the support ticket:
turns out that to get the sorting working, your Pie Chart config also needs to include
enableChartSorting: true
in order for the
sortBy
to work properly.
This was not documented in the UI Chart Config docs here, but can be found in the API reference docs here. Additionally it seems to only be relevant for some charts while others will work as expected without it. Thanks again @Radek Novacek for the assistance!
🙌 1