A basic Pivot Chart

A simple pivot chart.

Points to notice:

  • You can use the default django convention of double underscore (__) to follow to the fields in different models.

code

ds = PivotDataPool(
      series= [
       {'options':{
          'source': SalesHistory.objects.all(),
          'categories': 'bookstore__city__city'},
        'terms': {
          'tot_sales':Sum('sale_qty')}}])

pivcht = PivotChart(
          datasource = ds, 
          series_options = [
            {'options': {
               'type': 'column'},
             'terms': ['tot_sales']}])