Combination of line and pie

A combination of line and pie charts displayed on the same chart.

Points to note:

  • center and size are used to center the pie chart and scale it to fit in the chart. Remember that any of the Highcharts series options are valid options for the Chart series_options - options dict.

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.

code

ds = DataPool(
       series=
        [{'options': {
            'source': MonthlyWeatherByCity.objects.all()},
          'terms': [
            'month', 
            'boston_temp',
            'houston_temp']}
         ])

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(
        datasource = ds, 
        series_options = 
          [{'options':{
              'type': 'line'},
            'terms':{
              'month': [
                'boston_temp']
              }},
           {'options':{
              'type': 'pie',
              'center': [150, 100],
              'size': '50%'},
            'terms':{
              'month': [
                'houston_temp']
              }}],
        chart_options = 
          {'title': {
               'text': 'Weather Data of Boston (line) and Houston (pie)'}},
        x_sortf_mapf_mts = [(None, monthname, False),
                            (None, monthname, False)])