Pivot chart with top few items per category

Pivot Chart each category limited to a select top items.

Points to note:

  • These charts are helpful when there are too many items in each category and we only want to focus on the top few items in each category.


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

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