# Heuristics to choose most appropriate chart for given data

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...

Depending...

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?

• 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