Get statistic shown in pie charts and diagrams using data from a database