Pie chart

This is a pie chart of temperature by month for Boston.

Points to note:

  • terms is a list of all fields (both for x-axis and y-axis) to retrieve from the model.
  • Remember that for a Chart, the x and y terms in the series_options are written as x: [y, ...] pairs.
  • Any valid items in the Highcharts options object are valid chart_options.
  • We use the x_mapf_sortf_mts parameter to convert the month numbers retrieved from the database to month names.

Note: This demo is to demonstrate the use of the API and not to teach you data analysis and data presentation skills. Not all charts plotted in this demo may make sense in real life applications. But they can still be useful in demonstrating the API.


ds = DataPool(
            'options': {
                'source': MonthlyWeatherByCity.objects.all()
            'terms': [

def monthname(month_num):
    names = {1: 'Jan', 2: 'Feb', 3: 'Mar', 4: 'Apr', 5: 'May', 6: 'Jun',
             7: 'Jul', 8: 'Aug', 9: 'Sep', 10: 'Oct', 11: 'Nov', 12: 'Dec'}
    return names[month_num]

cht = Chart(
            'options': {
                'type': 'pie',
                'stacking': False
            'terms': {
                'month': ['boston_temp']
            'title': {
                'text': 'Monthly Temperature of Boston'
        x_sortf_mapf_mts=(None, monthname, False)