Cayce Collins
10/11/2023, 8:07 PM<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?Cayce Collins
10/13/2023, 5:23 PMRadek Novacek
10/16/2023, 8:17 AMCayce Collins
10/16/2023, 3:19 PMCayce Collins
10/16/2023, 6:28 PMCayce Collins
10/16/2023, 6:33 PMRadek Novacek
10/17/2023, 8:22 AMCayce Collins
10/18/2023, 4:08 PMtigerFactory
(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:
// 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}
/>
Cayce Collins
10/19/2023, 6:03 PMturns out that to get the sorting working, your Pie Chart config also needs to includeThis 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!in order for theenableChartSorting: true
to work properly.sortBy