Pivot chart with multiple categories

Pivot Chart with multiple categories. In this chart the total sale quantity is plotted with respect to state and city.

Points to note:

  • You can add any number of categories and legend_by entries in a list.
  • Order matters! Retrieving state and then city may yield different results compared to retrieving city and state depending on what you are trying to plot.


ds = PivotDataPool(
      series= [
          'source': SalesHistory.objects.all(),
          'categories': [
          'legend_by': 'book__genre__name'},
        'terms': {

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