order groups in stacked bars chart

Does anyone know how to change the order of the groups in a stacked bar chart?  I want my bars ordered so that the group that is the largest is on the bottom of the bar.  Is this possible without custom d3?

2replies Oldest first
  • Oldest first
  • Newest first
  • Active threads
  • Popular
  • Hey Bill, 

    You can achieve the results that you are looking for by using the rank function in SQL. I've attached a working example where I use the rank function, then concat the rank to the value that I want to order by in the stacked bar chart. 

    https://modeanalytics.com/chasewright/reports/ccae43e6e415

     

    SELECT *,
           RANK() over (ORDER BY pop DESC) || '-' || city AS rnk
    FROM
      ( SELECT SUM(population_estimate_2012) AS pop,
               city,
               state
       FROM tutorial.city_populations
       WHERE state = 'CA'
       GROUP BY state,
                city ) sub_query
    Like
  • Chase , I took a similar approach to make a top 10, but the sorting convention in Mode ordered the output in the visualization as 1, 10, 2, 3, 4, 5, 6, 7, 8, 9. 

    Is there a workaround for this to get the numbers and series presented in sequential order?

    Like
Like Follow
  • Status Answered
  • 3 wk agoLast active
  • 2Replies
  • 1416Views
  • 4 Following