Pivot chart with legend by

Pivot Chart with legend by field. This pivot chart plots total sale quantity of books in each city legended by the book genre name.

code

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

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