Sort and Limit Categorical Data¶
By default, Charts sorts data categories by their corresponding aggregated values in descending order. To toggle between ascending or descending sort order, click the button to the right of the Sort By dropdown. The direction of the arrow on the button indicates the sort direction.
Alternatively, you can sort your data categories in alphabetical order by selecting Category in the Sort By dropdown menu. Changing your selection in the dropdown menu does not affect the sort direction.
You can apply a limit to the category encoding channel to only include a specified number of categories in your visualization. The categories included are the first matching categories based on the sort order specified. Limiting data can be useful when visualizing data with so many categories it becomes difficult to create a meaningful chart.
The following chart shows the average IMDb rating of movies from a particular country:
The dataset contains movies from many different countries, but it would be most interesting to see which countries produce the highest-rated movies. We can accomplish this by applying a limit to only show countries with the 10 highest average ratings for movies.
Switch the Limit Results toggle to
On and leave the
Show input at the default value of 10. The chart is now
much easier to understand, and we have a clear view of the countries
with the highest-rated movies: