I have typical web app. where the user effectively makes a query and he/she gets back some data. The data is in the format of 1 dimension/1 metric. For instance:

  • city/population
  • country/population
  • gender/population

on returning the data my javascript uses the google charts api and displays either a pie chart or table chart or a line chart...


What I discovered is that if I have two or three cities a pie chart is perfect, however if I have hundreds of cities a Pie chart is awful. (and hence I switch to a table chart)

My question is:

What's the algorithm to choose the most appropriate chart depending on the data ? Have people made some studies on this ?

For instance one simple answer (e.g. my current implementation) says:

if the number of cities is smaller than 5 use a pie chart
else use a table chart

Can somebody suggest a better algorithm ?

Also can somebody point me to some external resources where this problem is discussed?

  • 1
    What pie charts are best at is showing proportions, e.g. % votes for each candidate, breakdown of a group by age range, etc. It sounds like you're showing independent values. Is that correct? May 21, 2012 at 18:55

1 Answer 1


According to this Workshop result, you should not have more than five "parts" in a pie chart, just as you also suggested. (Pie charts are covered about 3/4 into the article).

The workshop also discusses a range of other best practices when displaying data graphically.

  • Quite a lot of stuff in your link. Thanks for that. Interesting thanks
    – jad
    May 21, 2012 at 11:28
  • I thought that too! 208 pages of goodness! =) May 21, 2012 at 11:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.